@visactor/vseed 0.5.5 → 0.5.6
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/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/builder/register/all.js +3 -1
- package/dist/esm/builder/register/all.js.map +1 -1
- package/dist/esm/builder/register/chartType/hierarchySankey.d.ts +4 -0
- package/dist/esm/builder/register/chartType/hierarchySankey.js +9 -0
- package/dist/esm/builder/register/chartType/hierarchySankey.js.map +1 -0
- package/dist/esm/builder/register/chartType/index.d.ts +2 -0
- package/dist/esm/builder/register/chartType/index.js +2 -0
- package/dist/esm/builder/register/chartType/sankey.d.ts +1 -0
- package/dist/esm/builder/register/chartType/sankey.js +9 -0
- package/dist/esm/builder/register/chartType/sankey.js.map +1 -0
- package/dist/esm/dataReshape/constant.d.ts +2 -0
- package/dist/esm/dataReshape/constant.js +3 -1
- package/dist/esm/dataReshape/constant.js.map +1 -1
- package/dist/esm/dataReshape/unfoldDimensions.js +8 -2
- package/dist/esm/dataReshape/unfoldDimensions.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/hierarchySankey.d.ts +2 -0
- package/dist/esm/pipeline/advanced/chart/pipeline/hierarchySankey.js +33 -0
- package/dist/esm/pipeline/advanced/chart/pipeline/hierarchySankey.js.map +1 -0
- package/dist/esm/pipeline/advanced/chart/pipeline/index.d.ts +2 -0
- package/dist/esm/pipeline/advanced/chart/pipeline/index.js +2 -0
- package/dist/esm/pipeline/advanced/chart/pipeline/sankey.d.ts +2 -0
- package/dist/esm/pipeline/advanced/chart/pipeline/sankey.js +33 -0
- package/dist/esm/pipeline/advanced/chart/pipeline/sankey.js.map +1 -0
- package/dist/esm/pipeline/advanced/chart/pipes/config/hierarchySankey.d.ts +2 -0
- package/dist/esm/pipeline/advanced/chart/pipes/config/hierarchySankey.js +27 -0
- package/dist/esm/pipeline/advanced/chart/pipes/config/hierarchySankey.js.map +1 -0
- package/dist/esm/pipeline/advanced/chart/pipes/config/index.d.ts +2 -0
- package/dist/esm/pipeline/advanced/chart/pipes/config/index.js +2 -0
- package/dist/esm/pipeline/advanced/chart/pipes/config/index.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/config/sankey.d.ts +2 -0
- package/dist/esm/pipeline/advanced/chart/pipes/config/sankey.js +27 -0
- package/dist/esm/pipeline/advanced/chart/pipes/config/sankey.js.map +1 -0
- package/dist/esm/pipeline/advanced/chart/pipes/encoding/index.d.ts +1 -0
- package/dist/esm/pipeline/advanced/chart/pipes/encoding/index.js +1 -0
- package/dist/esm/pipeline/advanced/chart/pipes/encoding/sankey.d.ts +3 -0
- package/dist/esm/pipeline/advanced/chart/pipes/encoding/sankey.js +83 -0
- package/dist/esm/pipeline/advanced/chart/pipes/encoding/sankey.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipeline/hierarchySankey.d.ts +1 -0
- package/dist/esm/pipeline/spec/chart/pipeline/hierarchySankey.js +39 -0
- package/dist/esm/pipeline/spec/chart/pipeline/hierarchySankey.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipeline/index.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipeline/index.js +2 -0
- package/dist/esm/pipeline/spec/chart/pipeline/sankey.d.ts +1 -0
- package/dist/esm/pipeline/spec/chart/pipeline/sankey.js +39 -0
- package/dist/esm/pipeline/spec/chart/pipeline/sankey.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetHierarchy.js +5 -2
- package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetHierarchy.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetHierarchySankey.d.ts +4 -0
- package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetHierarchySankey.js +136 -0
- package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetHierarchySankey.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetPivotHierarchy.d.ts +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetPivotHierarchy.js +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetPivotHierarchy.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetPivotHierarchySankey.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetPivotHierarchySankey.js +44 -0
- package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetPivotHierarchySankey.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetPivotSankey.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetPivotSankey.js +50 -0
- package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetPivotSankey.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetSankey.d.ts +16 -0
- package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetSankey.js +97 -0
- package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetSankey.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/dataset/index.d.ts +4 -0
- package/dist/esm/pipeline/spec/chart/pipes/dataset/index.js +4 -0
- package/dist/esm/pipeline/spec/chart/pipes/init/circlePacking.js +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/init/circlePacking.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/init/hierarchySankey.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/init/hierarchySankey.js +32 -0
- package/dist/esm/pipeline/spec/chart/pipes/init/hierarchySankey.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/init/index.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/init/index.js +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/init/sankey.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/init/sankey.js +33 -0
- package/dist/esm/pipeline/spec/chart/pipes/init/sankey.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/init/sunburst.js +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/init/sunburst.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/init/treeMap.js +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/init/treeMap.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/label/index.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/label/index.js +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/label/label.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/label/labelHierarchySankey.d.ts +17 -0
- package/dist/esm/pipeline/spec/chart/pipes/label/labelHierarchySankey.js +92 -0
- package/dist/esm/pipeline/spec/chart/pipes/label/labelHierarchySankey.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/label/labelSankey.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/label/labelSankey.js +78 -0
- package/dist/esm/pipeline/spec/chart/pipes/label/labelSankey.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/label/labelTreeMapLeaf.js +4 -4
- package/dist/esm/pipeline/spec/chart/pipes/label/labelTreeMapLeaf.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/legend/pivotColorLegend.js +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/legend/pivotColorLegend.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/legend/pivotDiscreteLegend.js +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/legend/pivotDiscreteLegend.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/markStyle/index.d.ts +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/markStyle/index.js +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/markStyle/sankeyInteractive.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/markStyle/sankeyInteractive.js +33 -0
- package/dist/esm/pipeline/spec/chart/pipes/markStyle/sankeyInteractive.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/index.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/index.js +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipHierarchySankey.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipHierarchySankey.js +150 -0
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipHierarchySankey.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipSankey.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipSankey.js +75 -0
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipSankey.js.map +1 -0
- package/dist/esm/pipeline/utils/chatType.d.ts +2 -0
- package/dist/esm/pipeline/utils/chatType.js +3 -1
- package/dist/esm/pipeline/utils/chatType.js.map +1 -1
- package/dist/esm/pipeline/utils/constant.d.ts +2 -0
- package/dist/esm/pipeline/utils/constant.js +2 -0
- package/dist/esm/pipeline/utils/constant.js.map +1 -1
- package/dist/esm/pipeline/utils/measures/typeGuard.js +1 -1
- package/dist/esm/pipeline/utils/measures/typeGuard.js.map +1 -1
- package/dist/esm/theme/dark/dark.js +3 -1
- package/dist/esm/theme/dark/dark.js.map +1 -1
- package/dist/esm/theme/dark/hierarchy.d.ts +132 -0
- package/dist/esm/theme/dark/hierarchy.js +3 -1
- package/dist/esm/theme/dark/hierarchy.js.map +1 -1
- package/dist/esm/theme/light/hierarchy.d.ts +132 -0
- package/dist/esm/theme/light/hierarchy.js +3 -1
- package/dist/esm/theme/light/hierarchy.js.map +1 -1
- package/dist/esm/theme/light/light.js +3 -1
- package/dist/esm/theme/light/light.js.map +1 -1
- package/dist/esm/types/chartType/area/zArea.d.ts +4 -0
- package/dist/esm/types/chartType/areaPercent/zAreaPercent.d.ts +4 -0
- package/dist/esm/types/chartType/bar/zBar.d.ts +4 -0
- package/dist/esm/types/chartType/barParallel/zBarParallel.d.ts +4 -0
- package/dist/esm/types/chartType/barPercent/zBarPercent.d.ts +4 -0
- package/dist/esm/types/chartType/boxPlot/zBoxPlot.d.ts +4 -0
- package/dist/esm/types/chartType/circlePacking/zCirclePacking.d.ts +2 -0
- package/dist/esm/types/chartType/column/zColumn.d.ts +4 -0
- package/dist/esm/types/chartType/columnParallel/zColumnParallel.d.ts +4 -0
- package/dist/esm/types/chartType/columnPercent/zColumnPercent.d.ts +4 -0
- package/dist/esm/types/chartType/donut/zDonut.d.ts +4 -0
- package/dist/esm/types/chartType/dualAxis/zDualAxis.d.ts +2 -0
- package/dist/esm/types/chartType/funnel/zFunnel.d.ts +4 -0
- package/dist/esm/types/chartType/heatmap/zHeatmap.d.ts +2 -0
- package/dist/esm/types/chartType/hierarchySankey/hierarchySankey.d.ts +92 -0
- package/dist/esm/types/chartType/hierarchySankey/hierarchySankey.js +0 -0
- package/dist/esm/types/chartType/hierarchySankey/index.d.ts +2 -0
- package/dist/esm/types/chartType/hierarchySankey/index.js +1 -0
- package/dist/esm/types/chartType/hierarchySankey/zHierarchySankey.d.ts +422 -0
- package/dist/esm/types/chartType/hierarchySankey/zHierarchySankey.js +20 -0
- package/dist/esm/types/chartType/hierarchySankey/zHierarchySankey.js.map +1 -0
- package/dist/esm/types/chartType/histogram/zHistogram.d.ts +4 -0
- package/dist/esm/types/chartType/index.d.ts +2 -0
- package/dist/esm/types/chartType/index.js +2 -0
- package/dist/esm/types/chartType/line/zLine.d.ts +4 -0
- package/dist/esm/types/chartType/pie/zPie.d.ts +4 -0
- package/dist/esm/types/chartType/pivotTable/zPivotTable.d.ts +2 -0
- package/dist/esm/types/chartType/raceBar/zRaceBar.d.ts +4 -0
- package/dist/esm/types/chartType/raceColumn/zRaceColumn.d.ts +4 -0
- package/dist/esm/types/chartType/raceDonut/zRaceDonut.d.ts +4 -0
- package/dist/esm/types/chartType/raceLine/zRaceLine.d.ts +4 -0
- package/dist/esm/types/chartType/racePie/zRacePie.d.ts +4 -0
- package/dist/esm/types/chartType/raceScatter/zRaceScatter.d.ts +4 -0
- package/dist/esm/types/chartType/radar/zRadar.d.ts +4 -0
- package/dist/esm/types/chartType/rose/zRose.d.ts +4 -0
- package/dist/esm/types/chartType/roseParallel/zRoseParallel.d.ts +4 -0
- package/dist/esm/types/chartType/sankey/index.d.ts +2 -0
- package/dist/esm/types/chartType/sankey/index.js +1 -0
- package/dist/esm/types/chartType/sankey/sankey.d.ts +91 -0
- package/dist/esm/types/chartType/sankey/sankey.js +0 -0
- package/dist/esm/types/chartType/sankey/zSankey.d.ts +422 -0
- package/dist/esm/types/chartType/sankey/zSankey.js +20 -0
- package/dist/esm/types/chartType/sankey/zSankey.js.map +1 -0
- package/dist/esm/types/chartType/scatter/zScatter.d.ts +4 -0
- package/dist/esm/types/chartType/sunburst/zSunburst.d.ts +2 -0
- package/dist/esm/types/chartType/table/zTable.d.ts +2 -0
- package/dist/esm/types/chartType/treeMap/zTreeMap.d.ts +2 -0
- package/dist/esm/types/properties/chartType/chartType.d.ts +3 -1
- package/dist/esm/types/properties/chartType/chartType.js +2 -0
- package/dist/esm/types/properties/chartType/chartType.js.map +1 -1
- package/dist/esm/types/properties/config/config.d.ts +602 -0
- package/dist/esm/types/properties/config/config.js +4 -0
- package/dist/esm/types/properties/config/config.js.map +1 -1
- package/dist/esm/types/properties/config/hierarchySankey.d.ts +303 -0
- package/dist/esm/types/properties/config/hierarchySankey.js +18 -0
- package/dist/esm/types/properties/config/hierarchySankey.js.map +1 -0
- package/dist/esm/types/properties/config/index.d.ts +2 -0
- package/dist/esm/types/properties/config/index.js +2 -0
- package/dist/esm/types/properties/config/sankey.d.ts +303 -0
- package/dist/esm/types/properties/config/sankey.js +18 -0
- package/dist/esm/types/properties/config/sankey.js.map +1 -0
- package/dist/esm/types/properties/datasetReshapeInfo/datasetReshapeInfo.d.ts +2 -0
- package/dist/esm/types/properties/datasetReshapeInfo/zDatasetReshapeInfo.d.ts +4 -0
- package/dist/esm/types/properties/datasetReshapeInfo/zDatasetReshapeInfo.js +2 -0
- package/dist/esm/types/properties/datasetReshapeInfo/zDatasetReshapeInfo.js.map +1 -1
- package/dist/esm/types/properties/dimensions/index.d.ts +1 -0
- package/dist/esm/types/properties/dimensions/sankeyDimension.d.ts +15 -0
- package/dist/esm/types/properties/dimensions/sankeyDimension.js +0 -0
- package/dist/esm/types/properties/dimensions/zDimensions.d.ts +6 -0
- package/dist/esm/types/properties/encoding/dimensionEncoding.d.ts +3 -1
- package/dist/esm/types/properties/encoding/encoding.d.ts +8 -0
- package/dist/esm/types/properties/encoding/zDimensionEncoding.d.ts +4 -0
- package/dist/esm/types/properties/encoding/zDimensionEncoding.js +6 -2
- package/dist/esm/types/properties/encoding/zDimensionEncoding.js.map +1 -1
- package/dist/esm/types/properties/encoding/zEncoding.d.ts +4 -0
- package/dist/esm/types/properties/encoding/zEncoding.js +5 -1
- package/dist/esm/types/properties/encoding/zEncoding.js.map +1 -1
- package/dist/esm/types/properties/measures/index.d.ts +1 -0
- package/dist/esm/types/properties/measures/sankeyMeasure.d.ts +11 -0
- package/dist/esm/types/properties/measures/sankeyMeasure.js +0 -0
- package/dist/esm/types/properties/theme/customTheme.d.ts +3752 -2548
- package/dist/esm/types/vseed.d.ts +2 -2
- package/dist/esm/types/zVseed.js +3 -1
- package/dist/esm/types/zVseed.js.map +1 -1
- package/dist/umd/index.js +1303 -185
- package/dist/umd/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ const pivotColorLegend = (spec, context)=>{
|
|
|
5
5
|
const { advancedVSeed } = context;
|
|
6
6
|
const { chartType } = advancedVSeed;
|
|
7
7
|
const baseConfig = advancedVSeed.config[chartType];
|
|
8
|
-
if (!baseConfig || !baseConfig.legend) return result;
|
|
8
|
+
if (!baseConfig || !baseConfig.legend || !baseConfig.color) return result;
|
|
9
9
|
const { datasetReshapeInfo } = advancedVSeed;
|
|
10
10
|
const max = Math.max(...datasetReshapeInfo.map((d)=>d.foldInfo.statistics.colorMax));
|
|
11
11
|
const min = Math.min(...datasetReshapeInfo.map((d)=>d.foldInfo.statistics.colorMin));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/legend/pivotColorLegend.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/legend/pivotColorLegend.ts"],"sourcesContent":["import type { PivotChartConstructorOptions } from '@visactor/vtable'\nimport type { Color, Legend, PivotChartSpecPipe } from 'src/types'\n\nexport const pivotColorLegend: PivotChartSpecPipe = (spec, context) => {\n const result = { ...spec } as PivotChartConstructorOptions\n const { advancedVSeed } = context\n const { chartType } = advancedVSeed\n const baseConfig = advancedVSeed.config[chartType] as { legend
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/legend/pivotColorLegend.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/legend/pivotColorLegend.ts"],"sourcesContent":["import type { PivotChartConstructorOptions } from '@visactor/vtable'\nimport type { Color, Legend, PivotChartSpecPipe } from 'src/types'\n\nexport const pivotColorLegend: PivotChartSpecPipe = (spec, context) => {\n const result = { ...spec } as PivotChartConstructorOptions\n const { advancedVSeed } = context\n const { chartType } = advancedVSeed\n const baseConfig = advancedVSeed.config[chartType] as { legend?: Legend; color?: Color }\n\n if (!baseConfig || !baseConfig.legend || !baseConfig.color) {\n return result\n }\n\n const { datasetReshapeInfo } = advancedVSeed\n const max = Math.max(...datasetReshapeInfo.map((d) => d.foldInfo.statistics.colorMax))\n const min = Math.min(...datasetReshapeInfo.map((d) => d.foldInfo.statistics.colorMin))\n const { legend, color } = baseConfig\n const { colorScheme, linearColorScheme } = color\n\n const {\n enable,\n position = 'bottom',\n labelFontColor,\n labelColor,\n labelFontSize = 12,\n labelFontWeight = 400,\n } = legend || {}\n\n const orient = ['bottom', 'bottomLeft', 'bottomRight', 'bl', 'br'].includes(position)\n ? 'bottom'\n : ['top', 'topLeft', 'topRight', 'tl', 'tr'].includes(position)\n ? 'top'\n : ['left', 'leftTop', 'leftBottom', 'lt', 'lb'].includes(position)\n ? 'left'\n : 'right'\n\n const legendPosition = ['topLeft', 'bottomLeft', 'leftTop', 'rightTop', 'lt', 'rt', 'tl', 'bl'].includes(position)\n ? 'start'\n : ['topRight', 'bottomRight', 'leftBottom', 'rightBottom', 'lb', 'rb', 'rt', 'br'].includes(position)\n ? 'end'\n : 'middle'\n\n const legends = {\n visible: enable,\n type: 'color',\n orient,\n position: legendPosition,\n\n colors: linearColorScheme || colorScheme || [],\n value: [min, max],\n min: min,\n max: max,\n\n maxWidth: '30%',\n handlerText: {\n visible: true,\n style: {\n fill: labelColor || labelFontColor,\n fontSize: labelFontSize,\n fontWeight: labelFontWeight,\n },\n },\n } as unknown\n return { ...result, legends } as Partial<PivotChartConstructorOptions>\n}\n"],"names":["pivotColorLegend","spec","context","result","advancedVSeed","chartType","baseConfig","datasetReshapeInfo","max","Math","d","min","legend","color","colorScheme","linearColorScheme","enable","position","labelFontColor","labelColor","labelFontSize","labelFontWeight","orient","legendPosition","legends"],"mappings":"AAGO,MAAMA,mBAAuC,CAACC,MAAMC;IACzD,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAE,GAAGF;IAC1B,MAAM,EAAEG,SAAS,EAAE,GAAGD;IACtB,MAAME,aAAaF,cAAc,MAAM,CAACC,UAAU;IAElD,IAAI,CAACC,cAAc,CAACA,WAAW,MAAM,IAAI,CAACA,WAAW,KAAK,EACxD,OAAOH;IAGT,MAAM,EAAEI,kBAAkB,EAAE,GAAGH;IAC/B,MAAMI,MAAMC,KAAK,GAAG,IAAIF,mBAAmB,GAAG,CAAC,CAACG,IAAMA,EAAE,QAAQ,CAAC,UAAU,CAAC,QAAQ;IACpF,MAAMC,MAAMF,KAAK,GAAG,IAAIF,mBAAmB,GAAG,CAAC,CAACG,IAAMA,EAAE,QAAQ,CAAC,UAAU,CAAC,QAAQ;IACpF,MAAM,EAAEE,MAAM,EAAEC,KAAK,EAAE,GAAGP;IAC1B,MAAM,EAAEQ,WAAW,EAAEC,iBAAiB,EAAE,GAAGF;IAE3C,MAAM,EACJG,MAAM,EACNC,WAAW,QAAQ,EACnBC,cAAc,EACdC,UAAU,EACVC,gBAAgB,EAAE,EAClBC,kBAAkB,GAAG,EACtB,GAAGT,UAAU,CAAC;IAEf,MAAMU,SAAS;QAAC;QAAU;QAAc;QAAe;QAAM;KAAK,CAAC,QAAQ,CAACL,YACxE,WACA;QAAC;QAAO;QAAW;QAAY;QAAM;KAAK,CAAC,QAAQ,CAACA,YAClD,QACA;QAAC;QAAQ;QAAW;QAAc;QAAM;KAAK,CAAC,QAAQ,CAACA,YACrD,SACA;IAER,MAAMM,iBAAiB;QAAC;QAAW;QAAc;QAAW;QAAY;QAAM;QAAM;QAAM;KAAK,CAAC,QAAQ,CAACN,YACrG,UACA;QAAC;QAAY;QAAe;QAAc;QAAe;QAAM;QAAM;QAAM;KAAK,CAAC,QAAQ,CAACA,YACxF,QACA;IAEN,MAAMO,UAAU;QACd,SAASR;QACT,MAAM;QACNM;QACA,UAAUC;QAEV,QAAQR,qBAAqBD,eAAe,EAAE;QAC9C,OAAO;YAACH;YAAKH;SAAI;QACjB,KAAKG;QACL,KAAKH;QAEL,UAAU;QACV,aAAa;YACX,SAAS;YACT,OAAO;gBACL,MAAMW,cAAcD;gBACpB,UAAUE;gBACV,YAAYC;YACd;QACF;IACF;IACA,OAAO;QAAE,GAAGlB,MAAM;QAAEqB;IAAQ;AAC9B"}
|
|
@@ -7,7 +7,7 @@ const pivotDiscreteLegend = (spec, context)=>{
|
|
|
7
7
|
const { advancedVSeed } = context;
|
|
8
8
|
const { chartType } = advancedVSeed;
|
|
9
9
|
const baseConfig = advancedVSeed.config[chartType];
|
|
10
|
-
if (!baseConfig || !baseConfig.legend) return result;
|
|
10
|
+
if (!baseConfig || !baseConfig.legend || !baseConfig.color) return result;
|
|
11
11
|
const { datasetReshapeInfo } = advancedVSeed;
|
|
12
12
|
const colorItems = unique(datasetReshapeInfo.flatMap((d)=>d.unfoldInfo.colorItems));
|
|
13
13
|
const colorIdMap = datasetReshapeInfo.reduce((prev, cur)=>({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/legend/pivotDiscreteLegend.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/legend/pivotDiscreteLegend.ts"],"sourcesContent":["import type { PivotChartConstructorOptions } from '@visactor/vtable'\nimport { unique } from 'remeda'\nimport type { Color, Legend, PivotChartSpecPipe } from 'src/types'\nimport { createSpecifiedForColorMapping } from '../color/color'\n\nexport const pivotDiscreteLegend: PivotChartSpecPipe = (spec, context): Partial<PivotChartConstructorOptions> => {\n const result = { ...spec } as PivotChartConstructorOptions\n const { advancedVSeed } = context\n const { chartType } = advancedVSeed\n const baseConfig = advancedVSeed.config[chartType] as { legend
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/legend/pivotDiscreteLegend.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/legend/pivotDiscreteLegend.ts"],"sourcesContent":["import type { PivotChartConstructorOptions } from '@visactor/vtable'\nimport { unique } from 'remeda'\nimport type { Color, Legend, PivotChartSpecPipe } from 'src/types'\nimport { createSpecifiedForColorMapping } from '../color/color'\n\nexport const pivotDiscreteLegend: PivotChartSpecPipe = (spec, context): Partial<PivotChartConstructorOptions> => {\n const result = { ...spec } as PivotChartConstructorOptions\n const { advancedVSeed } = context\n const { chartType } = advancedVSeed\n const baseConfig = advancedVSeed.config[chartType] as { legend?: Legend; color?: Color }\n\n if (!baseConfig || !baseConfig.legend || !baseConfig.color) {\n return result\n }\n\n const { datasetReshapeInfo } = advancedVSeed\n\n const colorItems = unique(\n datasetReshapeInfo.flatMap((d) => {\n return d.unfoldInfo.colorItems\n }),\n )\n\n const colorIdMap = datasetReshapeInfo.reduce<Record<string, { id: string; alias: string }>>((prev, cur) => {\n return { ...prev, ...cur.unfoldInfo.colorIdMap }\n }, {})\n\n const { legend, color } = baseConfig\n const { colorScheme, colorMapping } = color\n\n const colorSpecified = createSpecifiedForColorMapping(colorMapping, colorIdMap, colorItems)\n\n const {\n enable,\n position = 'bottom',\n labelFontColor,\n labelColor,\n labelFontSize = 12,\n labelFontWeight = 400,\n maxSize = 1,\n border,\n shapeType = 'rectRound',\n } = legend || {}\n\n const orient = ['bottom', 'bottomLeft', 'bottomRight', 'bl', 'br'].includes(position)\n ? 'bottom'\n : ['top', 'topLeft', 'topRight', 'tl', 'tr'].includes(position)\n ? 'top'\n : ['left', 'leftTop', 'leftBottom', 'lt', 'lb'].includes(position)\n ? 'left'\n : 'right'\n\n const legendPosition = ['topLeft', 'bottomLeft', 'leftTop', 'rightTop', 'lt', 'rt', 'tl', 'bl'].includes(position)\n ? 'start'\n : ['topRight', 'bottomRight', 'leftBottom', 'rightBottom', 'lb', 'rb', 'rt', 'br'].includes(position)\n ? 'end'\n : 'middle'\n\n const legends = {\n padding: 0,\n visible: enable,\n type: 'discrete',\n orient,\n position: legendPosition,\n maxCol: Math.max(1, maxSize),\n maxRow: Math.max(1, maxSize),\n data: colorItems.map((d: string, index: number) => {\n const color = colorSpecified?.[d] ?? colorScheme?.[index % colorScheme.length]\n return {\n label: d,\n shape: {\n outerBorder: border\n ? {\n stroke: color,\n distance: 3,\n lineWidth: 1,\n }\n : undefined,\n fill: color,\n },\n }\n }),\n\n item: {\n focus: true,\n maxWidth: '30%',\n focusIconStyle: {\n size: labelFontSize + 2,\n fill: labelColor || labelFontColor,\n fontWeight: labelFontWeight,\n },\n shape: {\n space: border ? 6 : 4,\n style: {\n symbolType: shapeType,\n size: border ? 8 : 10,\n },\n },\n label: {\n formatMethod: (value: string) => {\n return colorIdMap[value]?.alias ?? value\n },\n style: {\n fontSize: labelFontSize,\n fill: labelColor || labelFontColor,\n fontWeight: labelFontWeight,\n },\n },\n background: {\n state: {\n selectedHover: {\n fill: labelColor || labelFontColor,\n fillOpacity: 0.05,\n },\n },\n },\n },\n }\n return { ...result, legends } as Partial<PivotChartConstructorOptions>\n}\n"],"names":["pivotDiscreteLegend","spec","context","result","advancedVSeed","chartType","baseConfig","datasetReshapeInfo","colorItems","unique","d","colorIdMap","prev","cur","legend","color","colorScheme","colorMapping","colorSpecified","createSpecifiedForColorMapping","enable","position","labelFontColor","labelColor","labelFontSize","labelFontWeight","maxSize","border","shapeType","orient","legendPosition","legends","Math","index","undefined","value"],"mappings":";;AAKO,MAAMA,sBAA0C,CAACC,MAAMC;IAC5D,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAE,GAAGF;IAC1B,MAAM,EAAEG,SAAS,EAAE,GAAGD;IACtB,MAAME,aAAaF,cAAc,MAAM,CAACC,UAAU;IAElD,IAAI,CAACC,cAAc,CAACA,WAAW,MAAM,IAAI,CAACA,WAAW,KAAK,EACxD,OAAOH;IAGT,MAAM,EAAEI,kBAAkB,EAAE,GAAGH;IAE/B,MAAMI,aAAaC,OACjBF,mBAAmB,OAAO,CAAC,CAACG,IACnBA,EAAE,UAAU,CAAC,UAAU;IAIlC,MAAMC,aAAaJ,mBAAmB,MAAM,CAAgD,CAACK,MAAMC,MAC1F;YAAE,GAAGD,IAAI;YAAE,GAAGC,IAAI,UAAU,CAAC,UAAU;QAAC,IAC9C,CAAC;IAEJ,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAE,GAAGT;IAC1B,MAAM,EAAEU,WAAW,EAAEC,YAAY,EAAE,GAAGF;IAEtC,MAAMG,iBAAiBC,+BAA+BF,cAAcN,YAAYH;IAEhF,MAAM,EACJY,MAAM,EACNC,WAAW,QAAQ,EACnBC,cAAc,EACdC,UAAU,EACVC,gBAAgB,EAAE,EAClBC,kBAAkB,GAAG,EACrBC,UAAU,CAAC,EACXC,MAAM,EACNC,YAAY,WAAW,EACxB,GAAGd,UAAU,CAAC;IAEf,MAAMe,SAAS;QAAC;QAAU;QAAc;QAAe;QAAM;KAAK,CAAC,QAAQ,CAACR,YACxE,WACA;QAAC;QAAO;QAAW;QAAY;QAAM;K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+10,4 @@ export { roseStyle } from "./roseStyle.js";
|
|
|
10
10
|
export { funnelTransformStyle } from "./funnelTransformStyle.js";
|
|
11
11
|
export { boxPlotStyle } from "./boxPlotStyle.js";
|
|
12
12
|
export { outlierStyle } from "./outlierStyle.js";
|
|
13
|
+
export { sankeyInteractive } from "./sankeyInteractive.js";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isSankey } from "../../../../utils/index.js";
|
|
2
|
+
const sankeyInteractive = (spec, context)=>{
|
|
3
|
+
const result = {
|
|
4
|
+
...spec
|
|
5
|
+
};
|
|
6
|
+
const { vseed } = context;
|
|
7
|
+
result.emphasis = {
|
|
8
|
+
enable: true,
|
|
9
|
+
effect: isSankey(vseed) ? 'adjacency' : 'related'
|
|
10
|
+
};
|
|
11
|
+
result.node = {
|
|
12
|
+
...result.node || {},
|
|
13
|
+
state: {
|
|
14
|
+
...result.node?.state || {},
|
|
15
|
+
blur: {
|
|
16
|
+
opacity: 0.2
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
result.link = {
|
|
21
|
+
...result.link || {},
|
|
22
|
+
state: {
|
|
23
|
+
...result.link?.state || {},
|
|
24
|
+
blur: {
|
|
25
|
+
opacity: 0.05
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
export { sankeyInteractive };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=sankeyInteractive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/markStyle/sankeyInteractive.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/markStyle/sankeyInteractive.ts"],"sourcesContent":["import { isSankey } from 'src/pipeline/utils'\nimport type { VChartSpecPipe } from 'src/types'\n\nexport const sankeyInteractive: VChartSpecPipe = (spec, context) => {\n const result = { ...spec } as Record<string, any>\n const { vseed } = context\n result.emphasis = {\n enable: true,\n effect: isSankey(vseed) ? 'adjacency' : 'related',\n }\n\n result.node = {\n ...(result.node || {}),\n state: {\n ...(result.node?.state || {}),\n blur: {\n opacity: 0.2,\n },\n },\n }\n\n result.link = {\n ...(result.link || {}),\n state: {\n ...(result.link?.state || {}),\n blur: {\n opacity: 0.05,\n },\n },\n }\n\n return result as any\n}\n"],"names":["sankeyInteractive","spec","context","result","vseed","isSankey"],"mappings":";AAGO,MAAMA,oBAAoC,CAACC,MAAMC;IACtD,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,KAAK,EAAE,GAAGF;IAClBC,OAAO,QAAQ,GAAG;QAChB,QAAQ;QACR,QAAQE,SAASD,SAAS,cAAc;IAC1C;IAEAD,OAAO,IAAI,GAAG;QACZ,GAAIA,OAAO,IAAI,IAAI,CAAC,CAAC;QACrB,OAAO;YACL,GAAIA,OAAO,IAAI,EAAE,SAAS,CAAC,CAAC;YAC5B,MAAM;gBACJ,SAAS;YACX;QACF;IACF;IAEAA,OAAO,IAAI,GAAG;QACZ,GAAIA,OAAO,IAAI,IAAI,CAAC,CAAC;QACrB,OAAO;YACL,GAAIA,OAAO,IAAI,EAAE,SAAS,CAAC,CAAC;YAC5B,MAAM;gBACJ,SAAS;YACX;QACF;IACF;IAEA,OAAOA;AACT"}
|
|
@@ -5,3 +5,5 @@ export { tooltipHeatmap } from './tooltipHeatmap';
|
|
|
5
5
|
export { tooltipBoxplot } from './tooltipBoxplot';
|
|
6
6
|
export { tooltipHistogram } from './tooltipHistogram';
|
|
7
7
|
export { tooltipHierarchy } from './tooltipHierarchy';
|
|
8
|
+
export { tooltipHierarchySankey } from './tooltipHierarchySankey';
|
|
9
|
+
export { tooltipSankey } from './tooltipSankey';
|
|
@@ -5,3 +5,5 @@ export { tooltipHeatmap } from "./tooltipHeatmap.js";
|
|
|
5
5
|
export { tooltipBoxplot } from "./tooltipBoxplot.js";
|
|
6
6
|
export { tooltipHistogram } from "./tooltipHistogram.js";
|
|
7
7
|
export { tooltipHierarchy } from "./tooltipHierarchy.js";
|
|
8
|
+
export { tooltipHierarchySankey } from "./tooltipHierarchySankey.js";
|
|
9
|
+
export { tooltipSankey } from "./tooltipSankey.js";
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { pipe, uniqueBy } from "remeda";
|
|
2
|
+
import { createFormatterByDimension, createFormatterByMeasure, findMeasureById } from "../../../../utils/index.js";
|
|
3
|
+
import { tooltip as external_tooltip_js_tooltip } from "./tooltip.js";
|
|
4
|
+
import { getHierarchySankeyNodesFromSpec } from "../dataset/datasetHierarchySankey.js";
|
|
5
|
+
const tooltipHierarchySankey = (spec, context)=>{
|
|
6
|
+
const result = external_tooltip_js_tooltip()(spec, context);
|
|
7
|
+
const { advancedVSeed, vseed } = context;
|
|
8
|
+
const { datasetReshapeInfo, dimensions = [], encoding, dataset = [] } = advancedVSeed;
|
|
9
|
+
const { foldInfo, unfoldInfo } = datasetReshapeInfo[0];
|
|
10
|
+
const hierarchyDataset = getHierarchySankeyNodesFromSpec(result, dataset);
|
|
11
|
+
if (result.tooltip) result.tooltip.mark = {
|
|
12
|
+
title: {
|
|
13
|
+
visible: true,
|
|
14
|
+
value: (value)=>createTitle(value, dimensions, hierarchyDataset, advancedVSeed.locale)
|
|
15
|
+
},
|
|
16
|
+
content: createMarkContent(encoding.tooltip || [], dimensions, vseed.measures, hierarchyDataset, foldInfo, unfoldInfo, advancedVSeed.locale)
|
|
17
|
+
};
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
20
|
+
const flattenHierarchyNodes = (nodes = [], depth = 0)=>nodes.flatMap((node)=>[
|
|
21
|
+
{
|
|
22
|
+
datum: node,
|
|
23
|
+
depth
|
|
24
|
+
},
|
|
25
|
+
...flattenHierarchyNodes(node.children || [], depth + 1)
|
|
26
|
+
]);
|
|
27
|
+
const createNodeMetaMap = (dataset = [])=>flattenHierarchyNodes(dataset).reduce((prev, item)=>{
|
|
28
|
+
const key = String(item.datum.key ?? '');
|
|
29
|
+
if (key) prev[key] = item;
|
|
30
|
+
return prev;
|
|
31
|
+
}, {});
|
|
32
|
+
const isLinkDatum = (value)=>{
|
|
33
|
+
const datum = value;
|
|
34
|
+
return !!datum && void 0 !== datum.source && void 0 !== datum.target;
|
|
35
|
+
};
|
|
36
|
+
const getHierarchyPath = (value)=>{
|
|
37
|
+
const datum = value;
|
|
38
|
+
if (!datum) return [];
|
|
39
|
+
if (Array.isArray(datum.datum)) return datum.datum;
|
|
40
|
+
if (datum.datum && Array.isArray(datum.datum.datum)) return datum.datum.datum;
|
|
41
|
+
if (datum.datum && 'object' == typeof datum.datum) return [
|
|
42
|
+
datum.datum
|
|
43
|
+
];
|
|
44
|
+
return [
|
|
45
|
+
datum
|
|
46
|
+
];
|
|
47
|
+
};
|
|
48
|
+
const getHierarchyDatum = (value)=>{
|
|
49
|
+
const path = getHierarchyPath(value);
|
|
50
|
+
if (!path.length) return;
|
|
51
|
+
const datum = value;
|
|
52
|
+
if ('number' == typeof datum?.depth && path[datum.depth]) return path[datum.depth];
|
|
53
|
+
return path[path.length - 1];
|
|
54
|
+
};
|
|
55
|
+
const createTitle = (value, dimensions = [], dataset = [], locale)=>{
|
|
56
|
+
if (isLinkDatum(value)) {
|
|
57
|
+
const nodeMetaMap = createNodeMetaMap(dataset);
|
|
58
|
+
const datum = value;
|
|
59
|
+
const source = nodeMetaMap[String(datum.source ?? '')]?.datum;
|
|
60
|
+
const target = nodeMetaMap[String(datum.target ?? '')]?.datum;
|
|
61
|
+
return [
|
|
62
|
+
source?.name,
|
|
63
|
+
target?.name
|
|
64
|
+
].filter(Boolean).join(' -> ');
|
|
65
|
+
}
|
|
66
|
+
const path = getHierarchyPath(value);
|
|
67
|
+
if (!path.length) return '';
|
|
68
|
+
return path.map((item, index)=>{
|
|
69
|
+
const dim = dimensions[index];
|
|
70
|
+
const formatter = createFormatterByDimension(dim, locale);
|
|
71
|
+
return formatter(String(item?.name ?? ''));
|
|
72
|
+
}).join(' / ');
|
|
73
|
+
};
|
|
74
|
+
const createMarkContent = (tooltip, dimensions = [], measures = [], dataset = [], foldInfo, _unfoldInfo, locale)=>{
|
|
75
|
+
const nodeMetaMap = createNodeMetaMap(dataset);
|
|
76
|
+
const dims = pipe(dimensions.filter((item)=>tooltip.includes(item.id)), uniqueBy((item)=>item.id), uniqueBy((item)=>item.alias));
|
|
77
|
+
const meas = pipe(measures.filter((item)=>tooltip.includes(item.id)), uniqueBy((item)=>item.id), uniqueBy((item)=>item.alias));
|
|
78
|
+
const dimContent = dims.map((item)=>({
|
|
79
|
+
visible: (value)=>{
|
|
80
|
+
if (isLinkDatum(value)) return false;
|
|
81
|
+
const datum = getHierarchyDatum(value);
|
|
82
|
+
return datum?.[item.id] !== void 0 && datum?.[item.id] !== null;
|
|
83
|
+
},
|
|
84
|
+
hasShape: true,
|
|
85
|
+
shapeType: 'rectRound',
|
|
86
|
+
key: item.alias || item.id,
|
|
87
|
+
value: (value)=>{
|
|
88
|
+
const datum = getHierarchyDatum(value);
|
|
89
|
+
const formatter = createFormatterByDimension(item, locale);
|
|
90
|
+
return datum ? formatter(datum[item.id]) : '';
|
|
91
|
+
}
|
|
92
|
+
}));
|
|
93
|
+
const measureContent = meas.map((item)=>({
|
|
94
|
+
visible: (value)=>!isLinkDatum(value),
|
|
95
|
+
hasShape: true,
|
|
96
|
+
shapeType: 'rectRound',
|
|
97
|
+
key: item.alias || item.id,
|
|
98
|
+
value: (value)=>{
|
|
99
|
+
const datum = getHierarchyDatum(value);
|
|
100
|
+
if (!datum) return '';
|
|
101
|
+
const measure = findMeasureById(measures, item.id);
|
|
102
|
+
const formatter = createFormatterByMeasure(measure);
|
|
103
|
+
const measureValue = datum[item.id] ?? datum[foldInfo.measureValue];
|
|
104
|
+
return formatter(measureValue);
|
|
105
|
+
}
|
|
106
|
+
}));
|
|
107
|
+
const linkDimensionContent = dims.map((item)=>({
|
|
108
|
+
visible: (value)=>{
|
|
109
|
+
if (!isLinkDatum(value)) return false;
|
|
110
|
+
const datum = value;
|
|
111
|
+
const sourceMeta = nodeMetaMap[String(datum.source ?? '')];
|
|
112
|
+
const targetMeta = nodeMetaMap[String(datum.target ?? '')];
|
|
113
|
+
return sourceMeta?.datum?.[item.id] !== void 0 || targetMeta?.datum?.[item.id] !== void 0;
|
|
114
|
+
},
|
|
115
|
+
hasShape: true,
|
|
116
|
+
shapeType: 'rectRound',
|
|
117
|
+
key: item.alias || item.id,
|
|
118
|
+
value: (value)=>{
|
|
119
|
+
const datum = value;
|
|
120
|
+
const sourceMeta = nodeMetaMap[String(datum.source ?? '')];
|
|
121
|
+
const targetMeta = nodeMetaMap[String(datum.target ?? '')];
|
|
122
|
+
const matchedNode = sourceMeta?.depth !== void 0 && dimensions[sourceMeta.depth]?.id === item.id ? sourceMeta.datum : targetMeta?.depth !== void 0 && dimensions[targetMeta.depth]?.id === item.id ? targetMeta.datum : sourceMeta?.datum?.[item.id] !== void 0 ? sourceMeta.datum : targetMeta?.datum;
|
|
123
|
+
const formatter = createFormatterByDimension(item, locale);
|
|
124
|
+
const rawValue = matchedNode?.[item.id] ?? matchedNode?.name;
|
|
125
|
+
return null != rawValue ? formatter(rawValue) : '';
|
|
126
|
+
}
|
|
127
|
+
}));
|
|
128
|
+
const linkMeasureContent = meas.map((item)=>({
|
|
129
|
+
visible: (value)=>isLinkDatum(value),
|
|
130
|
+
hasShape: true,
|
|
131
|
+
shapeType: 'rectRound',
|
|
132
|
+
key: item.alias || item.id,
|
|
133
|
+
value: (value)=>{
|
|
134
|
+
const datum = value;
|
|
135
|
+
const measure = findMeasureById(measures, item.id);
|
|
136
|
+
const formatter = createFormatterByMeasure(measure);
|
|
137
|
+
const measureValue = datum[item.id] ?? datum[foldInfo.measureValue] ?? datum.value;
|
|
138
|
+
return formatter(measureValue);
|
|
139
|
+
}
|
|
140
|
+
}));
|
|
141
|
+
return [
|
|
142
|
+
...dimContent,
|
|
143
|
+
...linkDimensionContent,
|
|
144
|
+
...measureContent,
|
|
145
|
+
...linkMeasureContent
|
|
146
|
+
];
|
|
147
|
+
};
|
|
148
|
+
export { tooltipHierarchySankey };
|
|
149
|
+
|
|
150
|
+
//# sourceMappingURL=tooltipHierarchySankey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/tooltip/tooltipHierarchySankey.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/tooltip/tooltipHierarchySankey.ts"],"sourcesContent":["import { pipe, uniqueBy } from 'remeda'\nimport { createFormatterByDimension, createFormatterByMeasure, findMeasureById } from 'src/pipeline/utils'\nimport type {\n Datum,\n FoldInfo,\n HierarchyDimension,\n HierarchyMeasure,\n Locale,\n UnfoldInfo,\n VChartSpecPipe,\n} from 'src/types'\nimport { tooltip as commonTooltip } from './tooltip'\nimport { getHierarchySankeyNodesFromSpec } from '../dataset/datasetHierarchySankey'\n\nexport const tooltipHierarchySankey: VChartSpecPipe = (spec, context) => {\n const result = commonTooltip()(spec, context)\n const { advancedVSeed, vseed } = context\n const { datasetReshapeInfo, dimensions = [], encoding, dataset = [] } = advancedVSeed\n const { foldInfo, unfoldInfo } = datasetReshapeInfo[0]\n const hierarchyDataset = getHierarchySankeyNodesFromSpec(result as Record<string, any>, dataset as Datum[])\n\n if (result.tooltip) {\n result.tooltip.mark = {\n title: {\n visible: true,\n value: (value: unknown) =>\n createTitle(value, dimensions as HierarchyDimension[], hierarchyDataset, advancedVSeed.locale),\n },\n content: createMarkContent(\n encoding.tooltip || [],\n dimensions as HierarchyDimension[],\n vseed.measures as HierarchyMeasure[],\n hierarchyDataset,\n foldInfo,\n unfoldInfo,\n advancedVSeed.locale,\n ),\n }\n }\n\n return result\n}\n\ntype NodeMeta = {\n datum: Datum\n depth: number\n}\n\nconst flattenHierarchyNodes = (nodes: Datum[] = [], depth = 0): NodeMeta[] => {\n return nodes.flatMap((node) => [\n { datum: node, depth },\n ...flattenHierarchyNodes((node.children as Datum[]) || [], depth + 1),\n ])\n}\n\nconst createNodeMetaMap = (dataset: Datum[] = []) => {\n return flattenHierarchyNodes(dataset).reduce(\n (prev, item) => {\n const key = String(item.datum.key ?? '')\n if (key) {\n prev[key] = item\n }\n return prev\n },\n {} as Record<string, NodeMeta>,\n )\n}\n\nconst isLinkDatum = (value: unknown): boolean => {\n const datum = value as Datum\n return !!datum && datum.source !== undefined && datum.target !== undefined\n}\n\nconst getHierarchyPath = (value: unknown): Datum[] => {\n const datum = value as Datum\n if (!datum) {\n return []\n }\n\n if (Array.isArray(datum.datum)) {\n return datum.datum as Datum[]\n }\n\n if (datum.datum && Array.isArray((datum.datum as Datum).datum)) {\n return (datum.datum as Datum).datum as Datum[]\n }\n\n if (datum.datum && typeof datum.datum === 'object') {\n return [datum.datum as Datum]\n }\n\n return [datum]\n}\n\nconst getHierarchyDatum = (value: unknown): Datum | undefined => {\n const path = getHierarchyPath(value)\n if (!path.length) {\n return undefined\n }\n\n const datum = value as Datum\n if (typeof datum?.depth === 'number' && path[datum.depth]) {\n return path[datum.depth] as Datum\n }\n\n return path[path.length - 1] as Datum\n}\n\nconst createTitle = (value: unknown, dimensions: HierarchyDimension[] = [], dataset: Datum[] = [], locale?: Locale) => {\n if (isLinkDatum(value)) {\n const nodeMetaMap = createNodeMetaMap(dataset)\n const datum = value as Datum\n const source = nodeMetaMap[String(datum.source ?? '')]?.datum\n const target = nodeMetaMap[String(datum.target ?? '')]?.datum\n\n return [source?.name, target?.name].filter(Boolean).join(' -> ')\n }\n\n const path = getHierarchyPath(value)\n if (!path.length) {\n return ''\n }\n\n return path\n .map((item, index) => {\n const dim = dimensions[index]\n const formatter = createFormatterByDimension(dim, locale)\n return formatter(String(item?.name ?? ''))\n })\n .join(' / ')\n}\n\nconst createMarkContent = (\n tooltip: string[],\n dimensions: HierarchyDimension[] = [],\n measures: HierarchyMeasure[] = [],\n dataset: Datum[] = [],\n foldInfo: FoldInfo,\n _unfoldInfo: UnfoldInfo,\n locale?: Locale,\n) => {\n const nodeMetaMap = createNodeMetaMap(dataset)\n const dims = pipe(\n dimensions.filter((item) => tooltip.includes(item.id)),\n uniqueBy((item: HierarchyDimension) => item.id),\n uniqueBy((item: HierarchyDimension) => item.alias),\n )\n const meas = pipe(\n measures.filter((item) => tooltip.includes(item.id)),\n uniqueBy((item: HierarchyMeasure) => item.id),\n uniqueBy((item: HierarchyMeasure) => item.alias),\n )\n\n const dimContent = dims.map((item: HierarchyDimension) => ({\n visible: (value: unknown) => {\n if (isLinkDatum(value)) {\n return false\n }\n const datum = getHierarchyDatum(value)\n return datum?.[item.id] !== undefined && datum?.[item.id] !== null\n },\n hasShape: true,\n shapeType: 'rectRound',\n key: item.alias || item.id,\n value: (value: unknown) => {\n const datum = getHierarchyDatum(value)\n const formatter = createFormatterByDimension(item, locale)\n return datum ? formatter(datum[item.id] as string | number) : ''\n },\n }))\n\n const measureContent = meas.map((item: HierarchyMeasure) => ({\n visible: (value: unknown) => !isLinkDatum(value),\n hasShape: true,\n shapeType: 'rectRound',\n key: item.alias || item.id,\n value: (value: unknown) => {\n const datum = getHierarchyDatum(value)\n if (!datum) {\n return ''\n }\n\n const measure = findMeasureById(measures, item.id)\n const formatter = createFormatterByMeasure(measure)\n const measureValue = (datum[item.id] ?? datum[foldInfo.measureValue]) as string | number\n return formatter(measureValue)\n },\n }))\n\n const linkDimensionContent = dims.map((item: HierarchyDimension) => ({\n visible: (value: unknown) => {\n if (!isLinkDatum(value)) {\n return false\n }\n\n const datum = value as Datum\n const sourceMeta = nodeMetaMap[String(datum.source ?? '')]\n const targetMeta = nodeMetaMap[String(datum.target ?? '')]\n return sourceMeta?.datum?.[item.id] !== undefined || targetMeta?.datum?.[item.id] !== undefined\n },\n hasShape: true,\n shapeType: 'rectRound',\n key: item.alias || item.id,\n value: (value: unknown) => {\n const datum = value as Datum\n const sourceMeta = nodeMetaMap[String(datum.source ?? '')]\n const targetMeta = nodeMetaMap[String(datum.target ?? '')]\n\n const matchedNode =\n sourceMeta?.depth !== undefined && dimensions[sourceMeta.depth]?.id === item.id\n ? sourceMeta.datum\n : targetMeta?.depth !== undefined && dimensions[targetMeta.depth]?.id === item.id\n ? targetMeta.datum\n : sourceMeta?.datum?.[item.id] !== undefined\n ? sourceMeta.datum\n : targetMeta?.datum\n\n const formatter = createFormatterByDimension(item, locale)\n const rawValue = matchedNode?.[item.id] ?? matchedNode?.name\n return rawValue !== undefined && rawValue !== null ? formatter(rawValue as string | number) : ''\n },\n }))\n\n const linkMeasureContent = meas.map((item: HierarchyMeasure) => ({\n visible: (value: unknown) => isLinkDatum(value),\n hasShape: true,\n shapeType: 'rectRound',\n key: item.alias || item.id,\n value: (value: unknown) => {\n const datum = value as Datum\n const measure = findMeasureById(measures, item.id)\n const formatter = createFormatterByMeasure(measure)\n const measureValue = (datum[item.id] ?? datum[foldInfo.measureValue] ?? datum.value) as string | number\n return formatter(measureValue)\n },\n }))\n\n return [...dimContent, ...linkDimensionContent, ...measureContent, ...linkMeasureContent]\n}\n"],"names":["tooltipHierarchySankey","spec","context","result","commonTooltip","advancedVSeed","vseed","datasetReshapeInfo","dimensions","encoding","dataset","foldInfo","unfoldInfo","hierarchyDataset","getHierarchySankeyNodesFromSpec","value","createTitle","createMarkContent","flattenHierarchyNodes","nodes","depth","node","createNodeMetaMap","prev","item","key","String","isLinkDatum","datum","undefined","getHierarchyPath","Array","getHierarchyDatum","path","locale","nodeMetaMap","source","target","Boolean","index","dim","formatter","createFormatterByDimension","tooltip","measures","_unfoldInfo","dims","pipe","uniqueBy","meas","dimContent","measureContent","measure","findMeasureById","createFormatterByMeasure","measureValue","linkDimensionContent","sourceMeta","targetMeta","matchedNode","rawValue","linkMeasureContent"],"mappings":";;;;AAcO,MAAMA,yBAAyC,CAACC,MAAMC;IAC3D,MAAMC,SAASC,8BAAgBH,MAAMC;IACrC,MAAM,EAAEG,aAAa,EAAEC,KAAK,EAAE,GAAGJ;IACjC,MAAM,EAAEK,kBAAkB,EAAEC,aAAa,EAAE,EAAEC,QAAQ,EAAEC,UAAU,EAAE,EAAE,GAAGL;IACxE,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AACT,QAAmBY,YAAYZ;YACzC,UAAU;YACV,WAAW;YACX,KAAKS,KAAK,KAAK,IAAIA,KAAK,EAAE;YAC1B,OAAO,CAACT;gBACN,MAAMa,QAAQb;gBACd,MAAMqC,UAAUC,gBAAgBT,UAAUpB,KAAK,EAAE;gBACjD,MAAMiB,YAAYa,yBAAyBF;gBAC3C,MAAMG,eAAgB3B,KAAK,CAACJ,KAAK,EAAE,CAAC,IAAII,KAAK,CAACjB,SAAS,YAAY,CAAC,IAAIiB,MAAM,KAAK;gBACnF,OAAOa,UAAUc;YACnB;QACF;IAEA,OAAO;WAAIL;WAAeM;WAAyBL;WAAmBU;KAAmB;AAC3F"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { createFormatterByMeasure, findMeasureById } from "../../../../utils/index.js";
|
|
2
|
+
import { tooltip } from "./tooltip.js";
|
|
3
|
+
const isLinkDatum = (value)=>{
|
|
4
|
+
const datum = value;
|
|
5
|
+
return !!datum && void 0 !== datum.source && void 0 !== datum.target;
|
|
6
|
+
};
|
|
7
|
+
const getNodes = (spec)=>((spec.data || [])[0]?.values || [])[0]?.nodes || [];
|
|
8
|
+
const getNodeNameByIndex = (nodes, index)=>{
|
|
9
|
+
const node = nodes[Number(index)];
|
|
10
|
+
return node?.nodeName ?? '';
|
|
11
|
+
};
|
|
12
|
+
const getWrappedDatum = (value)=>{
|
|
13
|
+
const datum = value;
|
|
14
|
+
const wrappedDatum = datum?.datum;
|
|
15
|
+
if (Array.isArray(wrappedDatum)) return wrappedDatum[wrappedDatum.length - 1] || datum;
|
|
16
|
+
if (wrappedDatum && 'object' == typeof wrappedDatum) return wrappedDatum;
|
|
17
|
+
return datum;
|
|
18
|
+
};
|
|
19
|
+
const getNodeTitle = (value)=>{
|
|
20
|
+
const datum = getWrappedDatum(value);
|
|
21
|
+
return String(datum?.nodeName ?? datum?.name ?? datum?.id ?? '');
|
|
22
|
+
};
|
|
23
|
+
const getEncodingAlias = (dimensions, encodedIds, fallback, measureId)=>dimensions.find((dimension)=>(encodedIds || []).includes(dimension.id) && dimension.id !== measureId)?.alias || fallback;
|
|
24
|
+
const tooltipSankey = (spec, context)=>{
|
|
25
|
+
const result = tooltip()(spec, context);
|
|
26
|
+
const { advancedVSeed, vseed } = context;
|
|
27
|
+
const { datasetReshapeInfo, dimensions = [] } = advancedVSeed;
|
|
28
|
+
const { foldInfo } = datasetReshapeInfo[0];
|
|
29
|
+
const nodes = getNodes(result);
|
|
30
|
+
const measures = vseed.measures || [];
|
|
31
|
+
const sourceAlias = getEncodingAlias(dimensions, advancedVSeed.encoding?.source, 'Source', foldInfo.measureId);
|
|
32
|
+
if (result.tooltip) result.tooltip.mark = {
|
|
33
|
+
title: {
|
|
34
|
+
visible: true,
|
|
35
|
+
value: (value)=>{
|
|
36
|
+
const datum = value;
|
|
37
|
+
if (isLinkDatum(value)) return `${getNodeNameByIndex(nodes, datum.source)} -> ${getNodeNameByIndex(nodes, datum.target)}`;
|
|
38
|
+
return getNodeTitle(value);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
content: createMarkContent(nodes, measures, foldInfo, sourceAlias)
|
|
42
|
+
};
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
const createMarkContent = (nodes, measures = [], foldInfo, sourceAlias)=>{
|
|
46
|
+
const fallbackMeasure = findMeasureById(measures, foldInfo.measureValue) || measures[0];
|
|
47
|
+
const fallbackMeasureAlias = fallbackMeasure?.alias || fallbackMeasure?.id || 'Value';
|
|
48
|
+
return [
|
|
49
|
+
{
|
|
50
|
+
visible: (value)=>isLinkDatum(value),
|
|
51
|
+
hasShape: true,
|
|
52
|
+
shapeType: 'rectRound',
|
|
53
|
+
key: sourceAlias,
|
|
54
|
+
value: (value)=>{
|
|
55
|
+
const datum = value;
|
|
56
|
+
return String(datum.sourceNodeName ?? getNodeNameByIndex(nodes, datum.source));
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
visible: ()=>true,
|
|
61
|
+
hasShape: true,
|
|
62
|
+
shapeType: 'rectRound',
|
|
63
|
+
key: fallbackMeasureAlias,
|
|
64
|
+
value: (value)=>{
|
|
65
|
+
const datum = value;
|
|
66
|
+
const measure = findMeasureById(measures, datum?.[foldInfo.measureId]) || fallbackMeasure;
|
|
67
|
+
const formatter = createFormatterByMeasure(measure);
|
|
68
|
+
return formatter((datum?.[foldInfo.measureValue] ?? datum?.value ?? 0) || 0);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
};
|
|
73
|
+
export { tooltipSankey };
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=tooltipSankey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/tooltip/tooltipSankey.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/tooltip/tooltipSankey.ts"],"sourcesContent":["import { createFormatterByMeasure, findMeasureById } from 'src/pipeline/utils'\nimport type { Datum, Dimension, FoldInfo, Measure, VChartSpecPipe } from 'src/types'\nimport { tooltip as commonTooltip } from './tooltip'\n\nconst isLinkDatum = (value: unknown) => {\n const datum = value as Datum\n return !!datum && datum.source !== undefined && datum.target !== undefined\n}\n\nconst getNodes = (spec: Record<string, any>) =>\n ((((spec.data || [])[0] as Record<string, any>)?.values || [])[0]?.nodes || []) as Array<Datum>\n\nconst getNodeNameByIndex = (nodes: Datum[], index: unknown) => {\n const node = nodes[Number(index)]\n return node?.nodeName ?? ''\n}\n\nconst getWrappedDatum = (value: unknown): Datum => {\n const datum = value as Datum\n const wrappedDatum = datum?.datum\n\n if (Array.isArray(wrappedDatum)) {\n return (wrappedDatum[wrappedDatum.length - 1] || datum) as Datum\n }\n\n if (wrappedDatum && typeof wrappedDatum === 'object') {\n return wrappedDatum as Datum\n }\n\n return datum\n}\n\nconst getNodeTitle = (value: unknown) => {\n const datum = getWrappedDatum(value)\n return String(datum?.nodeName ?? datum?.name ?? datum?.id ?? '')\n}\n\nconst getEncodingAlias = (\n dimensions: Dimension[],\n encodedIds: string[] | null | undefined,\n fallback: string,\n measureId: string,\n) =>\n dimensions.find((dimension) => (encodedIds || []).includes(dimension.id) && dimension.id !== measureId)?.alias ||\n fallback\n\nexport const tooltipSankey: VChartSpecPipe = (spec, context) => {\n const result = commonTooltip()(spec, context) as Record<string, any>\n const { advancedVSeed, vseed } = context\n const { datasetReshapeInfo, dimensions = [] } = advancedVSeed\n const { foldInfo } = datasetReshapeInfo[0]\n const nodes = getNodes(result)\n const measures = (vseed.measures || []) as Measure[]\n const sourceAlias = getEncodingAlias(dimensions, advancedVSeed.encoding?.source, 'Source', foldInfo.measureId)\n\n if (result.tooltip) {\n result.tooltip.mark = {\n title: {\n visible: true,\n value: (value: unknown) => {\n const datum = value as Datum\n if (isLinkDatum(value)) {\n return `${getNodeNameByIndex(nodes, datum.source)} -> ${getNodeNameByIndex(nodes, datum.target)}`\n }\n return getNodeTitle(value)\n },\n },\n content: createMarkContent(nodes, measures, foldInfo, sourceAlias),\n }\n }\n\n return result\n}\n\nconst createMarkContent = (nodes: Datum[], measures: Measure[] = [], foldInfo: FoldInfo, sourceAlias: string) => {\n const fallbackMeasure = findMeasureById(measures, foldInfo.measureValue) || measures[0]\n const fallbackMeasureAlias = fallbackMeasure?.alias || fallbackMeasure?.id || 'Value'\n\n return [\n {\n visible: (value: unknown) => isLinkDatum(value),\n hasShape: true,\n shapeType: 'rectRound',\n key: sourceAlias,\n value: (value: unknown) => {\n const datum = value as Datum\n return String(datum.sourceNodeName ?? getNodeNameByIndex(nodes, datum.source))\n },\n },\n {\n visible: () => true,\n hasShape: true,\n shapeType: 'rectRound',\n key: fallbackMeasureAlias,\n value: (value: unknown) => {\n const datum = value as Datum\n const measure = findMeasureById(measures, datum?.[foldInfo.measureId] as string) || fallbackMeasure\n const formatter = createFormatterByMeasure(measure)\n return formatter(((datum?.[foldInfo.measureValue] ?? datum?.value ?? 0) as string | number) || 0)\n },\n },\n ]\n}\n"],"names":["isLinkDatum","value","datum","undefined","getNodes","spec","getNodeNameByIndex","nodes","index","node","Number","getWrappedDatum","wrappedDatum","Array","getNodeTitle","String","getEncodingAlias","dimensions","encodedIds","fallback","measureId","dimension","tooltipSankey","context","result","commonTooltip","advancedVSeed","vseed","datasetReshapeInfo","foldInfo","measures","sourceAlias","createMarkContent","fallbackMeasure","findMeasureById","fallbackMeasureAlias","measure","formatter","createFormatterByMeasure"],"mappings":";;AAIA,MAAMA,cAAc,CAACC;IACnB,MAAMC,QAAQD;IACd,OAAO,CAAC,CAACC,SAASA,AAAiBC,WAAjBD,MAAM,MAAM,IAAkBA,AAAiBC,WAAjBD,MAAM,MAAM;AAC9D;AAEA,MAAME,WAAW,CAACC,OACd,AAAEA,CAAAA,CAAAA,KAAK,IAAI,IAAI,EAAC,CAAE,CAAC,EAAE,EAA0B,UAAU,EAAC,CAAE,CAAC,EAAE,EAAE,SAAS,EAAE;AAEhF,MAAMC,qBAAqB,CAACC,OAAgBC;IAC1C,MAAMC,OAAOF,KAAK,CAACG,OAAOF,OAAO;IACjC,OAAOC,MAAM,YAAY;AAC3B;AAEA,MAAME,kBAAkB,CAACV;IACvB,MAAMC,QAAQD;IACd,MAAMW,eAAeV,OAAO;IAE5B,IAAIW,MAAM,OAAO,CAACD,eAChB,OAAQA,YAAY,CAACA,aAAa,MAAM,GAAG,EAAE,IAAIV;IAGnD,IAAIU,gBAAgB,AAAwB,YAAxB,OAAOA,cACzB,OAAOA;IAGT,OAAOV;AACT;AAEA,MAAMY,eAAe,CAACb;IACpB,MAAMC,QAAQS,gBAAgBV;IAC9B,OAAOc,OAAOb,OAAO,YAAYA,OAAO,QAAQA,OAAO,MAAM;AAC/D;AAEA,MAAMc,mBAAmB,CACvBC,YACAC,YACAC,UACAC,YAEAH,WAAW,IAAI,CAAC,CAACI,YAAeH,AAAAA,CAAAA,cAAc,EAAC,EAAG,QAAQ,CAACG,UAAU,EAAE,KAAKA,UAAU,EAAE,KAAKD,YAAY,SACzGD;AAEK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ACN,MAAMC,QAAQD;gBACd,MAAMmC,UAAUF,gBAAgBJ,UAAU5B,OAAO,CAAC2B,SAAS,SAAS,CAAC,KAAeI;gBACpF,MAAMI,YAAYC,yBAAyBF;gBAC3C,OAAOC,UAAYnC,AAAAA,CAAAA,OAAO,CAAC2B,SAAS,YAAY,CAAC,IAAI3B,OAAO,SAAS,MAA0B;YACjG;QACF;KACD;AACH"}
|
|
@@ -5,6 +5,8 @@ export declare const isRadar: (vseed: VSeed) => vseed is import("../../types").R
|
|
|
5
5
|
export declare const isAreaPercent: (vseed: VSeed) => vseed is import("../../types").AreaPercent;
|
|
6
6
|
export declare const isColumnPercent: (vseed: VSeed) => vseed is import("../../types").ColumnPercent;
|
|
7
7
|
export declare const isBarPercent: (vseed: VSeed) => vseed is import("../../types").BarPercent;
|
|
8
|
+
export declare const isSankey: (vseed: VSeed) => vseed is import("../../types").Sankey;
|
|
9
|
+
export declare const isHierarchySankey: (vseed: VSeed) => vseed is import("../../types").HierarchySankey;
|
|
8
10
|
export declare const isBarLikeChart: (vseed: VSeed) => vseed is import("../../types").Bar | import("../../types").RaceBar | import("../../types").BarParallel | import("../../types").BarPercent;
|
|
9
11
|
export declare const isVTable: (vseed: VSeed) => boolean;
|
|
10
12
|
export declare const isVChart: (vseed: VSeed) => boolean;
|
|
@@ -8,6 +8,8 @@ const isRadar = (vseed)=>vseed.chartType === ChartTypeEnum.Radar;
|
|
|
8
8
|
const isAreaPercent = (vseed)=>vseed.chartType === ChartTypeEnum.AreaPercent;
|
|
9
9
|
const isColumnPercent = (vseed)=>vseed.chartType === ChartTypeEnum.ColumnPercent;
|
|
10
10
|
const isBarPercent = (vseed)=>vseed.chartType === ChartTypeEnum.BarPercent;
|
|
11
|
+
const isSankey = (vseed)=>vseed.chartType === ChartTypeEnum.Sankey;
|
|
12
|
+
const isHierarchySankey = (vseed)=>vseed.chartType === ChartTypeEnum.HierarchySankey;
|
|
11
13
|
const isBarLikeChart = (vseed)=>vseed.chartType === ChartTypeEnum.Bar || vseed.chartType === ChartTypeEnum.RaceBar || vseed.chartType === ChartTypeEnum.BarPercent || vseed.chartType === ChartTypeEnum.BarParallel;
|
|
12
14
|
const isVTable = (vseed)=>[
|
|
13
15
|
'table',
|
|
@@ -85,6 +87,6 @@ const isDualAxisChartType = (chartType)=>chartType && [
|
|
|
85
87
|
'areaPercent',
|
|
86
88
|
'scatter'
|
|
87
89
|
].includes(chartType);
|
|
88
|
-
export { DEFAULT_DUAL_CHART_TYPE, isAreaPercent, isBarLikeChart, isBarPercent, isColumnPercent, isCombination, isDualAxisChartType, isPivot, isPivotChart, isPivotTable, isRadar, isRectungularCoordinate, isTable, isVChart, isVTable };
|
|
90
|
+
export { DEFAULT_DUAL_CHART_TYPE, isAreaPercent, isBarLikeChart, isBarPercent, isColumnPercent, isCombination, isDualAxisChartType, isHierarchySankey, isPivot, isPivotChart, isPivotTable, isRadar, isRectungularCoordinate, isSankey, isTable, isVChart, isVTable };
|
|
89
91
|
|
|
90
92
|
//# sourceMappingURL=chatType.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/utils/chatType.js","sources":["../../../../src/pipeline/utils/chatType.ts"],"sourcesContent":["import type { MeasureEncoding, Measures } from 'src/types'\nimport { type Dimensions, type DimensionGroup, type VSeed, type Measure } from 'src/types'\nimport { isPositionMeasure } from './measures'\nimport { isCommonMeasureEncoding, isMeasureTreeWithParentId } from '../advanced/chart/pipes/measures/utils'\nimport { unique } from 'remeda'\nimport { ChartTypeEnum, DEFAULT_PARENT_ID } from './constant'\n\nexport const isTable = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.Table\n}\nexport const isPivotTable = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.PivotTable\n}\nexport const isRadar = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.Radar\n}\nexport const isAreaPercent = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.AreaPercent\n}\nexport const isColumnPercent = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.ColumnPercent\n}\nexport const isBarPercent = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.BarPercent\n}\n\nexport const isBarLikeChart = (vseed: VSeed) => {\n return (\n vseed.chartType === ChartTypeEnum.Bar ||\n vseed.chartType === ChartTypeEnum.RaceBar ||\n vseed.chartType === ChartTypeEnum.BarPercent ||\n vseed.chartType === ChartTypeEnum.BarParallel\n )\n}\n\nexport const isVTable = (vseed: VSeed) => {\n return ['table', 'pivotTable'].includes(vseed.chartType)\n}\nexport const isVChart = (vseed: VSeed): boolean => {\n return !isVTable(vseed)\n}\n\n/**\n * @description 透视图表或组合图\n * - 透视图表定义: 存在 column 或 row的 encoding\n * - 组合图表定义: 存在多组指标的情况\n * - 透视组合图表: 存在 column 或 row的 encoding 且 存在多组指标的情况\n * 上述三者都只能使用 VTable.PivotChart 绘制\n */\nexport const isPivotChart = (vseed: VSeed) => {\n if (isVTable(vseed)) {\n return false\n }\n\n if (isPivot(vseed)) {\n return true\n }\n\n return isCombination(vseed)\n}\n\n/**\n * @description 存在column 或 row的encoding\n */\nexport const isPivot = (vseed: VSeed) => {\n const { dimensions = [], measures = [] } = vseed as {\n dimensions: Dimensions\n measures: Measures\n }\n\n if (dimensions && dimensions.some((dimension) => dimension.encoding === 'row' || dimension.encoding === 'column')) {\n return true\n }\n\n if (vseed.chartType === ChartTypeEnum.Scatter) {\n const xCount = measures.filter((m: Measure) => m.encoding === 'xAxis').length\n const yCount = measures.filter((m: Measure) => m.encoding === 'yAxis').length\n const otherCount = measures.filter(\n (m: Measure) =>\n !['size', 'xAxis', 'yAxis'].includes(m.encoding as string) &&\n !isCommonMeasureEncoding(m.encoding as MeasureEncoding),\n ).length\n\n /**\n * Scatter \"matrix\" detection logic\n *\n * xCount: number of measures explicitly encoded on the x-axis\n * yCount: number of measures explicitly encoded on the y-axis\n * otherCount: measures that are not size/xAxis/yAxis and are not common encodings\n *\n * When there is at least one explicit x-axis measure (xCount > 0):\n * - All x-encoded measures are counted as X.\n * - Remaining measures (y-encoded + \"other\") are treated as Y variants.\n *\n * When there is no explicit x-axis measure (xCount === 0):\n * - If there is at least one \"other\" measure, we treat exactly one of them as the X measure\n * (so finalXCount = 1), and the remaining \"other\" measures contribute to Y alongside\n * the explicit y-encoded measures.\n * - Since we conceptually \"promote\" one of the other measures to X, only (otherCount - 1)\n * are left to be counted towards Y. Math.max(..., 0) protects against negative values\n * when otherCount is 0.\n */\n let finalXCount: number\n let finalYCount: number\n\n if (xCount > 0) {\n // Explicit x-axis measures exist: X is fixed, Y aggregates y-encoded + other measures.\n finalXCount = xCount\n finalYCount = yCount + otherCount\n } else {\n // No explicit x-axis measure:\n // - If there are \"other\" measures, treat one as X.\n // - Remaining \"other\" measures contribute to Y, together with any y-encoded measures.\n finalXCount = otherCount > 0 ? 1 : 0\n finalYCount = yCount + Math.max(otherCount - 1, 0)\n }\n if (finalXCount > 1 || finalYCount > 1) return true\n }\n\n return false\n}\n\n/**\n * @description 不存在column 或 row的encoding, 但是有多组指标的情况\n */\nexport const isCombination = (vseed: VSeed) => {\n if (isMeasureTreeWithParentId(vseed.measures)) {\n const parentIds = vseed.measures\n ?.filter((m: Measure) => isPositionMeasure(m, vseed.chartType))\n .map((measure: Measure) => measure.parentId || DEFAULT_PARENT_ID)\n return parentIds && unique(parentIds).length > 1\n }\n\n const { measures = [] } = vseed as {\n measures: Measures\n dimensions: Dimensions\n }\n\n const hasMeasureGroup = measures && measures.some((measure: DimensionGroup) => measure && measure.children)\n\n return hasMeasureGroup\n}\n\nexport const isRectungularCoordinate = (chartType: string) => {\n return (\n [\n ChartTypeEnum.Bar,\n ChartTypeEnum.RaceBar,\n ChartTypeEnum.RaceColumn,\n ChartTypeEnum.RaceScatter,\n ChartTypeEnum.BarPercent,\n ChartTypeEnum.BarParallel,\n ChartTypeEnum.Column,\n ChartTypeEnum.ColumnPercent,\n ChartTypeEnum.ColumnParallel,\n ChartTypeEnum.Line,\n ChartTypeEnum.Area,\n ChartTypeEnum.AreaPercent,\n ChartTypeEnum.DualAxis,\n ChartTypeEnum.Boxplot,\n ChartTypeEnum.DualAxis,\n ChartTypeEnum.Scatter,\n ChartTypeEnum.Heatmap,\n ChartTypeEnum.Boxplot,\n ] as string[]\n ).includes(chartType)\n}\n\n/**\n * 默认的双轴图图表类型配置\n */\nexport const DEFAULT_DUAL_CHART_TYPE = {\n primary: 'column',\n secondary: 'line',\n}\n\nexport const isDualAxisChartType = (chartType: string | undefined) => {\n return (\n chartType &&\n ['column', 'columnParallel', 'columnPercent', 'line', 'area', 'areaPercent', 'scatter'].includes(chartType)\n )\n}\n"],"names":["isTable","vseed","ChartTypeEnum","isPivotTable","isRadar","isAreaPercent","isColumnPercent","isBarPercent","isBarLikeChart","isVTable","isVChart","isPivotChart","isPivot","isCombination","dimensions","measures","dimension","xCount","m","yCount","otherCount","isCommonMeasureEncoding","finalXCount","finalYCount","Math","isMeasureTreeWithParentId","parentIds","isPositionMeasure","measure","DEFAULT_PARENT_ID","unique","hasMeasureGroup","isRectungularCoordinate","chartType","DEFAULT_DUAL_CHART_TYPE","isDualAxisChartType"],"mappings":";;;;AAOO,MAAMA,UAAU,CAACC,QACfA,MAAM,SAAS,KAAKC,cAAc,KAAK;AAEzC,MAAMC,eAAe,CAACF,QACpBA,MAAM,SAAS,KAAKC,cAAc,UAAU;AAE9C,MAAME,UAAU,CAACH,QACfA,MAAM,SAAS,KAAKC,cAAc,KAAK;AAEzC,MAAMG,gBAAgB,CAACJ,QACrBA,MAAM,SAAS,KAAKC,cAAc,WAAW;AAE/C,MAAMI,kBAAkB,CAACL,QACvBA,MAAM,SAAS,KAAKC,cAAc,aAAa;AAEjD,MAAMK,eAAe,CAACN,QACpBA,MAAM,SAAS,KAAKC,cAAc,UAAU;
|
|
1
|
+
{"version":3,"file":"pipeline/utils/chatType.js","sources":["../../../../src/pipeline/utils/chatType.ts"],"sourcesContent":["import type { MeasureEncoding, Measures } from 'src/types'\nimport { type Dimensions, type DimensionGroup, type VSeed, type Measure } from 'src/types'\nimport { isPositionMeasure } from './measures'\nimport { isCommonMeasureEncoding, isMeasureTreeWithParentId } from '../advanced/chart/pipes/measures/utils'\nimport { unique } from 'remeda'\nimport { ChartTypeEnum, DEFAULT_PARENT_ID } from './constant'\n\nexport const isTable = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.Table\n}\nexport const isPivotTable = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.PivotTable\n}\nexport const isRadar = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.Radar\n}\nexport const isAreaPercent = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.AreaPercent\n}\nexport const isColumnPercent = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.ColumnPercent\n}\nexport const isBarPercent = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.BarPercent\n}\nexport const isSankey = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.Sankey\n}\nexport const isHierarchySankey = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.HierarchySankey\n}\n\nexport const isBarLikeChart = (vseed: VSeed) => {\n return (\n vseed.chartType === ChartTypeEnum.Bar ||\n vseed.chartType === ChartTypeEnum.RaceBar ||\n vseed.chartType === ChartTypeEnum.BarPercent ||\n vseed.chartType === ChartTypeEnum.BarParallel\n )\n}\n\nexport const isVTable = (vseed: VSeed) => {\n return ['table', 'pivotTable'].includes(vseed.chartType)\n}\nexport const isVChart = (vseed: VSeed): boolean => {\n return !isVTable(vseed)\n}\n\n/**\n * @description 透视图表或组合图\n * - 透视图表定义: 存在 column 或 row的 encoding\n * - 组合图表定义: 存在多组指标的情况\n * - 透视组合图表: 存在 column 或 row的 encoding 且 存在多组指标的情况\n * 上述三者都只能使用 VTable.PivotChart 绘制\n */\nexport const isPivotChart = (vseed: VSeed) => {\n if (isVTable(vseed)) {\n return false\n }\n\n if (isPivot(vseed)) {\n return true\n }\n\n return isCombination(vseed)\n}\n\n/**\n * @description 存在column 或 row的encoding\n */\nexport const isPivot = (vseed: VSeed) => {\n const { dimensions = [], measures = [] } = vseed as {\n dimensions: Dimensions\n measures: Measures\n }\n\n if (dimensions && dimensions.some((dimension) => dimension.encoding === 'row' || dimension.encoding === 'column')) {\n return true\n }\n\n if (vseed.chartType === ChartTypeEnum.Scatter) {\n const xCount = measures.filter((m: Measure) => m.encoding === 'xAxis').length\n const yCount = measures.filter((m: Measure) => m.encoding === 'yAxis').length\n const otherCount = measures.filter(\n (m: Measure) =>\n !['size', 'xAxis', 'yAxis'].includes(m.encoding as string) &&\n !isCommonMeasureEncoding(m.encoding as MeasureEncoding),\n ).length\n\n /**\n * Scatter \"matrix\" detection logic\n *\n * xCount: number of measures explicitly encoded on the x-axis\n * yCount: number of measures explicitly encoded on the y-axis\n * otherCount: measures that are not size/xAxis/yAxis and are not common encodings\n *\n * When there is at least one explicit x-axis measure (xCount > 0):\n * - All x-encoded measures are counted as X.\n * - Remaining measures (y-encoded + \"other\") are treated as Y variants.\n *\n * When there is no explicit x-axis measure (xCount === 0):\n * - If there is at least one \"other\" measure, we treat exactly one of them as the X measure\n * (so finalXCount = 1), and the remaining \"other\" measures contribute to Y alongside\n * the explicit y-encoded measures.\n * - Since we conceptually \"promote\" one of the other measures to X, only (otherCount - 1)\n * are left to be counted towards Y. Math.max(..., 0) protects against negative values\n * when otherCount is 0.\n */\n let finalXCount: number\n let finalYCount: number\n\n if (xCount > 0) {\n // Explicit x-axis measures exist: X is fixed, Y aggregates y-encoded + other measures.\n finalXCount = xCount\n finalYCount = yCount + otherCount\n } else {\n // No explicit x-axis measure:\n // - If there are \"other\" measures, treat one as X.\n // - Remaining \"other\" measures contribute to Y, together with any y-encoded measures.\n finalXCount = otherCount > 0 ? 1 : 0\n finalYCount = yCount + Math.max(otherCount - 1, 0)\n }\n if (finalXCount > 1 || finalYCount > 1) return true\n }\n\n return false\n}\n\n/**\n * @description 不存在column 或 row的encoding, 但是有多组指标的情况\n */\nexport const isCombination = (vseed: VSeed) => {\n if (isMeasureTreeWithParentId(vseed.measures)) {\n const parentIds = vseed.measures\n ?.filter((m: Measure) => isPositionMeasure(m, vseed.chartType))\n .map((measure: Measure) => measure.parentId || DEFAULT_PARENT_ID)\n return parentIds && unique(parentIds).length > 1\n }\n\n const { measures = [] } = vseed as {\n measures: Measures\n dimensions: Dimensions\n }\n\n const hasMeasureGroup = measures && measures.some((measure: DimensionGroup) => measure && measure.children)\n\n return hasMeasureGroup\n}\n\nexport const isRectungularCoordinate = (chartType: string) => {\n return (\n [\n ChartTypeEnum.Bar,\n ChartTypeEnum.RaceBar,\n ChartTypeEnum.RaceColumn,\n ChartTypeEnum.RaceScatter,\n ChartTypeEnum.BarPercent,\n ChartTypeEnum.BarParallel,\n ChartTypeEnum.Column,\n ChartTypeEnum.ColumnPercent,\n ChartTypeEnum.ColumnParallel,\n ChartTypeEnum.Line,\n ChartTypeEnum.Area,\n ChartTypeEnum.AreaPercent,\n ChartTypeEnum.DualAxis,\n ChartTypeEnum.Boxplot,\n ChartTypeEnum.DualAxis,\n ChartTypeEnum.Scatter,\n ChartTypeEnum.Heatmap,\n ChartTypeEnum.Boxplot,\n ] as string[]\n ).includes(chartType)\n}\n\n/**\n * 默认的双轴图图表类型配置\n */\nexport const DEFAULT_DUAL_CHART_TYPE = {\n primary: 'column',\n secondary: 'line',\n}\n\nexport const isDualAxisChartType = (chartType: string | undefined) => {\n return (\n chartType &&\n ['column', 'columnParallel', 'columnPercent', 'line', 'area', 'areaPercent', 'scatter'].includes(chartType)\n )\n}\n"],"names":["isTable","vseed","ChartTypeEnum","isPivotTable","isRadar","isAreaPercent","isColumnPercent","isBarPercent","isSankey","isHierarchySankey","isBarLikeChart","isVTable","isVChart","isPivotChart","isPivot","isCombination","dimensions","measures","dimension","xCount","m","yCount","otherCount","isCommonMeasureEncoding","finalXCount","finalYCount","Math","isMeasureTreeWithParentId","parentIds","isPositionMeasure","measure","DEFAULT_PARENT_ID","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AAU;QACxBA,cAAc,WAAW;QACzBA,cAAc,MAAM;QACpBA,cAAc,aAAa;QAC3BA,cAAc,cAAc;QAC5BA,cAAc,IAAI;QAClBA,cAAc,IAAI;QAClBA,cAAc,WAAW;QACzBA,cAAc,QAAQ;QACtBA,cAAc,OAAO;QACrBA,cAAc,QAAQ;QACtBA,cAAc,OAAO;QACrBA,cAAc,OAAO;QACrBA,cAAc,OAAO;KACtB,CACD,QAAQ,CAACiC;AAMN,MAAMC,0BAA0B;IACrC,SAAS;IACT,WAAW;AACb;AAEO,MAAMC,sBAAsB,CAACF,YAEhCA,aACA;QAAC;QAAU;QAAkB;QAAiB;QAAQ;QAAQ;QAAe;KAAU,CAAC,QAAQ,CAACA"}
|
|
@@ -26,6 +26,8 @@ export declare const ChartTypeEnum: {
|
|
|
26
26
|
readonly Donut: "donut";
|
|
27
27
|
readonly Radar: "radar";
|
|
28
28
|
readonly CirclePacking: "circlePacking";
|
|
29
|
+
readonly Sankey: "sankey";
|
|
30
|
+
readonly HierarchySankey: "hierarchySankey";
|
|
29
31
|
readonly Sunburst: "sunburst";
|
|
30
32
|
readonly TreeMap: "treeMap";
|
|
31
33
|
readonly RaceBar: "raceBar";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/utils/constant.js","sources":["../../../../src/pipeline/utils/constant.ts"],"sourcesContent":["// 标注层 z-index\nexport const ANNOTATION_Z_INDEX = 1000\n// 线性轴 顶部空隙 预留5px\nexport const LINEAR_AXIS_INNER_OFFSET_TOP = 12\n// 双轴图 柱图 ZIndex\nexport const DUAL_AXIS_CHART_COLUMN_Z_INDEX = 1000\n// 双轴图 非柱图 ZIndex\nexport const DUAL_AXIS_CHART_NON_COLUMN_Z_INDEX = 1001\n// 双轴图 标注层 ZIndex\nexport const DUAL_AXIS_LABEL_Z_INDEX = 1002\n// 默认父级id\nexport const DEFAULT_PARENT_ID = '__DefaultParentId__'\n// 轴标签间距\nexport const AXIS_LABEL_SPACE = 8\n// 透视轴 band 类型内边距\nexport const BAND_AXIS_INNER_OFFSET_IN_PIVOT = 2\n\n// 图表类型枚举\nexport const ChartTypeEnum = {\n Table: 'table',\n PivotTable: 'pivotTable',\n // cartesian\n Line: 'line',\n Column: 'column',\n ColumnPercent: 'columnPercent',\n ColumnParallel: 'columnParallel',\n Bar: 'bar',\n BarPercent: 'barPercent',\n BarParallel: 'barParallel',\n Area: 'area',\n AreaPercent: 'areaPercent',\n DualAxis: 'dualAxis',\n Scatter: 'scatter',\n // polar\n Rose: 'rose',\n RoseParallel: 'roseParallel',\n Pie: 'pie',\n Donut: 'donut',\n Radar: 'radar',\n // hierarchical\n CirclePacking: 'circlePacking',\n Sunburst: 'sunburst',\n TreeMap: 'treeMap',\n // Race\n RaceBar: 'raceBar',\n RaceColumn: 'raceColumn',\n RaceScatter: 'raceScatter',\n RaceLine: 'raceLine',\n RacePie: 'racePie',\n RaceDonut: 'raceDonut',\n // other\n Funnel: 'funnel',\n Heatmap: 'heatmap',\n Boxplot: 'boxPlot',\n Histogram: 'histogram',\n} as const\n\n// Heatmap hide cell\nexport const DATUM_HIDE_KEY = '__VSEED_HideItem__'\n"],"names":["ANNOTATION_Z_INDEX","LINEAR_AXIS_INNER_OFFSET_TOP","DUAL_AXIS_CHART_COLUMN_Z_INDEX","DUAL_AXIS_CHART_NON_COLUMN_Z_INDEX","DUAL_AXIS_LABEL_Z_INDEX","DEFAULT_PARENT_ID","AXIS_LABEL_SPACE","BAND_AXIS_INNER_OFFSET_IN_PIVOT","ChartTypeEnum","DATUM_HIDE_KEY"],"mappings":"AACO,MAAMA,qBAAqB;AAE3B,MAAMC,+BAA+B;AAErC,MAAMC,iCAAiC;AAEvC,MAAMC,qCAAqC;AAE3C,MAAMC,0BAA0B;AAEhC,MAAMC,oBAAoB;AAE1B,MAAMC,mBAAmB;AAEzB,MAAMC,kCAAkC;AAGxC,MAAMC,gBAAgB;IAC3B,OAAO;IACP,YAAY;IAEZ,MAAM;IACN,QAAQ;IACR,eAAe;IACf,gBAAgB;IAChB,KAAK;IACL,YAAY;IACZ,aAAa;IACb,MAAM;IACN,aAAa;IACb,UAAU;IACV,SAAS;IAET,MAAM;IACN,cAAc;IACd,KAAK;IACL,OAAO;IACP,OAAO;IAEP,eAAe;IACf,UAAU;IACV,SAAS;IAET,SAAS;IACT,YAAY;IACZ,aAAa;IACb,UAAU;IACV,SAAS;IACT,WAAW;IAEX,QAAQ;IACR,SAAS;IACT,SAAS;IACT,WAAW;AACb;AAGO,MAAMC,iBAAiB"}
|
|
1
|
+
{"version":3,"file":"pipeline/utils/constant.js","sources":["../../../../src/pipeline/utils/constant.ts"],"sourcesContent":["// 标注层 z-index\nexport const ANNOTATION_Z_INDEX = 1000\n// 线性轴 顶部空隙 预留5px\nexport const LINEAR_AXIS_INNER_OFFSET_TOP = 12\n// 双轴图 柱图 ZIndex\nexport const DUAL_AXIS_CHART_COLUMN_Z_INDEX = 1000\n// 双轴图 非柱图 ZIndex\nexport const DUAL_AXIS_CHART_NON_COLUMN_Z_INDEX = 1001\n// 双轴图 标注层 ZIndex\nexport const DUAL_AXIS_LABEL_Z_INDEX = 1002\n// 默认父级id\nexport const DEFAULT_PARENT_ID = '__DefaultParentId__'\n// 轴标签间距\nexport const AXIS_LABEL_SPACE = 8\n// 透视轴 band 类型内边距\nexport const BAND_AXIS_INNER_OFFSET_IN_PIVOT = 2\n\n// 图表类型枚举\nexport const ChartTypeEnum = {\n Table: 'table',\n PivotTable: 'pivotTable',\n // cartesian\n Line: 'line',\n Column: 'column',\n ColumnPercent: 'columnPercent',\n ColumnParallel: 'columnParallel',\n Bar: 'bar',\n BarPercent: 'barPercent',\n BarParallel: 'barParallel',\n Area: 'area',\n AreaPercent: 'areaPercent',\n DualAxis: 'dualAxis',\n Scatter: 'scatter',\n // polar\n Rose: 'rose',\n RoseParallel: 'roseParallel',\n Pie: 'pie',\n Donut: 'donut',\n Radar: 'radar',\n // hierarchical\n CirclePacking: 'circlePacking',\n Sankey: 'sankey',\n HierarchySankey: 'hierarchySankey',\n Sunburst: 'sunburst',\n TreeMap: 'treeMap',\n // Race\n RaceBar: 'raceBar',\n RaceColumn: 'raceColumn',\n RaceScatter: 'raceScatter',\n RaceLine: 'raceLine',\n RacePie: 'racePie',\n RaceDonut: 'raceDonut',\n // other\n Funnel: 'funnel',\n Heatmap: 'heatmap',\n Boxplot: 'boxPlot',\n Histogram: 'histogram',\n} as const\n\n// Heatmap hide cell\nexport const DATUM_HIDE_KEY = '__VSEED_HideItem__'\n"],"names":["ANNOTATION_Z_INDEX","LINEAR_AXIS_INNER_OFFSET_TOP","DUAL_AXIS_CHART_COLUMN_Z_INDEX","DUAL_AXIS_CHART_NON_COLUMN_Z_INDEX","DUAL_AXIS_LABEL_Z_INDEX","DEFAULT_PARENT_ID","AXIS_LABEL_SPACE","BAND_AXIS_INNER_OFFSET_IN_PIVOT","ChartTypeEnum","DATUM_HIDE_KEY"],"mappings":"AACO,MAAMA,qBAAqB;AAE3B,MAAMC,+BAA+B;AAErC,MAAMC,iCAAiC;AAEvC,MAAMC,qCAAqC;AAE3C,MAAMC,0BAA0B;AAEhC,MAAMC,oBAAoB;AAE1B,MAAMC,mBAAmB;AAEzB,MAAMC,kCAAkC;AAGxC,MAAMC,gBAAgB;IAC3B,OAAO;IACP,YAAY;IAEZ,MAAM;IACN,QAAQ;IACR,eAAe;IACf,gBAAgB;IAChB,KAAK;IACL,YAAY;IACZ,aAAa;IACb,MAAM;IACN,aAAa;IACb,UAAU;IACV,SAAS;IAET,MAAM;IACN,cAAc;IACd,KAAK;IACL,OAAO;IACP,OAAO;IAEP,eAAe;IACf,QAAQ;IACR,iBAAiB;IACjB,UAAU;IACV,SAAS;IAET,SAAS;IACT,YAAY;IACZ,aAAa;IACb,UAAU;IACV,SAAS;IACT,WAAW;IAEX,QAAQ;IACR,SAAS;IACT,SAAS;IACT,WAAW;AACb;AAGO,MAAMC,iBAAiB"}
|
|
@@ -4,7 +4,7 @@ const isMeasureGroup = (measure)=>'children' in measure;
|
|
|
4
4
|
const isMeasures = (measures)=>measures.every(isMeasure);
|
|
5
5
|
const isPositionMeasure = (measure, chartType)=>{
|
|
6
6
|
if (!measure.encoding) return true;
|
|
7
|
-
if (ChartTypeEnum.Funnel === chartType || ChartTypeEnum.CirclePacking === chartType || ChartTypeEnum.Sunburst === chartType || ChartTypeEnum.TreeMap === chartType) return 'size' === measure.encoding;
|
|
7
|
+
if (ChartTypeEnum.Funnel === chartType || ChartTypeEnum.CirclePacking === chartType || ChartTypeEnum.Sankey === chartType || ChartTypeEnum.HierarchySankey === chartType || ChartTypeEnum.Sunburst === chartType || ChartTypeEnum.TreeMap === chartType) return 'size' === measure.encoding;
|
|
8
8
|
if (chartType === ChartTypeEnum.Heatmap) return 'color' === measure.encoding;
|
|
9
9
|
if ([
|
|
10
10
|
ChartTypeEnum.Pie,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/utils/measures/typeGuard.js","sources":["../../../../../src/pipeline/utils/measures/typeGuard.ts"],"sourcesContent":["import type { ChartType, Measure, MeasureGroup } from 'src/types'\nimport { ChartTypeEnum } from '../constant'\n\nexport const isMeasure = (measure: Measure | MeasureGroup): measure is Measure => {\n return !('children' in measure)\n}\n\nexport const isMeasureGroup = (measure: Measure | MeasureGroup): measure is MeasureGroup => {\n return 'children' in measure\n}\n\nexport const isMeasures = (measures: Measure[] | MeasureGroup[]): measures is Measure[] => {\n return measures.every(isMeasure)\n}\n\nexport const isPositionMeasure = (measure: Measure, chartType: ChartType): boolean => {\n if (!measure.encoding) {\n return true\n }\n\n if (\n ChartTypeEnum.Funnel === chartType ||\n ChartTypeEnum.CirclePacking === chartType ||\n ChartTypeEnum.Sunburst === chartType ||\n ChartTypeEnum.TreeMap === chartType\n ) {\n return measure.encoding === 'size'\n }\n\n if (chartType === ChartTypeEnum.Heatmap) {\n return measure.encoding === 'color'\n }\n\n if (\n ([ChartTypeEnum.Pie, ChartTypeEnum.Donut, ChartTypeEnum.Rose, ChartTypeEnum.RoseParallel] as string[]).includes(\n chartType,\n )\n ) {\n return measure.encoding === 'angle'\n }\n\n if (chartType === ChartTypeEnum.DualAxis) {\n return ['primaryYAxis', 'secondaryYAxis'].includes(measure.encoding as string)\n }\n\n if (ChartTypeEnum.Radar === chartType) {\n return measure.encoding === 'radius'\n }\n\n if (\n (\n [\n ChartTypeEnum.Line,\n ChartTypeEnum.Area,\n ChartTypeEnum.AreaPercent,\n ChartTypeEnum.Column,\n ChartTypeEnum.ColumnParallel,\n ChartTypeEnum.ColumnPercent,\n ] as string[]\n ).includes(chartType)\n ) {\n return measure.encoding === 'yAxis'\n }\n\n if (([ChartTypeEnum.Bar, ChartTypeEnum.BarParallel, ChartTypeEnum.BarPercent] as string[]).includes(chartType)) {\n return measure.encoding === 'xAxis'\n }\n\n return chartType === ChartTypeEnum.Boxplot && measure.encoding === 'value'\n}\n"],"names":["isMeasure","measure","isMeasureGroup","isMeasures","measures","isPositionMeasure","chartType","ChartTypeEnum"],"mappings":";AAGO,MAAMA,YAAY,CAACC,UACjB,CAAE,eAAcA,OAAM;AAGxB,MAAMC,iBAAiB,CAACD,UACtB,cAAcA;AAGhB,MAAME,aAAa,CAACC,WAClBA,SAAS,KAAK,CAACJ;AAGjB,MAAMK,oBAAoB,CAACJ,SAAkBK;IAClD,IAAI,CAACL,QAAQ,QAAQ,EACnB,OAAO;IAGT,IACEM,cAAc,MAAM,KAAKD,aACzBC,cAAc,aAAa,KAAKD,aAChCC,cAAc,QAAQ,KAAKD,aAC3BC,cAAc,OAAO,KAAKD,WAE1B,OAAOL,AAAqB,WAArBA,QAAQ,QAAQ;IAGzB,IAAIK,cAAcC,cAAc,OAAO,EACrC,OAAON,AAAqB,YAArBA,QAAQ,QAAQ;IAGzB,IACG;QAACM,cAAc,GAAG;QAAEA,cAAc,KAAK;QAAEA,cAAc,IAAI;QAAEA,cAAc,YAAY;KAAC,CAAc,QAAQ,CAC7GD,YAGF,OAAOL,AAAqB,YAArBA,QAAQ,QAAQ;IAGzB,IAAIK,cAAcC,cAAc,QAAQ,EACtC,OAAO;QAAC;QAAgB;KAAiB,CAAC,QAAQ,CAACN,QAAQ,QAAQ;IAGrE,IAAIM,cAAc,KAAK,KAAKD,WAC1B,OAAOL,AAAqB,aAArBA,QAAQ,QAAQ;IAGzB,IAEI;QACEM,cAAc,IAAI;QAClBA,cAAc,IAAI;QAClBA,cAAc,WAAW;QACzBA,cAAc,MAAM;QACpBA,cAAc,cAAc;QAC5BA,cAAc,aAAa;KAC5B,CACD,QAAQ,CAACD,YAEX,OAAOL,AAAqB,YAArBA,QAAQ,QAAQ;IAGzB,IAAK;QAACM,cAAc,GAAG;QAAEA,cAAc,WAAW;QAAEA,cAAc,UAAU;KAAC,CAAc,QAAQ,CAACD,YAClG,OAAOL,AAAqB,YAArBA,QAAQ,QAAQ;IAGzB,OAAOK,cAAcC,cAAc,OAAO,IAAIN,AAAqB,YAArBA,QAAQ,QAAQ;AAChE"}
|
|
1
|
+
{"version":3,"file":"pipeline/utils/measures/typeGuard.js","sources":["../../../../../src/pipeline/utils/measures/typeGuard.ts"],"sourcesContent":["import type { ChartType, Measure, MeasureGroup } from 'src/types'\nimport { ChartTypeEnum } from '../constant'\n\nexport const isMeasure = (measure: Measure | MeasureGroup): measure is Measure => {\n return !('children' in measure)\n}\n\nexport const isMeasureGroup = (measure: Measure | MeasureGroup): measure is MeasureGroup => {\n return 'children' in measure\n}\n\nexport const isMeasures = (measures: Measure[] | MeasureGroup[]): measures is Measure[] => {\n return measures.every(isMeasure)\n}\n\nexport const isPositionMeasure = (measure: Measure, chartType: ChartType): boolean => {\n if (!measure.encoding) {\n return true\n }\n\n if (\n ChartTypeEnum.Funnel === chartType ||\n ChartTypeEnum.CirclePacking === chartType ||\n ChartTypeEnum.Sankey === chartType ||\n ChartTypeEnum.HierarchySankey === chartType ||\n ChartTypeEnum.Sunburst === chartType ||\n ChartTypeEnum.TreeMap === chartType\n ) {\n return measure.encoding === 'size'\n }\n\n if (chartType === ChartTypeEnum.Heatmap) {\n return measure.encoding === 'color'\n }\n\n if (\n ([ChartTypeEnum.Pie, ChartTypeEnum.Donut, ChartTypeEnum.Rose, ChartTypeEnum.RoseParallel] as string[]).includes(\n chartType,\n )\n ) {\n return measure.encoding === 'angle'\n }\n\n if (chartType === ChartTypeEnum.DualAxis) {\n return ['primaryYAxis', 'secondaryYAxis'].includes(measure.encoding as string)\n }\n\n if (ChartTypeEnum.Radar === chartType) {\n return measure.encoding === 'radius'\n }\n\n if (\n (\n [\n ChartTypeEnum.Line,\n ChartTypeEnum.Area,\n ChartTypeEnum.AreaPercent,\n ChartTypeEnum.Column,\n ChartTypeEnum.ColumnParallel,\n ChartTypeEnum.ColumnPercent,\n ] as string[]\n ).includes(chartType)\n ) {\n return measure.encoding === 'yAxis'\n }\n\n if (([ChartTypeEnum.Bar, ChartTypeEnum.BarParallel, ChartTypeEnum.BarPercent] as string[]).includes(chartType)) {\n return measure.encoding === 'xAxis'\n }\n\n return chartType === ChartTypeEnum.Boxplot && measure.encoding === 'value'\n}\n"],"names":["isMeasure","measure","isMeasureGroup","isMeasures","measures","isPositionMeasure","chartType","ChartTypeEnum"],"mappings":";AAGO,MAAMA,YAAY,CAACC,UACjB,CAAE,eAAcA,OAAM;AAGxB,MAAMC,iBAAiB,CAACD,UACtB,cAAcA;AAGhB,MAAME,aAAa,CAACC,WAClBA,SAAS,KAAK,CAACJ;AAGjB,MAAMK,oBAAoB,CAACJ,SAAkBK;IAClD,IAAI,CAACL,QAAQ,QAAQ,EACnB,OAAO;IAGT,IACEM,cAAc,MAAM,KAAKD,aACzBC,cAAc,aAAa,KAAKD,aAChCC,cAAc,MAAM,KAAKD,aACzBC,cAAc,eAAe,KAAKD,aAClCC,cAAc,QAAQ,KAAKD,aAC3BC,cAAc,OAAO,KAAKD,WAE1B,OAAOL,AAAqB,WAArBA,QAAQ,QAAQ;IAGzB,IAAIK,cAAcC,cAAc,OAAO,EACrC,OAAON,AAAqB,YAArBA,QAAQ,QAAQ;IAGzB,IACG;QAACM,cAAc,GAAG;QAAEA,cAAc,KAAK;QAAEA,cAAc,IAAI;QAAEA,cAAc,YAAY;KAAC,CAAc,QAAQ,CAC7GD,YAGF,OAAOL,AAAqB,YAArBA,QAAQ,QAAQ;IAGzB,IAAIK,cAAcC,cAAc,QAAQ,EACtC,OAAO;QAAC;QAAgB;KAAiB,CAAC,QAAQ,CAACN,QAAQ,QAAQ;IAGrE,IAAIM,cAAc,KAAK,KAAKD,WAC1B,OAAOL,AAAqB,aAArBA,QAAQ,QAAQ;IAGzB,IAEI;QACEM,cAAc,IAAI;QAClBA,cAAc,IAAI;QAClBA,cAAc,WAAW;QACzBA,cAAc,MAAM;QACpBA,cAAc,cAAc;QAC5BA,cAAc,aAAa;KAC5B,CACD,QAAQ,CAACD,YAEX,OAAOL,AAAqB,YAArBA,QAAQ,QAAQ;IAGzB,IAAK;QAACM,cAAc,GAAG;QAAEA,cAAc,WAAW;QAAEA,cAAc,UAAU;KAAC,CAAc,QAAQ,CAACD,YAClG,OAAOL,AAAqB,YAArBA,QAAQ,QAAQ;IAGzB,OAAOK,cAAcC,cAAc,OAAO,IAAIN,AAAqB,YAArBA,QAAQ,QAAQ;AAChE"}
|
|
@@ -12,7 +12,7 @@ import { getFunnelTheme } from "./funnel.js";
|
|
|
12
12
|
import { getHeatmapTheme } from "./heatmap.js";
|
|
13
13
|
import { getHistogramTheme } from "./histogram.js";
|
|
14
14
|
import { getBoxPlotTheme } from "./boxPlot.js";
|
|
15
|
-
import { getCirclePackingTheme, getSunburstTheme, getTreeMapTheme } from "./hierarchy.js";
|
|
15
|
+
import { getCirclePackingTheme, getHierarchySankeyTheme, getSankeyTheme, getSunburstTheme, getTreeMapTheme } from "./hierarchy.js";
|
|
16
16
|
import { getRaceBarTheme, getRaceColumnTheme, getRaceScatterTheme } from "./race.js";
|
|
17
17
|
import { getRaceLineTheme } from "./raceLine.js";
|
|
18
18
|
import { getRaceDonutTheme, getRacePieTheme } from "./racePie.js";
|
|
@@ -41,6 +41,8 @@ const darkTheme = ()=>{
|
|
|
41
41
|
treeMap: getTreeMapTheme(),
|
|
42
42
|
sunburst: getSunburstTheme(),
|
|
43
43
|
circlePacking: getCirclePackingTheme(),
|
|
44
|
+
hierarchySankey: getHierarchySankeyTheme(),
|
|
45
|
+
sankey: getSankeyTheme(),
|
|
44
46
|
raceBar: getRaceBarTheme(),
|
|
45
47
|
raceColumn: getRaceColumnTheme(),
|
|
46
48
|
raceScatter: getRaceScatterTheme(),
|