@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.
- package/build/es5/index.js +1 -1
- package/build/index.js +566 -320
- package/build/index.min.js +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/cjs/compile/grammar-item.js +2 -1
- package/cjs/component/axis/cartesian/axis.d.ts +3 -0
- package/cjs/component/axis/cartesian/axis.js +12 -5
- package/cjs/component/axis/cartesian/axis.js.map +1 -1
- package/cjs/component/data-zoom/data-filter-base-component.js +4 -3
- package/cjs/component/data-zoom/data-filter-base-component.js.map +1 -1
- package/cjs/component/data-zoom/data-zoom/data-zoom.js +9 -5
- package/cjs/component/data-zoom/data-zoom/data-zoom.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/util.js.map +1 -1
- package/cjs/constant/polar.js +1 -2
- package/cjs/constant/scroll-bar.js +2 -1
- package/cjs/core/factory.js +1 -2
- package/cjs/core/index.d.ts +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/index.js.map +1 -1
- package/cjs/data/transforms/sankey.d.ts +3 -6
- package/cjs/data/transforms/sankey.js +40 -23
- package/cjs/data/transforms/sankey.js.map +1 -1
- package/cjs/event/event.js +2 -1
- package/cjs/interaction/interaction.js +1 -2
- package/cjs/series/sankey/sankey.d.ts +6 -1
- package/cjs/series/sankey/sankey.js +48 -42
- package/cjs/series/sankey/sankey.js.map +1 -1
- package/esm/compile/grammar-item.js +2 -1
- package/esm/component/axis/cartesian/axis.d.ts +3 -0
- package/esm/component/axis/cartesian/axis.js +12 -5
- package/esm/component/axis/cartesian/axis.js.map +1 -1
- package/esm/component/data-zoom/data-filter-base-component.js +4 -3
- package/esm/component/data-zoom/data-filter-base-component.js.map +1 -1
- package/esm/component/data-zoom/data-zoom/data-zoom.js +9 -5
- package/esm/component/data-zoom/data-zoom/data-zoom.js.map +1 -1
- package/esm/component/tooltip/handler/dom/util.js.map +1 -1
- package/esm/constant/polar.js +1 -2
- package/esm/constant/scroll-bar.js +2 -1
- package/esm/core/factory.js +1 -2
- package/esm/core/index.d.ts +1 -1
- package/esm/core/index.js +1 -1
- package/esm/core/index.js.map +1 -1
- package/esm/data/transforms/sankey.d.ts +3 -6
- package/esm/data/transforms/sankey.js +36 -22
- package/esm/data/transforms/sankey.js.map +1 -1
- package/esm/event/event.js +2 -1
- package/esm/interaction/interaction.js +1 -2
- package/esm/series/sankey/sankey.d.ts +6 -1
- package/esm/series/sankey/sankey.js +49 -46
- package/esm/series/sankey/sankey.js.map +1 -1
- 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
|
|
11
|
+
import { registerDataSetInstanceTransform } from "../../data/register";
|
|
12
12
|
|
|
13
|
-
import {
|
|
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
|
|
21
|
+
import { DataView } from "@visactor/vdataset";
|
|
22
22
|
|
|
23
|
-
import {
|
|
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
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
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
|
|
389
|
-
|
|
390
|
-
|
|
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),
|
|
417
|
-
|
|
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),
|
|
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
|
|
488
|
-
const
|
|
489
|
-
|
|
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.
|
|
644
|
-
model: this
|
|
645
|
-
}), this._nodesSeriesData.updateData(), this._setNodeOrdinalColorScale();
|
|
641
|
+
this._nodesSeriesData.updateData(), this._setNodeOrdinalColorScale();
|
|
646
642
|
}
|
|
647
643
|
linksSeriesDataUpdate() {
|
|
648
|
-
this.
|
|
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
|
-
|
|
691
|
-
var _a
|
|
692
|
-
if (this.
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
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.
|
|
704
|
-
this._linksSeriesData.updateData();
|
|
707
|
+
this.getViewData().reRunAllTransform(), this._nodesSeriesData.updateData(), this._linksSeriesData.updateData();
|
|
705
708
|
}
|
|
706
709
|
getDefaultShapeType() {
|
|
707
710
|
return "square";
|