@visactor/vseed 0.2.1 → 0.2.2

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 (74) hide show
  1. package/dist/cjs/index.cjs +2 -2
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/esm/builder/register/all.js +2 -2
  4. package/dist/esm/builder/register/all.js.map +1 -1
  5. package/dist/esm/builder/register/chartType/boxplot.d.ts +1 -1
  6. package/dist/esm/builder/register/chartType/boxplot.js +2 -2
  7. package/dist/esm/builder/register/chartType/boxplot.js.map +1 -1
  8. package/dist/esm/builder/register/chartType/index.d.ts +1 -1
  9. package/dist/esm/builder/register/chartType/index.js +2 -2
  10. package/dist/esm/index.d.ts +1 -1
  11. package/dist/esm/index.js +2 -2
  12. package/dist/esm/pipeline/advanced/chart/pipes/config/histogram.js +17 -0
  13. package/dist/esm/pipeline/advanced/chart/pipes/config/histogram.js.map +1 -1
  14. package/dist/esm/pipeline/spec/chart/pipeline/histogram.js +3 -3
  15. package/dist/esm/pipeline/spec/chart/pipeline/histogram.js.map +1 -1
  16. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPoint.js +3 -76
  17. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPoint.js.map +1 -1
  18. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPointCommon.d.ts +6 -0
  19. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPointCommon.js +95 -0
  20. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPointCommon.js.map +1 -0
  21. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPointOfDualAxis.js +16 -84
  22. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPointOfDualAxis.js.map +1 -1
  23. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPointOfHistogram.d.ts +2 -0
  24. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPointOfHistogram.js +23 -0
  25. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPointOfHistogram.js.map +1 -0
  26. package/dist/esm/pipeline/spec/chart/pipes/annotation/index.d.ts +1 -0
  27. package/dist/esm/pipeline/spec/chart/pipes/annotation/index.js +2 -1
  28. package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipHistogram.js +8 -7
  29. package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipHistogram.js.map +1 -1
  30. package/dist/esm/pipeline/spec/chart/utils/histogram.d.ts +1 -0
  31. package/dist/esm/pipeline/spec/chart/utils/histogram.js +6 -2
  32. package/dist/esm/pipeline/spec/chart/utils/histogram.js.map +1 -1
  33. package/dist/esm/types/chartType/area/area.d.ts +2 -2
  34. package/dist/esm/types/chartType/areaPercent/areaPercent.d.ts +3 -5
  35. package/dist/esm/types/chartType/bar/bar.d.ts +3 -3
  36. package/dist/esm/types/chartType/barParallel/barParallel.d.ts +3 -3
  37. package/dist/esm/types/chartType/barPercent/barPercent.d.ts +3 -3
  38. package/dist/esm/types/chartType/{boxplot/boxplot.d.ts → boxPlot/boxPlot.d.ts} +6 -6
  39. package/dist/esm/types/chartType/boxPlot/index.d.ts +2 -0
  40. package/dist/esm/types/chartType/boxPlot/index.js +1 -0
  41. package/dist/esm/types/chartType/{boxplot/zBoxplot.d.ts → boxPlot/zBoxPlot.d.ts} +1 -1
  42. package/dist/esm/types/chartType/{boxplot/zBoxplot.js → boxPlot/zBoxPlot.js} +3 -3
  43. package/dist/esm/types/chartType/{boxplot/zBoxplot.js.map → boxPlot/zBoxPlot.js.map} +1 -1
  44. package/dist/esm/types/chartType/column/column.d.ts +4 -4
  45. package/dist/esm/types/chartType/column/zColumn.d.ts +2 -2
  46. package/dist/esm/types/chartType/column/zColumn.js +1 -1
  47. package/dist/esm/types/chartType/column/zColumn.js.map +1 -1
  48. package/dist/esm/types/chartType/columnParallel/columnParallel.d.ts +3 -5
  49. package/dist/esm/types/chartType/columnPercent/columnPercent.d.ts +3 -3
  50. package/dist/esm/types/chartType/dualAxis/dualAxis.d.ts +3 -3
  51. package/dist/esm/types/chartType/histogram/histogram.d.ts +6 -6
  52. package/dist/esm/types/chartType/index.d.ts +1 -1
  53. package/dist/esm/types/chartType/index.js +1 -1
  54. package/dist/esm/types/chartType/line/line.d.ts +3 -5
  55. package/dist/esm/types/chartType/pivotTable/pivotTable.d.ts +1 -1
  56. package/dist/esm/types/chartType/scatter/scatter.d.ts +7 -7
  57. package/dist/esm/types/chartType/scatter/zScatter.d.ts +8 -8
  58. package/dist/esm/types/chartType/scatter/zScatter.js +4 -4
  59. package/dist/esm/types/chartType/scatter/zScatter.js.map +1 -1
  60. package/dist/esm/types/chartType/table/table.d.ts +1 -1
  61. package/dist/esm/types/properties/regressionLine/linearRegressionLine.d.ts +4 -0
  62. package/dist/esm/types/properties/regressionLine/logisticRegressionLine.d.ts +4 -0
  63. package/dist/esm/types/properties/regressionLine/lowessRegressionLine.d.ts +4 -0
  64. package/dist/esm/types/properties/regressionLine/polynomialRegressionLine.d.ts +4 -0
  65. package/dist/esm/types/vseed.d.ts +2 -2
  66. package/dist/esm/types/zVseed.d.ts +10 -10
  67. package/dist/esm/types/zVseed.js +2 -2
  68. package/dist/esm/types/zVseed.js.map +1 -1
  69. package/dist/umd/index.js +170 -135
  70. package/dist/umd/index.js.map +1 -1
  71. package/package.json +1 -1
  72. package/dist/esm/types/chartType/boxplot/index.d.ts +0 -2
  73. package/dist/esm/types/chartType/boxplot/index.js +0 -1
  74. /package/dist/esm/types/chartType/{boxplot/boxplot.js → boxPlot/boxPlot.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { registerArea, registerAreaPercent, registerBar, registerBarParallel, registerBarPercent, registerBoxplot, registerColumn, registerColumnParallel, registerColumnPercent, registerDonut, registerDualAxis, registerFunnel, registerHeatmap, registerHistogram, registerLine, registerPie, registerPivotTable, registerRadar, registerRose, registerRoseParallel, registerScatter, registerTable } from "./chartType/index.js";
1
+ import { registerArea, registerAreaPercent, registerBar, registerBarParallel, registerBarPercent, registerBoxPlot, registerColumn, registerColumnParallel, registerColumnPercent, registerDonut, registerDualAxis, registerFunnel, registerHeatmap, registerHistogram, registerLine, registerPie, registerPivotTable, registerRadar, registerRose, registerRoseParallel, registerScatter, registerTable } from "./chartType/index.js";
2
2
  import { registerDarkTheme, registerLightTheme } from "./theme/index.js";
3
3
  const registerAll = ()=>{
4
4
  registerTable();
@@ -21,7 +21,7 @@ const registerAll = ()=>{
21
21
  registerRadar();
22
22
  registerFunnel();
23
23
  registerHeatmap();
24
- registerBoxplot();
24
+ registerBoxPlot();
25
25
  registerHistogram();
26
26
  registerLightTheme();
27
27
  registerDarkTheme();
@@ -1 +1 @@
1
- {"version":3,"file":"builder/register/all.js","sources":["../../../../src/builder/register/all.ts"],"sourcesContent":["import {\n registerArea,\n registerAreaPercent,\n registerBar,\n registerBarParallel,\n registerBarPercent,\n registerColumn,\n registerColumnParallel,\n registerColumnPercent,\n registerLine,\n registerPie,\n registerDonut,\n registerRose,\n registerRoseParallel,\n registerFunnel,\n registerScatter,\n registerTable,\n registerPivotTable,\n registerHeatmap,\n registerRadar,\n registerDualAxis,\n registerBoxplot,\n registerHistogram,\n} from './chartType'\nimport { registerDarkTheme, registerLightTheme } from './theme'\n\nexport const registerAll = () => {\n // table\n registerTable()\n registerPivotTable()\n // cartesian\n registerLine()\n registerColumn()\n registerColumnParallel()\n registerColumnPercent()\n registerBar()\n registerBarParallel()\n registerBarPercent()\n registerArea()\n registerAreaPercent()\n registerScatter()\n registerDualAxis()\n // polar\n registerPie()\n registerDonut()\n registerRose()\n registerRoseParallel()\n registerRadar()\n // other\n registerFunnel()\n registerHeatmap()\n registerBoxplot()\n registerHistogram()\n // theme\n registerLightTheme()\n registerDarkTheme()\n}\n"],"names":["registerAll","registerTable","registerPivotTable","registerLine","registerColumn","registerColumnParallel","registerColumnPercent","registerBar","registerBarParallel","registerBarPercent","registerArea","registerAreaPercent","registerScatter","registerDualAxis","registerPie","registerDonut","registerRose","registerRoseParallel","registerRadar","registerFunnel","registerHeatmap","registerBoxplot","registerHistogram","registerLightTheme","registerDarkTheme"],"mappings":";;AA0BO,MAAMA,cAAc;IAEzBC;IACAC;IAEAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IAEAC;IACAC;IACAC;IACAC;IACAC;IAEAC;IACAC;IACAC;IACAC;IAEAC;IACAC;AACF"}
1
+ {"version":3,"file":"builder/register/all.js","sources":["../../../../src/builder/register/all.ts"],"sourcesContent":["import {\n registerArea,\n registerAreaPercent,\n registerBar,\n registerBarParallel,\n registerBarPercent,\n registerColumn,\n registerColumnParallel,\n registerColumnPercent,\n registerLine,\n registerPie,\n registerDonut,\n registerRose,\n registerRoseParallel,\n registerFunnel,\n registerScatter,\n registerTable,\n registerPivotTable,\n registerHeatmap,\n registerRadar,\n registerDualAxis,\n registerBoxPlot,\n registerHistogram,\n} from './chartType'\nimport { registerDarkTheme, registerLightTheme } from './theme'\n\nexport const registerAll = () => {\n // table\n registerTable()\n registerPivotTable()\n // cartesian\n registerLine()\n registerColumn()\n registerColumnParallel()\n registerColumnPercent()\n registerBar()\n registerBarParallel()\n registerBarPercent()\n registerArea()\n registerAreaPercent()\n registerScatter()\n registerDualAxis()\n // polar\n registerPie()\n registerDonut()\n registerRose()\n registerRoseParallel()\n registerRadar()\n // other\n registerFunnel()\n registerHeatmap()\n registerBoxPlot()\n registerHistogram()\n // theme\n registerLightTheme()\n registerDarkTheme()\n}\n"],"names":["registerAll","registerTable","registerPivotTable","registerLine","registerColumn","registerColumnParallel","registerColumnPercent","registerBar","registerBarParallel","registerBarPercent","registerArea","registerAreaPercent","registerScatter","registerDualAxis","registerPie","registerDonut","registerRose","registerRoseParallel","registerRadar","registerFunnel","registerHeatmap","registerBoxPlot","registerHistogram","registerLightTheme","registerDarkTheme"],"mappings":";;AA0BO,MAAMA,cAAc;IAEzBC;IACAC;IAEAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IAEAC;IACAC;IACAC;IACAC;IACAC;IAEAC;IACAC;IACAC;IACAC;IAEAC;IACAC;AACF"}
@@ -1 +1 @@
1
- export declare const registerBoxplot: () => void;
1
+ export declare const registerBoxPlot: () => void;
@@ -1,9 +1,9 @@
1
1
  import { boxplotAdvancedPipeline, boxplotSpecPipeline } from "../../../pipeline/index.js";
2
2
  import { Builder } from "../../builder/index.js";
3
- const registerBoxplot = ()=>{
3
+ const registerBoxPlot = ()=>{
4
4
  Builder._advancedPipelineMap.boxPlot = boxplotAdvancedPipeline;
5
5
  Builder._specPipelineMap.boxPlot = boxplotSpecPipeline;
6
6
  };
7
- export { registerBoxplot };
7
+ export { registerBoxPlot };
8
8
 
9
9
  //# sourceMappingURL=boxplot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"builder/register/chartType/boxplot.js","sources":["../../../../../src/builder/register/chartType/boxplot.ts"],"sourcesContent":["import { boxplotAdvancedPipeline, boxplotSpecPipeline } from '../../../pipeline'\nimport { Builder } from '../../builder'\n\nexport const registerBoxplot = () => {\n Builder._advancedPipelineMap['boxPlot'] = boxplotAdvancedPipeline\n Builder._specPipelineMap['boxPlot'] = boxplotSpecPipeline\n}\n"],"names":["registerBoxplot","Builder","boxplotAdvancedPipeline","boxplotSpecPipeline"],"mappings":";;AAGO,MAAMA,kBAAkB;IAC7BC,QAAQ,oBAAoB,CAA5BA,OAAuC,GAAGC;IAC1CD,QAAQ,gBAAgB,CAAxBA,OAAmC,GAAGE;AACxC"}
1
+ {"version":3,"file":"builder/register/chartType/boxplot.js","sources":["../../../../../src/builder/register/chartType/boxplot.ts"],"sourcesContent":["import { boxplotAdvancedPipeline, boxplotSpecPipeline } from '../../../pipeline'\nimport { Builder } from '../../builder'\n\nexport const registerBoxPlot = () => {\n Builder._advancedPipelineMap['boxPlot'] = boxplotAdvancedPipeline\n Builder._specPipelineMap['boxPlot'] = boxplotSpecPipeline\n}\n"],"names":["registerBoxPlot","Builder","boxplotAdvancedPipeline","boxplotSpecPipeline"],"mappings":";;AAGO,MAAMA,kBAAkB;IAC7BC,QAAQ,oBAAoB,CAA5BA,OAAuC,GAAGC;IAC1CD,QAAQ,gBAAgB,CAAxBA,OAAmC,GAAGE;AACxC"}
@@ -18,5 +18,5 @@ export { registerRoseParallel } from './roseParallel';
18
18
  export { registerRadar } from './radar';
19
19
  export { registerHeatmap } from './heatmap';
20
20
  export { registerFunnel } from './funnel';
21
- export { registerBoxplot } from './boxplot';
21
+ export { registerBoxPlot } from './boxplot';
22
22
  export { registerHistogram } from './histogram';
@@ -18,6 +18,6 @@ import { registerRoseParallel } from "./roseParallel.js";
18
18
  import { registerRadar } from "./radar.js";
19
19
  import { registerHeatmap } from "./heatmap.js";
20
20
  import { registerFunnel } from "./funnel.js";
21
- import { registerBoxplot } from "./boxplot.js";
21
+ import { registerBoxPlot } from "./boxplot.js";
22
22
  import { registerHistogram } from "./histogram.js";
23
- export { registerArea, registerAreaPercent, registerBar, registerBarParallel, registerBarPercent, registerBoxplot, registerColumn, registerColumnParallel, registerColumnPercent, registerDonut, registerDualAxis, registerFunnel, registerHeatmap, registerHistogram, registerLine, registerPie, registerPivotTable, registerRadar, registerRose, registerRoseParallel, registerScatter, registerTable };
23
+ export { registerArea, registerAreaPercent, registerBar, registerBarParallel, registerBarPercent, registerBoxPlot, registerColumn, registerColumnParallel, registerColumnPercent, registerDonut, registerDualAxis, registerFunnel, registerHeatmap, registerHistogram, registerLine, registerPie, registerPivotTable, registerRadar, registerRose, registerRoseParallel, registerScatter, registerTable };
@@ -2,7 +2,7 @@ export { Builder } from './builder';
2
2
  export { registerAll } from './builder/register/all';
3
3
  export { updateAdvanced, updateSpec } from './builder/register/custom';
4
4
  export { registerDarkTheme, registerLightTheme, registerCustomTheme } from './builder/register/theme';
5
- export { registerArea, registerAreaPercent, registerBar, registerBarParallel, registerBarPercent, registerColumn, registerColumnParallel, registerColumnPercent, registerLine, registerPie, registerDonut, registerRose, registerRoseParallel, registerFunnel, registerScatter, registerTable, registerPivotTable, registerHeatmap, registerRadar, registerBoxplot, registerHistogram, registerDualAxis, } from './builder/register/chartType';
5
+ export { registerArea, registerAreaPercent, registerBar, registerBarParallel, registerBarPercent, registerColumn, registerColumnParallel, registerColumnPercent, registerLine, registerPie, registerDonut, registerRose, registerRoseParallel, registerFunnel, registerScatter, registerTable, registerPivotTable, registerHeatmap, registerRadar, registerBoxPlot, registerHistogram, registerDualAxis, } from './builder/register/chartType';
6
6
  export * from './pipeline';
7
7
  export * from './types';
8
8
  export * from './dataReshape';
package/dist/esm/index.js CHANGED
@@ -2,11 +2,11 @@ import { Builder } from "./builder/index.js";
2
2
  import { registerAll } from "./builder/register/all.js";
3
3
  import { updateAdvanced, updateSpec } from "./builder/register/custom.js";
4
4
  import { registerCustomTheme, registerDarkTheme, registerLightTheme } from "./builder/register/theme/index.js";
5
- import { registerArea, registerAreaPercent, registerBar, registerBarParallel, registerBarPercent, registerBoxplot, registerColumn, registerColumnParallel, registerColumnPercent, registerDonut, registerDualAxis, registerFunnel, registerHeatmap, registerHistogram, registerLine, registerPie, registerPivotTable, registerRadar, registerRose, registerRoseParallel, registerScatter, registerTable } from "./builder/register/chartType/index.js";
5
+ import { registerArea, registerAreaPercent, registerBar, registerBarParallel, registerBarPercent, registerBoxPlot, registerColumn, registerColumnParallel, registerColumnPercent, registerDonut, registerDualAxis, registerFunnel, registerHeatmap, registerHistogram, registerLine, registerPie, registerPivotTable, registerRadar, registerRose, registerRoseParallel, registerScatter, registerTable } from "./builder/register/chartType/index.js";
6
6
  export * from "./pipeline/index.js";
7
7
  export * from "./types/index.js";
8
8
  export * from "./dataReshape/index.js";
9
9
  export * from "./dataSelector/index.js";
10
10
  export * from "./theme/index.js";
11
11
  export * from "./i18n/index.js";
12
- export { Builder, registerAll, registerArea, registerAreaPercent, registerBar, registerBarParallel, registerBarPercent, registerBoxplot, registerColumn, registerColumnParallel, registerColumnPercent, registerCustomTheme, registerDarkTheme, registerDonut, registerDualAxis, registerFunnel, registerHeatmap, registerHistogram, registerLightTheme, registerLine, registerPie, registerPivotTable, registerRadar, registerRose, registerRoseParallel, registerScatter, registerTable, updateAdvanced, updateSpec };
12
+ export { Builder, registerAll, registerArea, registerAreaPercent, registerBar, registerBarParallel, registerBarPercent, registerBoxPlot, registerColumn, registerColumnParallel, registerColumnPercent, registerCustomTheme, registerDarkTheme, registerDonut, registerDualAxis, registerFunnel, registerHeatmap, registerHistogram, registerLightTheme, registerLine, registerPie, registerPivotTable, registerRadar, registerRose, registerRoseParallel, registerScatter, registerTable, updateAdvanced, updateSpec };
@@ -1,3 +1,4 @@
1
+ import { merge } from "@visactor/vutils";
1
2
  import { pick } from "remeda";
2
3
  import { BinEndMeasureId, BinStartMeasureId } from "../../../../../dataReshape/index.js";
3
4
  import { replaceNullToUndefined } from "../../../../utils/index.js";
@@ -23,6 +24,22 @@ const histogramConfig = (advancedVSeed, context)=>{
23
24
  'dimensionLinkage'
24
25
  ]);
25
26
  let config = replaceNullToUndefined(pickedConfig);
27
+ if (pickedConfig?.binValueType === 'percentage') config = merge({}, {
28
+ yAxis: {
29
+ autoFomat: false,
30
+ numFormat: {
31
+ type: 'percent',
32
+ fractionDigits: 1
33
+ }
34
+ },
35
+ label: {
36
+ autoFormat: false,
37
+ numFormat: {
38
+ type: 'percent',
39
+ fractionDigits: 1
40
+ }
41
+ }
42
+ }, config);
26
43
  if (!hasColorEncoding && !config?.legend?.enable) config = {
27
44
  ...config,
28
45
  legend: {
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline/advanced/chart/pipes/config/histogram.js","sources":["../../../../../../../src/pipeline/advanced/chart/pipes/config/histogram.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport { pick } from 'remeda'\nimport { BinEndMeasureId, BinStartMeasureId } from 'src/dataReshape'\nimport { replaceNullToUndefined } from 'src/pipeline/utils'\nimport type { AdvancedPipe, AdvancedVSeed, Config, Dimension } from 'src/types'\n\nexport const histogramConfig: AdvancedPipe = (advancedVSeed, context) => {\n const { vseed } = context\n const { chartType } = vseed\n const result = {\n ...advancedVSeed,\n }\n const hasColorEncoding = (advancedVSeed?.dimensions || []).find((field: Dimension) => field?.encoding === 'color')\n\n const pickedConfig = pick(vseed, [\n 'backgroundColor',\n 'color',\n 'label',\n 'legend',\n 'tooltip',\n 'xAxis',\n 'yAxis',\n 'crosshairRect',\n 'binCount',\n 'binStep',\n 'binValueType',\n\n 'dimensionLinkage',\n ]) as Config['histogram']\n\n let config = replaceNullToUndefined(pickedConfig)\n\n if (!hasColorEncoding && !config?.legend?.enable) {\n config = {\n ...config,\n legend: {\n ...config?.legend,\n enable: false,\n },\n }\n }\n result.config = {\n ...(result.config || {}),\n [chartType]: {\n ...config,\n },\n }\n\n return result as AdvancedVSeed\n}\n\nexport const histogramXAxisConfig: AdvancedPipe = (advancedVSeed, context) => {\n const { vseed } = context\n const { chartType } = vseed\n const result = {\n ...advancedVSeed,\n }\n const { dataset = [] } = advancedVSeed\n const flattenDatasert = dataset.flat()\n const minValue = Math.min(...flattenDatasert.map((v) => +v[BinStartMeasureId]))\n const maxValue = Math.max(...flattenDatasert.map((v) => +v[BinEndMeasureId]))\n\n const chartConfig = result.config?.[chartType] as any\n result.config = {\n ...(result.config || {}),\n [chartType]: {\n ...chartConfig,\n xAxis: {\n min: Number.isNaN(minValue) ? undefined : minValue,\n max: Number.isNaN(maxValue) ? undefined : maxValue,\n ...(chartConfig?.xAxis || {}),\n },\n },\n }\n\n return result as AdvancedVSeed\n}\n"],"names":["histogramConfig","advancedVSeed","context","vseed","chartType","result","hasColorEncoding","field","pickedConfig","pick","config","replaceNullToUndefined","histogramXAxisConfig","dataset","flattenDatasert","minValue","Math","v","BinStartMeasureId","maxValue","BinEndMeasureId","chartConfig","Number","undefined"],"mappings":";;;AAMO,MAAMA,kBAAgC,CAACC,eAAeC;IAC3D,MAAM,EAAEC,KAAK,EAAE,GAAGD;IAClB,MAAM,EAAEE,SAAS,EAAE,GAAGD;IACtB,MAAME,SAAS;QACb,GA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C,GAAIE,aAAa,SAAS,CAAC,CAAC;YAC9B;QACF;IACF;IAEA,OAAOhB;AACT"}
1
+ {"version":3,"file":"pipeline/advanced/chart/pipes/config/histogram.js","sources":["../../../../../../../src/pipeline/advanced/chart/pipes/config/histogram.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport { merge } from '@visactor/vutils'\nimport { pick } from 'remeda'\nimport { BinEndMeasureId, BinStartMeasureId } from 'src/dataReshape'\nimport { replaceNullToUndefined } from 'src/pipeline/utils'\nimport type { AdvancedPipe, AdvancedVSeed, Config, Dimension } from 'src/types'\n\nexport const histogramConfig: AdvancedPipe = (advancedVSeed, context) => {\n const { vseed } = context\n const { chartType } = vseed\n const result = {\n ...advancedVSeed,\n }\n const hasColorEncoding = (advancedVSeed?.dimensions || []).find((field: Dimension) => field?.encoding === 'color')\n\n const pickedConfig = pick(vseed, [\n 'backgroundColor',\n 'color',\n 'label',\n 'legend',\n 'tooltip',\n 'xAxis',\n 'yAxis',\n 'crosshairRect',\n 'binCount',\n 'binStep',\n 'binValueType',\n\n 'dimensionLinkage',\n ]) as Config['histogram']\n\n let config = replaceNullToUndefined(pickedConfig)\n\n if (pickedConfig?.binValueType === 'percentage') {\n config = merge(\n {},\n {\n yAxis: {\n autoFomat: false,\n numFormat: {\n type: 'percent',\n fractionDigits: 1,\n },\n },\n label: {\n autoFormat: false,\n numFormat: {\n type: 'percent',\n fractionDigits: 1,\n },\n },\n },\n config,\n )\n }\n if (!hasColorEncoding && !config?.legend?.enable) {\n config = {\n ...config,\n legend: {\n ...config?.legend,\n enable: false,\n },\n }\n }\n result.config = {\n ...(result.config || {}),\n [chartType]: {\n ...config,\n },\n }\n\n return result as AdvancedVSeed\n}\n\nexport const histogramXAxisConfig: AdvancedPipe = (advancedVSeed, context) => {\n const { vseed } = context\n const { chartType } = vseed\n const result = {\n ...advancedVSeed,\n }\n const { dataset = [] } = advancedVSeed\n const flattenDatasert = dataset.flat()\n const minValue = Math.min(...flattenDatasert.map((v) => +v[BinStartMeasureId]))\n const maxValue = Math.max(...flattenDatasert.map((v) => +v[BinEndMeasureId]))\n\n const chartConfig = result.config?.[chartType] as any\n result.config = {\n ...(result.config || {}),\n [chartType]: {\n ...chartConfig,\n xAxis: {\n min: Number.isNaN(minValue) ? undefined : minValue,\n max: Number.isNaN(maxValue) ? undefined : maxValue,\n ...(chartConfig?.xAxis || {}),\n },\n },\n }\n\n return result as AdvancedVSeed\n}\n"],"names":["histogramConfig","advancedVSeed","context","vseed","chartType","result","hasColorEncoding","field","pickedConfig","pick","config","replaceNullToUndefined","merge","histogramXAxisConfig","dataset","flattenDatasert","minValue","Math","v","BinStartMeasureId","maxValue","BinEndMeasureId","chartConfig","Number","undefined"],"mappings":";;;;AAOO,MAAMA,kBAAgC,CAACC,eAAeC;IAC3D,MAAM,EAAEC,KAAK,EAAE,GAAGD;IAClB,MAAM,EAAEE,SAAS,EAAE,GAAGD;IACtB,MAAME,SAAS;QACb,GAAGJ,aAAa;IAClB;IACA,MAAMK,mBAAoBL,AAAAA,CAAAA,eAAe,cAAc,EAAC,EAAG,IAAI,CAAC,CAACM,QAAqBA,OAAO,aAAa;IAE1G,MAAMC,eAAeC,KAAKN,OAAO;QAC/B;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QAEA;KACD;IAED,IAAIO,SAASC,uBAAuBH;IAEpC,IAAIA,cAAc,iBAAiB,cACjCE,SAASE,MACP,CAAC,GACD;QACE,OAAO;YACL,WAAW;YACX,WAAW;gBACT,MAAM;gBACN,gBAAgB;YAClB;QACF;QACA,OAAO;YACL,YAAY;YACZ,WAAW;gBACT,MAAM;gBACN,gBAAgB;YAClB;QACF;IACF,GACAF;IAGJ,IAAI,CAACJ,oBAAoB,CAACI,QAAQ,QAAQ,QACxCA,SAAS;QACP,GAAGA,MAAM;QACT,QAAQ;YACN,GAAGA,QAAQ,MAAM;YACjB,QAAQ;QACV;IACF;IAEFL,OAAO,MAAM,GAAG;QACd,GAAIA,OAAO,MAAM,IAAI,CAAC,CAAC;QACvB,CAACD,UAAU,EAAE;YACX,GAAGM,MAAM;QACX;IACF;IAEA,OAAOL;AACT;AAEO,MAAMQ,uBAAqC,CAACZ,eAAeC;IAChE,MAAM,EAAEC,KAAK,EAAE,GAAGD;IAClB,MAAM,EAAEE,SAAS,EAAE,GAAGD;IACtB,MAAME,SAAS;QACb,GAAGJ,aAAa;IAClB;IACA,MAAM,EAAEa,UAAU,EAAE,EAAE,GAAGb;IACzB,MAAMc,kBAAkBD,QAAQ,IAAI;IACpC,MAAME,WAAWC,KAAK,GAAG,IAAIF,gBAAgB,GAAG,CAAC,CAACG,IAAM,CAACA,CAAC,CAACC,kBAAkB;IAC7E,MAAMC,WAAWH,KAAK,GAAG,IAAIF,gBAAgB,GAAG,CAAC,CAACG,IAAM,CAACA,CAAC,CAACG,gBAAgB;IAE3E,MAAMC,cAAcjB,OAAO,MAAM,EAAE,CAACD,UAAU;IAC9CC,OAAO,MAAM,GAAG;QACd,GAAIA,OAAO,MAAM,IAAI,CAAC,CAAC;QACvB,CAACD,UAAU,EAAE;YACX,GAAGkB,WAAW;YACd,OAAO;gBACL,KAAKC,OAAO,KAAK,CAACP,YAAYQ,SAAYR;gBAC1C,KAAKO,OAAO,KAAK,CAACH,YAAYI,SAAYJ;gBAC1C,GAAIE,aAAa,SAAS,CAAC,CAAC;YAC9B;QACF;IACF;IAEA,OAAOjB;AACT"}
@@ -1,4 +1,4 @@
1
- import { annotationAreaBand, annotationHorizontalLine, annotationPoint, annotationVerticalLine, backgroundColor, barStyle, color, colorAdapter, colorBarStyleFill, colorLegend, datasetHistogram, datasetPivot, dimensionLinkage, discreteLegend, ecdfRegressionLine, histogramVerticalCrosshairRect, initHistogram, initPivot, kdeRegressionLine, label, linearColor, pivotAdapter, pivotAxisStyle, pivotColorLegend, pivotColumnDimensions, pivotDiscreteLegend, pivotGridStyle, pivotIndicators, pivotRowDimensions, pivotTitle, progressive, tooltipHistogram, xLinear, yLinear } from "../pipes/index.js";
1
+ import { annotationAreaBand, annotationHorizontalLine, annotationPointOfHistogram, annotationVerticalLine, backgroundColor, barStyle, color, colorAdapter, colorBarStyleFill, colorLegend, datasetHistogram, datasetPivot, dimensionLinkage, discreteLegend, ecdfRegressionLine, histogramVerticalCrosshairRect, initHistogram, initPivot, kdeRegressionLine, label, linearColor, pivotAdapter, pivotAxisStyle, pivotColorLegend, pivotColumnDimensions, pivotDiscreteLegend, pivotGridStyle, pivotIndicators, pivotRowDimensions, pivotTitle, progressive, tooltipHistogram, xLinear, yLinear } from "../pipes/index.js";
2
2
  const histogram = [
3
3
  initHistogram,
4
4
  colorAdapter(color, linearColor),
@@ -12,7 +12,7 @@ const histogram = [
12
12
  colorAdapter(discreteLegend, colorLegend),
13
13
  histogramVerticalCrosshairRect,
14
14
  colorBarStyleFill(barStyle),
15
- annotationPoint,
15
+ annotationPointOfHistogram,
16
16
  annotationVerticalLine,
17
17
  annotationHorizontalLine,
18
18
  annotationAreaBand,
@@ -35,7 +35,7 @@ const pivotHistogram = [
35
35
  tooltipHistogram,
36
36
  colorBarStyleFill(barStyle),
37
37
  histogramVerticalCrosshairRect,
38
- annotationPoint,
38
+ annotationPointOfHistogram,
39
39
  annotationVerticalLine,
40
40
  annotationHorizontalLine,
41
41
  annotationAreaBand,
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline/spec/chart/pipeline/histogram.js","sources":["../../../../../../src/pipeline/spec/chart/pipeline/histogram.ts"],"sourcesContent":["import type { PivotChartSpecPipeline, VChartSpecPipeline } from 'src/types'\nimport {\n label,\n xLinear,\n backgroundColor,\n discreteLegend,\n color,\n pivotAdapter,\n initPivot,\n datasetPivot,\n pivotIndicators,\n pivotDiscreteLegend,\n pivotGridStyle,\n pivotColumnDimensions,\n pivotRowDimensions,\n barStyle,\n annotationPoint,\n annotationVerticalLine,\n annotationHorizontalLine,\n annotationAreaBand,\n datasetHistogram,\n progressive,\n colorAdapter,\n linearColor,\n colorLegend,\n colorBarStyleFill,\n pivotColorLegend,\n initHistogram,\n yLinear,\n histogramVerticalCrosshairRect,\n tooltipHistogram,\n kdeRegressionLine,\n ecdfRegressionLine,\n pivotTitle,\n pivotAxisStyle,\n dimensionLinkage,\n} from '../pipes'\n\nconst histogram: VChartSpecPipeline = [\n initHistogram,\n colorAdapter(color, linearColor),\n backgroundColor,\n datasetHistogram,\n progressive,\n xLinear,\n yLinear,\n label,\n tooltipHistogram,\n colorAdapter(discreteLegend, colorLegend),\n histogramVerticalCrosshairRect,\n colorBarStyleFill(barStyle),\n annotationPoint,\n annotationVerticalLine,\n annotationHorizontalLine,\n annotationAreaBand,\n kdeRegressionLine,\n ecdfRegressionLine,\n]\n\nconst pivotHistogram: PivotChartSpecPipeline = [\n initPivot,\n pivotGridStyle,\n datasetPivot,\n pivotIndicators([\n initHistogram,\n colorAdapter(color, linearColor),\n backgroundColor,\n datasetHistogram,\n progressive,\n xLinear,\n pivotAxisStyle(yLinear),\n label,\n tooltipHistogram,\n colorBarStyleFill(barStyle),\n histogramVerticalCrosshairRect,\n annotationPoint,\n annotationVerticalLine,\n annotationHorizontalLine,\n annotationAreaBand,\n kdeRegressionLine,\n ecdfRegressionLine,\n ]),\n pivotRowDimensions,\n pivotColumnDimensions,\n pivotTitle,\n colorAdapter(pivotDiscreteLegend, pivotColorLegend),\n dimensionLinkage,\n]\n\nexport const histogramSpecPipeline = [pivotAdapter(histogram, pivotHistogram)]\n"],"names":["histogram","initHistogram","colorAdapter","color","linearColor","backgroundColor","datasetHistogram","progressive","xLinear","yLinear","label","tooltipHistogram","discreteLegend","colorLegend","histogramVerticalCrosshairRect","colorBarStyleFill","barStyle","annotationPoint","annotationVerticalLine","annotationHorizontalLine","annotationAreaBand","kdeRegressionLine","ecdfRegressionLine","pivotHistogram","initPivot","pivotGridStyle","datasetPivot","pivotIndicators","pivotAxisStyle","pivotRowDimensions","pivotColumnDimensions","pivotTitle","pivotDiscreteLegend","pivotColorLegend","dimensionLinkage","histogramSpecPipeline","pivotAdapter"],"mappings":";AAsCA,MAAMA,YAAgC;IACpCC;IACAC,aAAaC,OAAOC;IACpBC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAT,aAAaU,gBAAgBC;IAC7BC;IACAC,kBAAkBC;IAClBC;IACAC;IACAC;IACAC;IACAC;IACAC;CACD;AAED,MAAMC,iBAAyC;IAC7CC;IACAC;IACAC;IACAC,gBAAgB;QACd1B;QACAC,aAAaC,OAAOC;QACpBC;QACAC;QACAC;QACAC;QACAoB,eAAenB;QACfC;QACAC;QACAI,kBAAkBC;QAClBF;QACAG;QACAC;QACAC;QACAC;QACAC;QACAC;KACD;IACDO;IACAC;IACAC;IACA7B,aAAa8B,qBAAqBC;IAClCC;CACD;AAEM,MAAMC,wBAAwB;IAACC,aAAapC,WAAWuB;CAAgB"}
1
+ {"version":3,"file":"pipeline/spec/chart/pipeline/histogram.js","sources":["../../../../../../src/pipeline/spec/chart/pipeline/histogram.ts"],"sourcesContent":["import type { PivotChartSpecPipeline, VChartSpecPipeline } from 'src/types'\nimport {\n label,\n xLinear,\n backgroundColor,\n discreteLegend,\n color,\n pivotAdapter,\n initPivot,\n datasetPivot,\n pivotIndicators,\n pivotDiscreteLegend,\n pivotGridStyle,\n pivotColumnDimensions,\n pivotRowDimensions,\n barStyle,\n annotationPointOfHistogram,\n annotationVerticalLine,\n annotationHorizontalLine,\n annotationAreaBand,\n datasetHistogram,\n progressive,\n colorAdapter,\n linearColor,\n colorLegend,\n colorBarStyleFill,\n pivotColorLegend,\n initHistogram,\n yLinear,\n histogramVerticalCrosshairRect,\n tooltipHistogram,\n kdeRegressionLine,\n ecdfRegressionLine,\n pivotTitle,\n pivotAxisStyle,\n dimensionLinkage,\n} from '../pipes'\n\nconst histogram: VChartSpecPipeline = [\n initHistogram,\n colorAdapter(color, linearColor),\n backgroundColor,\n datasetHistogram,\n progressive,\n xLinear,\n yLinear,\n label,\n tooltipHistogram,\n colorAdapter(discreteLegend, colorLegend),\n histogramVerticalCrosshairRect,\n colorBarStyleFill(barStyle),\n annotationPointOfHistogram,\n annotationVerticalLine,\n annotationHorizontalLine,\n annotationAreaBand,\n kdeRegressionLine,\n ecdfRegressionLine,\n]\n\nconst pivotHistogram: PivotChartSpecPipeline = [\n initPivot,\n pivotGridStyle,\n datasetPivot,\n pivotIndicators([\n initHistogram,\n colorAdapter(color, linearColor),\n backgroundColor,\n datasetHistogram,\n progressive,\n xLinear,\n pivotAxisStyle(yLinear),\n label,\n tooltipHistogram,\n colorBarStyleFill(barStyle),\n histogramVerticalCrosshairRect,\n annotationPointOfHistogram,\n annotationVerticalLine,\n annotationHorizontalLine,\n annotationAreaBand,\n kdeRegressionLine,\n ecdfRegressionLine,\n ]),\n pivotRowDimensions,\n pivotColumnDimensions,\n pivotTitle,\n colorAdapter(pivotDiscreteLegend, pivotColorLegend),\n dimensionLinkage,\n]\n\nexport const histogramSpecPipeline = [pivotAdapter(histogram, pivotHistogram)]\n"],"names":["histogram","initHistogram","colorAdapter","color","linearColor","backgroundColor","datasetHistogram","progressive","xLinear","yLinear","label","tooltipHistogram","discreteLegend","colorLegend","histogramVerticalCrosshairRect","colorBarStyleFill","barStyle","annotationPointOfHistogram","annotationVerticalLine","annotationHorizontalLine","annotationAreaBand","kdeRegressionLine","ecdfRegressionLine","pivotHistogram","initPivot","pivotGridStyle","datasetPivot","pivotIndicators","pivotAxisStyle","pivotRowDimensions","pivotColumnDimensions","pivotTitle","pivotDiscreteLegend","pivotColorLegend","dimensionLinkage","histogramSpecPipeline","pivotAdapter"],"mappings":";AAsCA,MAAMA,YAAgC;IACpCC;IACAC,aAAaC,OAAOC;IACpBC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAT,aAAaU,gBAAgBC;IAC7BC;IACAC,kBAAkBC;IAClBC;IACAC;IACAC;IACAC;IACAC;IACAC;CACD;AAED,MAAMC,iBAAyC;IAC7CC;IACAC;IACAC;IACAC,gBAAgB;QACd1B;QACAC,aAAaC,OAAOC;QACpBC;QACAC;QACAC;QACAC;QACAoB,eAAenB;QACfC;QACAC;QACAI,kBAAkBC;QAClBF;QACAG;QACAC;QACAC;QACAC;QACAC;QACAC;KACD;IACDO;IACAC;IACAC;IACA7B,aAAa8B,qBAAqBC;IAClCC;CACD;AAEM,MAAMC,wBAAwB;IAACC,aAAapC,WAAWuB;CAAgB"}
@@ -1,78 +1,5 @@
1
- import { selector } from "../../../../../dataSelector/index.js";
2
- import { isSubset } from "./utils.js";
3
- import { ANNOTATION_Z_INDEX } from "../../../../utils/constant.js";
4
- import { isBarLikeChart } from "../../../../utils/chatType.js";
5
- const annotationPoint_annotationPoint = (spec, context)=>{
6
- const { advancedVSeed, vseed } = context;
7
- const { annotation, config } = advancedVSeed;
8
- if (!annotation || !annotation.annotationPoint) return spec;
9
- const theme = config?.[vseed.chartType]?.annotation?.annotationPoint;
10
- const { annotationPoint } = annotation;
11
- const annotationPointList = Array.isArray(annotationPoint) ? annotationPoint : [
12
- annotationPoint
13
- ];
14
- const isHorizontalBar = isBarLikeChart(advancedVSeed);
15
- const defaultStyle = isHorizontalBar ? {
16
- textAlign: 'right',
17
- textBaseline: 'middle'
18
- } : {
19
- textAlign: 'center',
20
- textBaseline: 'top'
21
- };
22
- const markPoint = annotationPointList.flatMap((annotationPoint)=>{
23
- const { selector: selectorPoint, text = '', textColor = theme?.textColor ?? '#ffffff', textFontSize = theme?.textFontSize ?? 12, textFontWeight = theme?.textFontWeight ?? 400, textAlign = defaultStyle.textAlign, textBaseline = defaultStyle.textBaseline, textBackgroundBorderColor = theme?.textBackgroundBorderColor, textBackgroundBorderRadius = theme?.textBackgroundBorderRadius ?? 4, textBackgroundBorderWidth = theme?.textBackgroundBorderWidth ?? 1, textBackgroundColor = theme?.textBackgroundColor ?? '#212121', textBackgroundPadding = theme?.textBackgroundPadding ?? 2, textBackgroundVisible = theme?.textBackgroundVisible ?? true, offsetX = theme?.offsetX ?? 0, offsetY = theme?.offsetY ?? 0 } = annotationPoint;
24
- const dataset = advancedVSeed.dataset.flat();
25
- const selectedData = selectorPoint ? dataset.filter((datum)=>selector(datum, selectorPoint)) : [];
26
- const dx = -10 - (isHorizontalBar ? textFontSize : 0);
27
- const dy = isHorizontalBar ? 0 : textFontSize;
28
- return selectedData.map((datum)=>({
29
- zIndex: ANNOTATION_Z_INDEX,
30
- regionRelative: true,
31
- coordinate: (data)=>data.find((item)=>isSubset(datum, item)),
32
- itemLine: {
33
- visible: false
34
- },
35
- itemContent: {
36
- offsetY,
37
- offsetX,
38
- confine: true,
39
- text: {
40
- text: text,
41
- style: {
42
- opacity: 0.95,
43
- visible: true,
44
- textAlign: textAlign,
45
- textBaseline: textBaseline,
46
- fill: textColor,
47
- stroke: textBackgroundColor,
48
- lineWidth: 1,
49
- fontSize: textFontSize,
50
- fontWeight: textFontWeight,
51
- dx,
52
- dy
53
- },
54
- labelBackground: {
55
- visible: textBackgroundVisible,
56
- padding: textBackgroundPadding,
57
- style: {
58
- opacity: 0.95,
59
- cornerRadius: textBackgroundBorderRadius ?? 4,
60
- fill: textBackgroundColor,
61
- stroke: textBackgroundBorderColor,
62
- lineWidth: textBackgroundBorderWidth,
63
- dx,
64
- dy
65
- }
66
- }
67
- }
68
- }
69
- }));
70
- });
71
- return {
72
- ...spec,
73
- markPoint
74
- };
75
- };
76
- export { annotationPoint_annotationPoint as annotationPoint };
1
+ import { generateAnnotationPointPipe } from "./annotationPointCommon.js";
2
+ const annotationPoint = generateAnnotationPointPipe({});
3
+ export { annotationPoint };
77
4
 
78
5
  //# sourceMappingURL=annotationPoint.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationPoint.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/annotationPoint.ts"],"sourcesContent":["import type { ILineChartSpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { Datum, VChartSpecPipe, VSeed } from 'src/types'\nimport { isSubset } from './utils'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport { isBarLikeChart } from 'src/pipeline/utils/chatType'\n\nexport const annotationPoint: VChartSpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const { annotation, config } = advancedVSeed\n\n if (!annotation || !annotation.annotationPoint) {\n return spec\n }\n\n const theme = config?.[vseed.chartType as 'column']?.annotation?.annotationPoint\n const { annotationPoint } = annotation\n const annotationPointList = Array.isArray(annotationPoint) ? annotationPoint : [annotationPoint]\n const isHorizontalBar = isBarLikeChart(advancedVSeed as VSeed)\n const defaultStyle = isHorizontalBar\n ? {\n textAlign: 'right',\n textBaseline: 'middle',\n }\n : {\n textAlign: 'center',\n textBaseline: 'top',\n }\n\n const markPoint = annotationPointList.flatMap((annotationPoint) => {\n const {\n selector: selectorPoint,\n text = '',\n textColor = theme?.textColor ?? '#ffffff',\n textFontSize = theme?.textFontSize ?? 12,\n textFontWeight = theme?.textFontWeight ?? 400,\n textAlign = defaultStyle.textAlign,\n textBaseline = defaultStyle.textBaseline,\n textBackgroundBorderColor = theme?.textBackgroundBorderColor,\n textBackgroundBorderRadius = theme?.textBackgroundBorderRadius ?? 4,\n textBackgroundBorderWidth = theme?.textBackgroundBorderWidth ?? 1,\n textBackgroundColor = theme?.textBackgroundColor ?? '#212121',\n textBackgroundPadding = theme?.textBackgroundPadding ?? 2,\n textBackgroundVisible = theme?.textBackgroundVisible ?? true,\n offsetX = theme?.offsetX ?? 0,\n offsetY = theme?.offsetY ?? 0,\n } = annotationPoint\n\n const dataset = advancedVSeed.dataset.flat()\n const selectedData = selectorPoint ? dataset.filter((datum) => selector(datum, selectorPoint)) : []\n const dx = -10 - (isHorizontalBar ? (textFontSize as number) : 0) // 由于vchart tag实现问题,需要设置这个强制偏移量\n const dy = isHorizontalBar ? 0 : (textFontSize as number)\n\n return selectedData.map((datum) => {\n return {\n zIndex: ANNOTATION_Z_INDEX,\n regionRelative: true,\n coordinate: (data: Datum[]) => {\n return data.find((item) => isSubset(datum, item))\n },\n\n itemLine: {\n visible: false,\n },\n itemContent: {\n offsetY,\n offsetX,\n confine: true,\n text: {\n text: text,\n style: {\n opacity: 0.95,\n visible: true,\n textAlign: textAlign,\n textBaseline: textBaseline,\n fill: textColor,\n stroke: textBackgroundColor,\n lineWidth: 1,\n fontSize: textFontSize,\n fontWeight: textFontWeight,\n dx,\n dy,\n },\n labelBackground: {\n visible: textBackgroundVisible,\n padding: textBackgroundPadding,\n style: {\n opacity: 0.95,\n cornerRadius: textBackgroundBorderRadius ?? 4,\n fill: textBackgroundColor,\n stroke: textBackgroundBorderColor,\n lineWidth: textBackgroundBorderWidth,\n dx,\n dy,\n },\n },\n },\n },\n }\n })\n }) as ILineChartSpec['markPoint']\n\n return {\n ...spec,\n markPoint,\n }\n}\n"],"names":["annotationPoint","spec","context","advancedVSeed","vseed","annotation","config","theme","annotationPointList","Array","isHorizontalBar","isBarLikeChart","defaultStyle","markPoint","selectorPoint","text","textColor","textFontSize","textFontWeight","textAlign","textBaseline","textBackgroundBorderColor","textBackgroundBorderRadius","textBackgroundBorderWidth","textBackgroundColor","textBackgroundPadding","textBackgroundVisible","offsetX","offsetY","dataset","selectedData","datum","selector","dx","dy","ANNOTATION_Z_INDEX","data","item","isSubset"],"mappings":";;;;AAOO,MAAMA,kCAAkC,CAACC,MAAMC;IACpD,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IACjC,MAAM,EAAEG,UAAU,EAAEC,MAAM,EAAE,GAAGH;IAE/B,IAAI,CAACE,cAAc,CAACA,WAAW,eAAe,EAC5C,OAAOJ;IAGT,MAAMM,QAAQD,QAAQ,CAACF,MAAM,SAAS,CAAa,EAAE,YAAY;IACjE,MAAM,EAAEJ,eAAe,EAAE,GAAGK;IAC5B,MAAMG,sBAAsBC,MAAM,OAAO,CAACT,mBAAmBA,kBAAkB;QAACA;KAAgB;IAChG,MAAMU,kBAAkBC,eAAeR;IACvC,MAAMS,eAAeF,kBACjB;QACE,WAAW;QACX,cAAc;IAChB,IACA;QACE,WAAW;QACX,c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AASR;4BACT,SAASD;4BACT,OAAO;gCACL,SAAS;gCACT,cAAcH,8BAA8B;gCAC5C,MAAME;gCACN,QAAQH;gCACR,WAAWE;gCACXU;gCACAC;4BACF;wBACF;oBACF;gBACF;YACF;IAEJ;IAEA,OAAO;QACL,GAAGjC,IAAI;QACPY;IACF;AACF"}
1
+ {"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationPoint.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/annotationPoint.ts"],"sourcesContent":["import type { VChartSpecPipe } from 'src/types'\nimport { generateAnnotationPointPipe } from './annotationPointCommon'\n\nexport const annotationPoint: VChartSpecPipe = generateAnnotationPointPipe({})\n"],"names":["annotationPoint","generateAnnotationPointPipe"],"mappings":";AAGO,MAAMA,kBAAkCC,4BAA4B,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { ISpec, IMarkPointSpec } from '@visactor/vchart';
2
+ import type { Datum, Selector, Selectors, SpecPipelineContext, VChartSpecPipe } from '../../../../../types';
3
+ export declare const generateAnnotationPointPipe: (options: {
4
+ findSelectedDatas?: (dataset: Datum[], selector: Selector | Selectors | undefined | null, spec: ISpec, context: SpecPipelineContext) => Datum[];
5
+ generateMarkPoint?: (datum: Datum, spec: ISpec, context: SpecPipelineContext) => IMarkPointSpec[] | undefined;
6
+ }) => VChartSpecPipe;
@@ -0,0 +1,95 @@
1
+ import { selector } from "../../../../../dataSelector/index.js";
2
+ import { isSubset } from "./utils.js";
3
+ import { ANNOTATION_Z_INDEX } from "../../../../utils/constant.js";
4
+ import { isBarLikeChart } from "../../../../utils/chatType.js";
5
+ const generateAnnotationPointPipe = (options)=>{
6
+ const findSelectedDatas = options.findSelectedDatas ?? ((dataset, s)=>dataset.filter((datum)=>selector(datum, s)));
7
+ const generateMarkPoint = options.generateMarkPoint ?? ((datum)=>[
8
+ {
9
+ coordinate: (data)=>data.find((item)=>isSubset(datum, item))
10
+ }
11
+ ]);
12
+ return (spec, context)=>{
13
+ const { advancedVSeed, vseed } = context;
14
+ const { annotation, config } = advancedVSeed;
15
+ if (!annotation || !annotation.annotationPoint) return spec;
16
+ const theme = config?.[vseed.chartType]?.annotation?.annotationPoint;
17
+ const { annotationPoint } = annotation;
18
+ const annotationPointList = Array.isArray(annotationPoint) ? annotationPoint : [
19
+ annotationPoint
20
+ ];
21
+ const isHorizontalBar = isBarLikeChart(advancedVSeed);
22
+ const defaultStyle = isHorizontalBar ? {
23
+ textAlign: 'right',
24
+ textBaseline: 'middle'
25
+ } : {
26
+ textAlign: 'center',
27
+ textBaseline: 'top'
28
+ };
29
+ const markPoint = annotationPointList.flatMap((annotationPoint)=>{
30
+ const { selector: selectorPoint, text = '', textColor = theme?.textColor ?? '#ffffff', textFontSize = theme?.textFontSize ?? 12, textFontWeight = theme?.textFontWeight ?? 400, textAlign = defaultStyle.textAlign, textBaseline = defaultStyle.textBaseline, textBackgroundBorderColor = theme?.textBackgroundBorderColor, textBackgroundBorderRadius = theme?.textBackgroundBorderRadius ?? 4, textBackgroundBorderWidth = theme?.textBackgroundBorderWidth ?? 1, textBackgroundColor = theme?.textBackgroundColor ?? '#212121', textBackgroundPadding = theme?.textBackgroundPadding ?? 2, textBackgroundVisible = theme?.textBackgroundVisible ?? true, offsetX = theme?.offsetX ?? 0, offsetY = theme?.offsetY ?? 0 } = annotationPoint;
31
+ const dataset = advancedVSeed.dataset.flat();
32
+ const selectedData = selectorPoint ? findSelectedDatas(dataset, selectorPoint, spec, context) : [];
33
+ const dx = -10 - (isHorizontalBar ? textFontSize : 0);
34
+ const dy = isHorizontalBar ? 0 : textFontSize;
35
+ const markPointStyle = {
36
+ zIndex: ANNOTATION_Z_INDEX,
37
+ regionRelative: true,
38
+ itemLine: {
39
+ visible: false
40
+ },
41
+ itemContent: {
42
+ offsetY,
43
+ offsetX,
44
+ confine: true,
45
+ text: {
46
+ text: text,
47
+ style: {
48
+ opacity: 0.95,
49
+ visible: true,
50
+ textAlign: textAlign,
51
+ textBaseline: textBaseline,
52
+ fill: textColor,
53
+ stroke: textBackgroundColor,
54
+ lineWidth: 1,
55
+ fontSize: textFontSize,
56
+ fontWeight: textFontWeight,
57
+ dx,
58
+ dy
59
+ },
60
+ labelBackground: {
61
+ visible: textBackgroundVisible,
62
+ padding: textBackgroundPadding,
63
+ style: {
64
+ opacity: 0.95,
65
+ cornerRadius: textBackgroundBorderRadius ?? 4,
66
+ fill: textBackgroundColor,
67
+ stroke: textBackgroundBorderColor,
68
+ lineWidth: textBackgroundBorderWidth,
69
+ dx,
70
+ dy
71
+ }
72
+ }
73
+ }
74
+ }
75
+ };
76
+ return selectedData.reduce((res, datum)=>{
77
+ const marks = generateMarkPoint(datum, spec, context);
78
+ if (marks && marks.length) marks.forEach((mark)=>{
79
+ res.push({
80
+ ...markPointStyle,
81
+ ...mark
82
+ });
83
+ });
84
+ return res;
85
+ }, []);
86
+ });
87
+ return {
88
+ ...spec,
89
+ markPoint
90
+ };
91
+ };
92
+ };
93
+ export { generateAnnotationPointPipe };
94
+
95
+ //# sourceMappingURL=annotationPointCommon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationPointCommon.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/annotationPointCommon.ts"],"sourcesContent":["import type { ISpec, IMarkPointSpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { Datum, Selector, Selectors, SpecPipelineContext, VChartSpecPipe, VSeed } from 'src/types'\nimport { isSubset } from './utils'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport { isBarLikeChart } from 'src/pipeline/utils/chatType'\n\nexport const generateAnnotationPointPipe = (options: {\n findSelectedDatas?: (\n dataset: Datum[],\n selector: Selector | Selectors | undefined | null,\n spec: ISpec,\n context: SpecPipelineContext,\n ) => Datum[]\n generateMarkPoint?: (datum: Datum, spec: ISpec, context: SpecPipelineContext) => IMarkPointSpec[] | undefined\n}) => {\n const findSelectedDatas = options.findSelectedDatas ?? ((dataset, s) => dataset.filter((datum) => selector(datum, s)))\n const generateMarkPoint =\n options.generateMarkPoint ??\n ((datum: Datum) => {\n return [\n {\n coordinate: (data: Datum[]) => {\n return data.find((item) => isSubset(datum, item))\n },\n },\n ]\n })\n\n return ((spec: ISpec, context: SpecPipelineContext) => {\n const { advancedVSeed, vseed } = context\n const { annotation, config } = advancedVSeed\n\n if (!annotation || !annotation.annotationPoint) {\n return spec\n }\n\n const theme = config?.[vseed.chartType as 'column']?.annotation?.annotationPoint\n const { annotationPoint } = annotation\n const annotationPointList = Array.isArray(annotationPoint) ? annotationPoint : [annotationPoint]\n const isHorizontalBar = isBarLikeChart(advancedVSeed as VSeed)\n const defaultStyle = isHorizontalBar\n ? {\n textAlign: 'right',\n textBaseline: 'middle',\n }\n : {\n textAlign: 'center',\n textBaseline: 'top',\n }\n\n const markPoint = annotationPointList.flatMap((annotationPoint) => {\n const {\n selector: selectorPoint,\n text = '',\n textColor = theme?.textColor ?? '#ffffff',\n textFontSize = theme?.textFontSize ?? 12,\n textFontWeight = theme?.textFontWeight ?? 400,\n textAlign = defaultStyle.textAlign,\n textBaseline = defaultStyle.textBaseline,\n textBackgroundBorderColor = theme?.textBackgroundBorderColor,\n textBackgroundBorderRadius = theme?.textBackgroundBorderRadius ?? 4,\n textBackgroundBorderWidth = theme?.textBackgroundBorderWidth ?? 1,\n textBackgroundColor = theme?.textBackgroundColor ?? '#212121',\n textBackgroundPadding = theme?.textBackgroundPadding ?? 2,\n textBackgroundVisible = theme?.textBackgroundVisible ?? true,\n offsetX = theme?.offsetX ?? 0,\n offsetY = theme?.offsetY ?? 0,\n } = annotationPoint\n\n const dataset = advancedVSeed.dataset.flat()\n const selectedData = selectorPoint ? findSelectedDatas(dataset, selectorPoint, spec, context) : []\n const dx = -10 - (isHorizontalBar ? (textFontSize as number) : 0) // 由于vchart tag实现问题,需要设置这个强制偏移量\n const dy = isHorizontalBar ? 0 : (textFontSize as number)\n const markPointStyle = {\n zIndex: ANNOTATION_Z_INDEX,\n regionRelative: true,\n itemLine: {\n visible: false,\n },\n itemContent: {\n offsetY,\n offsetX,\n confine: true,\n text: {\n text: text,\n style: {\n opacity: 0.95,\n visible: true,\n textAlign: textAlign,\n textBaseline: textBaseline,\n fill: textColor,\n stroke: textBackgroundColor,\n lineWidth: 1,\n fontSize: textFontSize,\n fontWeight: textFontWeight,\n dx,\n dy,\n },\n labelBackground: {\n visible: textBackgroundVisible,\n padding: textBackgroundPadding,\n style: {\n opacity: 0.95,\n cornerRadius: textBackgroundBorderRadius ?? 4,\n fill: textBackgroundColor,\n stroke: textBackgroundBorderColor,\n lineWidth: textBackgroundBorderWidth,\n dx,\n dy,\n },\n },\n },\n },\n } as Partial<IMarkPointSpec>\n\n return selectedData.reduce((res: IMarkPointSpec[], datum) => {\n const marks = generateMarkPoint(datum, spec, context)\n\n if (marks && marks.length) {\n marks.forEach((mark) => {\n res.push({\n ...markPointStyle,\n ...mark,\n } as IMarkPointSpec)\n })\n }\n\n return res\n }, [])\n }) as unknown as IMarkPointSpec[]\n\n return {\n ...spec,\n markPoint,\n } as ISpec\n }) as VChartSpecPipe\n}\n"],"names":["generateAnnotationPointPipe","options","findSelectedDatas","dataset","s","datum","selector","generateMarkPoint","data","item","isSubset","spec","context","advancedVSeed","vseed","annotation","config","theme","annotationPoint","annotationPointList","Array","isHorizontalBar","isBarLikeChart","defaultStyle","markPoint","selectorPoint","text","textColor","textFontSize","textFontWeight","textAlign","textBaseline","textBackgroundBorderColor","textBackgroundBorderRadius","textBackgroundBorderWidth","textBackgroundColor","textBackgroundPadding","textBackgroundVisible","offsetX","offsetY","selectedData","dx","dy","markPointStyle","ANNOTATION_Z_INDEX","res","marks","mark"],"mappings":";;;;AAOO,MAAMA,8BAA8B,CAACC;IAS1C,MAAMC,oBAAoBD,QAAQ,iBAAiB,IAAM,EAAAE,SAASC,IAAMD,QAAQ,MAAM,CAAC,CAACE,QAAUC,SAASD,OAAOD,GAAE;IACpH,MAAMG,oBACJN,QAAQ,iB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AM2B,eAAef,gBAAgBvB,kBAAkBC,SAASsB,eAAed,MAAMC,WAAW,EAAE;YAClG,MAAM6B,KAAK,MAAOpB,CAAAA,kBAAmBO,eAA0B;YAC/D,MAAMc,KAAKrB,kBAAkB,IAAKO;YAClC,MAAMe,iBAAiB;gBACrB,QAAQC;gBACR,gBAAgB;gBAChB,UAAU;oBACR,SAAS;gBACX;gBACA,aAAa;oBACXL;oBACAD;oBACA,SAAS;oBACT,MAAM;wBACJ,MAAMZ;wBACN,OAAO;4BACL,SAAS;4BACT,SAAS;4BACT,WAAWI;4BACX,cAAcC;4BACd,MAAMJ;4BACN,QAAQQ;4BACR,WAAW;4BACX,UAAUP;4BACV,YAAYC;4BACZY;4BACAC;wBACF;wBACA,iBAAiB;4BACf,SAASL;4BACT,SAASD;4BACT,OAAO;gCACL,SAAS;gCACT,cAAcH,8BAA8B;gCAC5C,MAAME;gCACN,QAAQH;gCACR,WAAWE;gCACXO;gCACAC;4BACF;wBACF;oBACF;gBACF;YACF;YAEA,OAAOF,aAAa,MAAM,CAAC,CAACK,KAAuBxC;gBACjD,MAAMyC,QAAQvC,kBAAkBF,OAAOM,MAAMC;gBAE7C,IAAIkC,SAASA,MAAM,MAAM,EACvBA,MAAM,OAAO,CAAC,CAACC;oBACbF,IAAI,IAAI,CAAC;wBACP,GAAGF,cAAc;wBACjB,GAAGI,IAAI;oBACT;gBACF;gBAGF,OAAOF;YACT,GAAG,EAAE;QACP;QAEA,OAAO;YACL,GAAGlC,IAAI;YACPa;QACF;IACF;AACF"}
@@ -1,94 +1,26 @@
1
1
  import { selector } from "../../../../../dataSelector/index.js";
2
2
  import { isSubset } from "./utils.js";
3
- import { ANNOTATION_Z_INDEX } from "../../../../utils/constant.js";
4
- import { isBarLikeChart } from "../../../../utils/chatType.js";
5
3
  import { findAllMeasures } from "../../../../utils/index.js";
6
4
  import { MeasureId } from "../../../../../dataReshape/constant.js";
7
5
  import { pickWithout } from "@visactor/vutils";
8
- const annotationPointOfDualAxis = (spec, context)=>{
9
- const { advancedVSeed, vseed } = context;
10
- const { annotation, config } = advancedVSeed;
11
- if (!annotation || !annotation.annotationPoint) return spec;
12
- const theme = config?.[vseed.chartType]?.annotation?.annotationPoint;
13
- const { annotationPoint } = annotation;
14
- const annotationPointList = Array.isArray(annotationPoint) ? annotationPoint : [
15
- annotationPoint
16
- ];
17
- const isHorizontalBar = isBarLikeChart(advancedVSeed);
18
- const defaultStyle = isHorizontalBar ? {
19
- textAlign: 'right',
20
- textBaseline: 'middle'
21
- } : {
22
- textAlign: 'center',
23
- textBaseline: 'top'
24
- };
25
- const allMeasureIds = findAllMeasures(advancedVSeed.reshapeMeasures ?? advancedVSeed.measures).map((m)=>m.id);
26
- const markPoint = annotationPointList.flatMap((annotationPoint)=>{
27
- const { selector: selectorPoint, text = '', textColor = theme?.textColor ?? '#ffffff', textFontSize = theme?.textFontSize ?? 12, textFontWeight = theme?.textFontWeight ?? 400, textAlign = defaultStyle.textAlign, textBaseline = defaultStyle.textBaseline, textBackgroundBorderColor = theme?.textBackgroundBorderColor, textBackgroundBorderRadius = theme?.textBackgroundBorderRadius ?? 4, textBackgroundBorderWidth = theme?.textBackgroundBorderWidth ?? 1, textBackgroundColor = theme?.textBackgroundColor ?? '#212121', textBackgroundPadding = theme?.textBackgroundPadding ?? 2, textBackgroundVisible = theme?.textBackgroundVisible ?? true, offsetX = theme?.offsetX ?? 0, offsetY = theme?.offsetY ?? 0 } = annotationPoint;
28
- const dataset = advancedVSeed.dataset.flat();
29
- const selectedData = selectorPoint ? dataset.reduce((res, d)=>{
6
+ import { generateAnnotationPointPipe } from "./annotationPointCommon.js";
7
+ const annotationPointOfDualAxis = generateAnnotationPointPipe({
8
+ findSelectedDatas: (dataset, s, spec, context)=>dataset.reduce((res, d)=>{
9
+ const { advancedVSeed } = context;
10
+ const allMeasureIds = findAllMeasures(advancedVSeed.reshapeMeasures ?? advancedVSeed.measures).map((m)=>m.id);
30
11
  const pickedDatum = pickWithout(d, allMeasureIds.filter((id)=>id !== d[MeasureId]));
31
- if (selector(pickedDatum, selectorPoint)) res.push(pickedDatum);
12
+ if (selector(pickedDatum, s)) res.push(pickedDatum);
32
13
  return res;
33
- }, []) : [];
34
- const dx = -10 - (isHorizontalBar ? textFontSize : 0);
35
- const dy = isHorizontalBar ? 0 : textFontSize;
36
- const baseConfig = {
37
- zIndex: ANNOTATION_Z_INDEX,
38
- itemLine: {
39
- visible: false
40
- },
41
- itemContent: {
42
- offsetY,
43
- offsetX,
44
- confine: true,
45
- text: {
46
- text: text,
47
- style: {
48
- opacity: 0.95,
49
- visible: true,
50
- textAlign: textAlign,
51
- textBaseline: textBaseline,
52
- fill: textColor,
53
- stroke: textBackgroundColor,
54
- lineWidth: 1,
55
- fontSize: textFontSize,
56
- fontWeight: textFontWeight,
57
- dx,
58
- dy
59
- },
60
- labelBackground: {
61
- visible: textBackgroundVisible,
62
- padding: textBackgroundPadding,
63
- style: {
64
- opacity: 0.95,
65
- cornerRadius: textBackgroundBorderRadius ?? 4,
66
- fill: textBackgroundColor,
67
- stroke: textBackgroundBorderColor,
68
- lineWidth: textBackgroundBorderWidth,
69
- dx,
70
- dy
71
- }
72
- }
73
- }
74
- }
75
- };
76
- return spec.series?.reduce((res, s, index)=>{
77
- selectedData.forEach((datum)=>{
78
- res.push({
79
- ...baseConfig,
80
- relativeSeriesIndex: index,
81
- coordinate: (data)=>data.find((item)=>isSubset(datum, item, allMeasureIds.filter((id)=>id !== item[MeasureId])))
82
- });
83
- });
84
- return res;
85
- }, []);
86
- });
87
- return {
88
- ...spec,
89
- markPoint
90
- };
91
- };
14
+ }, []),
15
+ generateMarkPoint: (datum, spec, context)=>{
16
+ const { advancedVSeed } = context;
17
+ const allMeasureIds = findAllMeasures(advancedVSeed.reshapeMeasures ?? advancedVSeed.measures).map((m)=>m.id);
18
+ return spec.series?.map((s, index)=>({
19
+ relativeSeriesIndex: index,
20
+ coordinate: (data)=>data.find((item)=>isSubset(datum, item, allMeasureIds.filter((id)=>id !== item[MeasureId])))
21
+ }));
22
+ }
23
+ });
92
24
  export { annotationPointOfDualAxis };
93
25
 
94
26
  //# sourceMappingURL=annotationPointOfDualAxis.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationPointOfDualAxis.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/annotationPointOfDualAxis.ts"],"sourcesContent":["import type { ILineChartSpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { Datum, VChartSpecPipe, VSeed } from 'src/types'\nimport { isSubset } from './utils'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport { isBarLikeChart } from 'src/pipeline/utils/chatType'\nimport { findAllMeasures } from 'src/pipeline/utils'\nimport { MeasureId } from 'src/dataReshape/constant'\nimport { pickWithout } from '@visactor/vutils'\n\nexport const annotationPointOfDualAxis: VChartSpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const { annotation, config } = advancedVSeed\n\n if (!annotation || !annotation.annotationPoint) {\n return spec\n }\n\n const theme = config?.[vseed.chartType as 'column']?.annotation?.annotationPoint\n const { annotationPoint } = annotation\n const annotationPointList = Array.isArray(annotationPoint) ? annotationPoint : [annotationPoint]\n const isHorizontalBar = isBarLikeChart(advancedVSeed as VSeed)\n const defaultStyle = isHorizontalBar\n ? {\n textAlign: 'right',\n textBaseline: 'middle',\n }\n : {\n textAlign: 'center',\n textBaseline: 'top',\n }\n const allMeasureIds = findAllMeasures(advancedVSeed.reshapeMeasures ?? advancedVSeed.measures).map((m) => m.id)\n\n const markPoint = annotationPointList.flatMap((annotationPoint) => {\n const {\n selector: selectorPoint,\n text = '',\n textColor = theme?.textColor ?? '#ffffff',\n textFontSize = theme?.textFontSize ?? 12,\n textFontWeight = theme?.textFontWeight ?? 400,\n textAlign = defaultStyle.textAlign,\n textBaseline = defaultStyle.textBaseline,\n textBackgroundBorderColor = theme?.textBackgroundBorderColor,\n textBackgroundBorderRadius = theme?.textBackgroundBorderRadius ?? 4,\n textBackgroundBorderWidth = theme?.textBackgroundBorderWidth ?? 1,\n textBackgroundColor = theme?.textBackgroundColor ?? '#212121',\n textBackgroundPadding = theme?.textBackgroundPadding ?? 2,\n textBackgroundVisible = theme?.textBackgroundVisible ?? true,\n offsetX = theme?.offsetX ?? 0,\n offsetY = theme?.offsetY ?? 0,\n } = annotationPoint\n\n const dataset = advancedVSeed.dataset.flat()\n const selectedData = selectorPoint\n ? dataset.reduce((res: Datum[], d: Datum) => {\n const pickedDatum = pickWithout(\n d,\n allMeasureIds.filter((id) => id !== d[MeasureId]),\n )\n\n if (selector(pickedDatum, selectorPoint)) {\n res.push(pickedDatum)\n }\n\n return res\n }, [])\n : []\n\n const dx = -10 - (isHorizontalBar ? (textFontSize as number) : 0) // 由于vchart tag实现问题,需要设置这个强制偏移量\n const dy = isHorizontalBar ? 0 : (textFontSize as number)\n const baseConfig = {\n zIndex: ANNOTATION_Z_INDEX,\n itemLine: {\n visible: false,\n },\n itemContent: {\n offsetY,\n offsetX,\n confine: true,\n text: {\n text: text,\n style: {\n opacity: 0.95,\n visible: true,\n textAlign: textAlign,\n textBaseline: textBaseline,\n fill: textColor,\n stroke: textBackgroundColor,\n lineWidth: 1,\n fontSize: textFontSize,\n fontWeight: textFontWeight,\n dx,\n dy,\n },\n labelBackground: {\n visible: textBackgroundVisible,\n padding: textBackgroundPadding,\n style: {\n opacity: 0.95,\n cornerRadius: textBackgroundBorderRadius ?? 4,\n fill: textBackgroundColor,\n stroke: textBackgroundBorderColor,\n lineWidth: textBackgroundBorderWidth,\n dx,\n dy,\n },\n },\n },\n },\n }\n\n return spec.series?.reduce((res: any[], s: any, index: number) => {\n selectedData.forEach((datum: Datum) => {\n res.push({\n ...baseConfig,\n relativeSeriesIndex: index,\n coordinate: (data: Datum[]) => {\n return data.find((item) => {\n return isSubset(\n datum,\n item,\n allMeasureIds.filter((id) => id !== item[MeasureId]),\n )\n })\n },\n })\n })\n\n return res\n }, [] as any[])\n }) as ILineChartSpec['markPoint']\n\n return {\n ...spec,\n markPoint,\n }\n}\n"],"names":["annotationPointOfDualAxis","spec","context","advancedVSeed","vseed","annotation","config","theme","annotationPoint","annotationPointList","Array","isHorizontalBar","isBarLikeChart","defaultStyle","allMeasureIds","findAllMeasures","m","markPoint","selectorPoint","text","textColor","textFontSize","textFontWeight","textAlign","textBaseline","textBackgroundBorderColor","textBackgroundBorderRadius","textBackgroundBorderWidth","textBackgroundColor","textBackgroundPadding","textBackgroundVisible","offsetX","offsetY","dataset","selectedData","res","d","pickedDatum","pickWithout","id","MeasureId","selector","dx","dy","baseConfig","ANNOTATION_Z_INDEX","s","index","datum","data","item","isSubset"],"mappings":";;;;;;;AAUO,MAAMA,4BAA4C,CAACC,MAAMC;IAC9D,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IACjC,MAAM,EAAEG,UAAU,EAAEC,MAAM,EAAE,GAAGH;IAE/B,IAAI,CAACE,cAAc,CAACA,WAAW,eAAe,EAC5C,OAAOJ;IAGT,MAAMM,QAAQD,QAAQ,CAACF,MAAM,SAAS,CAAa,EAAE,YAAY;IACjE,MAAM,EAAEI,eAAe,EAAE,GAAGH;IAC5B,MAAMI,sBAAsBC,MAAM,OAAO,CAACF,mBAAmBA,kBAAkB;QAACA;KAAgB;IAChG,MAAMG,kBAAkBC,eAAeT;IACvC,MAAMU,eAAeF,kBACjB;QACE,WAAW;QACX,cAAc;IAChB,IACA;QACE,WAAW;QACX,cAAc;IAChB;IACJ,MAAMG,gBAAgBC,gBAAgBZ,cAAc,eAAe,IAAIA,cAAc,QAAQ,EAAE,GAAG,CAAC,CAACa,IAAMA,EAAE,EAAE;IAE9G,MAAMC,YAAYR,oBAAoB,OAAO,CAAC,CAACD;QAC7C,MAAM,EACJ,UAAUU,aAAa,EACvBC,OAAO,EAAE,EACTC,YAAYb,OAAO,aAAa,SAAS,EACzCc,eAAed,OAAO,gBAAgB,EAAE,EACxCe,iBAAiBf,OAAO,kBAAkB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O1C,KAAK,MAAM,EAAE,OAAO,CAACkC,KAAYW,GAAQC;YAC9Cb,aAAa,OAAO,CAAC,CAACc;gBACpBb,IAAI,IAAI,CAAC;oBACP,GAAGS,UAAU;oBACb,qBAAqBG;oBACrB,YAAY,CAACE,OACJA,KAAK,IAAI,CAAC,CAACC,OACTC,SACLH,OACAE,MACApC,cAAc,MAAM,CAAC,CAACyB,KAAOA,OAAOW,IAAI,CAACV,UAAU;gBAI3D;YACF;YAEA,OAAOL;QACT,GAAG,EAAE;IACP;IAEA,OAAO;QACL,GAAGlC,IAAI;QACPgB;IACF;AACF"}
1
+ {"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationPointOfDualAxis.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/annotationPointOfDualAxis.ts"],"sourcesContent":["import type { IMarkPointSpec, ISpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { Datum, SpecPipelineContext, VChartSpecPipe } from 'src/types'\nimport { isSubset } from './utils'\nimport { findAllMeasures } from 'src/pipeline/utils'\nimport { MeasureId } from 'src/dataReshape/constant'\nimport { pickWithout } from '@visactor/vutils'\nimport { generateAnnotationPointPipe } from './annotationPointCommon'\n\nexport const annotationPointOfDualAxis: VChartSpecPipe = generateAnnotationPointPipe({\n findSelectedDatas: (dataset, s, spec: ISpec, context: SpecPipelineContext) => {\n return dataset.reduce((res: Datum[], d: Datum) => {\n const { advancedVSeed } = context\n const allMeasureIds = findAllMeasures(advancedVSeed.reshapeMeasures ?? advancedVSeed.measures).map((m) => m.id)\n const pickedDatum = pickWithout(\n d,\n allMeasureIds.filter((id) => id !== d[MeasureId]),\n )\n\n if (selector(pickedDatum, s)) {\n res.push(pickedDatum)\n }\n\n return res\n }, [])\n },\n generateMarkPoint: (datum: Datum, spec: ISpec, context: SpecPipelineContext) => {\n const { advancedVSeed } = context\n const allMeasureIds = findAllMeasures(advancedVSeed.reshapeMeasures ?? advancedVSeed.measures).map((m) => m.id)\n return spec.series?.map((s: any, index: number) => {\n return {\n relativeSeriesIndex: index,\n coordinate: (data: Datum[]) => {\n return data.find((item) => {\n return isSubset(\n datum,\n item,\n allMeasureIds.filter((id) => id !== item[MeasureId]),\n )\n })\n },\n } as IMarkPointSpec\n })\n },\n})\n"],"names":["annotationPointOfDualAxis","generateAnnotationPointPipe","dataset","s","spec","context","res","d","advancedVSeed","allMeasureIds","findAllMeasures","m","pickedDatum","pickWithout","id","MeasureId","selector","datum","index","data","item","isSubset"],"mappings":";;;;;;AASO,MAAMA,4BAA4CC,4BAA4B;IACnF,mBAAmB,CAACC,SAASC,GAAGC,MAAaC,UACpCH,QAAQ,MAAM,CAAC,CAACI,KAAcC;YACnC,MAAM,EAAEC,aAAa,EAAE,GAAGH;YAC1B,MAAMI,gBAAgBC,gBAAgBF,cAAc,eAAe,IAAIA,cAAc,QAAQ,EAAE,GAAG,CAAC,CAACG,IAAMA,EAAE,EAAE;YAC9G,MAAMC,cAAcC,YAClBN,GACAE,cAAc,MAAM,CAAC,CAACK,KAAOA,OAAOP,CAAC,CAACQ,UAAU;YAGlD,IAAIC,SAASJ,aAAaT,IACxBG,IAAI,IAAI,CAACM;YAGX,OAAON;QACT,GAAG,EAAE;IAEP,mBAAmB,CAACW,OAAcb,MAAaC;QAC7C,MAAM,EAAEG,aAAa,EAAE,GAAGH;QAC1B,MAAMI,gBAAgBC,gBAAgBF,cAAc,eAAe,IAAIA,cAAc,QAAQ,EAAE,GAAG,CAAC,CAACG,IAAMA,EAAE,EAAE;QAC9G,OAAOP,KAAK,MAAM,EAAE,IAAI,CAACD,GAAQe,QACxB;gBACL,qBAAqBA;gBACrB,YAAY,CAACC,OACJA,KAAK,IAAI,CAAC,CAACC,OACTC,SACLJ,OACAG,MACAX,cAAc,MAAM,CAAC,CAACK,KAAOA,OAAOM,IAAI,CAACL,UAAU;YAI3D;IAEJ;AACF"}
@@ -0,0 +1,2 @@
1
+ import type { VChartSpecPipe } from '../../../../../types';
2
+ export declare const annotationPointOfHistogram: VChartSpecPipe;
@@ -0,0 +1,23 @@
1
+ import { isSubset } from "./utils.js";
2
+ import { generateAnnotationPointPipe } from "./annotationPointCommon.js";
3
+ const annotationPointOfHistogram = generateAnnotationPointPipe({
4
+ generateMarkPoint: (datum, spec)=>{
5
+ const histogramSpec = spec;
6
+ const xField = histogramSpec.xField;
7
+ const x2Field = histogramSpec.x2Field;
8
+ return [
9
+ {
10
+ coordinate: (data)=>{
11
+ const d = data.find((item)=>isSubset(datum, item));
12
+ return d ? {
13
+ ...d,
14
+ [xField]: (d[xField] + d[x2Field]) / 2
15
+ } : void 0;
16
+ }
17
+ }
18
+ ];
19
+ }
20
+ });
21
+ export { annotationPointOfHistogram };
22
+
23
+ //# sourceMappingURL=annotationPointOfHistogram.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationPointOfHistogram.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/annotationPointOfHistogram.ts"],"sourcesContent":["import type { IHistogramChartSpec, IMarkPointSpec } from '@visactor/vchart'\nimport type { Datum, VChartSpecPipe } from 'src/types'\nimport { isSubset } from './utils'\nimport { generateAnnotationPointPipe } from './annotationPointCommon'\n\nexport const annotationPointOfHistogram: VChartSpecPipe = generateAnnotationPointPipe({\n generateMarkPoint: (datum: Datum, spec) => {\n const histogramSpec = spec as IHistogramChartSpec\n const xField = histogramSpec.xField as string\n const x2Field = histogramSpec.x2Field as string\n\n return [\n {\n coordinate: (data: Datum[]) => {\n const d = data.find((item) => isSubset(datum, item))\n\n return d\n ? {\n ...d,\n [xField]: (d[xField] + d[x2Field]) / 2,\n }\n : undefined\n },\n } as IMarkPointSpec,\n ]\n },\n})\n"],"names":["annotationPointOfHistogram","generateAnnotationPointPipe","datum","spec","histogramSpec","xField","x2Field","data","d","item","isSubset","undefined"],"mappings":";;AAKO,MAAMA,6BAA6CC,4BAA4B;IACpF,mBAAmB,CAACC,OAAcC;QAChC,MAAMC,gBAAgBD;QACtB,MAAME,SAASD,cAAc,MAAM;QACnC,MAAME,UAAUF,cAAc,OAAO;QAErC,OAAO;YACL;gBACE,YAAY,CAACG;oBACX,MAAMC,IAAID,KAAK,IAAI,CAAC,CAACE,OAASC,SAASR,OAAOO;oBAE9C,OAAOD,IACH;wBACE,GAAGA,CAAC;wBACJ,CAACH,OAAO,EAAGG,AAAAA,CAAAA,CAAC,CAACH,OAAO,GAAGG,CAAC,CAACF,QAAO,IAAK;oBACvC,IACAK;gBACN;YACF;SACD;IACH;AACF"}