@visactor/vchart-extension 1.13.9-alpha.10 → 1.13.9-alpha.11

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 (95) hide show
  1. package/build/index.js +818 -9
  2. package/build/index.min.js +1 -1
  3. package/cjs/charts/sequence-scatter-kde/constant.d.ts +3 -0
  4. package/cjs/charts/sequence-scatter-kde/constant.js +7 -0
  5. package/cjs/charts/sequence-scatter-kde/constant.js.map +1 -0
  6. package/cjs/charts/sequence-scatter-kde/interface.d.ts +29 -0
  7. package/cjs/charts/sequence-scatter-kde/interface.js +6 -0
  8. package/cjs/charts/sequence-scatter-kde/interface.js.map +1 -0
  9. package/cjs/charts/sequence-scatter-kde/sequence-scatter-kde-transformer.d.ts +6 -0
  10. package/cjs/charts/sequence-scatter-kde/sequence-scatter-kde-transformer.js +142 -0
  11. package/cjs/charts/sequence-scatter-kde/sequence-scatter-kde-transformer.js.map +1 -0
  12. package/cjs/charts/sequence-scatter-kde/sequence-scatter-kde.d.ts +16 -0
  13. package/cjs/charts/sequence-scatter-kde/sequence-scatter-kde.js +34 -0
  14. package/cjs/charts/sequence-scatter-kde/sequence-scatter-kde.js.map +1 -0
  15. package/cjs/charts/sequence-scatter-kde/utils.d.ts +9 -0
  16. package/cjs/charts/sequence-scatter-kde/utils.js +42 -0
  17. package/cjs/charts/sequence-scatter-kde/utils.js.map +1 -0
  18. package/cjs/charts/sequence-scatter-link/interface.d.ts +59 -0
  19. package/cjs/charts/sequence-scatter-link/interface.js +6 -0
  20. package/cjs/charts/sequence-scatter-link/interface.js.map +1 -0
  21. package/cjs/charts/sequence-scatter-link/sequence-scatter-link-transformer.d.ts +6 -0
  22. package/cjs/charts/sequence-scatter-link/sequence-scatter-link-transformer.js +328 -0
  23. package/cjs/charts/sequence-scatter-link/sequence-scatter-link-transformer.js.map +1 -0
  24. package/cjs/charts/sequence-scatter-link/sequence-scatter-link.d.ts +16 -0
  25. package/cjs/charts/sequence-scatter-link/sequence-scatter-link.js +34 -0
  26. package/cjs/charts/sequence-scatter-link/sequence-scatter-link.js.map +1 -0
  27. package/cjs/charts/sequence-scatter-link/utils.d.ts +9 -0
  28. package/cjs/charts/sequence-scatter-link/utils.js +108 -0
  29. package/cjs/charts/sequence-scatter-link/utils.js.map +1 -0
  30. package/cjs/charts/sequence-scatter-pixel/constant.d.ts +3 -0
  31. package/cjs/charts/sequence-scatter-pixel/constant.js +7 -0
  32. package/cjs/charts/sequence-scatter-pixel/constant.js.map +1 -0
  33. package/cjs/charts/sequence-scatter-pixel/interface.d.ts +29 -0
  34. package/cjs/charts/sequence-scatter-pixel/interface.js +6 -0
  35. package/cjs/charts/sequence-scatter-pixel/interface.js.map +1 -0
  36. package/cjs/charts/sequence-scatter-pixel/sequence-scatter-pixel-transformer.d.ts +4 -0
  37. package/cjs/charts/sequence-scatter-pixel/sequence-scatter-pixel-transformer.js +68 -0
  38. package/cjs/charts/sequence-scatter-pixel/sequence-scatter-pixel-transformer.js.map +1 -0
  39. package/cjs/charts/sequence-scatter-pixel/sequence-scatter-pixel.d.ts +16 -0
  40. package/cjs/charts/sequence-scatter-pixel/sequence-scatter-pixel.js +34 -0
  41. package/cjs/charts/sequence-scatter-pixel/sequence-scatter-pixel.js.map +1 -0
  42. package/cjs/charts/sequence-scatter-pixel/utils.d.ts +3 -0
  43. package/cjs/charts/sequence-scatter-pixel/utils.js +53 -0
  44. package/cjs/charts/sequence-scatter-pixel/utils.js.map +1 -0
  45. package/cjs/components/series-label/type.js +2 -1
  46. package/cjs/index.d.ts +3 -0
  47. package/cjs/index.js +5 -2
  48. package/cjs/index.js.map +1 -1
  49. package/esm/charts/sequence-scatter-kde/constant.d.ts +3 -0
  50. package/esm/charts/sequence-scatter-kde/constant.js +6 -0
  51. package/esm/charts/sequence-scatter-kde/constant.js.map +1 -0
  52. package/esm/charts/sequence-scatter-kde/interface.d.ts +29 -0
  53. package/esm/charts/sequence-scatter-kde/interface.js +2 -0
  54. package/esm/charts/sequence-scatter-kde/interface.js.map +1 -0
  55. package/esm/charts/sequence-scatter-kde/sequence-scatter-kde-transformer.d.ts +6 -0
  56. package/esm/charts/sequence-scatter-kde/sequence-scatter-kde-transformer.js +137 -0
  57. package/esm/charts/sequence-scatter-kde/sequence-scatter-kde-transformer.js.map +1 -0
  58. package/esm/charts/sequence-scatter-kde/sequence-scatter-kde.d.ts +16 -0
  59. package/esm/charts/sequence-scatter-kde/sequence-scatter-kde.js +28 -0
  60. package/esm/charts/sequence-scatter-kde/sequence-scatter-kde.js.map +1 -0
  61. package/esm/charts/sequence-scatter-kde/utils.d.ts +9 -0
  62. package/esm/charts/sequence-scatter-kde/utils.js +34 -0
  63. package/esm/charts/sequence-scatter-kde/utils.js.map +1 -0
  64. package/esm/charts/sequence-scatter-link/interface.d.ts +59 -0
  65. package/esm/charts/sequence-scatter-link/interface.js +2 -0
  66. package/esm/charts/sequence-scatter-link/interface.js.map +1 -0
  67. package/esm/charts/sequence-scatter-link/sequence-scatter-link-transformer.d.ts +6 -0
  68. package/esm/charts/sequence-scatter-link/sequence-scatter-link-transformer.js +321 -0
  69. package/esm/charts/sequence-scatter-link/sequence-scatter-link-transformer.js.map +1 -0
  70. package/esm/charts/sequence-scatter-link/sequence-scatter-link.d.ts +16 -0
  71. package/esm/charts/sequence-scatter-link/sequence-scatter-link.js +28 -0
  72. package/esm/charts/sequence-scatter-link/sequence-scatter-link.js.map +1 -0
  73. package/esm/charts/sequence-scatter-link/utils.d.ts +9 -0
  74. package/esm/charts/sequence-scatter-link/utils.js +100 -0
  75. package/esm/charts/sequence-scatter-link/utils.js.map +1 -0
  76. package/esm/charts/sequence-scatter-pixel/constant.d.ts +3 -0
  77. package/esm/charts/sequence-scatter-pixel/constant.js +6 -0
  78. package/esm/charts/sequence-scatter-pixel/constant.js.map +1 -0
  79. package/esm/charts/sequence-scatter-pixel/interface.d.ts +29 -0
  80. package/esm/charts/sequence-scatter-pixel/interface.js +2 -0
  81. package/esm/charts/sequence-scatter-pixel/interface.js.map +1 -0
  82. package/esm/charts/sequence-scatter-pixel/sequence-scatter-pixel-transformer.d.ts +4 -0
  83. package/esm/charts/sequence-scatter-pixel/sequence-scatter-pixel-transformer.js +64 -0
  84. package/esm/charts/sequence-scatter-pixel/sequence-scatter-pixel-transformer.js.map +1 -0
  85. package/esm/charts/sequence-scatter-pixel/sequence-scatter-pixel.d.ts +16 -0
  86. package/esm/charts/sequence-scatter-pixel/sequence-scatter-pixel.js +28 -0
  87. package/esm/charts/sequence-scatter-pixel/sequence-scatter-pixel.js.map +1 -0
  88. package/esm/charts/sequence-scatter-pixel/utils.d.ts +3 -0
  89. package/esm/charts/sequence-scatter-pixel/utils.js +45 -0
  90. package/esm/charts/sequence-scatter-pixel/utils.js.map +1 -0
  91. package/esm/components/series-label/type.js +2 -1
  92. package/esm/index.d.ts +3 -0
  93. package/esm/index.js +6 -0
  94. package/esm/index.js.map +1 -1
  95. package/package.json +8 -8
