@visactor/vchart-extension 1.13.21-alpha.0 → 1.13.21-alpha.1

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 (61) hide show
  1. package/build/index.js +442 -0
  2. package/build/index.min.js +2 -2
  3. package/cjs/charts/compare-sankey/compare-sankey-sub-data.d.ts +20 -0
  4. package/cjs/charts/compare-sankey/compare-sankey-sub-data.js +118 -0
  5. package/cjs/charts/compare-sankey/compare-sankey-sub-data.js.map +1 -0
  6. package/cjs/charts/compare-sankey/compare-sankey-sub-nodes.d.ts +2 -0
  7. package/cjs/charts/compare-sankey/compare-sankey-sub-nodes.js +21 -0
  8. package/cjs/charts/compare-sankey/compare-sankey-sub-nodes.js.map +1 -0
  9. package/cjs/charts/compare-sankey/compare-sankey-transformer.d.ts +6 -0
  10. package/cjs/charts/compare-sankey/compare-sankey-transformer.js +22 -0
  11. package/cjs/charts/compare-sankey/compare-sankey-transformer.js.map +1 -0
  12. package/cjs/charts/compare-sankey/compare-sankey.d.ts +36 -0
  13. package/cjs/charts/compare-sankey/compare-sankey.js +185 -0
  14. package/cjs/charts/compare-sankey/compare-sankey.js.map +1 -0
  15. package/cjs/charts/compare-sankey/index.d.ts +2 -0
  16. package/cjs/charts/compare-sankey/index.js +21 -0
  17. package/cjs/charts/compare-sankey/index.js.map +1 -0
  18. package/cjs/charts/compare-sankey/interface.d.ts +23 -0
  19. package/cjs/charts/compare-sankey/interface.js +6 -0
  20. package/cjs/charts/compare-sankey/interface.js.map +1 -0
  21. package/cjs/charts/conversion-funnel/interface.js +1 -2
  22. package/cjs/charts/ranking-list/ranking-list-transformer.js +2 -1
  23. package/cjs/charts/sequence-scatter-link/sequence-scatter-link-transformer.js +1 -2
  24. package/cjs/components/bar-link/type.js +2 -1
  25. package/cjs/components/series-label/type.js +1 -2
  26. package/cjs/index.d.ts +1 -0
  27. package/cjs/index.js +2 -2
  28. package/cjs/index.js.map +1 -1
  29. package/cjs/utils/mark.d.ts +2 -0
  30. package/cjs/utils/mark.js +14 -0
  31. package/cjs/utils/mark.js.map +1 -0
  32. package/esm/charts/compare-sankey/compare-sankey-sub-data.d.ts +20 -0
  33. package/esm/charts/compare-sankey/compare-sankey-sub-data.js +106 -0
  34. package/esm/charts/compare-sankey/compare-sankey-sub-data.js.map +1 -0
  35. package/esm/charts/compare-sankey/compare-sankey-sub-nodes.d.ts +2 -0
  36. package/esm/charts/compare-sankey/compare-sankey-sub-nodes.js +13 -0
  37. package/esm/charts/compare-sankey/compare-sankey-sub-nodes.js.map +1 -0
  38. package/esm/charts/compare-sankey/compare-sankey-transformer.d.ts +6 -0
  39. package/esm/charts/compare-sankey/compare-sankey-transformer.js +14 -0
  40. package/esm/charts/compare-sankey/compare-sankey-transformer.js.map +1 -0
  41. package/esm/charts/compare-sankey/compare-sankey.d.ts +36 -0
  42. package/esm/charts/compare-sankey/compare-sankey.js +184 -0
  43. package/esm/charts/compare-sankey/compare-sankey.js.map +1 -0
  44. package/esm/charts/compare-sankey/index.d.ts +2 -0
  45. package/esm/charts/compare-sankey/index.js +4 -0
  46. package/esm/charts/compare-sankey/index.js.map +1 -0
  47. package/esm/charts/compare-sankey/interface.d.ts +23 -0
  48. package/esm/charts/compare-sankey/interface.js +2 -0
  49. package/esm/charts/compare-sankey/interface.js.map +1 -0
  50. package/esm/charts/conversion-funnel/interface.js +1 -2
  51. package/esm/charts/ranking-list/ranking-list-transformer.js +2 -1
  52. package/esm/charts/sequence-scatter-link/sequence-scatter-link-transformer.js +1 -2
  53. package/esm/components/bar-link/type.js +2 -1
  54. package/esm/components/series-label/type.js +1 -2
  55. package/esm/index.d.ts +1 -0
  56. package/esm/index.js +2 -0
  57. package/esm/index.js.map +1 -1
  58. package/esm/utils/mark.d.ts +2 -0
  59. package/esm/utils/mark.js +4 -0
  60. package/esm/utils/mark.js.map +1 -0
  61. package/package.json +5 -4
