@visactor/vchart 1.6.3 → 1.6.4

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 (51) hide show
  1. package/build/es5/index.js +1 -1
  2. package/build/index.js +566 -320
  3. package/build/index.min.js +1 -1
  4. package/build/tsconfig.tsbuildinfo +1 -1
  5. package/cjs/compile/grammar-item.js +2 -1
  6. package/cjs/component/axis/cartesian/axis.d.ts +3 -0
  7. package/cjs/component/axis/cartesian/axis.js +12 -5
  8. package/cjs/component/axis/cartesian/axis.js.map +1 -1
  9. package/cjs/component/data-zoom/data-filter-base-component.js +4 -3
  10. package/cjs/component/data-zoom/data-filter-base-component.js.map +1 -1
  11. package/cjs/component/data-zoom/data-zoom/data-zoom.js +9 -5
  12. package/cjs/component/data-zoom/data-zoom/data-zoom.js.map +1 -1
  13. package/cjs/component/tooltip/handler/dom/util.js.map +1 -1
  14. package/cjs/constant/polar.js +1 -2
  15. package/cjs/constant/scroll-bar.js +2 -1
  16. package/cjs/core/factory.js +1 -2
  17. package/cjs/core/index.d.ts +1 -1
  18. package/cjs/core/index.js +1 -1
  19. package/cjs/core/index.js.map +1 -1
  20. package/cjs/data/transforms/sankey.d.ts +3 -6
  21. package/cjs/data/transforms/sankey.js +40 -23
  22. package/cjs/data/transforms/sankey.js.map +1 -1
  23. package/cjs/event/event.js +2 -1
  24. package/cjs/interaction/interaction.js +1 -2
  25. package/cjs/series/sankey/sankey.d.ts +6 -1
  26. package/cjs/series/sankey/sankey.js +48 -42
  27. package/cjs/series/sankey/sankey.js.map +1 -1
  28. package/esm/compile/grammar-item.js +2 -1
  29. package/esm/component/axis/cartesian/axis.d.ts +3 -0
  30. package/esm/component/axis/cartesian/axis.js +12 -5
  31. package/esm/component/axis/cartesian/axis.js.map +1 -1
  32. package/esm/component/data-zoom/data-filter-base-component.js +4 -3
  33. package/esm/component/data-zoom/data-filter-base-component.js.map +1 -1
  34. package/esm/component/data-zoom/data-zoom/data-zoom.js +9 -5
  35. package/esm/component/data-zoom/data-zoom/data-zoom.js.map +1 -1
  36. package/esm/component/tooltip/handler/dom/util.js.map +1 -1
  37. package/esm/constant/polar.js +1 -2
  38. package/esm/constant/scroll-bar.js +2 -1
  39. package/esm/core/factory.js +1 -2
  40. package/esm/core/index.d.ts +1 -1
  41. package/esm/core/index.js +1 -1
  42. package/esm/core/index.js.map +1 -1
  43. package/esm/data/transforms/sankey.d.ts +3 -6
  44. package/esm/data/transforms/sankey.js +36 -22
  45. package/esm/data/transforms/sankey.js.map +1 -1
  46. package/esm/event/event.js +2 -1
  47. package/esm/interaction/interaction.js +1 -2
  48. package/esm/series/sankey/sankey.d.ts +6 -1
  49. package/esm/series/sankey/sankey.js +49 -46
  50. package/esm/series/sankey/sankey.js.map +1 -1
  51. package/package.json +10 -10
@@ -8,9 +8,9 @@ import { animationConfig, userAnimationConfig } from "../../animation/utils";
8
8
 
9
9
  import { registerFadeInOutAnimation } from "../../animation/config";
10
10
 
11
- import { registerDataSetInstanceTransform, registerDataSetInstanceParser } from "../../data/register";
11
+ import { registerDataSetInstanceTransform } from "../../data/register";
12
12
 
13
- import { sankey } from "../../data/transforms/sankey";
13
+ import { sankeyFormat, sankeyLayout, collectHierarchyField } from "../../data/transforms/sankey";
14
14
 
