index.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { __assign, __extends } from "tslib";
  2. import { BRUSH_FILTER_EVENTS, VIEW_LIFE_CIRCLE } from '@antv/g2';
  3. import { Plot } from '../../core/plot';
  4. import { deepAssign } from '../../utils';
  5. import { adaptor, meta, transformOptions } from './adaptor';
  6. import { DEFAULT_OPTIONS } from './constant';
  7. import './interactions';
  8. var Scatter = /** @class */ (function (_super) {
  9. __extends(Scatter, _super);
  10. function Scatter(container, options) {
  11. var _this = _super.call(this, container, options) || this;
  12. /** 图表类型 */
  13. _this.type = 'scatter';
  14. // 监听 brush 事件,处理 meta
  15. _this.on(VIEW_LIFE_CIRCLE.BEFORE_RENDER, function (evt) {
  16. var _a, _b;
  17. // 运行时,读取 option
  18. var _c = _this, options = _c.options, chart = _c.chart;
  19. if (((_a = evt.data) === null || _a === void 0 ? void 0 : _a.source) === BRUSH_FILTER_EVENTS.FILTER) {
  20. var filteredData = _this.chart.filterData(_this.chart.getData());
  21. meta({ chart: chart, options: __assign(__assign({}, options), { data: filteredData }) });
  22. }
  23. if (((_b = evt.data) === null || _b === void 0 ? void 0 : _b.source) === BRUSH_FILTER_EVENTS.RESET) {
  24. meta({ chart: chart, options: options });
  25. }
  26. });
  27. return _this;
  28. }
  29. /**
  30. * 获取 散点图 默认配置项
  31. * 供外部使用
  32. */
  33. Scatter.getDefaultOptions = function () {
  34. return DEFAULT_OPTIONS;
  35. };
  36. /**
  37. * @override
  38. * @param data
  39. */
  40. Scatter.prototype.changeData = function (data) {
  41. this.updateOption(transformOptions(deepAssign({}, this.options, { data: data })));
  42. var _a = this, options = _a.options, chart = _a.chart;
  43. meta({ chart: chart, options: options });
  44. this.chart.changeData(data);
  45. };
  46. /**
  47. * 获取 散点图 的适配器
  48. */
  49. Scatter.prototype.getSchemaAdaptor = function () {
  50. return adaptor;
  51. };
  52. Scatter.prototype.getDefaultOptions = function () {
  53. return Scatter.getDefaultOptions();
  54. };
  55. return Scatter;
  56. }(Plot));
  57. export { Scatter };
  58. //# sourceMappingURL=index.js.map