package/build/index.js CHANGED
@@ -495,6 +495,18 @@
495
495
  return target;
496
496
  }
497
497
 
498
+ function pickWithout(obj, keys) {
499
+ if (!obj || !isPlainObject$1(obj)) return obj;
500
+ const result = {};
501
+ return Object.keys(obj).forEach(k => {
502
+ const v = obj[k];
503
+ let match = !1;
504
+ keys.forEach(itKey => {
505
+ (isString$1(itKey) && itKey === k || itKey instanceof RegExp && k.match(itKey)) && (match = !0);
506
+ }), match || (result[k] = v);
507
+ }), result;
508
+ }
509
+
498
510
  function array(arr) {
499
511
  return isValid$1(arr) ? isArray$1(arr) ? arr : [arr] : [];
500
512
  }
@@ -618,6 +630,28 @@
618
630
  };
619
631
  var clamp$1 = clamp;
620
632
 
633
+ function toValidNumber(v) {
634
+ if (isValidNumber$1(v)) return v;
635
+ const value = +v;
636
+ return isValidNumber$1(value) ? value : 0;
637
+ }
638
+
639
+ const getter = path => obj => get$1(obj, path);
640
+ const fieldSingle = function (fieldStr) {
641
+ let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
642
+ if (isFunction$1(fieldStr)) return fieldStr;
643
+ const path = [fieldStr];
644
+ return (opt && opt.get || getter)(path);
645
+ };
646
+ const field = function (fieldStr) {
647
+ let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
648
+ if (isArray$1(fieldStr)) {
649
+ const funcs = fieldStr.map(entry => fieldSingle(entry, opt));
650
+ return datum => funcs.map(func => func(datum));
651
+ }
652
+ return fieldSingle(fieldStr, opt);
653
+ };
654
+
621
655
  const epsilon = 1e-12;
622
656
  const pi = Math.PI;
623
657
  const halfPi = pi / 2;
@@ -4232,6 +4266,411 @@
4232
4266
  }
4233
4267
  };
4234
4268
 