15
15
  import { sankeyNodes } from "../../data/transforms/sankey-nodes";
16
16
 
@@ -18,16 +18,12 @@ import { sankeyLinks } from "../../data/transforms/sankey-links";
18
18
 
19
19
  import { STATE_VALUE_ENUM } from "../../compile/mark/interface";
20
20
 
21
- import { DataView, DataSet, dataViewParser } from "@visactor/vdataset";
21
+ import { DataView } from "@visactor/vdataset";
22
22
 
23
- import { DEFAULT_DATA_INDEX, LayoutZIndex, AttributeLevel, Event_Bubble_Level, ChartEvent } from "../../constant";
23
+ import { LayoutZIndex, AttributeLevel, Event_Bubble_Level, DEFAULT_DATA_INDEX } from "../../constant";
24
24
 
25
25
  import { SeriesData } from "../base/series-data";
26
26
 
27
- import { addVChartProperty } from "../../data/transforms/add-property";
28
-
29
- import { addDataKey, initKeyMap } from "../../data/transforms/data-key";
30
-
31
27
  import { SankeySeriesTooltipHelper } from "./tooltip-helper";
32
28
 
33
29
  import { Bounds, array, isNil } from "@visactor/vutils";
@@ -50,6 +46,8 @@ import { Factory } from "../../core/factory";
50
46
 
51
47
  import { TransformLevel } from "../../data/initialize";
52
48
 