package/build/index.js CHANGED
@@ -467,7 +467,7 @@
467
467
  return { min: dataMin, max: dataMax };
468
468
  };
469
469
 
470
- const DATA_KEY = 'dataKey';
470
+ const DATA_KEY$3 = 'dataKey';
471
471
  const ORDER_KEY = 'VCHART_ORDER';
472
472
  const SUPPLY_DATA_KEY = 'SUPPLY_DATA_KEY';
473
473
  const NAME_LABEL_PADDING_RIGHT = 10;
@@ -525,7 +525,7 @@
525
525
  {
526
526
  id: 'datas',
527
527
  values: pagerData[order].map(d => {
528
- return Object.assign(Object.assign({}, d), { [DATA_KEY]: d[spec.yField] });
528
+ return Object.assign(Object.assign({}, d), { [DATA_KEY$3]: d[spec.yField] });
529
529
  })
530
530
  },
531
531
  {
@@ -618,7 +618,7 @@
618
618
  transformBaseSpec(spec) {
619
619
  var _a, _b, _c;
620
620
  spec.type = 'common';
621
- spec.dataKey = DATA_KEY;
621
+ spec.dataKey = DATA_KEY$3;
622
622
  spec.series = [
623
623
  {
624
624
  type: 'bar',
@@ -673,7 +673,7 @@
673
673
  type: spec.barBackground.type,
674
674
  dataId: 'data',
675
675
  visible: true,
676
- dataKey: DATA_KEY,
676
+ dataKey: DATA_KEY$3,
677
677
  zIndex: -99,
678
678
  state: (_a = spec.barBackground) === null || _a === void 0 ? void 0 : _a.state,
679
679
  style: Object.assign(Object.assign({ x: (datum, ctx) => spec.barBackground.type === 'symbol' ? ctx.getRegion().getLayoutRect().width / 2 : 0, y: (datum, ctx) => {
@@ -700,7 +700,7 @@
700
700
  type: 'symbol',
701
701
  dataId: 'data',
702
702
  visible: true,
703
- dataKey: DATA_KEY,
703
+ dataKey: DATA_KEY$3,
704
704
  state: decorateHaloIcon === null || decorateHaloIcon === void 0 ? void 0 : decorateHaloIcon.state,
705
705
  style: Object.assign(Object.assign({ x: (datum, ctx) => {
706
706
  if (datum[spec.xField] === undefined || datum[spec.xField] === null) {
@@ -728,7 +728,7 @@
728
728
  type: 'symbol',
729
729
  dataId: 'data',
730
730
  visible: true,
731
- dataKey: DATA_KEY,
731
+ dataKey: DATA_KEY$3,
732
732
  state: spec.rankingIcon.state,
733
733
  style: Object.assign(Object.assign({ x: (datum) => {
734
734
  if (spec.labelLayout === 'bothEnd') {
@@ -769,7 +769,7 @@
769
769
  return {
770
770
  type: 'text',
771
771
  dataId: 'data',
772
- dataKey: DATA_KEY,
772
+ dataKey: DATA_KEY$3,
773
773
  state: (_a = spec.nameLabel) === null || _a === void 0 ? void 0 : _a.state,
774
774
  style: Object.assign(Object.assign({ text: (datum) => this.formatDatum(spec.yField, datum), x: () => {
775
775
  var _a;
@@ -803,7 +803,7 @@
803
803
  return {
804
804
  type: 'text',
805
805
  dataId: 'data',
806
- dataKey: DATA_KEY,
806
+ dataKey: DATA_KEY$3,
807
807
  state: (_a = spec.orderLabel) === null || _a === void 0 ? void 0 : _a.state,
808
808
  style: Object.assign(Object.assign({ text: (datum) => this.formatDatum(ORDER_KEY, datum), x: (datum) => {
809
809
  var _a;
@@ -839,7 +839,7 @@
839
839
  type: 'text',
840
840
  dataId: 'data',
841
841
  visible: true,
842
- dataKey: DATA_KEY,
842
+ dataKey: DATA_KEY$3,
843
843
  state: (_a = spec.valueLabel) === null || _a === void 0 ? void 0 : _a.state,
844
844
  style: Object.assign(Object.assign({ text: (datum) => this.formatDatum(spec.xField, datum), x: (datum, ctx) => {
845
845
  if (spec.labelLayout === 'bothEnd') {
@@ -1667,6 +1667,809 @@
1667
1667
  fill: '#eff1f9'
1668
1668
  };
1669
1669
 
1670
+ const DATA_KEY$2 = 'dataKey';
1671
+ class SequenceScatterLinkChartSpecTransformer extends vchart.CommonChartSpecTransformer {
1672
+ transformSpec(spec) {
1673
+ var _a, _b, _c, _d, _e;
1674
+ super.transformSpec(spec);
1675
+ const dataSpecs = processSequenceData$2(spec);
1676
+ const showTooltip = spec.taskType === 'neighborhood' ? false : true;
1677
+ spec.type = 'common';
1678
+ spec.dataKey = DATA_KEY$2;
1679
+ spec.data = dataSpecs[0].data;
1680
+ spec.series = [
1681
+ {
1682
+ id: 'background-series',
1683
+ type: 'area',
1684
+ dataId: 'background',
1685
+ interactive: false,
1686
+ persent: true,
1687
+ xField: 'x',
1688
+ yField: 'y',
1689
+ point: {
1690
+ visible: false
1691
+ },
1692
+ line: {
1693
+ visible: false
1694
+ },
1695
+ area: {
1696
+ visible: true,
1697
+ interactive: false,
1698
+ style: {
1699
+ background: (datum) => {
1700
+ if (spec.taskType === 'neighborhood') {
1701
+ return '';
1702
+ }
1703
+ return `https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/sequence-scatter-bgimg-2/${datum.iter}.png`;
1704
+ },
1705
+ fill: 'transparent',
1706
+ fillOpacity: 0.5
1707
+ }
1708
+ },
1709
+ hover: {
1710
+ enable: false
1711
+ },
1712
+ select: {
1713
+ enable: false
1714
+ }
1715
+ },
1716
+ {
1717
+ id: 'line-series',
1718
+ type: 'line',
1719
+ dataId: 'endpoints',
1720
+ xField: 'x',
1721
+ yField: 'y',
1722
+ seriesField: 'edgeId',
1723
+ animation: true,
1724
+ point: {
1725
+ visible: false
1726
+ },
1727
+ line: {
1728
+ visible: true,
1729
+ style: {
1730
+ stroke: (datum) => {
1731
+ return datum.color;
1732
+ },
1733
+ lineDash: (datum) => {
1734
+ if (datum.type === 'same_type') {
1735
+ return [0, 0];
1736
+ }
1737
+ else {
1738
+ return [3, 2];
1739
+ }
1740
+ },
1741
+ lineWidth: 0.8,
1742
+ strokeOpacity: 0.6
1743
+ }
1744
+ }
1745
+ },
1746
+ {
1747
+ id: 'scatter-series',
1748
+ type: 'scatter',
1749
+ dataId: 'nodes',
1750
+ xField: spec.xField,
1751
+ yField: spec.yField,
1752
+ seriesField: 'label',
1753
+ point: {
1754
+ state: {
1755
+ hover: {
1756
+ scaleX: 1.5,
1757
+ scaleY: 1.5,
1758
+ fillOpacity: 1
1759
+ },
1760
+ hover_reverse: {
1761
+ scaleX: 1,
1762
+ scaleY: 1,
1763
+ fillOpacity: 0.3
1764
+ }
1765
+ },
1766
+ style: {
1767
+ size: () => {
1768
+ return spec.taskType === 'neighborhood' ? 6 : 4;
1769
+ },
1770
+ fill: (datum) => {
1771
+ var _a;
1772
+ const color = (_a = spec.labelColor[datum.label]) !== null && _a !== void 0 ? _a : 'gray';
1773
+ return color;
1774
+ },
1775
+ fillOpacity: (datum) => {
1776
+ return datum.confidence;
1777
+ }
1778
+ }
1779
+ },
1780
+ label: {
1781
+ visible: true,
1782
+ style: {
1783
+ visible: () => {
1784
+ return spec.taskType == 'neighborhood';
1785
+ },
1786
+ type: 'text',
1787
+ fontFamily: 'Console',
1788
+ fontStyle: 'italic',
1789
+ fontSize: 12,
1790
+ fill: 'black',
1791
+ fillOpacity: 0.6,
1792
+ text: (datum) => {
1793
+ return datum.id;
1794
+ }
1795
+ }
1796
+ }
1797
+ }
1798
+ ];
1799
+ if (spec.player) {
1800
+ spec.player = Object.assign(Object.assign({}, spec.player), { specs: dataSpecs });
1801
+ spec.animationAppear = {
1802
+ duration: (_b = (_a = spec.player) === null || _a === void 0 ? void 0 : _a.duration) !== null && _b !== void 0 ? _b : 2000,
1803
+ easing: 'linear'
1804
+ };
1805
+ spec.animationUpdate = {
1806
+ duration: (_d = (_c = spec.player) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 2000,
1807
+ easing: 'linear'
1808
+ };
1809
+ }
1810
+ spec.axes = [
1811
+ {
1812
+ orient: 'left',
1813
+ type: 'linear',
1814
+ inverse: true,
1815
+ min: spec.scope[1],
1816
+ max: spec.scope[3]
1817
+ },
1818
+ {
1819
+ orient: 'bottom',
1820
+ type: 'linear',
1821
+ min: spec.scope[0],
1822
+ max: spec.scope[2]
1823
+ }
1824
+ ];
1825
+ spec.customMark = [
1826
+ {
1827
+ type: 'text',
1828
+ dataId: 'iter',
1829
+ style: Object.assign({ x: 50, y: () => 10, textBaseline: 'top', textAlign: 'left', fontSize: 100, fontWeight: 'bolder', fill: 'black', fillOpacity: 0.2 }, (_e = spec.infoLabel) === null || _e === void 0 ? void 0 : _e.style)
1830
+ }
1831
+ ];
1832
+ (spec.legends = [
1833
+ {
1834
+ seriesId: 'scatter-series',
1835
+ visible: true,
1836
+ orient: 'right',
1837
+ position: 'middle',
1838
+ data: (items) => {
1839
+ return items.map(item => {
1840
+ item.shape.outerBorder = {
1841
+ stroke: item.shape.fill,
1842
+ distance: 2,
1843
+ lineWidth: 1
1844
+ };
1845
+ return item;
1846
+ });
1847
+ },
1848
+ title: {
1849
+ visible: true,
1850
+ align: 'left',
1851
+ textStyle: {
1852
+ text: 'Classes',
1853
+ fontFamily: 'Console',
1854
+ fontSize: 18,
1855
+ fontWeight: 'bold'
1856
+ }
1857
+ },
1858
+ item: {
1859
+ visible: true,
1860
+ width: '8%',
1861
+ value: {
1862
+ alignRight: true,
1863
+ style: {
1864
+ fill: '#000',
1865
+ fillOpacity: 1,
1866
+ fontSize: 12
1867
+ },
1868
+ state: {
1869
+ unselected: {
1870
+ fill: '#d8d8d8'
1871
+ }
1872
+ }
1873
+ }
1874
+ }
1875
+ }
1876
+ ]),
1877
+ (spec.tooltip = {
1878
+ visible: showTooltip,
1879
+ seriesId: 'scatter-series',
1880
+ lockAfterClick: false,
1881
+ activeType: 'mark',
1882
+ trigger: 'hover',
1883
+ mark: {
1884
+ title: {
1885
+ visible: true,
1886
+ value: 'Info'
1887
+ },
1888
+ content: [
1889
+ {
1890
+ key: 'Label',
1891
+ value: (datum) => {
1892
+ return datum.label;
1893
+ },
1894
+ shapeType: 'circle',
1895
+ shapeSize: 8
1896
+ },
1897
+ {
1898
+ key: 'Prediction',
1899
+ value: (datum) => {
1900
+ return datum.prediction;
1901
+ },
1902
+ shapeType: 'circle',
1903
+ shapeSize: 8,
1904
+ shapeFill: (datum) => {
1905
+ var _a;
1906
+ const color = (_a = spec.labelColor[datum.prediction]) !== null && _a !== void 0 ? _a : 'gray';
1907
+ return color;
1908
+ }
1909
+ },
1910
+ {
1911
+ key: 'Confidence',
1912
+ value: (datum) => {
1913
+ return datum.confidence.toFixed(2);
1914
+ },
1915
+ shapeType: 'square',
1916
+ shapeSize: 8,
1917
+ shapeFill: (datum) => {
1918
+ return datum.label === datum.prediction ? 'green' : 'red';
1919
+ }
1920
+ }
1921
+ ]
1922
+ },
1923
+ style: {
1924
+ panel: {
1925
+ padding: { top: 10, bottom: 15, left: 10, right: 10 },
1926
+ backgroundColor: '#fff',
1927
+ border: {
1928
+ color: '#eee',
1929
+ width: 1,
1930
+ radius: 10
1931
+ }
1932
+ },
1933
+ titleLabel: {
1934
+ fontSize: 20,
1935
+ fontFamily: 'Times New Roman',
1936
+ fill: 'brown',
1937
+ fontWeight: 'bold',
1938
+ textAlign: 'center',
1939
+ lineHeight: 24
1940
+ },
1941
+ keyLabel: {
1942
+ fontSize: 16,
1943
+ fontFamily: 'Times New Roman',
1944
+ fill: 'black',
1945
+ textAlign: 'center',
1946
+ lineHeight: 15,
1947
+ spacing: 10
1948
+ },
1949
+ valueLabel: {
1950
+ fontSize: 14,
1951
+ fill: 'black',
1952
+ textAlign: 'center',
1953
+ lineHeight: 15,
1954
+ spacing: 10
1955
+ }
1956
+ }
1957
+ });
1958
+ spec.dataZoom = [
1959
+ {
1960
+ visible: false,
1961
+ orient: 'left',
1962
+ filterMode: 'axis',
1963
+ showDetail: false,
1964
+ roamZoom: {
1965
+ enable: true,
1966
+ focus: true,
1967
+ rate: 3
1968
+ },
1969
+ roamDrag: {
1970
+ enable: true,
1971
+ reverse: true,
1972
+ rate: 1
1973
+ }
1974
+ },
1975
+ {
1976
+ visible: false,
1977
+ orient: 'bottom',
1978
+ filterMode: 'axis',
1979
+ showDetail: false,
1980
+ roamZoom: {
1981
+ enable: true,
1982
+ focus: true,
1983
+ rate: 3
1984
+ },
1985
+ roamDrag: {
1986
+ enable: true,
1987
+ reverse: true,
1988
+ rate: 1
1989
+ }
1990
+ }
1991
+ ];
1992
+ super.transformSpec(spec);
1993
+ }
1994
+ }
1995
+ function processSequenceData$2(spec) {
1996
+ const result = [];
1997
+ Object.keys(spec.data).forEach(iter => {
1998
+ const nodes = spec.data[iter].nodes;
1999
+ result.push({
2000
+ data: [
2001
+ {
2002
+ id: 'nodes',
2003
+ values: nodes.map((d, i) => {
2004
+ return Object.assign(Object.assign({}, d), { [DATA_KEY$2]: i });
2005
+ })
2006
+ },
2007
+ {
2008
+ id: 'endpoints',
2009
+ values: []
2010
+ },
2011
+ {
2012
+ id: 'iter',
2013
+ values: [
2014
+ {
2015
+ iter
2016
+ }
2017
+ ]
2018
+ },
2019
+ {
2020
+ id: 'background',
2021
+ values: [
2022
+ { iter: iter, x: spec.scope[0], y: spec.scope[1] },
2023
+ { iter: iter, x: spec.scope[0], y: spec.scope[3] },
2024
+ { iter: iter, x: spec.scope[2], y: spec.scope[3] },
2025
+ { iter: iter, x: spec.scope[2], y: spec.scope[1] },
2026
+ { iter: iter, x: spec.scope[0], y: spec.scope[1] }
2027
+ ]
2028
+ }
2029
+ ]
2030
+ });
2031
+ });
2032
+ return result;
2033
+ }
2034
+
2035
+ class SequenceScatterLink extends vchart.BaseChart {
2036
+ constructor() {
2037
+ super(...arguments);
2038
+ this.type = 'sequenceScatterLink';
2039
+ this.transformerConstructor = SequenceScatterLinkChartSpecTransformer;
2040
+ }
2041
+ init() {
2042
+ if (!this.isValid()) {
2043
+ return;
2044
+ }
2045
+ super.init();
2046
+ }
2047
+ isValid() {
2048
+ var _a, _b, _c, _d;
2049
+ const { xField, yField, data } = this._spec;
2050
+ if (!xField || !yField) {
2051
+ (_b = (_a = this._option).onError) === null || _b === void 0 ? void 0 : _b.call(_a, 'Missing Required Config: `xField`, `yField` ');
2052
+ return false;
2053
+ }
2054
+ if (!data) {
2055
+ (_d = (_c = this._option).onError) === null || _d === void 0 ? void 0 : _d.call(_c, 'Data is required');
2056
+ return false;
2057
+ }
2058
+ return true;
2059
+ }
2060
+ }
2061
+ SequenceScatterLink.type = 'sequenceScatterLink';
2062
+ SequenceScatterLink.view = 'singleDefault';
2063
+ SequenceScatterLink.transformerConstructor = SequenceScatterLinkChartSpecTransformer;
2064
+ const registerSequenceScatterLink = (option) => {
2065
+ const vchartConstructor = (option === null || option === void 0 ? void 0 : option.VChart) || vchart.VChart;
2066
+ if (vchartConstructor) {
2067
+ vchartConstructor.useChart([SequenceScatterLink, vchart.ScatterChart]);
2068
+ }
2069
+ };
2070
+
2071
+ const EXPAND_RATIO = 0.2;
2072
+
2073
+ function gaussKernel(x) {
2074
+ const SQRT2PI2 = Math.sqrt((Math.PI * 2) ** 2);
2075
+ return Math.exp(-(x ** 2) / 2) / SQRT2PI2;
2076
+ }
2077
+ function scottBandwidth(data) {
2078
+ return data.length ** (-1 / 6);
2079
+ }
2080
+ function calculateKDE(data, bins = 100, bandwidth) {
2081
+ const groupedData = data.reduce((groups, point) => {
2082
+ const label = point.label;
2083
+ groups[label] = groups[label] || [];
2084
+ groups[label].push(point);
2085
+ return groups;
2086
+ }, {});
2087
+ const kdeResult = [];
2088
+ Object.entries(groupedData).forEach(([label, points]) => {
2089
+ const h = bandwidth || scottBandwidth(points);
2090
+ const xValues = points.map(d => d.x);
2091
+ const yValues = points.map(d => d.y);
2092
+ const xMin = Math.min(...xValues);
2093
+ const xMax = Math.max(...xValues);
2094
+ const yMin = Math.min(...yValues);
2095
+ const yMax = Math.max(...yValues);
2096
+ const xExpand = (xMax - xMin) * EXPAND_RATIO;
2097
+ const yExpand = (yMax - yMin) * EXPAND_RATIO;
2098
+ const xExtent = { min: xMin - xExpand, max: xMax + xExpand };
2099
+ const yExtent = { min: yMin - yExpand, max: yMax + yExpand };
2100
+ const xStep = 0.1;
2101
+ const yStep = 0.1;
2102
+ for (let i = 0; i < bins; i++) {
2103
+ for (let j = 0; j < bins; j++) {
2104
+ const x = xExtent.min + i * xStep;
2105
+ const y = yExtent.min + j * yStep;
2106
+ let density = 0;
2107
+ for (const point of points) {
2108
+ const distance = Math.sqrt((x - point.x) ** 2 + (y - point.y) ** 2);
2109
+ density += gaussKernel(distance / h);
2110
+ }
2111
+ density = density / (points.length * h * h);
2112
+ kdeResult.push({ x, y, kde: density, label });
2113
+ }
2114
+ }
2115
+ });
2116
+ return kdeResult;
2117
+ }
2118
+
2119
+ const DATA_KEY$1 = 'dataKey';
2120
+ class SequenceScatterKDEChartSpecTransformer extends vchart.CommonChartSpecTransformer {
2121
+ transformSpec(spec) {
2122
+ var _a, _b, _c, _d, _e, _f;
2123
+ super.transformSpec(spec);
2124
+ const dataSpecs = processSequenceData$1(spec);
2125
+ spec.type = 'common';
2126
+ spec.dataKey = DATA_KEY$1;
2127
+ spec.data = dataSpecs[0].data;
2128
+ spec.scales = [
2129
+ {
2130
+ id: 'colorScale',
2131
+ type: 'ordinal',
2132
+ specified: {
2133
+ '0': 'rgb(150, 10, 100)',
2134
+ '1': 'rgb(31, 119, 180)',
2135
+ '2': 'rgb(255, 127, 14)',
2136
+ '3': 'rgb(44, 160, 44)',
2137
+ '4': 'rgb(214, 39, 40)',
2138
+ '5': 'rgb(148, 103, 189)',
2139
+ '6': 'rgb(140, 86, 75)',
2140
+ '7': 'rgb(227, 119, 194)',
2141
+ '8': 'rgb(127, 127, 127)',
2142
+ '9': 'rgb(188, 189, 34)',
2143
+ '10': 'rgb(23, 190, 207)'
2144
+ }
2145
+ },
2146
+ {
2147
+ id: 'brighterColorScale',
2148
+ type: 'ordinal',
2149
+ specified: {
2150
+ '0': 'rgb(150, 10, 150)',
2151
+ '1': 'rgb(31, 119, 230)',
2152
+ '2': 'rgb(255, 127, 64)',
2153
+ '3': 'rgb(44, 160, 94)',
2154
+ '4': 'rgb(214, 39, 90)',
2155
+ '5': 'rgb(148, 103, 239)',
2156
+ '6': 'rgb(140, 86, 125)',
2157
+ '7': 'rgb(227, 119, 244)',
2158
+ '8': 'rgb(127, 127, 177)',
2159
+ '9': 'rgb(188, 189, 84)',
2160
+ '10': 'rgb(23, 190, 255)'
2161
+ }
2162
+ },
2163
+ ...((_a = spec.scales) !== null && _a !== void 0 ? _a : [])
2164
+ ];
2165
+ spec.series = [
2166
+ {
2167
+ type: 'scatter',
2168
+ dataIndex: 0,
2169
+ xField: spec.xField,
2170
+ yField: spec.yField,
2171
+ seriesField: spec.seriesField,
2172
+ size: 5,
2173
+ point: {
2174
+ zIndex: 1000,
2175
+ style: {
2176
+ fill: {
2177
+ scale: 'colorScale',
2178
+ field: spec.seriesField
2179
+ }
2180
+ }
2181
+ }
2182
+ }
2183
+ ];
2184
+ const regionX = 54;
2185
+ const regionY = 26;
2186
+ spec.customMark = [
2187
+ {
2188
+ type: 'text',
2189
+ dataIndex: 1,
2190
+ style: Object.assign({ text: (datum) => datum['iter'], x: 10, y: () => 10, textBaseline: 'top', textAlign: 'left', fontSize: 25, fontWeight: 'bolder', fill: 'black', fillOpacity: 0.2 }, (_b = spec.infoLabel) === null || _b === void 0 ? void 0 : _b.style)
2191
+ },
2192
+ {
2193
+ type: 'symbol',
2194
+ dataIndex: 2,
2195
+ style: {
2196
+ symbolType: 'rect',
2197
+ x: (datum, ctx) => {
2198
+ const valueToX = ctx.chart.getAllSeries()[0]._markAttributeContext.valueToX;
2199
+ const markX = valueToX([datum.x]);
2200
+ return regionX + markX;
2201
+ },
2202
+ y: (datum, ctx) => {
2203
+ const valueToY = ctx.chart.getAllSeries()[0]._markAttributeContext.valueToY;
2204
+ const markY = valueToY([datum.y]);
2205
+ return markY + regionY;
2206
+ },
2207
+ size: 5,
2208
+ fill: {
2209
+ scale: 'brighterColorScale',
2210
+ field: 'label'
2211
+ },
2212
+ fillOpacity: (datum) => datum.kde * 10
2213
+ }
2214
+ }
2215
+ ];
2216
+ spec.tooltip = {
2217
+ visible: true,
2218
+ fields: ['x', 'y', 'label']
2219
+ };
2220
+ if (spec.player) {
2221
+ spec.player = Object.assign(Object.assign({}, spec.player), { specs: dataSpecs });
2222
+ spec.animationAppear = {
2223
+ duration: (_d = (_c = spec.player) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 2000,
2224
+ easing: 'linear'
2225
+ };
2226
+ spec.animationUpdate = {
2227
+ duration: (_f = (_e = spec.player) === null || _e === void 0 ? void 0 : _e.duration) !== null && _f !== void 0 ? _f : 2000,
2228
+ easing: 'linear'
2229
+ };
2230
+ }
2231
+ spec.axes = [
2232
+ {
2233
+ orient: 'left',
2234
+ type: 'linear',
2235
+ nice: true
2236
+ },
2237
+ {
2238
+ orient: 'bottom',
2239
+ type: 'linear',
2240
+ nice: true,
2241
+ label: { visible: true }
2242
+ }
2243
+ ];
2244
+ super.transformSpec(spec);
2245
+ }
2246
+ }
2247
+ function processSequenceData$1(spec) {
2248
+ const result = [];
2249
+ Object.keys(spec.data).forEach(iter => {
2250
+ const currentData = spec.data[iter].map((d, i) => (Object.assign(Object.assign({}, d), { [DATA_KEY$1]: i })));
2251
+ const kdeResults = calculateKDE(currentData, 150);
2252
+ result.push({
2253
+ data: [
2254
+ {
2255
+ id: 'nodes',
2256
+ values: currentData
2257
+ },
2258
+ {
2259
+ id: 'iter',
2260
+ values: [{ iter }]
2261
+ },
2262
+ {
2263
+ id: 'kde',
2264
+ values: kdeResults
2265
+ }
2266
+ ]
2267
+ });
2268
+ });
2269
+ return result;
2270
+ }
2271
+
2272
+ class SequenceScatterKDE extends vchart.BaseChart {
2273
+ constructor() {
2274
+ super(...arguments);
2275
+ this.type = 'sequenceScatterKDE';
2276
+ this.transformerConstructor = SequenceScatterKDEChartSpecTransformer;
2277
+ }
2278
+ init() {
2279
+ if (!this.isValid()) {
2280
+ return;
2281
+ }
2282
+ super.init();
2283
+ }
2284
+ isValid() {
2285
+ var _a, _b, _c, _d;
2286
+ const { xField, yField, data } = this._spec;
2287
+ if (!xField || !yField) {
2288
+ (_b = (_a = this._option).onError) === null || _b === void 0 ? void 0 : _b.call(_a, 'Missing Required Config: `xField`, `yField` ');
2289
+ return false;
2290
+ }
2291
+ if (!data) {
2292
+ (_d = (_c = this._option).onError) === null || _d === void 0 ? void 0 : _d.call(_c, 'Data is required');
2293
+ return false;
2294
+ }
2295
+ return true;
2296
+ }
2297
+ }
2298
+ SequenceScatterKDE.type = 'sequenceScatterKDE';
2299
+ SequenceScatterKDE.view = 'singleDefault';
2300
+ SequenceScatterKDE.transformerConstructor = SequenceScatterKDEChartSpecTransformer;
2301
+ const registerSequenceScatterKDE = (option) => {
2302
+ const vchartConstructor = (option === null || option === void 0 ? void 0 : option.VChart) || vchart.VChart;
2303
+ if (vchartConstructor) {
2304
+ vchartConstructor.useChart([SequenceScatterKDE, vchart.ScatterChart]);
2305
+ }
2306
+ };
2307
+
2308
+ const DATA_KEY = 'dataKey';
2309
+ const BACKGROUND_KEY = 'background';
2310
+
2311
+ function createImageDataFromColorMatrix(colorMatrix, spec) {
2312
+ var _a;
2313
+ if (typeof document === 'undefined') {
2314
+ throw new Error('Canvas rendering requires browser environment with document object');
2315
+ }
2316
+ const canvas = document.createElement('canvas');
2317
+ canvas.width = spec.width;
2318
+ canvas.height = spec.height;
2319
+ const ctx = canvas.getContext('2d');
2320
+ if (!ctx) {
2321
+ throw new Error('Failed to get 2D rendering context from canvas');
2322
+ }
2323
+ const imageData = ctx.createImageData(spec.width, spec.height);
2324
+ for (let y = 0; y < 300; y++) {
2325
+ for (let x = 0; x < 300; x++) {
2326
+ const rgb = ((_a = colorMatrix[y]) === null || _a === void 0 ? void 0 : _a[x]) || [0, 0, 0];
2327
+ const pixelIndex = (y * 300 + x) * 4;
2328
+ imageData.data[pixelIndex] = Math.round(rgb[0] * 255);
2329
+ imageData.data[pixelIndex + 1] = Math.round(rgb[1] * 255);
2330
+ imageData.data[pixelIndex + 2] = Math.round(rgb[2] * 255);
2331
+ imageData.data[pixelIndex + 3] = 255;
2332
+ }
2333
+ }
2334
+ ctx.putImageData(imageData, 0, 0);
2335
+ return canvas.toDataURL('image/png');
2336
+ }
2337
+ function processSequenceData(spec) {
2338
+ const result = [];
2339
+ Object.keys(spec.data).forEach(inter => {
2340
+ let backgroundData = null;
2341
+ if (spec.backgroundColors && spec.backgroundColors[inter]) {
2342
+ const imageData = createImageDataFromColorMatrix(spec.backgroundColors[inter], spec);
2343
+ backgroundData = { imageData };
2344
+ }
2345
+ result.push({
2346
+ data: [
2347
+ {
2348
+ id: 'nodes',
2349
+ values: spec.data[inter].map((d, i) => {
2350
+ return Object.assign(Object.assign({}, d), { [DATA_KEY]: i });
2351
+ })
2352
+ },
2353
+ {
2354
+ id: 'inter',
2355
+ values: [
2356
+ {
2357
+ inter
2358
+ }
2359
+ ]
2360
+ },
2361
+ {
2362
+ id: BACKGROUND_KEY,
2363
+ values: backgroundData ? [backgroundData] : []
2364
+ }
2365
+ ]
2366
+ });
2367
+ });
2368
+ return result;
2369
+ }
2370
+
2371
+ class SequenceScatterPixelChartSpecTransformer extends vchart.CommonChartSpecTransformer {
2372
+ transformSpec(spec) {
2373
+ var _a, _b, _c, _d, _e;
2374
+ super.transformSpec(spec);
2375
+ const dataSpecs = processSequenceData(spec);
2376
+ spec.type = 'common';
2377
+ spec.dataKey = DATA_KEY;
2378
+ spec.data = dataSpecs[0].data;
2379
+ spec.width = 300;
2380
+ spec.height = 300;
2381
+ spec.autoFit = false;
2382
+ spec.series = [
2383
+ {
2384
+ type: 'scatter',
2385
+ xField: spec.xField,
2386
+ yField: spec.yField
2387
+ }
2388
+ ];
2389
+ if (spec.player) {
2390
+ spec.player = Object.assign(Object.assign({}, spec.player), { specs: dataSpecs });
2391
+ spec.animationAppear = {
2392
+ duration: (_b = (_a = spec.player) === null || _a === void 0 ? void 0 : _a.duration) !== null && _b !== void 0 ? _b : 2000,
2393
+ easing: 'linear'
2394
+ };
2395
+ spec.animationUpdate = {
2396
+ duration: (_d = (_c = spec.player) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 2000,
2397
+ easing: 'linear'
2398
+ };
2399
+ }
2400
+ spec.axes = [
2401
+ {
2402
+ orient: 'left',
2403
+ type: 'linear'
2404
+ },
2405
+ {
2406
+ orient: 'bottom',
2407
+ label: { visible: true },
2408
+ type: 'linear'
2409
+ }
2410
+ ];
2411
+ spec.customMark = [
2412
+ {
2413
+ type: 'image',
2414
+ dataIndex: 2,
2415
+ style: {
2416
+ x: 0,
2417
+ y: 0,
2418
+ width: 300,
2419
+ height: 300,
2420
+ image: (datum) => datum.imageData,
2421
+ zIndex: -1
2422
+ }
2423
+ },
2424
+ {
2425
+ type: 'text',
2426
+ dataIndex: 1,
2427
+ style: Object.assign({ text: (datum) => datum['inter'], x: 50, y: () => 10, textBaseline: 'top', textAlign: 'left', fontSize: 100, fontWeight: 'bolder', fill: 'black', fillOpacity: 0.2 }, (_e = spec.infoLabel) === null || _e === void 0 ? void 0 : _e.style)
2428
+ }
2429
+ ];
2430
+ spec.tooltip = {
2431
+ visible: false
2432
+ };
2433
+ super.transformSpec(spec);
2434
+ }
2435
+ }
2436
+
2437
+ class SequenceScatterPixel extends vchart.BaseChart {
2438
+ constructor() {
2439
+ super(...arguments);
2440
+ this.type = 'sequenceScatterPixel';
2441
+ this.transformerConstructor = SequenceScatterPixelChartSpecTransformer;
2442
+ }
2443
+ init() {
2444
+ if (!this.isValid()) {
2445
+ return;
2446
+ }
2447
+ super.init();
2448
+ }
2449
+ isValid() {
2450
+ var _a, _b, _c, _d;
2451
+ const { xField, yField, data } = this._spec;
2452
+ if (!xField || !yField) {
2453
+ (_b = (_a = this._option).onError) === null || _b === void 0 ? void 0 : _b.call(_a, 'Missing Required Config: `xField`, `yField` ');
2454
+ return false;
2455
+ }
2456
+ if (!data) {
2457
+ (_d = (_c = this._option).onError) === null || _d === void 0 ? void 0 : _d.call(_c, 'Data is required');
2458
+ return false;
2459
+ }
2460
+ return true;
2461
+ }
2462
+ }
2463
+ SequenceScatterPixel.type = 'sequenceScatterPixel';
2464
+ SequenceScatterPixel.view = 'singleDefault';
2465
+ SequenceScatterPixel.transformerConstructor = SequenceScatterPixelChartSpecTransformer;
2466
+ const registerSequenceScatterPixel = (option) => {
2467
+ const vchartConstructor = (option === null || option === void 0 ? void 0 : option.VChart) || vchart.VChart;
2468
+ if (vchartConstructor) {
2469
+ vchartConstructor.useChart([SequenceScatterPixel, vchart.ScatterChart]);
2470
+ }
2471
+ };
2472
+
1670
2473
  class Generator {
1671
2474
  static GenAutoIncrementId() {
1672
2475
  return Generator.auto_increment_id++;
@@ -11351,6 +12154,9 @@
11351
12154
  exports.RankingBar = RankingBar;
11352
12155
  exports.RankingList = RankingList;
11353
12156
  exports.SERIES_BREAK = SERIES_BREAK;
12157
+ exports.SequenceScatterKDE = SequenceScatterKDE;
12158
+ exports.SequenceScatterLink = SequenceScatterLink;
12159
+ exports.SequenceScatterPixel = SequenceScatterPixel;
11354
12160
  exports.SeriesBreakComponent = SeriesBreakComponent;
11355
12161
  exports.SeriesLabelComponent = SeriesLabelComponent;
11356
12162
  exports.appendBarLinkConfig = appendBarLinkConfig;
@@ -11363,6 +12169,9 @@
11363
12169
  exports.registerConversionFunnelChart = registerConversionFunnelChart;
11364
12170
  exports.registerRankingBarChart = registerRankingBarChart;
11365
12171
  exports.registerRankingList = registerRankingList;
12172
+ exports.registerSequenceScatterKDE = registerSequenceScatterKDE;
12173
+ exports.registerSequenceScatterLink = registerSequenceScatterLink;
12174
+ exports.registerSequenceScatterPixel = registerSequenceScatterPixel;
11366
12175
  exports.registerSeriesBreak = registerSeriesBreak;
11367
12176
  exports.registerSeriesLabel = registerSeriesLabel;
11368
12177