@visactor/vseed 0.1.45 → 0.1.47
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 +3 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/builder/builder/builder.d.ts +86 -14
- package/dist/esm/dataReshape/constant.d.ts +2 -2
- package/dist/esm/dataReshape/constant.js +3 -3
- package/dist/esm/dataReshape/constant.js.map +1 -1
- package/dist/esm/i18n/i18n.js +2 -2
- package/dist/esm/i18n/i18n.js.map +1 -1
- package/dist/esm/i18n/i18nData.d.ts +2 -0
- package/dist/esm/i18n/i18nData.js +41 -5
- package/dist/esm/i18n/i18nData.js.map +1 -0
- package/dist/esm/pipeline/advanced/chart/pipeline/area.js +3 -3
- package/dist/esm/pipeline/advanced/chart/pipeline/area.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/areaPercent.js +3 -3
- package/dist/esm/pipeline/advanced/chart/pipeline/areaPercent.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/bar.js +3 -3
- package/dist/esm/pipeline/advanced/chart/pipeline/bar.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/barParallel.js +3 -3
- package/dist/esm/pipeline/advanced/chart/pipeline/barParallel.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/barPercent.js +3 -3
- package/dist/esm/pipeline/advanced/chart/pipeline/barPercent.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/boxplot.js +3 -3
- package/dist/esm/pipeline/advanced/chart/pipeline/boxplot.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/column.js +3 -3
- package/dist/esm/pipeline/advanced/chart/pipeline/column.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/columnParallel.js +3 -3
- package/dist/esm/pipeline/advanced/chart/pipeline/columnParallel.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/columnPercent.js +3 -3
- package/dist/esm/pipeline/advanced/chart/pipeline/columnPercent.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/donut.js +3 -3
- package/dist/esm/pipeline/advanced/chart/pipeline/donut.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/dualAxis.js +3 -3
- package/dist/esm/pipeline/advanced/chart/pipeline/dualAxis.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/funnel.js +3 -3
- package/dist/esm/pipeline/advanced/chart/pipeline/funnel.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/heatmap.js +3 -3
- package/dist/esm/pipeline/advanced/chart/pipeline/heatmap.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/histogram.js +3 -3
- package/dist/esm/pipeline/advanced/chart/pipeline/histogram.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/line.js +3 -3
- package/dist/esm/pipeline/advanced/chart/pipeline/line.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/pie.js +3 -3
- package/dist/esm/pipeline/advanced/chart/pipeline/pie.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/radar.js +3 -3
- package/dist/esm/pipeline/advanced/chart/pipeline/radar.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/rose.js +3 -3
- package/dist/esm/pipeline/advanced/chart/pipeline/rose.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/roseParallel.js +3 -3
- package/dist/esm/pipeline/advanced/chart/pipeline/roseParallel.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/scatter.js +3 -3
- package/dist/esm/pipeline/advanced/chart/pipeline/scatter.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/dimensions/index.d.ts +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/dimensions/index.js +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/dimensions/pickDimensionsForReshape.d.ts +2 -0
- package/dist/esm/pipeline/advanced/chart/pipes/dimensions/pickDimensionsForReshape.js +14 -0
- package/dist/esm/pipeline/advanced/chart/pipes/dimensions/pickDimensionsForReshape.js.map +1 -0
- package/dist/esm/pipeline/advanced/chart/pipes/measures/index.d.ts +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/measures/index.js +2 -2
- package/dist/esm/pipeline/advanced/chart/pipes/measures/pickMeasuresForReshape.d.ts +2 -0
- package/dist/esm/pipeline/advanced/chart/pipes/measures/pickMeasuresForReshape.js +14 -0
- package/dist/esm/pipeline/advanced/chart/pipes/measures/pickMeasuresForReshape.js.map +1 -0
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithBoxplotEncoding.js +35 -29
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithBoxplotEncoding.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithDualEncoding.js +3 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithDualEncoding.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithEncoding.js +3 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithEncoding.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithHistogramEncoding.js +5 -3
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithHistogramEncoding.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithScatterEncoding.js +3 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithScatterEncoding.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithBoxplotEncoding.js +33 -28
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithBoxplotEncoding.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithDualEncoding.js +3 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithDualEncoding.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithEncoding.js +3 -5
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithEncoding.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithHistogramEncoding.js +3 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithHistogramEncoding.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithScatterEncoding.js +3 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithScatterEncoding.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/boxplot.js +3 -2
- package/dist/esm/pipeline/spec/chart/pipeline/boxplot.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/histogram.js +3 -3
- package/dist/esm/pipeline/spec/chart/pipeline/histogram.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/xLinear.js +11 -3
- package/dist/esm/pipeline/spec/chart/pipes/axes/xLinear.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinear.js +11 -3
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinear.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/crosshair/histogramCrosshair.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/crosshair/histogramCrosshair.js +27 -0
- package/dist/esm/pipeline/spec/chart/pipes/crosshair/histogramCrosshair.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/crosshair/index.d.ts +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/crosshair/index.js +2 -1
- package/dist/esm/pipeline/spec/chart/pipes/init/boxplot.js +3 -3
- package/dist/esm/pipeline/spec/chart/pipes/init/boxplot.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/legend/boxLegend.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/legend/boxLegend.js +15 -0
- package/dist/esm/pipeline/spec/chart/pipes/legend/boxLegend.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/legend/colorLegend.js +3 -4
- package/dist/esm/pipeline/spec/chart/pipes/legend/colorLegend.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/ecdfRegressionLine.js +31 -1
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/ecdfRegressionLine.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/linearRegressionLine.js +5 -1
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/linearRegressionLine.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltip.d.ts +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltip.js +5 -1
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltip.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipBoxplot.js +14 -5
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipBoxplot.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipHistogram.js +6 -4
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipHistogram.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/utils/histogram.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/utils/histogram.js +12 -0
- package/dist/esm/pipeline/spec/chart/utils/histogram.js.map +1 -0
- package/dist/esm/pipeline/utils/measures/delete.d.ts +2 -2
- package/dist/esm/pipeline/utils/measures/delete.js +7 -3
- package/dist/esm/pipeline/utils/measures/delete.js.map +1 -1
- package/dist/esm/pipeline/utils/tree/traverse.d.ts +1 -0
- package/dist/esm/pipeline/utils/tree/traverse.js +12 -1
- package/dist/esm/pipeline/utils/tree/traverse.js.map +1 -1
- package/dist/esm/types/advancedVSeed.d.ts +116 -3
- package/dist/esm/types/advancedVSeed.js +2 -0
- package/dist/esm/types/advancedVSeed.js.map +1 -1
- package/dist/esm/types/chartType/area/zArea.d.ts +12 -3
- package/dist/esm/types/chartType/areaPercent/zAreaPercent.d.ts +12 -3
- package/dist/esm/types/chartType/bar/zBar.d.ts +12 -3
- package/dist/esm/types/chartType/barParallel/zBarParallel.d.ts +12 -3
- package/dist/esm/types/chartType/barPercent/zBarPercent.d.ts +12 -3
- package/dist/esm/types/chartType/boxplot/zBoxplot.d.ts +12 -3
- package/dist/esm/types/chartType/column/zColumn.d.ts +12 -3
- package/dist/esm/types/chartType/columnParallel/zColumnParallel.d.ts +12 -3
- package/dist/esm/types/chartType/columnPercent/zColumnPercent.d.ts +12 -3
- package/dist/esm/types/chartType/donut/zDonut.d.ts +12 -3
- package/dist/esm/types/chartType/dualAxis/zDualAxis.d.ts +42 -15
- package/dist/esm/types/chartType/funnel/zFunnel.d.ts +12 -3
- package/dist/esm/types/chartType/heatmap/zHeatmap.d.ts +12 -3
- package/dist/esm/types/chartType/histogram/zHistogram.d.ts +12 -3
- package/dist/esm/types/chartType/line/zLine.d.ts +12 -3
- package/dist/esm/types/chartType/pie/zPie.d.ts +12 -3
- package/dist/esm/types/chartType/pivotTable/zPivotTable.d.ts +12 -3
- package/dist/esm/types/chartType/radar/zRadar.d.ts +12 -3
- package/dist/esm/types/chartType/rose/zRose.d.ts +12 -3
- package/dist/esm/types/chartType/roseParallel/zRoseParallel.d.ts +12 -3
- package/dist/esm/types/chartType/scatter/zScatter.d.ts +42 -15
- package/dist/esm/types/chartType/table/zTable.d.ts +12 -3
- package/dist/esm/types/properties/measures/zDualMeasures.d.ts +60 -24
- package/dist/esm/types/properties/measures/zMeasures.d.ts +36 -9
- package/dist/esm/types/properties/measures/zMeasures.js +13 -4
- package/dist/esm/types/properties/measures/zMeasures.js.map +1 -1
- package/dist/esm/types/properties/measures/zScatterMeasures.d.ts +60 -24
- package/dist/esm/types/properties/regressionLine/linearRegressionLine.d.ts +5 -0
- package/dist/esm/types/properties/regressionLine/logisticRegressionLine.d.ts +5 -0
- package/dist/esm/types/properties/regressionLine/lowessRegressionLine.d.ts +5 -0
- package/dist/esm/types/properties/regressionLine/polynomialRegressionLine.d.ts +5 -0
- package/dist/esm/types/zVseed.d.ts +324 -90
- package/dist/umd/index.js +349 -197
- package/dist/umd/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/dimensions/deleteTooltipAndLabelDimensions.d.ts +0 -2
- package/dist/esm/pipeline/advanced/chart/pipes/dimensions/deleteTooltipAndLabelDimensions.js +0 -12
- package/dist/esm/pipeline/advanced/chart/pipes/dimensions/deleteTooltipAndLabelDimensions.js.map +0 -1
- package/dist/esm/pipeline/advanced/chart/pipes/measures/deleteEncodingForMeasure.d.ts +0 -2
- package/dist/esm/pipeline/advanced/chart/pipes/measures/deleteEncodingForMeasure.js +0 -12
- package/dist/esm/pipeline/advanced/chart/pipes/measures/deleteEncodingForMeasure.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipeline/boxplot.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipeline/boxplot.ts"],"sourcesContent":["import type { PivotChartSpecPipeline, VChartSpecPipeline } from 'src/types'\nimport {\n backgroundColor,\n label,\n tooltipBoxplot,\n
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipeline/boxplot.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipeline/boxplot.ts"],"sourcesContent":["import type { PivotChartSpecPipeline, VChartSpecPipeline } from 'src/types'\nimport {\n backgroundColor,\n label,\n tooltipBoxplot,\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 stackCornerRadius,\n progressive,\n colorAdapter,\n linearColor,\n colorLegend,\n colorBarStyleFill,\n pivotColorLegend,\n initBoxplot,\n xBand,\n yLinear,\n verticalCrosshairRect,\n datasetBoxplot,\n pivotAxisStyle,\n pivotTitle,\n} from '../pipes'\nimport { boxLegend } from '../pipes/legend/boxLegend'\n\nconst boxplot: VChartSpecPipeline = [\n initBoxplot,\n stackCornerRadius,\n colorAdapter(color, linearColor),\n backgroundColor,\n datasetBoxplot,\n progressive,\n xBand,\n yLinear,\n label,\n tooltipBoxplot,\n colorAdapter(boxLegend, colorLegend),\n verticalCrosshairRect,\n colorBarStyleFill(barStyle),\n annotationPoint,\n annotationVerticalLine,\n annotationHorizontalLine,\n annotationAreaBand,\n]\n\nconst pivotBoxplot: PivotChartSpecPipeline = [\n initPivot,\n pivotGridStyle,\n datasetPivot,\n pivotIndicators([\n initBoxplot,\n stackCornerRadius,\n colorAdapter(color, linearColor),\n backgroundColor,\n datasetBoxplot,\n progressive,\n xBand,\n pivotAxisStyle(yLinear),\n label,\n tooltipBoxplot,\n colorBarStyleFill(barStyle),\n verticalCrosshairRect,\n annotationPoint,\n annotationVerticalLine,\n annotationHorizontalLine,\n annotationAreaBand,\n ]),\n pivotRowDimensions,\n pivotColumnDimensions,\n pivotTitle,\n colorAdapter(pivotDiscreteLegend, pivotColorLegend),\n]\n\nexport const boxplotSpecPipeline = [pivotAdapter(boxplot, pivotBoxplot)]\n"],"names":["boxplot","initBoxplot","stackCornerRadius","colorAdapter","color","linearColor","backgroundColor","datasetBoxplot","progressive","xBand","yLinear","label","tooltipBoxplot","boxLegend","colorLegend","verticalCrosshairRect","colorBarStyleFill","barStyle","annotationPoint","annotationVerticalLine","annotationHorizontalLine","annotationAreaBand","pivotBoxplot","initPivot","pivotGridStyle","datasetPivot","pivotIndicators","pivotAxisStyle","pivotRowDimensions","pivotColumnDimensions","pivotTitle","pivotDiscreteLegend","pivotColorLegend","boxplotSpecPipeline","pivotAdapter"],"mappings":";;AAoCA,MAAMA,UAA8B;IAClCC;IACAC;IACAC,aAAaC,OAAOC;IACpBC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAT,aAAaU,WAAWC;IACxBC;IACAC,kBAAkBC;IAClBC;IACAC;IACAC;IACAC;CACD;AAED,MAAMC,eAAuC;IAC3CC;IACAC;IACAC;IACAC,gBAAgB;QACdzB;QACAC;QACAC,aAAaC,OAAOC;QACpBC;QACAC;QACAC;QACAC;QACAkB,eAAejB;QACfC;QACAC;QACAI,kBAAkBC;QAClBF;QACAG;QACAC;QACAC;QACAC;KACD;IACDO;IACAC;IACAC;IACA3B,aAAa4B,qBAAqBC;CACnC;AAEM,MAAMC,sBAAsB;IAACC,aAAalC,SAASsB;CAAc"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { annotationAreaBand, annotationHorizontalLine, annotationPoint, annotationVerticalLine, backgroundColor, barStyle, color, colorAdapter, colorBarStyleFill, colorLegend, datasetHistogram, datasetPivot, discreteLegend, ecdfRegressionLine, initHistogram, initPivot, kdeRegressionLine, label, linearColor, pivotAdapter, pivotAxisStyle, pivotColorLegend, pivotColumnDimensions, pivotDiscreteLegend, pivotGridStyle, pivotIndicators, pivotRowDimensions, pivotTitle, progressive, tooltipHistogram,
|
|
1
|
+
import { annotationAreaBand, annotationHorizontalLine, annotationPoint, annotationVerticalLine, backgroundColor, barStyle, color, colorAdapter, colorBarStyleFill, colorLegend, datasetHistogram, datasetPivot, 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),
|
|
@@ -10,7 +10,7 @@ const histogram = [
|
|
|
10
10
|
label,
|
|
11
11
|
tooltipHistogram,
|
|
12
12
|
colorAdapter(discreteLegend, colorLegend),
|
|
13
|
-
|
|
13
|
+
histogramVerticalCrosshairRect,
|
|
14
14
|
colorBarStyleFill(barStyle),
|
|
15
15
|
annotationPoint,
|
|
16
16
|
annotationVerticalLine,
|
|
@@ -34,7 +34,7 @@ const pivotHistogram = [
|
|
|
34
34
|
label,
|
|
35
35
|
tooltipHistogram,
|
|
36
36
|
colorBarStyleFill(barStyle),
|
|
37
|
-
|
|
37
|
+
histogramVerticalCrosshairRect,
|
|
38
38
|
annotationPoint,
|
|
39
39
|
annotationVerticalLine,
|
|
40
40
|
annotationHorizontalLine,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipeline/histogram.js","sources":["webpack://@visactor/vseed/./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
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipeline/histogram.js","sources":["webpack://@visactor/vseed/./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} 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]\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","histogramSpecPipeline","pivotAdapter"],"mappings":";AAqCA,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;CACnC;AAEM,MAAMC,wBAAwB;IAACC,aAAanC,WAAWuB;CAAgB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AXIS_LABEL_SPACE, LINEAR_AXIS_INNER_OFFSET_TOP, createNumFormatter, isAreaPercent, isBarPercent, isColumnPercent } from "../../../../utils/index.js";
|
|
1
|
+
import { AXIS_LABEL_SPACE, LINEAR_AXIS_INNER_OFFSET_TOP, createNumFormatter, isAreaPercent, isBarPercent, isColumnPercent, isPivotChart } from "../../../../utils/index.js";
|
|
2
2
|
import { createLinearFormat, createLinearPercentFormat } from "./format/linearFormat.js";
|
|
3
3
|
import { defaultTitleText } from "./title/defaultTitleText.js";
|
|
4
4
|
const xLinear = (spec, context)=>{
|
|
@@ -10,12 +10,22 @@ const xLinear = (spec, context)=>{
|
|
|
10
10
|
const { chartType } = vseed;
|
|
11
11
|
const config = advancedVSeed.config?.[chartType]?.xAxis;
|
|
12
12
|
if (!result.axes) result.axes = [];
|
|
13
|
+
const isPivot = isPivotChart(vseed);
|
|
13
14
|
const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10, autoFormat, numFormat = {} } = config;
|
|
14
15
|
const formatter = createNumFormatter(numFormat);
|
|
15
16
|
const percentFormatter = createNumFormatter({
|
|
16
17
|
type: 'percent'
|
|
17
18
|
});
|
|
18
19
|
const linearAxis = {
|
|
20
|
+
...isPivot ? {
|
|
21
|
+
range: {
|
|
22
|
+
min,
|
|
23
|
+
max
|
|
24
|
+
}
|
|
25
|
+
} : {
|
|
26
|
+
min,
|
|
27
|
+
max
|
|
28
|
+
},
|
|
19
29
|
visible,
|
|
20
30
|
type: log ? 'log' : 'linear',
|
|
21
31
|
base: logBase,
|
|
@@ -23,8 +33,6 @@ const xLinear = (spec, context)=>{
|
|
|
23
33
|
nice,
|
|
24
34
|
zero: log ? false : zero,
|
|
25
35
|
inverse,
|
|
26
|
-
max,
|
|
27
|
-
min,
|
|
28
36
|
label: {
|
|
29
37
|
space: AXIS_LABEL_SPACE,
|
|
30
38
|
visible: label?.visible,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/axes/xLinear.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/axes/xLinear.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport type { VChartSpecPipe, XLinearAxis } from 'src/types'\nimport {\n AXIS_LABEL_SPACE,\n createNumFormatter,\n isAreaPercent,\n isBarPercent,\n isColumnPercent,\n LINEAR_AXIS_INNER_OFFSET_TOP,\n} from 'src/pipeline/utils'\nimport { createLinearFormat, createLinearPercentFormat } from './format/linearFormat'\nimport { defaultTitleText } from './title/defaultTitleText'\n\nexport const xLinear: VChartSpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { encoding, dimensions, measures } = advancedVSeed\n const { chartType } = vseed\n const config = advancedVSeed.config?.[chartType as 'bar']?.xAxis as XLinearAxis\n\n if (!result.axes) {\n result.axes = []\n }\n\n const {\n visible = true,\n label,\n tick,\n title,\n grid,\n line,\n\n zero,\n nice,\n inverse,\n max,\n min,\n log,\n logBase = 10,\n autoFormat,\n numFormat = {},\n } = config\n\n const formatter = createNumFormatter(numFormat)\n const percentFormatter = createNumFormatter({\n type: 'percent',\n })\n\n const linearAxis = {\n visible,\n type: log ? 'log' : 'linear',\n base: logBase,\n orient: 'bottom',\n nice,\n zero: log ? false : zero,\n inverse,\n
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/axes/xLinear.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/axes/xLinear.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport type { VChartSpecPipe, XLinearAxis } from 'src/types'\nimport {\n AXIS_LABEL_SPACE,\n createNumFormatter,\n isAreaPercent,\n isBarPercent,\n isColumnPercent,\n isPivotChart,\n LINEAR_AXIS_INNER_OFFSET_TOP,\n} from 'src/pipeline/utils'\nimport { createLinearFormat, createLinearPercentFormat } from './format/linearFormat'\nimport { defaultTitleText } from './title/defaultTitleText'\n\nexport const xLinear: VChartSpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { encoding, dimensions, measures } = advancedVSeed\n const { chartType } = vseed\n const config = advancedVSeed.config?.[chartType as 'bar']?.xAxis as XLinearAxis\n\n if (!result.axes) {\n result.axes = []\n }\n const isPivot = isPivotChart(vseed)\n\n const {\n visible = true,\n label,\n tick,\n title,\n grid,\n line,\n\n zero,\n nice,\n inverse,\n max,\n min,\n log,\n logBase = 10,\n autoFormat,\n numFormat = {},\n } = config\n\n const formatter = createNumFormatter(numFormat)\n const percentFormatter = createNumFormatter({\n type: 'percent',\n })\n\n const linearAxis = {\n ...(isPivot\n ? {\n range: {\n min,\n max,\n },\n }\n : {\n min,\n max,\n }),\n visible,\n type: log ? 'log' : 'linear',\n base: logBase,\n orient: 'bottom',\n nice,\n zero: log ? false : zero,\n inverse,\n label: {\n space: AXIS_LABEL_SPACE,\n visible: label?.visible,\n formatMethod: (value: string) => {\n if (isBarPercent(vseed) || isColumnPercent(vseed) || isAreaPercent(vseed)) {\n return createLinearPercentFormat(value, autoFormat, numFormat, formatter, percentFormatter)\n }\n return createLinearFormat(value, autoFormat, numFormat, formatter)\n },\n style: {\n fill: label?.labelColor,\n angle: label?.labelAngle,\n fontSize: label?.labelFontSize,\n fontWeight: label?.labelFontWeight,\n },\n },\n title: {\n visible: title?.visible,\n text: title?.titleText || defaultTitleText(measures, dimensions, encoding.x as string[]),\n style: {\n fill: title?.titleColor,\n fontSize: title?.titleFontSize,\n fontWeight: title?.titleFontWeight,\n },\n },\n tick: {\n visible: tick?.visible,\n tickSize: tick?.tickSize,\n inside: tick?.tickInside,\n style: {\n stroke: tick?.tickColor,\n },\n },\n grid: {\n visible: grid?.visible,\n style: {\n lineWidth: grid?.gridWidth,\n stroke: grid?.gridColor,\n lineDash: grid?.gridLineDash,\n },\n },\n domainLine: {\n visible: line?.visible,\n style: {\n lineWidth: line?.lineWidth,\n stroke: line?.lineColor,\n },\n },\n innerOffset: {\n right: LINEAR_AXIS_INNER_OFFSET_TOP,\n // left: LINEAR_AXIS_INNER_OFFSET_TOP,\n },\n }\n\n result.axes = [...result.axes, linearAxis] as ISpec['axes']\n\n return result\n}\n"],"names":["xLinear","spec","context","result","advancedVSeed","vseed","encoding","dimensions","measures","chartType","config","isPivot","isPivotChart","visible","label","tick","title","grid","line","zero","nice","inverse","max","min","log","logBase","autoFormat","numFormat","formatter","createNumFormatter","percentFormatter","linearAxis","AXIS_LABEL_SPACE","value","isBarPercent","isColumnPercent","isAreaPercent","createLinearPercentFormat","createLinearFormat","defaultTitleText","LINEAR_AXIS_INNER_OFFSET_TOP"],"mappings":";;;AAcO,MAAMA,UAA0B,CAACC,MAAMC;IAC5C,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAEC,KAAK,EAAE,GAAGH;IACjC,MAAM,EAAEI,QAAQ,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAGJ;IAC3C,MAAM,EAAEK,SAAS,EAAE,GAAGJ;IACtB,MAAMK,SAASN,cAAc,MAAM,EAAE,CAACK,UAAmB,EAAE;IAE3D,IAAI,CAACN,OAAO,IAAI,EACdA,OAAO,IAAI,GAA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AM;gBACd,UAAUA,MAAM;YAClB;QACF;QACA,YAAY;YACV,SAASC,MAAM;YACf,OAAO;gBACL,WAAWA,MAAM;gBACjB,QAAQA,MAAM;YAChB;QACF;QACA,aAAa;YACX,OAAOsB;QAET;IACF;IAEArC,OAAO,IAAI,GAAG;WAAIA,OAAO,IAAI;QAAE4B;KAAW;IAE1C,OAAO5B;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AXIS_LABEL_SPACE, LINEAR_AXIS_INNER_OFFSET_TOP, createNumFormatter, isAreaPercent, isBarPercent, isColumnPercent } from "../../../../utils/index.js";
|
|
1
|
+
import { AXIS_LABEL_SPACE, LINEAR_AXIS_INNER_OFFSET_TOP, createNumFormatter, isAreaPercent, isBarPercent, isColumnPercent, isPivotChart } from "../../../../utils/index.js";
|
|
2
2
|
import { createLinearFormat, createLinearPercentFormat } from "./format/linearFormat.js";
|
|
3
3
|
import { defaultTitleText } from "./title/defaultTitleText.js";
|
|
4
4
|
const yLinear = (spec, context)=>{
|
|
@@ -10,12 +10,22 @@ const yLinear = (spec, context)=>{
|
|
|
10
10
|
const { measures, dimensions, encoding } = advancedVSeed;
|
|
11
11
|
const config = advancedVSeed.config?.[chartType]?.yAxis;
|
|
12
12
|
if (!result.axes) result.axes = [];
|
|
13
|
+
const isPivot = isPivotChart(vseed);
|
|
13
14
|
const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10, autoFormat, numFormat = {} } = config;
|
|
14
15
|
const formatter = createNumFormatter(numFormat);
|
|
15
16
|
const percentFormatter = createNumFormatter({
|
|
16
17
|
type: 'percent'
|
|
17
18
|
});
|
|
18
19
|
const linearAxis = {
|
|
20
|
+
...isPivot ? {
|
|
21
|
+
range: {
|
|
22
|
+
min,
|
|
23
|
+
max
|
|
24
|
+
}
|
|
25
|
+
} : {
|
|
26
|
+
min,
|
|
27
|
+
max
|
|
28
|
+
},
|
|
19
29
|
visible,
|
|
20
30
|
type: log ? 'log' : 'linear',
|
|
21
31
|
base: logBase,
|
|
@@ -23,8 +33,6 @@ const yLinear = (spec, context)=>{
|
|
|
23
33
|
nice,
|
|
24
34
|
zero: log ? false : zero,
|
|
25
35
|
inverse,
|
|
26
|
-
max,
|
|
27
|
-
min,
|
|
28
36
|
label: {
|
|
29
37
|
space: AXIS_LABEL_SPACE,
|
|
30
38
|
visible: label?.visible,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/axes/yLinear.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/axes/yLinear.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport {\n AXIS_LABEL_SPACE,\n createNumFormatter,\n isAreaPercent,\n isBarPercent,\n isColumnPercent,\n LINEAR_AXIS_INNER_OFFSET_TOP,\n} from 'src/pipeline/utils'\nimport type { VChartSpecPipe, YLinearAxis } from 'src/types'\nimport { createLinearFormat, createLinearPercentFormat } from './format/linearFormat'\nimport { defaultTitleText } from './title/defaultTitleText'\n\nexport const yLinear: VChartSpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n const { measures, dimensions, encoding } = advancedVSeed\n const config = advancedVSeed.config?.[chartType as 'column']?.yAxis as YLinearAxis\n\n if (!result.axes) {\n result.axes = []\n }\n\n const {\n visible = true,\n label,\n tick,\n title,\n grid,\n line,\n\n zero,\n nice,\n inverse,\n max,\n min,\n log,\n logBase = 10,\n autoFormat,\n numFormat = {},\n } = config\n\n const formatter = createNumFormatter(numFormat)\n const percentFormatter = createNumFormatter({\n type: 'percent',\n })\n\n const linearAxis = {\n visible,\n type: log ? 'log' : 'linear',\n base: logBase,\n orient: 'left',\n nice,\n zero: log ? false : zero,\n inverse,\n
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/axes/yLinear.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/axes/yLinear.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport {\n AXIS_LABEL_SPACE,\n createNumFormatter,\n isAreaPercent,\n isBarPercent,\n isColumnPercent,\n isPivotChart,\n LINEAR_AXIS_INNER_OFFSET_TOP,\n} from 'src/pipeline/utils'\nimport type { VChartSpecPipe, YLinearAxis } from 'src/types'\nimport { createLinearFormat, createLinearPercentFormat } from './format/linearFormat'\nimport { defaultTitleText } from './title/defaultTitleText'\n\nexport const yLinear: VChartSpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n const { measures, dimensions, encoding } = advancedVSeed\n const config = advancedVSeed.config?.[chartType as 'column']?.yAxis as YLinearAxis\n\n if (!result.axes) {\n result.axes = []\n }\n const isPivot = isPivotChart(vseed)\n\n const {\n visible = true,\n label,\n tick,\n title,\n grid,\n line,\n\n zero,\n nice,\n inverse,\n max,\n min,\n log,\n logBase = 10,\n autoFormat,\n numFormat = {},\n } = config\n\n const formatter = createNumFormatter(numFormat)\n const percentFormatter = createNumFormatter({\n type: 'percent',\n })\n\n const linearAxis = {\n ...(isPivot\n ? {\n range: {\n min,\n max,\n },\n }\n : {\n min,\n max,\n }),\n visible,\n type: log ? 'log' : 'linear',\n base: logBase,\n orient: 'left',\n nice,\n zero: log ? false : zero,\n inverse,\n label: {\n space: AXIS_LABEL_SPACE,\n visible: label?.visible,\n formatMethod: (value: string) => {\n if (isBarPercent(vseed) || isColumnPercent(vseed) || isAreaPercent(vseed)) {\n return createLinearPercentFormat(value, autoFormat, numFormat, formatter, percentFormatter)\n }\n return createLinearFormat(value, autoFormat, numFormat, formatter)\n },\n style: {\n fill: label?.labelColor,\n angle: label?.labelAngle,\n fontSize: label?.labelFontSize,\n fontWeight: label?.labelFontWeight,\n },\n },\n title: {\n visible: title?.visible,\n text: title?.titleText || defaultTitleText(measures, dimensions, encoding.y as string[]),\n style: {\n fill: title?.titleColor,\n fontSize: title?.titleFontSize,\n fontWeight: title?.titleFontWeight,\n },\n },\n tick: {\n visible: tick?.visible,\n tickSize: tick?.tickSize,\n inside: tick?.tickInside,\n style: {\n stroke: tick?.tickColor,\n },\n },\n grid: {\n visible: grid?.visible,\n style: {\n lineWidth: grid?.gridWidth,\n stroke: grid?.gridColor,\n lineDash: grid?.gridLineDash,\n },\n },\n domainLine: {\n visible: line?.visible,\n style: {\n lineWidth: line?.lineWidth,\n stroke: line?.lineColor,\n },\n },\n innerOffset: {\n top: LINEAR_AXIS_INNER_OFFSET_TOP,\n // bottom: LINEAR_AXIS_INNER_OFFSET_TOP,\n },\n }\n\n result.axes = [...result.axes, linearAxis] as ISpec['axes']\n\n return result\n}\n"],"names":["yLinear","spec","context","result","advancedVSeed","vseed","chartType","measures","dimensions","encoding","config","isPivot","isPivotChart","visible","label","tick","title","grid","line","zero","nice","inverse","max","min","log","logBase","autoFormat","numFormat","formatter","createNumFormatter","percentFormatter","linearAxis","AXIS_LABEL_SPACE","value","isBarPercent","isColumnPercent","isAreaPercent","createLinearPercentFormat","createLinearFormat","defaultTitleText","LINEAR_AXIS_INNER_OFFSET_TOP"],"mappings":";;;AAcO,MAAMA,UAA0B,CAACC,MAAMC;IAC5C,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAEC,KAAK,EAAE,GAAGH;IACjC,MAAM,EAAEI,SAAS,EAAE,GAAGD;IACtB,MAAM,EAAEE,QAAQ,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAGL;IAC3C,MAAMM,SAASN,cAAc,MAAM,EAAE,CAACE,UAAsB,EAAE;IAE9D,IAAI,CAACH,OAAO,IAAI,EACdA,OAAO,IAAI,GAAG,EAAE;IAElB,MAAMQ,UAAUC,aAAaP;IAE7B,MAAM,EACJQ,UAAU,IAAI,EACdC,KAAK,EACLC,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,IAAI,EAEJC,IAAI,EACJC,IAAI,EACJC,OAAO,EACPC,GAAG,EACHC,GAAG,EACHC,GAAG,EAC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E4B;KAAW;IAE1C,OAAO5B;AACT"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { verticalCrosshairRect } from "./verticalCrosshairRect.js";
|
|
2
|
+
import { getDefaultXFormatterOfHistogram } from "../../utils/histogram.js";
|
|
3
|
+
import { isArray } from "@visactor/vutils";
|
|
4
|
+
const histogramVerticalCrosshairRect = (spec, context)=>{
|
|
5
|
+
const result = verticalCrosshairRect(spec, context);
|
|
6
|
+
if (!result.crosshair) return result;
|
|
7
|
+
const crosshair = result.crosshair;
|
|
8
|
+
if (!crosshair.xField) return result;
|
|
9
|
+
const defaultXFormatter = getDefaultXFormatterOfHistogram(context.advancedVSeed);
|
|
10
|
+
crosshair.xField = {
|
|
11
|
+
...crosshair.xField || {},
|
|
12
|
+
label: {
|
|
13
|
+
...crosshair.xField?.label || {},
|
|
14
|
+
formatMethod: (text)=>{
|
|
15
|
+
if (isArray(text)) return text;
|
|
16
|
+
const binRange = `${text}`.split('~');
|
|
17
|
+
const binStart = defaultXFormatter(+binRange[0]);
|
|
18
|
+
const binEnd = defaultXFormatter(+binRange[1]);
|
|
19
|
+
return 1 === binRange.length ? binStart : `[${binStart}, ${binEnd})`;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
export { histogramVerticalCrosshairRect };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=histogramCrosshair.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/crosshair/histogramCrosshair.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/crosshair/histogramCrosshair.ts"],"sourcesContent":["import type { ICartesianCrosshairSpec } from '@visactor/vchart'\nimport type { VChartSpecPipe } from 'src/types'\nimport { verticalCrosshairRect } from './verticalCrosshairRect'\nimport { getDefaultXFormatterOfHistogram } from '../../utils/histogram'\nimport { isArray } from '@visactor/vutils'\n\nexport const histogramVerticalCrosshairRect: VChartSpecPipe = (spec, context) => {\n const result = verticalCrosshairRect(spec, context)\n if (!result.crosshair) {\n return result\n }\n const crosshair = result.crosshair as ICartesianCrosshairSpec\n if (!crosshair.xField) {\n return result\n }\n const defaultXFormatter = getDefaultXFormatterOfHistogram(context.advancedVSeed)\n crosshair.xField = {\n ...(crosshair.xField || {}),\n label: {\n ...(crosshair.xField?.label || {}),\n formatMethod: (text) => {\n if (isArray(text)) {\n return text\n }\n const binRange = `${text}`.split('~')\n const binStart = defaultXFormatter(+binRange[0])\n const binEnd = defaultXFormatter(+binRange[1])\n return binRange.length === 1 ? binStart : `[${binStart}, ${binEnd})`\n },\n },\n }\n\n return result\n}\n"],"names":["histogramVerticalCrosshairRect","spec","context","result","verticalCrosshairRect","crosshair","defaultXFormatter","getDefaultXFormatterOfHistogram","text","isArray","binRange","binStart","binEnd"],"mappings":";;;AAMO,MAAMA,iCAAiD,CAACC,MAAMC;IACnE,MAAMC,SAASC,sBAAsBH,MAAMC;IAC3C,IAAI,CAACC,OAAO,SAAS,EACnB,OAAOA;IAET,MAAME,YAAYF,OAAO,SAAS;IAClC,IAAI,CAACE,UAAU,MAAM,EACnB,OAAOF;IAET,MAAMG,oBAAoBC,gCAAgCL,QAAQ,aAAa;IAC/EG,UAAU,MAAM,GAAG;QACjB,GAAIA,UAAU,MAAM,IAAI,CAAC,CAAC;QAC1B,OAAO;YACL,GAAIA,UAAU,MAAM,EAAE,SAAS,CAAC,CAAC;YACjC,cAAc,CAACG;gBACb,IAAIC,QAAQD,OACV,OAAOA;gBAET,MAAME,WAAW,GAAGF,MAAM,CAAC,KAAK,CAAC;gBACjC,MAAMG,WAAWL,kBAAkB,CAACI,QAAQ,CAAC,EAAE;gBAC/C,MAAME,SAASN,kBAAkB,CAACI,QAAQ,CAAC,EAAE;gBAC7C,OAAOA,AAAoB,MAApBA,SAAS,MAAM,GAASC,WAAW,CAAC,CAAC,EAAEA,SAAS,EAAE,EAAEC,OAAO,CAAC,CAAC;YACtE;QACF;IACF;IAEA,OAAOT;AACT"}
|
|
@@ -2,3 +2,4 @@ export { verticalCrosshairLine } from './verticalCrosshairLine';
|
|
|
2
2
|
export { verticalCrosshairRect } from './verticalCrosshairRect';
|
|
3
3
|
export { horizontalCrosshairRect } from './horizontalCrosshairRect';
|
|
4
4
|
export { horizontalCrosshairLine } from './horizontalCrosshairLine';
|
|
5
|
+
export { histogramVerticalCrosshairRect } from './histogramCrosshair';
|
|
@@ -2,4 +2,5 @@ import { verticalCrosshairLine } from "./verticalCrosshairLine.js";
|
|
|
2
2
|
import { verticalCrosshairRect } from "./verticalCrosshairRect.js";
|
|
3
3
|
import { horizontalCrosshairRect } from "./horizontalCrosshairRect.js";
|
|
4
4
|
import { horizontalCrosshairLine } from "./horizontalCrosshairLine.js";
|
|
5
|
-
|
|
5
|
+
import { histogramVerticalCrosshairRect } from "./histogramCrosshair.js";
|
|
6
|
+
export { histogramVerticalCrosshairRect, horizontalCrosshairLine, horizontalCrosshairRect, verticalCrosshairLine, verticalCrosshairRect };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isDeepEqual } from "remeda";
|
|
2
|
-
import {
|
|
2
|
+
import { LowerWhisker, MeasureId, MedianMeasureId, OutliersMeasureId, Q1MeasureValue, Q3MeasureValue, UpperWhisker } from "../../../../../dataReshape/constant.js";
|
|
3
3
|
const initBoxplot = (spec, context)=>{
|
|
4
4
|
const result = {
|
|
5
5
|
...spec
|
|
@@ -8,10 +8,10 @@ const initBoxplot = (spec, context)=>{
|
|
|
8
8
|
const { datasetReshapeInfo, encoding } = advancedVSeed;
|
|
9
9
|
const { unfoldInfo } = datasetReshapeInfo[0];
|
|
10
10
|
result.type = 'boxPlot';
|
|
11
|
-
result.minField =
|
|
11
|
+
result.minField = LowerWhisker;
|
|
12
|
+
result.maxField = UpperWhisker;
|
|
12
13
|
result.q1Field = Q1MeasureValue;
|
|
13
14
|
result.medianField = MedianMeasureId;
|
|
14
|
-
result.maxField = MaxMeasureId;
|
|
15
15
|
result.q3Field = Q3MeasureValue;
|
|
16
16
|
result.outliersField = OutliersMeasureId;
|
|
17
17
|
result.xField = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/init/boxplot.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/init/boxplot.ts"],"sourcesContent":["import type { IBoxPlotChartSpec } from '@visactor/vchart'\nimport type { VChartSpecPipe } from 'src/types'\nimport { isDeepEqual } from 'remeda'\nimport {\n
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/init/boxplot.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/init/boxplot.ts"],"sourcesContent":["import type { IBoxPlotChartSpec } from '@visactor/vchart'\nimport type { VChartSpecPipe } from 'src/types'\nimport { isDeepEqual } from 'remeda'\nimport {\n LowerWhisker,\n MeasureId,\n MedianMeasureId,\n OutliersMeasureId,\n Q1MeasureValue,\n Q3MeasureValue,\n UpperWhisker,\n} from 'src/dataReshape/constant'\n\nexport const initBoxplot: VChartSpecPipe = (spec, context) => {\n const result = { ...spec } as IBoxPlotChartSpec\n const { advancedVSeed } = context\n const { datasetReshapeInfo, encoding } = advancedVSeed\n const { unfoldInfo } = datasetReshapeInfo[0]\n\n result.type = 'boxPlot'\n // 默认应该是盒须的位置\n result.minField = LowerWhisker\n result.maxField = UpperWhisker\n result.q1Field = Q1MeasureValue\n result.medianField = MedianMeasureId\n result.q3Field = Q3MeasureValue\n result.outliersField = OutliersMeasureId\n result.xField = [unfoldInfo.encodingX]\n result.seriesField = unfoldInfo.encodingColorId\n\n const sameDimensionsMode = isDeepEqual(encoding.x, encoding.color)\n\n if (!sameDimensionsMode) {\n result.xField.push(unfoldInfo.encodingColor)\n\n if (encoding.color?.[0] === MeasureId && encoding.value?.length === 1) {\n result.xField.pop()\n }\n }\n\n result.padding = 0\n result.region = [\n {\n clip: true,\n },\n ]\n result.animation = true\n return result\n}\n"],"names":["initBoxplot","spec","context","result","advancedVSeed","datasetReshapeInfo","encoding","unfoldInfo","LowerWhisker","UpperWhisker","Q1MeasureValue","MedianMeasureId","Q3MeasureValue","OutliersMeasureId","sameDimensionsMode","isDeepEqual","MeasureId"],"mappings":";;AAaO,MAAMA,cAA8B,CAACC,MAAMC;IAChD,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAE,GAAGF;IAC1B,MAAM,EAAEG,kBAAkB,EAAEC,QAAQ,EAAE,GAAGF;IACzC,MAAM,EAAEG,UAAU,EAAE,GAAGF,kBAAkB,CAAC,EAAE;IAE5CF,OAAO,IAAI,GAAG;IAEdA,OAAO,QAAQ,GAAGK;IAClBL,OAAO,QAAQ,GAAGM;IAClBN,OAAO,OAAO,GAAGO;IACjBP,OAAO,WAAW,GAAGQ;IACrBR,OAAO,OAAO,GAAGS;IACjBT,OAAO,aAAa,GAAGU;IACvBV,OAAO,MAAM,GAAG;QAACI,WAAW,SAAS;KAAC;IACtCJ,OAAO,WAAW,GAAGI,WAAW,eAAe;IAE/C,MAAMO,qBAAqBC,YAAYT,SAAS,CAAC,EAAEA,SAAS,KAAK;IAEjE,IAAI,CAACQ,oBAAoB;QACvBX,OAAO,MAAM,CAAC,IAAI,CAACI,WAAW,aAAa;QAE3C,IAAID,SAAS,KAAK,EAAE,CAAC,EAAE,KAAKU,aAAaV,SAAS,KAAK,EAAE,WAAW,GAClEH,OAAO,MAAM,CAAC,GAAG;IAErB;IAEAA,OAAO,OAAO,GAAG;IACjBA,OAAO,MAAM,GAAG;QACd;YACE,MAAM;QACR;KACD;IACDA,OAAO,SAAS,GAAG;IACnB,OAAOA;AACT"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { discreteLegend } from "./discreteLegend.js";
|
|
2
|
+
const boxLegend = (spec, context)=>{
|
|
3
|
+
const normalLegend = discreteLegend(spec, context);
|
|
4
|
+
normalLegend.legends = {
|
|
5
|
+
...normalLegend.legends,
|
|
6
|
+
data: (data)=>data.map((obj)=>{
|
|
7
|
+
obj.shape.fill = obj.shape.stroke;
|
|
8
|
+
return obj;
|
|
9
|
+
})
|
|
10
|
+
};
|
|
11
|
+
return normalLegend;
|
|
12
|
+
};
|
|
13
|
+
export { boxLegend };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=boxLegend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/legend/boxLegend.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/legend/boxLegend.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-return */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport type { VChartSpecPipe } from 'src/types'\nimport { discreteLegend } from './discreteLegend'\n\nexport const boxLegend: VChartSpecPipe = (spec, context) => {\n const normalLegend = discreteLegend(spec, context) as any\n normalLegend.legends = {\n ...normalLegend.legends,\n data: (data: any[]) => {\n return data.map((obj) => {\n obj.shape.fill = obj.shape.stroke\n return obj\n })\n },\n }\n return normalLegend\n}\n"],"names":["boxLegend","spec","context","normalLegend","discreteLegend","data","obj"],"mappings":";AAMO,MAAMA,YAA4B,CAACC,MAAMC;IAC9C,MAAMC,eAAeC,eAAeH,MAAMC;IAC1CC,aAAa,OAAO,GAAG;QACrB,GAAGA,aAAa,OAAO;QACvB,MAAM,CAACE,OACEA,KAAK,GAAG,CAAC,CAACC;gBACfA,IAAI,KAAK,CAAC,IAAI,GAAGA,IAAI,KAAK,CAAC,MAAM;gBACjC,OAAOA;YACT;IAEJ;IACA,OAAOH;AACT"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { createFormatterByMeasure,
|
|
1
|
+
import { createFormatterByMeasure, findTreeNodesBy } from "../../../../utils/index.js";
|
|
2
2
|
const colorLegend = (spec, context)=>{
|
|
3
3
|
const result = {
|
|
4
4
|
...spec
|
|
5
5
|
};
|
|
6
6
|
const { advancedVSeed } = context;
|
|
7
|
-
const { datasetReshapeInfo, chartType } = advancedVSeed;
|
|
7
|
+
const { datasetReshapeInfo, chartType, measures = [] } = advancedVSeed;
|
|
8
8
|
const { unfoldInfo } = datasetReshapeInfo[0];
|
|
9
9
|
const baseConfig = advancedVSeed.config[chartType];
|
|
10
10
|
if (!baseConfig || !baseConfig.legend) return result;
|
|
@@ -65,8 +65,7 @@ const colorLegend = (spec, context)=>{
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
|
-
const
|
|
69
|
-
const colorMeasure = measures.find((m)=>'color' === m.encoding);
|
|
68
|
+
const colorMeasure = findTreeNodesBy(measures, (m)=>'color' === m.encoding)?.[0];
|
|
70
69
|
if (colorMeasure) {
|
|
71
70
|
const formatter = createFormatterByMeasure(colorMeasure);
|
|
72
71
|
result.legends.handlerText.formatter = formatter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/legend/colorLegend.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/legend/colorLegend.ts"],"sourcesContent":["import { createFormatterByMeasure,
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/legend/colorLegend.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/legend/colorLegend.ts"],"sourcesContent":["import { createFormatterByMeasure, findTreeNodesBy } from 'src/pipeline/utils'\nimport type { Legend, Measure, VChartSpecPipe } from 'src/types'\n\nexport const colorLegend: VChartSpecPipe = (spec, context) => {\n const result = { ...spec }\n const { advancedVSeed } = context\n const { datasetReshapeInfo, chartType, measures = [] } = advancedVSeed\n const { unfoldInfo } = datasetReshapeInfo[0]\n const baseConfig = advancedVSeed.config[chartType] as { legend: Legend }\n if (!baseConfig || !baseConfig.legend) {\n return result\n }\n\n const { legend } = baseConfig\n const { enable, position = 'bottom', labelFontColor, labelColor, labelFontSize = 12, labelFontWeight } = 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 result.legends = {\n type: 'color',\n visible: enable,\n orient,\n position: legendPosition,\n padding: 0,\n field: unfoldInfo.encodingColor,\n maxWidth: '30%',\n handlerText: {\n visible: true,\n style: {\n fill: labelColor || labelFontColor,\n fontSize: labelFontSize,\n fontWeight: labelFontWeight,\n },\n },\n }\n const colorMeasure = findTreeNodesBy<Measure>(measures, (m) => m.encoding === 'color')?.[0]\n if (colorMeasure) {\n const formatter = createFormatterByMeasure(colorMeasure)\n result.legends.handlerText!.formatter = formatter\n }\n return result\n}\n"],"names":["colorLegend","spec","context","result","advancedVSeed","datasetReshapeInfo","chartType","measures","unfoldInfo","baseConfig","legend","enable","position","labelFontColor","labelColor","labelFontSize","labelFontWeight","orient","legendPosition","colorMeasure","findTreeNodesBy","m","formatter","createFormatterByMeasure"],"mappings":";AAGO,MAAMA,cAA8B,CAACC,MAAMC;IAChD,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAE,GAAGF;IAC1B,MAAM,EAAEG,kBAAkB,EAAEC,SAAS,EAAEC,WAAW,EAAE,EAAE,GAAGH;IACzD,MAAM,EAAEI,UAAU,EAAE,GAAGH,kBAAkB,CAAC,EAAE;IAC5C,MAAMI,aAAaL,cAAc,MAAM,CAACE,UAAU;IAClD,IAAI,CAACG,cAAc,CAACA,WAAW,MAAM,EACnC,OAAON;IAGT,MAAM,EAAEO,MAAM,EAAE,GAAGD;IACnB,MAAM,EAAEE,MAAM,EAAEC,WAAW,QAAQ,EAAEC,cAAc,EAAEC,UAAU,EAAEC,gBAAgB,EAAE,EAAEC,eAAe,EAAE,GAAGN,UAAU,CAAC;IAEpH,MAAMO,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;IAENT,OAAO,OAAO,GAAG;QACf,MAAM;QACN,SAASQ;QACTM;QACA,UAAUC;QACV,SAAS;QACT,OAAOV,WAAW,aAAa;QAC/B,UAAU;QACV,aAAa;YACX,SAAS;YACT,OAAO;gBACL,MAAMM,cAAcD;gBACpB,UAAUE;gBACV,YAAYC;YACd;QACF;IACF;IACA,MAAMG,eAAeC,gBAAyBb,UAAU,CAACc,IAAMA,AAAe,YAAfA,EAAE,QAAQ,GAAe,CAAC,EAAE;IAC3F,IAAIF,cAAc;QAChB,MAAMG,YAAYC,yBAAyBJ;QAC3ChB,OAAO,OAAO,CAAC,WAAW,CAAE,SAAS,GAAGmB;IAC1C;IACA,OAAOnB;AACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isNullish, uniqueBy } from "remeda";
|
|
2
|
-
import { array, ecdf } from "@visactor/vutils";
|
|
2
|
+
import { array, ecdf, isArray } from "@visactor/vutils";
|
|
3
3
|
import { defaultRegressionLineColor, defaultRegressionLineLabelX, defaultRegressionLineLabelY } from "./common.js";
|
|
4
4
|
const ecdfRegressionLine = (spec, context)=>{
|
|
5
5
|
const result = {
|
|
@@ -91,6 +91,36 @@ const ecdfRegressionLine = (spec, context)=>{
|
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
});
|
|
94
|
+
const leftAxis = result.axes?.find((v)=>'left' === v.orient);
|
|
95
|
+
if (leftAxis && lineList.length) result.axes?.push({
|
|
96
|
+
visible: true,
|
|
97
|
+
orient: 'right',
|
|
98
|
+
type: 'linear',
|
|
99
|
+
base: 10,
|
|
100
|
+
min: 0,
|
|
101
|
+
max: 1,
|
|
102
|
+
domainLine: {
|
|
103
|
+
...leftAxis.domainLine
|
|
104
|
+
},
|
|
105
|
+
grid: {
|
|
106
|
+
visible: false
|
|
107
|
+
},
|
|
108
|
+
tick: {
|
|
109
|
+
...leftAxis.tick
|
|
110
|
+
},
|
|
111
|
+
title: {
|
|
112
|
+
...leftAxis.title,
|
|
113
|
+
visible: false
|
|
114
|
+
},
|
|
115
|
+
label: {
|
|
116
|
+
...leftAxis.label,
|
|
117
|
+
visible: true,
|
|
118
|
+
formatMethod: (v)=>{
|
|
119
|
+
const text = isArray(v) ? v[0] : v;
|
|
120
|
+
return `${(100 * text).toFixed(1)}%`;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
94
124
|
return result;
|
|
95
125
|
};
|
|
96
126
|
export { ecdfRegressionLine };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/regressionLine/ecdfRegressionLine.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/regressionLine/ecdfRegressionLine.ts"],"sourcesContent":["import type { ICartesianSeries, IChart, IHistogramChartSpec, IVChart } from '@visactor/vchart'\nimport { isNullish, uniqueBy } from 'remeda'\nimport { ecdf, array } from '@visactor/vutils'\nimport type { Datum, Dimension, VChartSpecPipe, Encoding, RegressionLineConfig, EcdfRegressionLine } from 'src/types'\nimport { defaultRegressionLineColor, defaultRegressionLineLabelX, defaultRegressionLineLabelY } from './common'\n\nexport const ecdfRegressionLine: VChartSpecPipe = (spec, context) => {\n const result = { ...spec } as IHistogramChartSpec\n const { advancedVSeed, vseed } = context\n const { chartType, encoding = {} as Encoding, dimensions, regressionLine } = advancedVSeed\n const { dataset } = vseed\n const lineTheme = advancedVSeed.config[chartType as 'histogram']?.regressionLine as RegressionLineConfig\n\n if (!regressionLine || !regressionLine.ecdfRegressionLine) {\n return result\n }\n\n const rowColumnFields = uniqueBy(\n dimensions.filter((dim: Dimension) => dim.encoding === 'row' || dim.encoding === 'column'),\n (item: Dimension) => item.id,\n )\n\n const lineList = array(regressionLine.ecdfRegressionLine).filter((ecdfLine) => ecdfLine.enable !== false)\n\n if (!result.customMark) {\n result.customMark = []\n }\n\n lineList.forEach((line, lineIndex) => {\n const theme = (lineTheme?.ecdfRegressionLine ?? {}) as EcdfRegressionLine\n const { color, lineWidth, lineDash, text, textColor, textFontSize, textFontWeight } = line as EcdfRegressionLine\n\n const childrenMarks: any[] = []\n\n ;(result.customMark as any[]).push({\n type: 'group',\n interactive: false,\n zIndex: 500,\n name: `ecdfRegressionLine-${lineIndex}`,\n style: {\n data: (datum: any, ctx: any) => {\n const vchart = ctx.vchart as IVChart\n const chart = vchart.getChart() as IChart\n const series = chart.getAllSeries().filter((s: any) => s.type === 'bar')\n\n // 直方图使用的是bar系列\n if (series && series.length) {\n const s = series[0] as ICartesianSeries\n const region = s.getRegion().getLayoutStartPoint()\n\n const fieldX = s.fieldX?.[0]\n const scaleY = s.getYAxisHelper().getScale?.(0)\n const viewData = s.getViewData()?.latestData\n\n if (!dataset || !dataset.length || !viewData || !viewData.length || !scaleY) {\n return null\n }\n const simpleData = dataset\n .filter((entry: Datum) => {\n return rowColumnFields.length\n ? rowColumnFields.every((dim: Dimension) => {\n return entry[dim.id] === viewData[0][dim.id]\n })\n : true\n })\n .map((d: Datum) => +(d as any)[encoding.value?.[0] as string])\n const res = ecdf(simpleData)\n const N = Math.max(3, Math.floor(simpleData.length / 4))\n const lineData = res.evaluateGrid(N)\n const yRange = scaleY.range()\n const y0 = yRange[0]\n const y1 = yRange[yRange.length - 1]\n const scaleR = (e: number) => {\n return y0 + (y1 - y0) * e\n }\n\n const linePoints = lineData.map((ld: Datum) => {\n const d = { [fieldX]: ld.x }\n return {\n x: s.dataToPositionX(d)! + region.x,\n y: scaleR(ld.y as number) + region.y,\n }\n })\n\n return {\n linePoints,\n color: color ?? s.getOption().globalScale.getScale('color')?.scale(s.getSeriesKeys()[0]),\n }\n }\n return null\n },\n },\n children: childrenMarks,\n })\n\n childrenMarks.push({\n type: 'line',\n interactive: false,\n zIndex: 500,\n style: {\n lineWidth: lineWidth ?? theme.lineWidth,\n lineDash: lineDash ?? theme.lineDash,\n stroke: color ?? defaultRegressionLineColor,\n points: (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return parentNode.attribute.data.linePoints\n }\n\n return []\n },\n },\n })\n\n if (!isNullish(text)) {\n childrenMarks.push({\n type: 'text',\n interactive: false,\n zIndex: 500,\n style: {\n textAlign: 'end',\n fill: textColor ?? theme.textColor,\n fontSize: textFontSize ?? theme.textFontSize,\n fontWeight: textFontWeight ?? theme.textFontWeight,\n text: text,\n x: defaultRegressionLineLabelX,\n y: defaultRegressionLineLabelY,\n },\n })\n }\n })\n\n return result\n}\n"],"names":["ecdfRegressionLine","spec","context","result","advancedVSeed","vseed","chartType","encoding","dimensions","regressionLine","dataset","lineTheme","rowColumnFields","uniqueBy","dim","item","lineList","array","ecdfLine","line","lineIndex","theme","color","lineWidth","lineDash","text","textColor","textFontSize","textFontWeight","childrenMarks","datum","ctx","vchart","chart","series","s","region","fieldX","scaleY","viewData","simpleData","entry","d","res","ecdf","N","Math","lineData","yRange","y0","y1","scaleR","e","linePoints","ld","defaultRegressionLineColor","opt","parentNode","isNullish","defaultRegressionLineLabelX","defaultRegressionLineLabelY"],"mappings":";;;AAMO,MAAMA,qBA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AclB,OAAO,CAAC;4BACtC;wBACF;wBAEA,OAAO;4BACLiB;4BACA,OAAO/B,SAASa,EAAE,SAAS,GAAG,WAAW,CAAC,QAAQ,CAAC,UAAU,MAAMA,EAAE,aAAa,EAAE,CAAC,EAAE;wBACzF;oBACF;oBACA,OAAO;gBACT;YACF;YACA,UAAUN;QACZ;QAEAA,cAAc,IAAI,CAAC;YACjB,MAAM;YACN,aAAa;YACb,QAAQ;YACR,OAAO;gBACL,WAAWN,aAAaF,MAAM,SAAS;gBACvC,UAAUG,YAAYH,MAAM,QAAQ;gBACpC,QAAQC,SAASiC;gBACjB,QAAQ,CAACzB,OAAYC,KAAUyB;oBAC7B,MAAMC,aAAaD,IAAI,IAAI,EAAE,UAAU;oBAEvC,IAAIC,YAAY,WAAW,MAEzB,OAAOA,WAAW,SAAS,CAAC,IAAI,CAAC,UAAU;oBAG7C,OAAO,EAAE;gBACX;YACF;QACF;QAEA,IAAI,CAACC,UAAUjC,OACbI,cAAc,IAAI,CAAC;YACjB,MAAM;YACN,aAAa;YACb,QAAQ;YACR,OAAO;gBACL,WAAW;gBACX,MAAMH,aAAaL,MAAM,SAAS;gBAClC,UAAUM,gBAAgBN,MAAM,YAAY;gBAC5C,YAAYO,kBAAkBP,MAAM,cAAc;gBAClD,MAAMI;gBACN,GAAGkC;gBACH,GAAGC;YACL;QACF;IAEJ;IAEA,OAAOzD;AACT"}
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/regressionLine/ecdfRegressionLine.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/regressionLine/ecdfRegressionLine.ts"],"sourcesContent":["import type { ICartesianSeries, IChart, IHistogramChartSpec, IVChart } from '@visactor/vchart'\nimport { isNullish, uniqueBy } from 'remeda'\nimport { ecdf, array, isArray } from '@visactor/vutils'\nimport type { Datum, Dimension, VChartSpecPipe, Encoding, RegressionLineConfig, EcdfRegressionLine } from 'src/types'\nimport { defaultRegressionLineColor, defaultRegressionLineLabelX, defaultRegressionLineLabelY } from './common'\n\nexport const ecdfRegressionLine: VChartSpecPipe = (spec, context) => {\n const result = { ...spec } as IHistogramChartSpec\n const { advancedVSeed, vseed } = context\n const { chartType, encoding = {} as Encoding, dimensions, regressionLine } = advancedVSeed\n const { dataset } = vseed\n const lineTheme = advancedVSeed.config[chartType as 'histogram']?.regressionLine as RegressionLineConfig\n\n if (!regressionLine || !regressionLine.ecdfRegressionLine) {\n return result\n }\n\n const rowColumnFields = uniqueBy(\n dimensions.filter((dim: Dimension) => dim.encoding === 'row' || dim.encoding === 'column'),\n (item: Dimension) => item.id,\n )\n\n const lineList = array(regressionLine.ecdfRegressionLine).filter((ecdfLine) => ecdfLine.enable !== false)\n\n if (!result.customMark) {\n result.customMark = []\n }\n\n lineList.forEach((line, lineIndex) => {\n const theme = (lineTheme?.ecdfRegressionLine ?? {}) as EcdfRegressionLine\n const { color, lineWidth, lineDash, text, textColor, textFontSize, textFontWeight } = line as EcdfRegressionLine\n\n const childrenMarks: any[] = []\n\n ;(result.customMark as any[]).push({\n type: 'group',\n interactive: false,\n zIndex: 500,\n name: `ecdfRegressionLine-${lineIndex}`,\n style: {\n data: (datum: any, ctx: any) => {\n const vchart = ctx.vchart as IVChart\n const chart = vchart.getChart() as IChart\n const series = chart.getAllSeries().filter((s: any) => s.type === 'bar')\n\n // 直方图使用的是bar系列\n if (series && series.length) {\n const s = series[0] as ICartesianSeries\n const region = s.getRegion().getLayoutStartPoint()\n\n const fieldX = s.fieldX?.[0]\n const scaleY = s.getYAxisHelper().getScale?.(0)\n const viewData = s.getViewData()?.latestData\n\n if (!dataset || !dataset.length || !viewData || !viewData.length || !scaleY) {\n return null\n }\n const simpleData = dataset\n .filter((entry: Datum) => {\n return rowColumnFields.length\n ? rowColumnFields.every((dim: Dimension) => {\n return entry[dim.id] === viewData[0][dim.id]\n })\n : true\n })\n .map((d: Datum) => +(d as any)[encoding.value?.[0] as string])\n const res = ecdf(simpleData)\n const N = Math.max(3, Math.floor(simpleData.length / 4))\n const lineData = res.evaluateGrid(N)\n const yRange = scaleY.range()\n const y0 = yRange[0]\n const y1 = yRange[yRange.length - 1]\n const scaleR = (e: number) => {\n return y0 + (y1 - y0) * e\n }\n\n const linePoints = lineData.map((ld: Datum) => {\n const d = { [fieldX]: ld.x }\n return {\n x: s.dataToPositionX(d)! + region.x,\n y: scaleR(ld.y as number) + region.y,\n }\n })\n\n return {\n linePoints,\n color: color ?? s.getOption().globalScale.getScale('color')?.scale(s.getSeriesKeys()[0]),\n }\n }\n return null\n },\n },\n children: childrenMarks,\n })\n\n childrenMarks.push({\n type: 'line',\n interactive: false,\n zIndex: 500,\n style: {\n lineWidth: lineWidth ?? theme.lineWidth,\n lineDash: lineDash ?? theme.lineDash,\n stroke: color ?? defaultRegressionLineColor,\n points: (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return parentNode.attribute.data.linePoints\n }\n\n return []\n },\n },\n })\n\n if (!isNullish(text)) {\n childrenMarks.push({\n type: 'text',\n interactive: false,\n zIndex: 500,\n style: {\n textAlign: 'end',\n fill: textColor ?? theme.textColor,\n fontSize: textFontSize ?? theme.textFontSize,\n fontWeight: textFontWeight ?? theme.textFontWeight,\n text: text,\n x: defaultRegressionLineLabelX,\n y: defaultRegressionLineLabelY,\n },\n })\n }\n })\n\n // add percent axis of ecdf\n const leftAxis = result.axes?.find((v) => v.orient === 'left')\n if (leftAxis && lineList.length) {\n result.axes?.push({\n visible: true,\n orient: 'right',\n type: 'linear',\n base: 10,\n min: 0,\n max: 1,\n domainLine: {\n ...leftAxis.domainLine,\n },\n grid: {\n visible: false,\n },\n tick: {\n ...leftAxis.tick,\n },\n title: {\n ...leftAxis.title,\n visible: false,\n },\n label: {\n ...leftAxis.label,\n visible: true,\n formatMethod: (v) => {\n const text = isArray(v) ? v[0] : v\n return `${(+text * 100).toFixed(1)}%`\n },\n },\n })\n }\n\n return result\n}\n"],"names":["ecdfRegressionLine","spec","context","result","advancedVSeed","vseed","chartType","encoding","dimensions","regressionLine","dataset","lineTheme","rowColumnFields","uniqueBy","dim","item","lineList","array","ecdfLine","line","lineIndex","theme","color","lineWidth","lineDash","text","textColor","textFontSize","textFontWeight","childrenMarks","datum","ctx","vchart","chart","series","s","region","fieldX","scaleY","viewData","simpleData","entry","d","res","ecdf","N","Math","lineData","yRange","y0","y1","scaleR","e","linePoints","ld","defaultRegressionLineColor","opt","parentNode","isNullish","defaultRegressionLineLabelX","defaultRegressionLineLabelY","leftAxis","v","isArray"],"mappings":";;;AAMO,MAAMA,qBAAqC,CAACC,MAAMC;IACvD,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAEC,KAAK,EAAE,GAAGH;IACjC,MAAM,EAAEI,SAAS,EAAEC,WAAW,CAAC,CAAa,EAAEC,UAAU,EAAEC,cAAc,EAAE,GAAGL;IAC7E,MAAM,EAAEM,OAAO,EAAE,GAAGL;IACpB,MAAMM,YAAYP,cAAc,MAAM,CAACE,UAAyB,EAAE;IAElE,IAAI,CAACG,kBAAkB,CAACA,eAAe,kBAAkB,EACvD,OAAON;IAGT,MAAMS,kBAAkBC,SACtBL,WAAW,MAAM,CAAC,CAACM,MAAmBA,AAAiB,UAAjBA,IAAI,QAAQ,IAAcA,AAAiB,aAAjBA,IAAI,QAAQ,GAC5E,CAACC,OAAoBA,KAAK,EAAE;IAG9B,MAAMC,WAAWC,MAAMR,eAAe,kBAAkB,EAAE,MAAM,CAAC,CAACS,WAAaA,AAAoB,UAApBA,SAAS,MAAM;IAE9F,IAAI,CAACf,OAAO,UAAU,EACpBA,OAAO,UAAU,GAAG,EAAE;IAGxBa,SAAS,OAAO,CAAC,CAACG,MAAMC;QACtB,MAAMC,QAASV,WAAW,sBAAsB,CAAC;QACjD,MAAM,EAAEW,KAAK,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,SAA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;IAEJ;IAGA,MAAMC,WAAW1D,OAAO,IAAI,EAAE,KAAK,CAAC2D,IAAMA,AAAa,WAAbA,EAAE,MAAM;IAClD,IAAID,YAAY7C,SAAS,MAAM,EAC7Bb,OAAO,IAAI,EAAE,KAAK;QAChB,SAAS;QACT,QAAQ;QACR,MAAM;QACN,MAAM;QACN,KAAK;QACL,KAAK;QACL,YAAY;YACV,GAAG0D,SAAS,UAAU;QACxB;QACA,MAAM;YACJ,SAAS;QACX;QACA,MAAM;YACJ,GAAGA,SAAS,IAAI;QAClB;QACA,OAAO;YACL,GAAGA,SAAS,KAAK;YACjB,SAAS;QACX;QACA,OAAO;YACL,GAAGA,SAAS,KAAK;YACjB,SAAS;YACT,cAAc,CAACC;gBACb,MAAMrC,OAAOsC,QAAQD,KAAKA,CAAC,CAAC,EAAE,GAAGA;gBACjC,OAAO,GAAI,CAAQ,MAAPrC,IAAS,EAAG,OAAO,CAAC,GAAG,CAAC,CAAC;YACvC;QACF;IACF;IAGF,OAAOtB;AACT"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isNullish } from "remeda";
|
|
2
2
|
import { array, clamper, regressionLinear, regressionLogistic, regressionLowess, regressionPolynomial } from "@visactor/vutils";
|
|
3
|
-
const generateRegressionLinePipe = (type, regressionFunction, getOptions)=>(spec, context)=>{
|
|
3
|
+
const generateRegressionLinePipe = (type, regressionFunction, getOptions = getDefaultRegressionOptions)=>(spec, context)=>{
|
|
4
4
|
const result = {
|
|
5
5
|
...spec
|
|
6
6
|
};
|
|
@@ -148,9 +148,13 @@ const generateRegressionLinePipe = (type, regressionFunction, getOptions)=>(spec
|
|
|
148
148
|
});
|
|
149
149
|
return result;
|
|
150
150
|
};
|
|
151
|
+
const getDefaultRegressionOptions = (lineConfig)=>({
|
|
152
|
+
alpha: lineConfig?.confidenceLevel ?? 0.95
|
|
153
|
+
});
|
|
151
154
|
const linearRegressionLine = generateRegressionLinePipe('linearRegressionLine', regressionLinear);
|
|
152
155
|
const lowessRegressionLine = generateRegressionLinePipe('lowessRegressionLine', regressionLowess);
|
|
153
156
|
const polynomialRegressionLine = generateRegressionLinePipe('polynomialRegressionLine', regressionPolynomial, (lineConfig)=>({
|
|
157
|
+
...getDefaultRegressionOptions(lineConfig),
|
|
154
158
|
degree: lineConfig.degree ?? 2
|
|
155
159
|
}));
|
|
156
160
|
const logisticRegressionLine = generateRegressionLinePipe('logisticRegressionLine', regressionLogistic);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/regressionLine/linearRegressionLine.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/regressionLine/linearRegressionLine.ts"],"sourcesContent":["import type { ICartesianSeries, IChart, IScatterChartSpec, IVChart } from '@visactor/vchart'\nimport { isNullish } from 'remeda'\nimport {\n array,\n clamper,\n regressionLinear,\n regressionLowess,\n regressionPolynomial,\n regressionLogistic,\n} from '@visactor/vutils'\nimport type {\n Datum,\n VChartSpecPipe,\n RegressionLineConfig,\n LinearRegressionLine,\n PolynomialRegressionLine,\n SpecPipelineContext,\n} from 'src/types'\n\nexport const generateRegressionLinePipe = (\n type: 'linearRegressionLine' | 'lowessRegressionLine' | 'polynomialRegressionLine' | 'logisticRegressionLine',\n regressionFunction: (\n arr: Datum[],\n xAccessor: (d: Datum) => number,\n yAccessor: (d: Datum) => number,\n options?: any,\n ) => {\n confidenceInterval: (N: number) => { lower: number; upper: number; x: number }[]\n evaluateGrid: (N: number) => { x: number; y: number }[]\n },\n getOptions?: (lineConfig: any) => any,\n): VChartSpecPipe => {\n return ((spec: Partial<IScatterChartSpec>, context: SpecPipelineContext): Partial<IScatterChartSpec> => {\n const result = { ...spec }\n const { advancedVSeed } = context\n const { chartType, regressionLine } = advancedVSeed\n const lineTheme = advancedVSeed.config[chartType as 'scatter']?.regressionLine as RegressionLineConfig\n\n if (!regressionLine || !regressionLine[type]) {\n return result\n }\n\n const lineList = array(regressionLine[type])\n\n if (!result.customMark) {\n result.customMark = []\n }\n\n lineList.forEach((line, lineIndex) => {\n const theme = (lineTheme.linearRegressionLine ?? {}) as LinearRegressionLine\n const {\n color,\n lineWidth,\n lineDash,\n text,\n textColor,\n textFontSize,\n textFontWeight,\n confidenceIntervalOpacity,\n confidenceIntervalVisible = theme.confidenceIntervalVisible,\n } = line as LinearRegressionLine\n\n const childrenMarks: any[] = []\n\n ;(result.customMark as any[]).push({\n type: 'group',\n interactive: false,\n zIndex: 500,\n name: `${type}-${lineIndex}`,\n style: {\n data: (datum: any, ctx: any) => {\n const vchart = ctx.vchart as IVChart\n const chart = vchart.getChart() as IChart\n const s = chart.getAllSeries()[0] as ICartesianSeries\n\n if (s) {\n const rect = s.getRegion().getLayoutRect()\n const segments: {\n areaPoints?: { x: number; y: number; y1: number }[]\n linePoints: { x: number; y: number }[]\n color: string\n }[] = []\n\n if (rect.width === 0 || rect.height === 0) {\n return segments\n }\n\n const start = s.getRegion().getLayoutStartPoint()\n const yClamper = clamper(start.y, start.y + rect.height)\n const colorAttrOptions = s.getColorAttribute()\n const groups: (string | undefined)[] = s.getSeriesKeys()\n const data = s.getViewData()?.latestData as Datum[]\n const fieldX = s.fieldX?.[0]\n const fieldY = s.fieldY?.[0]\n\n if (!groups.length) {\n groups.push(undefined)\n }\n\n groups.forEach((group) => {\n const groupData = data.filter((d: Datum) => d[colorAttrOptions?.field] === group)\n\n if (!groupData.length) {\n return\n }\n const { confidenceInterval, evaluateGrid } = regressionFunction(\n groupData,\n (datum: Datum) => datum?.[fieldX],\n (datum: Datum) => datum?.[fieldY],\n getOptions?.(line),\n )\n const N = Math.max(3, Math.floor(groupData.length / 4))\n const mainColor = color ?? colorAttrOptions?.scale?.scale(group)\n\n const lineData = evaluateGrid(N)\n const linePoints = lineData.map((ld: Datum) => {\n const d = { [fieldX]: ld.x, [fieldY]: ld.y }\n return {\n x: s.dataToPositionX(d)! + start.x,\n y: yClamper(s.dataToPositionY(d)! + start.y),\n }\n })\n\n segments.push({\n color: mainColor,\n linePoints,\n })\n\n if (confidenceIntervalVisible) {\n const intervalData = confidenceInterval(N)\n const areaPoints = intervalData.map((datum: Datum) => {\n const d = { [fieldX]: datum.x, [fieldY]: datum.lower }\n return {\n x: s.dataToPositionX(d)! + start.x,\n y: yClamper(s.dataToPositionY(d)! + start.y),\n y1: yClamper(s.dataToPositionY({ [fieldY]: datum.upper })! + start.y),\n }\n })\n\n segments[segments.length - 1].areaPoints = areaPoints\n }\n })\n\n return segments\n }\n return []\n },\n },\n children: childrenMarks,\n })\n\n if (confidenceIntervalVisible) {\n childrenMarks.push({\n type: 'area',\n interactive: false,\n zIndex: 500,\n style: {\n lineWidth: lineWidth ?? theme.lineWidth,\n lineDash: lineDash ?? theme.lineDash,\n fillOpacity: confidenceIntervalOpacity ?? theme.confidenceIntervalOpacity,\n fill: 'red', // vrender bug,必须要设置一个全局的fill,才会绘制\n segments: (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data?.length) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call\n return parentNode.attribute.data.map((d: any) => {\n return {\n points: d.areaPoints ?? [],\n fill: d.color,\n }\n })\n }\n\n return []\n },\n },\n })\n }\n\n childrenMarks.push({\n type: 'line',\n interactive: false,\n zIndex: 500,\n style: {\n lineWidth: lineWidth ?? theme.lineWidth,\n lineDash: lineDash ?? theme.lineDash,\n stroke: 'red', // vrender bug,必须要设置一个全局的stroke,才会绘制\n segments: (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data?.length) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call\n return parentNode.attribute.data.map((d: any) => {\n return {\n points: d.linePoints,\n stroke: d.color,\n }\n })\n }\n\n return []\n },\n },\n })\n\n if (!isNullish(text)) {\n childrenMarks.push({\n type: 'text',\n interactive: false,\n zIndex: 500,\n style: {\n textAlign: 'end',\n fill: textColor ?? theme.textColor,\n fontSize: textFontSize ?? theme.textFontSize,\n fontWeight: textFontWeight ?? theme.textFontWeight,\n text: text,\n x: (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data?.length) {\n const point = parentNode.attribute.data[parentNode.attribute.data.length - 1].linePoints\n return point[point.length - 1]?.x\n }\n\n return undefined\n },\n y: (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data?.length) {\n const point = parentNode.attribute.data[parentNode.attribute.data.length - 1].linePoints\n return point[point.length - 1]?.y\n }\n\n return undefined\n },\n },\n })\n }\n })\n\n return result\n }) as VChartSpecPipe\n}\n\nexport const linearRegressionLine: VChartSpecPipe = generateRegressionLinePipe('linearRegressionLine', regressionLinear)\nexport const lowessRegressionLine: VChartSpecPipe = generateRegressionLinePipe('lowessRegressionLine', regressionLowess)\nexport const polynomialRegressionLine: VChartSpecPipe = generateRegressionLinePipe(\n 'polynomialRegressionLine',\n regressionPolynomial,\n (lineConfig: PolynomialRegressionLine) => {\n return { degree: lineConfig.degree ?? 2 }\n },\n)\nexport const logisticRegressionLine: VChartSpecPipe = generateRegressionLinePipe(\n 'logisticRegressionLine',\n regressionLogistic,\n)\n"],"names":["generateRegressionLinePipe","type","regressionFunction","getOptions","spec","context","result","advancedVSeed","chartType","regressionLine","lineTheme","lineList","array","line","lineIndex","theme","color","lineWidth","lineDash","text","textColor","textFontSize","textFontWeight","confidenceIntervalOpacity","confidenceIntervalVisible","childrenMarks","datum","ctx","vchart","chart","s","rect","segments","start","yClamper","clamper","colorAttrOptions","groups","data","fieldX","fieldY","undefined","group","groupData","d","confidenceInterval","evaluateGrid","N","Math","mainColor","lineData","linePoints","ld","intervalData","areaPoints","opt","parentNode","isNullish","point","linearRegressionLine","regressionLinear","lowessRegressionLine","regressionLowess","polynomialRegressionLine","regressionPolynomial","lineConfig","logisticRegressionLine","regressionLogistic"],"mappings":";;A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2BACtD,4BACAgE,sBACA,CAACC,aACQ;QAAE,QAAQA,WAAW,MAAM,IAAI;IAAE;AAGrC,MAAMC,yBAAyClE,2BACpD,0BACAmE"}
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/regressionLine/linearRegressionLine.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/regressionLine/linearRegressionLine.ts"],"sourcesContent":["import type { ICartesianSeries, IChart, IScatterChartSpec, IVChart } from '@visactor/vchart'\nimport { isNullish } from 'remeda'\nimport {\n array,\n clamper,\n regressionLinear,\n regressionLowess,\n regressionPolynomial,\n regressionLogistic,\n} from '@visactor/vutils'\nimport type {\n Datum,\n VChartSpecPipe,\n RegressionLineConfig,\n LinearRegressionLine,\n PolynomialRegressionLine,\n SpecPipelineContext,\n LogisticRegressionLine,\n LowessRegressionLine,\n} from 'src/types'\n\nexport const generateRegressionLinePipe = (\n type: 'linearRegressionLine' | 'lowessRegressionLine' | 'polynomialRegressionLine' | 'logisticRegressionLine',\n regressionFunction: (\n arr: Datum[],\n xAccessor: (d: Datum) => number,\n yAccessor: (d: Datum) => number,\n options?: any,\n ) => {\n confidenceInterval: (N: number) => { lower: number; upper: number; x: number }[]\n evaluateGrid: (N: number) => { x: number; y: number }[]\n },\n getOptions: (lineConfig: any) => any = getDefaultRegressionOptions,\n): VChartSpecPipe => {\n return ((spec: Partial<IScatterChartSpec>, context: SpecPipelineContext): Partial<IScatterChartSpec> => {\n const result = { ...spec }\n const { advancedVSeed } = context\n const { chartType, regressionLine } = advancedVSeed\n const lineTheme = advancedVSeed.config[chartType as 'scatter']?.regressionLine as RegressionLineConfig\n\n if (!regressionLine || !regressionLine[type]) {\n return result\n }\n\n const lineList = array(regressionLine[type])\n\n if (!result.customMark) {\n result.customMark = []\n }\n\n lineList.forEach((line, lineIndex) => {\n const theme = (lineTheme.linearRegressionLine ?? {}) as LinearRegressionLine\n const {\n color,\n lineWidth,\n lineDash,\n text,\n textColor,\n textFontSize,\n textFontWeight,\n confidenceIntervalOpacity,\n confidenceIntervalVisible = theme.confidenceIntervalVisible,\n } = line as LinearRegressionLine\n\n const childrenMarks: any[] = []\n\n ;(result.customMark as any[]).push({\n type: 'group',\n interactive: false,\n zIndex: 500,\n name: `${type}-${lineIndex}`,\n style: {\n data: (datum: any, ctx: any) => {\n const vchart = ctx.vchart as IVChart\n const chart = vchart.getChart() as IChart\n const s = chart.getAllSeries()[0] as ICartesianSeries\n\n if (s) {\n const rect = s.getRegion().getLayoutRect()\n const segments: {\n areaPoints?: { x: number; y: number; y1: number }[]\n linePoints: { x: number; y: number }[]\n color: string\n }[] = []\n\n if (rect.width === 0 || rect.height === 0) {\n return segments\n }\n\n const start = s.getRegion().getLayoutStartPoint()\n const yClamper = clamper(start.y, start.y + rect.height)\n const colorAttrOptions = s.getColorAttribute()\n const groups: (string | undefined)[] = s.getSeriesKeys()\n const data = s.getViewData()?.latestData as Datum[]\n const fieldX = s.fieldX?.[0]\n const fieldY = s.fieldY?.[0]\n\n if (!groups.length) {\n groups.push(undefined)\n }\n\n groups.forEach((group) => {\n const groupData = data.filter((d: Datum) => d[colorAttrOptions?.field] === group)\n\n if (!groupData.length) {\n return\n }\n const { confidenceInterval, evaluateGrid } = regressionFunction(\n groupData,\n (datum: Datum) => datum?.[fieldX],\n (datum: Datum) => datum?.[fieldY],\n getOptions?.(line),\n )\n const N = Math.max(3, Math.floor(groupData.length / 4))\n const mainColor = color ?? colorAttrOptions?.scale?.scale(group)\n\n const lineData = evaluateGrid(N)\n const linePoints = lineData.map((ld: Datum) => {\n const d = { [fieldX]: ld.x, [fieldY]: ld.y }\n return {\n x: s.dataToPositionX(d)! + start.x,\n y: yClamper(s.dataToPositionY(d)! + start.y),\n }\n })\n\n segments.push({\n color: mainColor,\n linePoints,\n })\n\n if (confidenceIntervalVisible) {\n const intervalData = confidenceInterval(N)\n const areaPoints = intervalData.map((datum: Datum) => {\n const d = { [fieldX]: datum.x, [fieldY]: datum.lower }\n return {\n x: s.dataToPositionX(d)! + start.x,\n y: yClamper(s.dataToPositionY(d)! + start.y),\n y1: yClamper(s.dataToPositionY({ [fieldY]: datum.upper })! + start.y),\n }\n })\n\n segments[segments.length - 1].areaPoints = areaPoints\n }\n })\n\n return segments\n }\n return []\n },\n },\n children: childrenMarks,\n })\n\n if (confidenceIntervalVisible) {\n childrenMarks.push({\n type: 'area',\n interactive: false,\n zIndex: 500,\n style: {\n lineWidth: lineWidth ?? theme.lineWidth,\n lineDash: lineDash ?? theme.lineDash,\n fillOpacity: confidenceIntervalOpacity ?? theme.confidenceIntervalOpacity,\n fill: 'red', // vrender bug,必须要设置一个全局的fill,才会绘制\n segments: (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data?.length) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call\n return parentNode.attribute.data.map((d: any) => {\n return {\n points: d.areaPoints ?? [],\n fill: d.color,\n }\n })\n }\n\n return []\n },\n },\n })\n }\n\n childrenMarks.push({\n type: 'line',\n interactive: false,\n zIndex: 500,\n style: {\n lineWidth: lineWidth ?? theme.lineWidth,\n lineDash: lineDash ?? theme.lineDash,\n stroke: 'red', // vrender bug,必须要设置一个全局的stroke,才会绘制\n segments: (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data?.length) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call\n return parentNode.attribute.data.map((d: any) => {\n return {\n points: d.linePoints,\n stroke: d.color,\n }\n })\n }\n\n return []\n },\n },\n })\n\n if (!isNullish(text)) {\n childrenMarks.push({\n type: 'text',\n interactive: false,\n zIndex: 500,\n style: {\n textAlign: 'end',\n fill: textColor ?? theme.textColor,\n fontSize: textFontSize ?? theme.textFontSize,\n fontWeight: textFontWeight ?? theme.textFontWeight,\n text: text,\n x: (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data?.length) {\n const point = parentNode.attribute.data[parentNode.attribute.data.length - 1].linePoints\n return point[point.length - 1]?.x\n }\n\n return undefined\n },\n y: (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data?.length) {\n const point = parentNode.attribute.data[parentNode.attribute.data.length - 1].linePoints\n return point[point.length - 1]?.y\n }\n\n return undefined\n },\n },\n })\n }\n })\n\n return result\n }) as VChartSpecPipe\n}\n\nconst getDefaultRegressionOptions = (\n lineConfig: PolynomialRegressionLine | LinearRegressionLine | LogisticRegressionLine | LowessRegressionLine,\n) => {\n return { alpha: lineConfig?.confidenceLevel ?? 0.95 }\n}\n\nexport const linearRegressionLine: VChartSpecPipe = generateRegressionLinePipe('linearRegressionLine', regressionLinear)\nexport const lowessRegressionLine: VChartSpecPipe = generateRegressionLinePipe('lowessRegressionLine', regressionLowess)\nexport const polynomialRegressionLine: VChartSpecPipe = generateRegressionLinePipe(\n 'polynomialRegressionLine',\n regressionPolynomial,\n (lineConfig: PolynomialRegressionLine) => {\n return { ...getDefaultRegressionOptions(lineConfig), degree: lineConfig.degree ?? 2 }\n },\n)\nexport const logisticRegressionLine: VChartSpecPipe = generateRegressionLinePipe(\n 'logisticRegressionLine',\n regressionLogistic,\n)\n"],"names":["generateRegressionLinePipe","type","regressionFunction","getOptions","getDefaultRegressionOptions","spec","context","result","advancedVSeed","chartType","regressionLine","lineTheme","lineList","array","line","lineIndex","theme","color","lineWidth","lineDash","text","textColor","textFontSize","textFontWeight","confidenceIntervalOpacity","confidenceIntervalVisible","childrenMarks","datum","ctx","vchart","chart","s","rect","segments","start","yClamper","clamper","colorAttrOptions","groups","data","fieldX","fieldY","undefined","group","groupData","d","confidenceInterval","evaluateGrid","N","Math","mainColor","lineData","linePoints","ld","intervalData","areaPoints","opt","parentNode","isNullish","point","lineConfig","linearRegressionLine","regressionLinear","lowessRegressionLine","regressionLowess","polynomialRegressionLine","regressionPolynom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mB;IAAK;AAG/C,MAAMC,uBAAuC7D,2BAA2B,wBAAwB8D;AAChG,MAAMC,uBAAuC/D,2BAA2B,wBAAwBgE;AAChG,MAAMC,2BAA2CjE,2BACtD,4BACAkE,sBACA,CAACN,aACQ;QAAE,GAAGxD,4BAA4BwD,WAAW;QAAE,QAAQA,WAAW,MAAM,IAAI;IAAE;AAGjF,MAAMO,yBAAyCnE,2BACpD,0BACAoE"}
|
|
@@ -4,7 +4,7 @@ export declare const createDimensionContent: (dimensions: Dimensions, measures:
|
|
|
4
4
|
visible: boolean;
|
|
5
5
|
shapeType: string;
|
|
6
6
|
hasShape: boolean;
|
|
7
|
-
key:
|
|
7
|
+
key: (v: unknown) => string;
|
|
8
8
|
value: (v: unknown) => string;
|
|
9
9
|
}[];
|
|
10
10
|
export declare const createMarkContent: (tooltip: string[], dimensions: Dimensions, measures: Measures, foldInfo: FoldInfo, unfoldInfo: UnfoldInfo) => ({
|
|
@@ -44,7 +44,11 @@ const createDimensionContent = (dimensions, measures, foldInfo, unfoldInfo)=>{
|
|
|
44
44
|
const datum = v;
|
|
45
45
|
const key = datum && datum[encodingColor] || '';
|
|
46
46
|
return unfoldInfo.colorIdMap[key].alias ?? key;
|
|
47
|
-
} :
|
|
47
|
+
} : (v)=>{
|
|
48
|
+
const datum = v;
|
|
49
|
+
const key = datum && datum[measureId] || '';
|
|
50
|
+
return foldMap[key] ?? key;
|
|
51
|
+
},
|
|
48
52
|
value: (v)=>{
|
|
49
53
|
const datum = v;
|
|
50
54
|
if (!datum) return '';
|