49
+ import { addDataKey, initKeyMap } from "../../data/transforms/data-key";
50
+
53
51
  export class SankeySeries extends CartesianSeries {
54
52
  constructor() {
55
53
  super(...arguments), this.type = SeriesTypeEnum.sankey, this._nodeLayoutZIndex = LayoutZIndex.Node,
@@ -355,10 +353,15 @@ export class SankeySeries extends CartesianSeries {
355
353
  this._labelLimit = null !== (_c = null === (_b = this._spec.label) || void 0 === _b ? void 0 : _b.limit) && void 0 !== _c ? _c : 100;
356
354
  }
357
355
  initData() {
358
- var _a, _b, _c, _d, _e, _f;
359
- if (super.initData(), this.getViewData()) {
360
- registerDataSetInstanceTransform(this._dataSet, "sankey", sankey), this.addViewDataFilter({
361
- type: "sankey",
356
+ var _a, _b, _c, _d;
357
+ super.initData();
358
+ const viewData = this.getViewData(), rawData = this.getRawData();
359
+ if (rawData && viewData) {
360
+ registerDataSetInstanceTransform(this._dataSet, "sankeyLayout", sankeyLayout), registerDataSetInstanceTransform(this._dataSet, "sankeyFormat", sankeyFormat),
361
+ rawData.transform({
362
+ type: "sankeyFormat"
363
+ }, !1), viewData.transform({
364
+ type: "sankeyLayout",
362
365
  options: {
363
366
  view: () => ({
364
367
  x0: this._viewBox.x1,
@@ -385,11 +388,9 @@ export class SankeySeries extends CartesianSeries {
385
388
  },
386
389
  level: TransformLevel.sankeyLayout
387
390
  });
388
- const nodesDataSet = new DataSet;
389
- registerDataSetInstanceParser(nodesDataSet, "dataview", dataViewParser), registerDataSetInstanceTransform(nodesDataSet, "sankeyNodes", sankeyNodes),
390
- registerDataSetInstanceTransform(nodesDataSet, "addVChartProperty", addVChartProperty),
391
- registerDataSetInstanceTransform(nodesDataSet, "flatten", flatten);
392
- const nodesDataView = new DataView(nodesDataSet, {
391
+ const {dataSet: dataSet} = this._option;
392
+ registerDataSetInstanceTransform(dataSet, "sankeyNodes", sankeyNodes), registerDataSetInstanceTransform(dataSet, "flatten", flatten);
393
+ const nodesDataView = new DataView(dataSet, {
393
394
  name: `sankey-node-${this.id}-data`
394
395
  });
395
396
  nodesDataView.parse([ this.getViewData() ], {
@@ -407,18 +408,14 @@ export class SankeySeries extends CartesianSeries {
407
408
  return node;
408
409
  }
409
410
  }
410
- }), nodesDataView.transform({
411
+ }, !1), nodesDataView.transform({
411
412
  type: "addVChartProperty",
412
413
  options: {
413
414
  beforeCall: initKeyMap.bind(this),
414
415
  call: addDataKey
415
416
  }
416
- }, !1), null === (_e = this._data) || void 0 === _e || _e.getDataView().target.addListener("change", nodesDataView.reRunAllTransform),
417
- this._nodesSeriesData = new SeriesData(this._option, nodesDataView);
418
- const linksDataSet = new DataSet;
419
- registerDataSetInstanceParser(linksDataSet, "dataview", dataViewParser), registerDataSetInstanceTransform(linksDataSet, "sankeyLinks", sankeyLinks),
420
- registerDataSetInstanceTransform(linksDataSet, "addVChartProperty", addVChartProperty);
421
- const linksDataView = new DataView(linksDataSet, {
417
+ }, !1), this._nodesSeriesData = new SeriesData(this._option, nodesDataView), registerDataSetInstanceTransform(dataSet, "sankeyLinks", sankeyLinks);
418
+ const linksDataView = new DataView(dataSet, {
422
419
  name: `sankey-link-${this.id}-data`
423
420
  });
424
421
  linksDataView.parse([ this.getViewData() ], {
@@ -431,8 +428,7 @@ export class SankeySeries extends CartesianSeries {
431
428
  beforeCall: initKeyMap.bind(this),
432
429
  call: addDataKey
433
430
  }
434
- }, !1), null === (_f = this._data) || void 0 === _f || _f.getDataView().target.addListener("change", linksDataView.reRunAllTransform),
435
- this._linksSeriesData = new SeriesData(this._option, linksDataView);
431
+ }, !1), this._linksSeriesData = new SeriesData(this._option, linksDataView);
436
432
  }
437
433
  }
438
434
  initMark() {
@@ -484,9 +480,11 @@ export class SankeySeries extends CartesianSeries {
484
480
  y1: datum => datum.y1,
485
481
  thickness: datum => datum.thickness,
486
482
  fill: datum => {
487
- var _a, _b, _c, _d, _e, _f, _g, _h;
488
- const sourceName = (null === (_a = this._spec) || void 0 === _a ? void 0 : _a.nodeKey) || (null === (_d = null === (_c = null === (_b = this._rawData.latestData[0]) || void 0 === _b ? void 0 : _b.nodes) || void 0 === _c ? void 0 : _c[0]) || void 0 === _d ? void 0 : _d.children) ? datum.source : this.getNodeList()[datum.source];
489
- return null !== (_g = null === (_f = null === (_e = this._spec.link) || void 0 === _e ? void 0 : _e.style) || void 0 === _f ? void 0 : _f.fill) && void 0 !== _g ? _g : null === (_h = this._colorScale) || void 0 === _h ? void 0 : _h.scale(sourceName);
483
+ var _a, _b, _c, _d, _e, _f, _g;
484
+ const fill = null === (_b = null === (_a = this._spec.link) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.fill;
485
+ if (fill) return fill;
486
+ const sourceName = (null === (_c = this._spec) || void 0 === _c ? void 0 : _c.nodeKey) || (null === (_f = null === (_e = null === (_d = this._rawData.latestData[0]) || void 0 === _d ? void 0 : _d.nodes) || void 0 === _e ? void 0 : _e[0]) || void 0 === _f ? void 0 : _f.children) ? datum.source : this.getNodeList()[datum.source];
487
+ return null === (_g = this._colorScale) || void 0 === _g ? void 0 : _g.scale(sourceName);
490
488
  },
491
489
  direction: null !== (_a = this._spec.direction) && void 0 !== _a ? _a : "horizontal"
492
490
  }, STATE_VALUE_ENUM.STATE_NORMAL, AttributeLevel.Series), this._trigger.registerMark(linkMark));
@@ -640,14 +638,10 @@ export class SankeySeries extends CartesianSeries {
640
638
  }, this._handleRelatedClick));
641
639
  }
642
640
  nodesSeriesDataUpdate() {
643
- this.event.emit(ChartEvent.legendFilter, {
644
- model: this
645
- }), this._nodesSeriesData.updateData(), this._setNodeOrdinalColorScale();
641
+ this._nodesSeriesData.updateData(), this._setNodeOrdinalColorScale();
646
642
  }
647
643
  linksSeriesDataUpdate() {
648
- this.event.emit(ChartEvent.legendFilter, {
649
- model: this
650
- }), this._linksSeriesData.updateData();
644
+ this._linksSeriesData.updateData();
651
645
  }
652
646
  initTooltip() {
653
647
  this._tooltipHelper = new SankeySeriesTooltipHelper(this), this._nodeMark && this._tooltipHelper.activeTriggerSet.mark.add(this._nodeMark),
@@ -687,21 +681,30 @@ export class SankeySeries extends CartesianSeries {
687
681
  getMeasureField() {
688
682
  return [ this._valueField ];
689
683
  }
690
- getSeriesKeys() {
691
- var _a, _b;
692
- if (this._seriesField) {
693
- const keyArray = [];
694
- return null === (_b = null === (_a = this._nodesSeriesData) || void 0 === _a ? void 0 : _a.getDataView()) || void 0 === _b || _b.latestData.forEach((datum => {
695
- var _a;
696
- keyArray.push(null !== (_a = datum[this._seriesField]) && void 0 !== _a ? _a : datum.datum[this._seriesField]);
697
- })), keyArray;
684
+ getRawDataStatisticsByField(field, isNumeric) {
685
+ var _a;
686
+ if (this._rawStatisticsCache || (this._rawStatisticsCache = {}), !this._rawStatisticsCache[field]) {
687
+ this._viewDataStatistics && this.getViewData().transformsArr.length <= 1 && (null === (_a = this._viewDataStatistics.latestData) || void 0 === _a ? void 0 : _a[field]) ? this._rawStatisticsCache[field] = this._viewDataStatistics.latestData[field] : this._rawData && (this._rawStatisticsCache[field] = {
688
+ values: this._collectByField(field)
689
+ });
698
690
  }
699
- return [];
691
+ return this._rawStatisticsCache[field];
692
+ }
693
+ _collectByField(field) {
694
+ var _a, _b, _c;
695
+ const keyArray = [], rawData = null === (_b = null === (_a = this.getRawData()) || void 0 === _a ? void 0 : _a.latestData) || void 0 === _b ? void 0 : _b[0];
696
+ if (!rawData) return [];
697
+ if (rawData.links) (null === (_c = rawData.nodes) || void 0 === _c ? void 0 : _c.length) && rawData.nodes.forEach((node => {
698
+ node[this._seriesField] && keyArray.push(node[this._seriesField]);
699
+ })); else if (rawData.nodes) {
700
+ const set = new Set;
701
+ return collectHierarchyField(set, rawData.nodes, this._seriesField), Array.from(set);
702
+ }
703
+ return keyArray;
700
704
  }
701
705
  onLayoutEnd(ctx) {
702
706
  super.onLayoutEnd(ctx), this._viewBox.set(0, 0, this._region.getLayoutRect().width, this._region.getLayoutRect().height),
703
- this._rawData.reRunAllTransform(), this.getViewData().reRunAllTransform(), this._nodesSeriesData.updateData(),
704
- this._linksSeriesData.updateData();
707
+ this.getViewData().reRunAllTransform(), this._nodesSeriesData.updateData(), this._linksSeriesData.updateData();
705
708
  }
706
709
  getDefaultShapeType() {
707
710
  return "square";