4269
+ class CompareSankeyChartSpecTransformer extends vchart.SankeyChartSpecTransformer {
4270
+ transformSpec(spec) {
4271
+ super.transformSpec(spec);
4272
+ }
4273
+ _getDefaultSeriesSpec(spec) {
4274
+ const seriesSpec = super._getDefaultSeriesSpec(spec);
4275
+ seriesSpec.subNodeGap = spec.subNodeGap;
4276
+ seriesSpec.compareNodeColor = spec.compareNodeColor;
4277
+ seriesSpec.compareLinkColor = spec.compareLinkColor;
4278
+ seriesSpec.activeLink = spec.activeLink;
4279
+ return seriesSpec;
4280
+ }
4281
+ }
4282
+
4283
+ const compareSankeySubNodes = (data) => {
4284
+ const viewData = data[0];
4285
+ if (!viewData.latestData) {
4286
+ return [];
4287
+ }
4288
+ const subData = Object.keys(viewData.latestData);
4289
+ if (!subData.length) {
4290
+ return {};
4291
+ }
4292
+ const subNodes = [];
4293
+ subData.forEach(key => {
4294
+ subNodes.push(...viewData.latestData[key].nodes);
4295
+ });
4296
+ return [{ nodes: subNodes }];
4297
+ };
4298
+
4299
+ const calculateNodeValue = (subTree) => {
4300
+ let sum = 0;
4301
+ subTree.forEach(node => {
4302
+ var _a;
4303
+ if (isNil$1(node.value)) {
4304
+ if ((_a = node.children) === null || _a === void 0 ? void 0 : _a.length) {
4305
+ node.value = calculateNodeValue(node.children);
4306
+ }
4307
+ else {
4308
+ node.value = 0;
4309
+ }
4310
+ }
4311
+ sum += Math.abs(node.value);
4312
+ });
4313
+ return sum;
4314
+ };
4315
+ function makeHierarchicNodes(originalNodes, nodeKeyFunc, nodes = [], nodeMap = {}, originalLinks) {
4316
+ calculateNodeValue(originalNodes);
4317
+ const doSubTree = (subTree, depth, parents) => {
4318
+ subTree.forEach((node, index) => {
4319
+ const nodeKey = nodeKeyFunc
4320
+ ? nodeKeyFunc(node)
4321
+ : parents
4322
+ ? `${parents[parents.length - 1].key}-${index}`
4323
+ : `${depth}-${index}`;
4324
+ const nodeValue = (isNil$1(node.value) ? 0 : toValidNumber(node.value));
4325
+ if (nodeMap[nodeKey]) {
4326
+ nodeMap[nodeKey].value = undefined;
4327
+ }
4328
+ else {
4329
+ const nodeElement = {
4330
+ depth,
4331
+ datum: node,
4332
+ index: index,
4333
+ key: nodeKey,
4334
+ value: nodeValue,
4335
+ sourceLinks: [],
4336
+ targetLinks: []
4337
+ };
4338
+ nodeMap[nodeKey] = nodeElement;
4339
+ nodes.push(nodeElement);
4340
+ }
4341
+ if (parents && originalLinks) {
4342
+ originalLinks.push({
4343
+ source: parents[parents.length - 1].key,
4344
+ target: nodeKey,
4345
+ value: nodeValue,
4346
+ parents
4347
+ });
4348
+ }
4349
+ if (node.children && node.children.length) {
4350
+ doSubTree(node.children, depth + 1, parents ? parents.concat([nodeMap[nodeKey]]) : [nodeMap[nodeKey]]);
4351
+ }
4352
+ });
4353
+ };
4354
+ doSubTree(originalNodes, 0, null);
4355
+ return nodes;
4356
+ }
4357
+ function computeHierarchicNodeLinks(originalNodes, nodeKeyFunc) {
4358
+ const nodes = [];
4359
+ const links = [];
4360
+ const nodeMap = {};
4361
+ const linkMap = {};
4362
+ const originalLinks = [];
4363
+ makeHierarchicNodes(originalNodes, nodeKeyFunc, nodes, nodeMap, originalLinks);
4364
+ originalLinks.forEach((link, index) => {
4365
+ const key = `${link.source}-${link.target}`;
4366
+ const linkDatum = pickWithout(link, ['parents']);
4367
+ linkDatum.parents = link.parents.map(node => {
4368
+ return pickWithout(node, ['sourceLinks', 'targetLinks']);
4369
+ });
4370
+ if (linkMap[key]) {
4371
+ linkMap[key].value += toValidNumber(link.value);
4372
+ linkMap[key].datum.push(linkDatum);
4373
+ return;
4374
+ }
4375
+ const linkElement = {
4376
+ index,
4377
+ key: `${link.source}-${link.target}`,
4378
+ source: link.source,
4379
+ target: link.target,
4380
+ datum: [linkDatum],
4381
+ value: link.value,
4382
+ parents: link.parents.map(parent => parent.key)
4383
+ };
4384
+ links.push(linkElement);
4385
+ nodeMap[link.source].sourceLinks.push(linkElement);
4386
+ nodeMap[link.target].targetLinks.push(linkElement);
4387
+ linkMap[key] = linkElement;
4388
+ });
4389
+ return { nodes, links, nodeMap };
4390
+ }
4391
+ function computeNodeValues(nodes) {
4392
+ for (let i = 0, len = nodes.length; i < len; i++) {
4393
+ const node = nodes[i];
4394
+ node.value = Math.max(isNil$1(node.value) ? 0 : toValidNumber(node.value), node.sourceLinks.reduce((sum, link) => {
4395
+ var _a;
4396
+ return sum + ((_a = toValidNumber(link.value)) !== null && _a !== void 0 ? _a : 0);
4397
+ }, 0), node.targetLinks.reduce((sum, link) => {
4398
+ var _a;
4399
+ return sum + ((_a = toValidNumber(link.value)) !== null && _a !== void 0 ? _a : 0);
4400
+ }, 0));
4401
+ }
4402
+ }
4403
+ const compareSankeySubData = (data, opt) => {
4404
+ var _a;
4405
+ const viewData = data[0];
4406
+ if (!((_a = viewData.latestData) === null || _a === void 0 ? void 0 : _a.length)) {
4407
+ return {};
4408
+ }
4409
+ const rawDataTree = opt.rawData().latestData[0];
4410
+ const subNodeGap = opt.subNodeGap;
4411
+ const keyFunc = isFunction$1(opt.nodeKey) ? opt.nodeKey : opt.nodeKey ? field(opt.nodeKey) : null;
4412
+ const subNodeMap = {};
4413
+ rawDataTree.subNode.forEach((sunGroup) => {
4414
+ subNodeMap[sunGroup.type] = computeHierarchicNodeLinks(sunGroup.nodes, keyFunc);
4415
+ computeNodeValues(subNodeMap[sunGroup.type].nodes);
4416
+ });
4417
+ const subCount = Object.keys(subNodeMap).length;
4418
+ viewData.latestData[0].nodes.forEach((n) => {
4419
+ let path = [];
4420
+ if (n.targetLinks.length) {
4421
+ const link = n.targetLinks[0];
4422
+ path = [...link.parents];
4423
+ }
4424
+ path.push(n.key);
4425
+ let currentY = n.y0;
4426
+ const totalSize = n.y1 - n.y0 - (subCount - 1) * subNodeGap;
4427
+ const totalValue = n.value;
4428
+ rawDataTree.subNode.forEach((sunGroup) => {
4429
+ const subNode = subNodeMap[sunGroup.type].nodes.find(subN => subN.key === n.key);
4430
+ if (!subNode) {
4431
+ return;
4432
+ }
4433
+ const percent = subNode.value / totalValue;
4434
+ subNode.x0 = n.x0;
4435
+ subNode.x1 = n.x1;
4436
+ subNode.y0 = currentY;
4437
+ subNode.y1 = currentY + totalSize * percent;
4438
+ subNode.type = sunGroup.type;
4439
+ subNode.sourceNode = n;
4440
+ currentY += totalSize * percent + subNodeGap;
4441
+ });
4442
+ });
4443
+ return subNodeMap;
4444
+ };
4445
+
4446
+ const getDatumOfGraphic = (g) => {
4447
+ if (!g || !g.graphicItem) {
4448
+ return null;
4449
+ }
4450
+ if (isCollectionMark(g.graphicItem.type)) {
4451
+ return g.data;
4452
+ }
4453
+ return g.data[0];
4454
+ };
4455
+ const isCollectionMark = (type) => {
4456
+ return type === 'line' || type === 'area';
4457
+ };
4458
+
4459
+ class CompareSankeyChart extends vchart.SankeyChart {
4460
+ constructor() {
4461
+ super(...arguments);
4462
+ this.type = 'compareSankey';
4463
+ this.transformerConstructor = CompareSankeyChartSpecTransformer;
4464
+ }
4465
+ }
4466
+ CompareSankeyChart.type = 'compareSankey';
4467
+ CompareSankeyChart.transformerConstructor = CompareSankeyChartSpecTransformer;
4468
+ class CompareSankeySeries extends vchart.SankeySeries {
4469
+ constructor() {
4470
+ super(...arguments);
4471
+ this._fillCompareNode = (datum) => {
4472
+ var _a, _b, _c;
4473
+ if ((_a = this._spec.compareNodeColor) === null || _a === void 0 ? void 0 : _a[datum.type]) {
4474
+ return this._spec.compareNodeColor[datum.type];
4475
+ }
4476
+ return (_c = (_b = this._spec.node.style) === null || _b === void 0 ? void 0 : _b.fill) !== null && _c !== void 0 ? _c : this._fillByNode(datum);
4477
+ };
4478
+ this._fillActiveLink = (datum) => {
4479
+ var _a, _b, _c;
4480
+ if ((_a = this._spec.compareLinkColor) === null || _a === void 0 ? void 0 : _a[datum.type]) {
4481
+ return this._spec.compareLinkColor[datum.type];
4482
+ }
4483
+ return (_c = (_b = this._spec.link.style) === null || _b === void 0 ? void 0 : _b.fill) !== null && _c !== void 0 ? _c : this._fillByLink(datum);
4484
+ };
4485
+ }
4486
+ initData() {
4487
+ var _a;
4488
+ super.initData();
4489
+ const { dataSet } = this._option;
4490
+ const compareSubData = new DataView(dataSet, { name: `compare-sankey-sub-data-${this.id}-data` });
4491
+ compareSubData.parse([this.getViewData()], {
4492
+ type: 'dataview'
4493
+ });
4494
+ this._subData = compareSubData;
4495
+ const compareNodeData = new DataView(dataSet, { name: `compare-sankey-node-${this.id}-data` });
4496
+ compareNodeData.parse([compareSubData], {
4497
+ type: 'dataview'
4498
+ });
4499
+ vchart.registerDataSetInstanceTransform(this._dataSet, 'compareSankeySubData', compareSankeySubData);
4500
+ compareSubData.transform({
4501
+ type: 'compareSankeySubData',
4502
+ options: {
4503
+ rawData: () => this.getRawData(),
4504
+ valueField: this._valueField,
4505
+ nodeKey: this._spec.nodeKey,
4506
+ subNodeGap: (_a = this._spec.subNodeGap) !== null && _a !== void 0 ? _a : 2
4507
+ }
4508
+ });
4509
+ vchart.registerDataSetInstanceTransform(this._dataSet, 'compareSankeySubNodes', compareSankeySubNodes);
4510
+ compareNodeData.transform({
4511
+ type: 'compareSankeySubNodes'
4512
+ });
4513
+ this._nodesSeriesData.getDataView().parse([compareNodeData], {
4514
+ type: 'dataview'
4515
+ });
4516
+ this._activeLinkData = new DataView(dataSet, { name: `compare-sankey-link-${this.id}-data` });
4517
+ }
4518
+ initEvent() {
4519
+ var _a;
4520
+ super.initEvent();
4521
+ (_a = this._activeLinkData) === null || _a === void 0 ? void 0 : _a.target.addListener('change', this.activeLinkDataUpdate.bind(this));
4522
+ }
4523
+ initMark() {
4524
+ super.initMark();
4525
+ const linkMark = this._createMark(Object.assign(Object.assign({}, vchart.SankeySeries.mark.link), { name: 'activeLink' }), {
4526
+ dataView: this._activeLinkData
4527
+ });
4528
+ if (linkMark) {
4529
+ this._activeLinkMark = linkMark;
4530
+ }
4531
+ }
4532
+ compileData() {
4533
+ var _a;
4534
+ super.compileData();
4535
+ (_a = this._activeLinkMark) === null || _a === void 0 ? void 0 : _a.compileData();
4536
+ }
4537
+ _initLinkMarkStyle() {
4538
+ super._initLinkMarkStyle();
4539
+ this._activeLinkMark.setAttribute('direction', this.direction);
4540
+ this.setMarkStyle(this._activeLinkMark, {
4541
+ x0: (datum) => datum.x0,
4542
+ x1: (datum) => datum.x1,
4543
+ y0: (datum) => datum.y0,
4544
+ y1: (datum) => datum.y1,
4545
+ thickness: (datum) => datum.thickness
4546
+ }, vchart.STATE_VALUE_ENUM.STATE_NORMAL, vchart.AttributeLevel.Series);
4547
+ this.setMarkStyle(this._activeLinkMark, {
4548
+ fill: this._fillActiveLink
4549
+ }, vchart.STATE_VALUE_ENUM.STATE_NORMAL, vchart.AttributeLevel.User_Mark);
4550
+ }
4551
+ _initNodeMarkStyle() {
4552
+ super._initNodeMarkStyle();
4553
+ if (this._spec.compareNodeColor) {
4554
+ this.setMarkStyle(this._nodeMark, {
4555
+ fill: this._fillCompareNode
4556
+ }, 'normal', vchart.AttributeLevel.User_Mark);
4557
+ }
4558
+ }
4559
+ activeLinkDataUpdate() {
4560
+ this._activeLinkMark.getData().updateData();
4561
+ }
4562
+ _handleNodeRelatedClick(element, highlightState, blurState) {
4563
+ const nodeDatum = element.getDatum();
4564
+ const allNodeElements = this._nodeMark.getProductElements();
4565
+ if (!allNodeElements || !allNodeElements.length) {
4566
+ return;
4567
+ }
4568
+ const allLinkElements = this._linkMark.getProductElements();
4569
+ if (!allLinkElements || !allLinkElements.length) {
4570
+ return;
4571
+ }
4572
+ allLinkElements.forEach(el => {
4573
+ el.removeState([vchart.STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS]);
4574
+ });
4575
+ this._highLightElements(allLinkElements, [], highlightState, blurState);
4576
+ const nodeDatums = allNodeElements.map(el => getDatumOfGraphic(el));
4577
+ const pickNodeDatums = nodeDatums.filter(d => d.key === nodeDatum.key);
4578
+ const highlightLinksData = [];
4579
+ const highlightNodeKeys = [];
4580
+ this._activeTargetLink(nodeDatum, pickNodeDatums, allNodeElements, allLinkElements, highlightNodeKeys, highlightLinksData, highlightState, blurState);
4581
+ this._activeSourceLink(nodeDatum, pickNodeDatums, nodeDatums, allNodeElements, highlightNodeKeys, highlightLinksData, highlightState, blurState);
4582
+ this._highLightElements(allNodeElements, highlightNodeKeys, highlightState, blurState);
4583
+ this._activeLinkData.parseNewData(highlightLinksData);
4584
+ this._needClear = true;
4585
+ }
4586
+ _activeTargetLink(nodeDatum, pickNodeDatums, allNodeElements, allLinkElements, highlightNodeKeys, highlightLinksData, highlightState, blurState) {
4587
+ this._handleClearEmpty(highlightState, blurState);
4588
+ const sourceNode = nodeDatum.sourceNode;
4589
+ const firstTarget = sourceNode.targetLinks[0];
4590
+ if (!firstTarget) {
4591
+ return;
4592
+ }
4593
+ let percent = 0;
4594
+ pickNodeDatums.forEach(n => {
4595
+ const link = n.targetLinks.find((l) => l.key === firstTarget.key);
4596
+ if (link) {
4597
+ const p = link.value / firstTarget.value;
4598
+ const key = firstTarget.key + '_' + n.type;
4599
+ const activeLink = Object.assign(Object.assign({}, firstTarget), { y0: firstTarget.y0 - firstTarget.thickness / 2 + (percent + p / 2) * firstTarget.thickness, y1: n.y0 + (p * firstTarget.thickness) / 2, thickness: p * firstTarget.thickness, key, type: n.type, [vchart.DEFAULT_DATA_INDEX]: highlightLinksData.length, [vchart.DEFAULT_DATA_KEY]: key });
4600
+ highlightLinksData.push(activeLink);
4601
+ percent += p;
4602
+ }
4603
+ });
4604
+ highlightNodeKeys.push(...firstTarget.parents, nodeDatum.key);
4605
+ const linkKeys = [];
4606
+ for (let i = 0; i < firstTarget.parents.length - 1; i++) {
4607
+ linkKeys.push(firstTarget.parents[i] + '-' + firstTarget.parents[i + 1]);
4608
+ }
4609
+ this._highLightElements(allLinkElements, linkKeys, highlightState, blurState);
4610
+ }
4611
+ _activeSourceLink(nodeDatum, pickNodeDatums, allNodeDatums, allNodeElements, highlightNodeKeys, highlightLinksData, highlightState, blurState) {
4612
+ this._handleClearEmpty(highlightState, blurState);
4613
+ const sourceNode = nodeDatum.sourceNode;
4614
+ const sourceLinks = sourceNode.sourceLinks;
4615
+ if (!(sourceLinks === null || sourceLinks === void 0 ? void 0 : sourceLinks.length)) {
4616
+ return;
4617
+ }
4618
+ const sourceValueTemp = {};
4619
+ sourceLinks.forEach((sourceLink) => {
4620
+ highlightNodeKeys.push(sourceLink.target);
4621
+ pickNodeDatums.forEach((n, index) => {
4622
+ var _a;
4623
+ sourceValueTemp[n.type] = (_a = sourceValueTemp[n.type]) !== null && _a !== void 0 ? _a : 0;
4624
+ const link = n.sourceLinks.find((l) => l.key === sourceLink.key);
4625
+ if (link) {
4626
+ const p = link.value / n.value;
4627
+ const totalSize = n.y1 - n.y0;
4628
+ const size = totalSize * p;
4629
+ const key = sourceLink.key + '_' + n.type;
4630
+ const activeLink = Object.assign(Object.assign({}, sourceLink), { y0: n.y0 + sourceValueTemp[n.type] * totalSize + size / 2, thickness: size, key, type: n.type, [vchart.DEFAULT_DATA_INDEX]: highlightLinksData.length, [vchart.DEFAULT_DATA_KEY]: key });
4631
+ if (index === 0) {
4632
+ activeLink.y1 = sourceLink.y1 - sourceLink.thickness / 2 + size / 2;
4633
+ }
4634
+ else {
4635
+ const targetNode = allNodeDatums.find(_n => _n.key === link.target && _n.type === n.type);
4636
+ if (targetNode) {
4637
+ activeLink.y1 = targetNode.y0 + size / 2;
4638
+ }
4639
+ else {
4640
+ return;
4641
+ }
4642
+ }
4643
+ highlightLinksData.push(activeLink);
4644
+ sourceValueTemp[n.type] += p;
4645
+ }
4646
+ });
4647
+ });
4648
+ }
4649
+ _handleClearEmpty(highlightState, blurState) {
4650
+ super._handleClearEmpty(highlightState, blurState);
4651
+ this._activeLinkData.parseNewData([]);
4652
+ const allNodeElements = this._nodeMark.getProductElements();
4653
+ if (allNodeElements || !allNodeElements.length) {
4654
+ allNodeElements.forEach(el => {
4655
+ el.removeState(vchart.STATE_VALUE_ENUM.STATE_HOVER);
4656
+ });
4657
+ }
4658
+ const allLinkElements = this._linkMark.getProductElements();
4659
+ if (allLinkElements || !allLinkElements.length) {
4660
+ allLinkElements.forEach(el => {
4661
+ el.removeState(vchart.STATE_VALUE_ENUM.STATE_HOVER);
4662
+ });
4663
+ }
4664
+ }
4665
+ }
4666
+ const registerCompareSankeyChart = (option) => {
4667
+ const vchartConstructor = (option === null || option === void 0 ? void 0 : option.VChart) || vchart.VChart;
4668
+ if (vchartConstructor) {
4669
+ vchartConstructor.useChart([CompareSankeyChart]);
4670
+ vchartConstructor.useSeries([CompareSankeySeries]);
4671
+ }
4672
+ };
4673
+
4235
4674
  class Generator {
4236
4675
  static GenAutoIncrementId() {
4237
4676
  return Generator.auto_increment_id++;
@@ -13957,6 +14396,8 @@
13957
14396
 
13958
14397
  exports.BAR_LINK = BAR_LINK;
13959
14398
  exports.BarLinkComponent = BarLinkComponent;
14399
+ exports.CompareSankeyChart = CompareSankeyChart;
14400
+ exports.CompareSankeySeries = CompareSankeySeries;
13960
14401
  exports.ConversionFunnelChart = ConversionFunnelChart;
13961
14402
  exports.ConversionFunnelSeries = ConversionFunnelSeries;
13962
14403
  exports.DEFAULT_ARROW_MARK_STYLE = DEFAULT_ARROW_MARK_STYLE;
@@ -13978,6 +14419,7 @@
13978
14419
  exports.getSeriesBreakConfig = getSeriesBreakConfig;
13979
14420
  exports.getSeriesLabelConfig = getSeriesLabelConfig;
13980
14421
  exports.registerBarLink = registerBarLink;
14422
+ exports.registerCompareSankeyChart = registerCompareSankeyChart;
13981
14423
  exports.registerConversionFunnelChart = registerConversionFunnelChart;
13982
14424
  exports.registerRankingBarChart = registerRankingBarChart;
13983
14425
  exports.registerRankingList = registerRankingList;