@visactor/vtable 1.20.0 → 1.20.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/cjs/PivotChart.d.ts +4 -0
  2. package/cjs/PivotChart.js +30 -18
  3. package/cjs/PivotChart.js.map +1 -1
  4. package/cjs/core/BaseTable.js +1 -1
  5. package/cjs/core/BaseTable.js.map +1 -1
  6. package/cjs/dataset/dataset-pivot-table.js +1 -2
  7. package/cjs/edit/editors.js +2 -1
  8. package/cjs/index.d.ts +1 -1
  9. package/cjs/index.js +1 -1
  10. package/cjs/index.js.map +1 -1
  11. package/cjs/layout/chart-helper/get-axis-config.js +73 -28
  12. package/cjs/layout/chart-helper/get-axis-config.js.map +1 -1
  13. package/cjs/layout/chart-helper/get-chart-spec.js +19 -9
  14. package/cjs/layout/chart-helper/get-chart-spec.js.map +1 -1
  15. package/cjs/layout/pivot-header-layout.d.ts +1 -1
  16. package/cjs/layout/pivot-header-layout.js +18 -8
  17. package/cjs/layout/pivot-header-layout.js.map +1 -1
  18. package/cjs/plugins/custom-cell-style.js +1 -1
  19. package/cjs/scenegraph/scenegraph.js +1 -1
  20. package/cjs/vrender.js.map +1 -1
  21. package/dist/vtable.js +226 -52
  22. package/dist/vtable.min.js +2 -2
  23. package/es/PivotChart.d.ts +4 -0
  24. package/es/PivotChart.js +30 -18
  25. package/es/PivotChart.js.map +1 -1
  26. package/es/core/BaseTable.js +1 -1
  27. package/es/core/BaseTable.js.map +1 -1
  28. package/es/dataset/dataset-pivot-table.js +1 -2
  29. package/es/edit/editors.js +2 -1
  30. package/es/index.d.ts +1 -1
  31. package/es/index.js +1 -1
  32. package/es/index.js.map +1 -1
  33. package/es/layout/chart-helper/get-axis-config.js +73 -28
  34. package/es/layout/chart-helper/get-axis-config.js.map +1 -1
  35. package/es/layout/chart-helper/get-chart-spec.js +19 -9
  36. package/es/layout/chart-helper/get-chart-spec.js.map +1 -1
  37. package/es/layout/pivot-header-layout.d.ts +1 -1
  38. package/es/layout/pivot-header-layout.js +18 -8
  39. package/es/layout/pivot-header-layout.js.map +1 -1
  40. package/es/plugins/custom-cell-style.js +1 -1
  41. package/es/scenegraph/scenegraph.js +1 -1
  42. package/es/vrender.js.map +1 -1
  43. package/package.json +5 -5
@@ -74,6 +74,10 @@ export declare class PivotChart extends BaseTable implements PivotChartAPI {
74
74
  private _generateAggregationRules;
75
75
  private setCustomStateNameToSpec;
76
76
  updateFilterRules(filterRules: FilterRules): void;
77
+ private _throttleTimer;
78
+ private _latestFilterRules;
79
+ private _throttledUpdateFilterRules;
80
+ private _executeFilterUpdate;
77
81
  clearChartCacheImage(col?: number, row?: number): void;
78
82
  getLegendSelected(): any[];
79
83
  setLegendSelected(selectedData: (string | number)[]): void;
package/cjs/PivotChart.js CHANGED
@@ -20,9 +20,9 @@ class PivotChart extends BaseTable_1.BaseTable {
20
20
  super(container, options), this.layoutNodeId = {
21
21
  seqId: 0
22
22
  }, this._selectedDataItemsInChart = [], this._selectedDimensionInChart = [], this._chartEventMap = {},
23
- (options = this.options).layout && Object.assign(options, options.layout), this.internalProps.columns = (0,
24
- vutils_1.cloneDeep)(options.columns), this.internalProps.rows = (0, vutils_1.cloneDeep)(options.rows),
25
- this.internalProps.indicators = (0, vutils_extension_1.cloneDeepSpec)(options.indicators),
23
+ this._throttleTimer = null, this._latestFilterRules = null, (options = this.options).layout && Object.assign(options, options.layout),
24
+ this.internalProps.columns = (0, vutils_1.cloneDeep)(options.columns), this.internalProps.rows = (0,
25
+ vutils_1.cloneDeep)(options.rows), this.internalProps.indicators = (0, vutils_extension_1.cloneDeepSpec)(options.indicators),
26
26
  this.internalProps.columnTree = !options.indicatorsAsCol || (null === (_a = options.columns) || void 0 === _a ? void 0 : _a.length) || options.columnTree ? (0,
27
27
  vutils_1.cloneDeep)(options.columnTree) : [], this.internalProps.rowTree = options.indicatorsAsCol || (null === (_b = options.rows) || void 0 === _b ? void 0 : _b.length) || options.rowTree ? (0,
28
28
  vutils_1.cloneDeep)(options.rowTree) : [], this.internalProps.records = options.records,
@@ -373,19 +373,19 @@ class PivotChart extends BaseTable_1.BaseTable {
373
373
  };
374
374
  }
375
375
  _generateCollectValuesConfig(columnKeys, rowKeys) {
376
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
376
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
377
377
  columnKeys = columnKeys.filter((key => key !== global_1.IndicatorDimensionKeyPlaceholder)),
378
378
  rowKeys = rowKeys.filter((key => key !== global_1.IndicatorDimensionKeyPlaceholder));
379
379
  const indicators = this.internalProps.indicators, collectValuesBy = {};
380
380
  for (let i = 0, len = null == indicators ? void 0 : indicators.length; i < len; i++) if ("string" != typeof indicators[i] && indicators[i].chartSpec) {
381
- if ("pie" === (null === (_a = indicators[i].chartSpec) || void 0 === _a ? void 0 : _a.type) || "rose" === (null === (_b = indicators[i].chartSpec) || void 0 === _b ? void 0 : _b.type) || "radar" === (null === (_c = indicators[i].chartSpec) || void 0 === _c ? void 0 : _c.type) || "gauge" === (null === (_d = indicators[i].chartSpec) || void 0 === _d ? void 0 : _d.type) || "wordCloud" === (null === (_e = indicators[i].chartSpec) || void 0 === _e ? void 0 : _e.type)) continue;
381
+ if ("pie" === (null === (_a = indicators[i].chartSpec) || void 0 === _a ? void 0 : _a.type) || "rose" === (null === (_b = indicators[i].chartSpec) || void 0 === _b ? void 0 : _b.type) || "funnel" === (null === (_c = indicators[i].chartSpec) || void 0 === _c ? void 0 : _c.type) || "radar" === (null === (_d = indicators[i].chartSpec) || void 0 === _d ? void 0 : _d.type) || "gauge" === (null === (_e = indicators[i].chartSpec) || void 0 === _e ? void 0 : _e.type) || "wordCloud" === (null === (_f = indicators[i].chartSpec) || void 0 === _f ? void 0 : _f.type) || "sunburst" === (null === (_g = indicators[i].chartSpec) || void 0 === _g ? void 0 : _g.type) || "treemap" === (null === (_h = indicators[i].chartSpec) || void 0 === _h ? void 0 : _h.type) || "sankey" === (null === (_j = indicators[i].chartSpec) || void 0 === _j ? void 0 : _j.type) || "circlePacking" === (null === (_k = indicators[i].chartSpec) || void 0 === _k ? void 0 : _k.type)) continue;
382
382
  const indicatorDefine = indicators[i], indicatorSpec = indicatorDefine.chartSpec;
383
383
  if (!1 === this.options.indicatorsAsCol) if (!1 !== (null == indicatorSpec ? void 0 : indicatorSpec.stack) && ("bar" === (null == indicatorSpec ? void 0 : indicatorSpec.type) || "area" === (null == indicatorSpec ? void 0 : indicatorSpec.type)) && (indicatorSpec.stack = !0),
384
- collectValuesBy[indicatorDefine.indicatorKey] = {
384
+ "heatmap" !== (null == indicatorSpec ? void 0 : indicatorSpec.type) && (collectValuesBy[indicatorDefine.indicatorKey] = {
385
385
  by: rowKeys,
386
386
  range: !0,
387
- sumBy: (null == indicatorSpec ? void 0 : indicatorSpec.stack) && columnKeys.concat(null == indicatorSpec ? void 0 : indicatorSpec.xField)
388
- }, indicatorSpec.series) indicatorSpec.series.forEach((chartSeries => {
387
+ sumBy: "histogram" === indicatorSpec.type ? columnKeys.concat(null == indicatorSpec ? void 0 : indicatorSpec.xField, null == indicatorSpec ? void 0 : indicatorSpec.x2Field) : (null == indicatorSpec ? void 0 : indicatorSpec.stack) && columnKeys.concat(null == indicatorSpec ? void 0 : indicatorSpec.xField)
388
+ }), indicatorSpec.series) indicatorSpec.series.forEach((chartSeries => {
389
389
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
390
390
  const xField = "string" == typeof chartSeries.xField ? chartSeries.xField : chartSeries.xField[0];
391
391
  collectValuesBy[xField] = {
@@ -404,29 +404,30 @@ class PivotChart extends BaseTable_1.BaseTable {
404
404
  extendRange: (0, tableHelper_1.parseMarkLineGetExtendRange)(indicatorSpec.markLine)
405
405
  };
406
406
  })); else {
407
- const xField = "string" == typeof indicatorSpec.xField ? indicatorSpec.xField : indicatorSpec.xField[0];
407
+ const xField = "histogram" === indicatorSpec.type ? indicatorSpec.x2Field : "string" == typeof indicatorSpec.xField ? indicatorSpec.xField : indicatorSpec.xField[0];
408
408
  collectValuesBy[xField] = {
409
409
  by: columnKeys,
410
410
  type: "horizontal" !== indicatorSpec.direction ? "xField" : void 0,
411
411
  range: (0, get_axis_config_1.hasLinearAxis)(indicatorSpec, this._axes, "horizontal" === indicatorSpec.direction, !0),
412
- sortBy: "horizontal" !== indicatorSpec.direction ? null === (_h = null === (_g = null === (_f = null == indicatorSpec ? void 0 : indicatorSpec.data) || void 0 === _f ? void 0 : _f.fields) || void 0 === _g ? void 0 : _g[xField]) || void 0 === _h ? void 0 : _h.domain : void 0
412
+ sortBy: "horizontal" !== indicatorSpec.direction ? null === (_o = null === (_m = null === (_l = null == indicatorSpec ? void 0 : indicatorSpec.data) || void 0 === _l ? void 0 : _l.fields) || void 0 === _m ? void 0 : _m[xField]) || void 0 === _o ? void 0 : _o.domain : void 0
413
413
  }, !1 !== (null == indicatorSpec ? void 0 : indicatorSpec.stack) && ("bar" === (null == indicatorSpec ? void 0 : indicatorSpec.type) || "area" === (null == indicatorSpec ? void 0 : indicatorSpec.type)) && (indicatorSpec.stack = !0);
414
414
  const yField = indicatorSpec.yField;
415
415
  collectValuesBy[yField] = {
416
416
  by: rowKeys,
417
- range: "horizontal" !== indicatorSpec.direction,
418
- sumBy: indicatorSpec.stack && columnKeys.concat(null == indicatorSpec ? void 0 : indicatorSpec.xField),
419
- sortBy: "horizontal" === indicatorSpec.direction ? null === (_l = null === (_k = null === (_j = null == indicatorSpec ? void 0 : indicatorSpec.data) || void 0 === _j ? void 0 : _j.fields) || void 0 === _k ? void 0 : _k[yField]) || void 0 === _l ? void 0 : _l.domain : void 0,
417
+ type: "horizontal" !== indicatorSpec.direction ? "yField" : void 0,
418
+ range: (0, get_axis_config_1.hasLinearAxis)(indicatorSpec, this._axes, "horizontal" === indicatorSpec.direction, !1),
419
+ sumBy: "histogram" === indicatorSpec.type ? columnKeys.concat(null == indicatorSpec ? void 0 : indicatorSpec.xField, null == indicatorSpec ? void 0 : indicatorSpec.x2Field) : indicatorSpec.stack && columnKeys.concat(null == indicatorSpec ? void 0 : indicatorSpec.xField),
420
+ sortBy: "horizontal" === indicatorSpec.direction ? null === (_r = null === (_q = null === (_p = null == indicatorSpec ? void 0 : indicatorSpec.data) || void 0 === _p ? void 0 : _p.fields) || void 0 === _q ? void 0 : _q[yField]) || void 0 === _r ? void 0 : _r.domain : void 0,
420
421
  extendRange: (0, tableHelper_1.parseMarkLineGetExtendRange)(indicatorSpec.markLine)
421
422
  };
422
423
  } else {
423
424
  const indicatorDefine = indicators[i];
424
425
  if (!1 !== (null == indicatorSpec ? void 0 : indicatorSpec.stack) && ("bar" === (null == indicatorSpec ? void 0 : indicatorSpec.type) || "area" === (null == indicatorSpec ? void 0 : indicatorSpec.type)) && (indicatorSpec.stack = !0),
425
- collectValuesBy[indicatorDefine.indicatorKey] = {
426
+ "heatmap" !== (null == indicatorSpec ? void 0 : indicatorSpec.type) && (collectValuesBy[indicatorDefine.indicatorKey] = {
426
427
  by: columnKeys,
427
428
  range: !0,
428
429
  sumBy: (null == indicatorSpec ? void 0 : indicatorSpec.stack) && rowKeys.concat(null == indicatorSpec ? void 0 : indicatorSpec.yField)
429
- }, indicatorSpec.series) indicatorSpec.series.forEach((chartSeries => {
430
+ }), indicatorSpec.series) indicatorSpec.series.forEach((chartSeries => {
430
431
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
431
432
  const yField = "string" == typeof chartSeries.yField ? chartSeries.yField : chartSeries.yField[0];
432
433
  collectValuesBy[yField] = {
@@ -450,14 +451,15 @@ class PivotChart extends BaseTable_1.BaseTable {
450
451
  by: rowKeys,
451
452
  type: "horizontal" === indicatorSpec.direction ? "yField" : void 0,
452
453
  range: (0, get_axis_config_1.hasLinearAxis)(indicatorSpec, this._axes, "horizontal" === indicatorSpec.direction, !1),
453
- sortBy: "horizontal" === indicatorSpec.direction ? null === (_p = null === (_o = null === (_m = null == indicatorSpec ? void 0 : indicatorSpec.data) || void 0 === _m ? void 0 : _m.fields) || void 0 === _o ? void 0 : _o[yField]) || void 0 === _p ? void 0 : _p.domain : void 0
454
+ sortBy: "horizontal" === indicatorSpec.direction ? null === (_u = null === (_t = null === (_s = null == indicatorSpec ? void 0 : indicatorSpec.data) || void 0 === _s ? void 0 : _s.fields) || void 0 === _t ? void 0 : _t[yField]) || void 0 === _u ? void 0 : _u.domain : void 0
454
455
  }, !1 !== (null == indicatorSpec ? void 0 : indicatorSpec.stack) && ("bar" === (null == indicatorSpec ? void 0 : indicatorSpec.type) || "area" === (null == indicatorSpec ? void 0 : indicatorSpec.type)) && (indicatorSpec.stack = !0);
455
- const xField = indicatorSpec.xField;
456
+ const xField = "histogram" === indicatorSpec.type ? indicatorSpec.x2Field : indicatorSpec.xField;
456
457
  collectValuesBy[xField] = {
457
458
  by: columnKeys,
459
+ type: "horizontal" === indicatorSpec.direction ? "xField" : void 0,
458
460
  range: (0, get_axis_config_1.hasLinearAxis)(indicatorSpec, this._axes, "horizontal" === indicatorSpec.direction, !0),
459
461
  sumBy: indicatorSpec.stack && rowKeys.concat(null == indicatorSpec ? void 0 : indicatorSpec.yField),
460
- sortBy: "horizontal" !== indicatorSpec.direction ? null === (_s = null === (_r = null === (_q = null == indicatorSpec ? void 0 : indicatorSpec.data) || void 0 === _q ? void 0 : _q.fields) || void 0 === _r ? void 0 : _r[xField]) || void 0 === _s ? void 0 : _s.domain : void 0,
462
+ sortBy: "horizontal" !== indicatorSpec.direction ? null === (_x = null === (_w = null === (_v = null == indicatorSpec ? void 0 : indicatorSpec.data) || void 0 === _v ? void 0 : _v.fields) || void 0 === _w ? void 0 : _w[xField]) || void 0 === _x ? void 0 : _x.domain : void 0,
461
463
  extendRange: (0, tableHelper_1.parseMarkLineGetExtendRange)(indicatorSpec.markLine)
462
464
  };
463
465
  }
@@ -520,6 +522,16 @@ class PivotChart extends BaseTable_1.BaseTable {
520
522
  }));
521
523
  }
522
524
  updateFilterRules(filterRules) {
525
+ this._throttledUpdateFilterRules(filterRules);
526
+ }
527
+ _throttledUpdateFilterRules(filterRules) {
528
+ this._latestFilterRules = filterRules, null === this._throttleTimer && (this._executeFilterUpdate(filterRules),
529
+ this._throttleTimer = window.setTimeout((() => {
530
+ this._latestFilterRules !== filterRules && this._executeFilterUpdate(this._latestFilterRules),
531
+ this._throttleTimer = null;
532
+ }), 200));
533
+ }
534
+ _executeFilterUpdate(filterRules) {
523
535
  this.internalProps.dataConfig.filterRules = filterRules, this.dataset.updateFilterRules(filterRules),
524
536
  (0, update_chart_1.clearChartCacheImage)(this.scenegraph), (0, update_chart_1.updateChartData)(this.scenegraph),
525
537
  this.render();