@visactor/vseed 0.1.51 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/builder/builder/builder.d.ts +334 -0
- 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/histogram.js +1 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/histogram.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/pipes/encoding/pie.js +8 -6
- package/dist/esm/pipeline/advanced/chart/pipes/encoding/pie.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/markStyle/markStyle.js +3 -1
- package/dist/esm/pipeline/advanced/chart/pipes/markStyle/markStyle.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/measures/buildMeasures.js +2 -1
- package/dist/esm/pipeline/advanced/chart/pipes/measures/buildMeasures.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithBoxplotEncoding.js +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithBoxplotEncoding.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithEncoding.js +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithEncoding.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithHistogramEncoding.js +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithHistogramEncoding.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/boxplot.js +6 -5
- package/dist/esm/pipeline/spec/chart/pipeline/boxplot.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/dualAxis.js +15 -13
- package/dist/esm/pipeline/spec/chart/pipeline/dualAxis.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/scatter.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/scatter.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/color/colorBoxPlotStyleFill.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/color/colorBoxPlotStyleFill.js +17 -0
- package/dist/esm/pipeline/spec/chart/pipes/color/colorBoxPlotStyleFill.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/color/index.d.ts +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/color/index.js +2 -1
- package/dist/esm/pipeline/spec/chart/pipes/crosshair/horizontalCrosshairRect.js +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/crosshair/horizontalCrosshairRect.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/crosshair/verticalCrosshairRect.js +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/crosshair/verticalCrosshairRect.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/index.d.ts +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/index.js +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/init/pivot.js +2 -2
- package/dist/esm/pipeline/spec/chart/pipes/init/pivot.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/markStyle/boxPlotStyle.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/markStyle/boxPlotStyle.js +52 -0
- package/dist/esm/pipeline/spec/chart/pipes/markStyle/boxPlotStyle.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/markStyle/index.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/markStyle/index.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipes/markStyle/outlierStyle.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/markStyle/outlierStyle.js +67 -0
- package/dist/esm/pipeline/spec/chart/pipes/markStyle/outlierStyle.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/pipeFilter/areaStyleFilter.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/pipeFilter/areaStyleFilter.js +7 -0
- package/dist/esm/pipeline/spec/chart/pipes/pipeFilter/areaStyleFilter.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/pipeFilter/barStyleFilter.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/pipeFilter/barStyleFilter.js +7 -0
- package/dist/esm/pipeline/spec/chart/pipes/pipeFilter/barStyleFilter.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/pipeFilter/index.d.ts +4 -0
- package/dist/esm/pipeline/spec/chart/pipes/pipeFilter/index.js +4 -0
- package/dist/esm/pipeline/spec/chart/pipes/pipeFilter/lineStyleFilter.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/pipeFilter/lineStyleFilter.js +7 -0
- package/dist/esm/pipeline/spec/chart/pipes/pipeFilter/lineStyleFilter.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/pipeFilter/pointStyleFilter.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/pipeFilter/pointStyleFilter.js +7 -0
- package/dist/esm/pipeline/spec/chart/pipes/pipeFilter/pointStyleFilter.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/pivotChart/dimensionLinkage.js +18 -20
- package/dist/esm/pipeline/spec/chart/pipes/pivotChart/dimensionLinkage.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotAxisStyle.js +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotAxisStyle.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotGridStyle.js +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotGridStyle.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotIndicators.js +2 -2
- package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotIndicators.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/columnRegressionLine.js +5 -3
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/columnRegressionLine.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/common.d.ts +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/common.js +2 -1
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/common.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/ecdfRegressionLine.js +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/ecdfRegressionLine.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/kdeRegressionLine.js +6 -1
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/kdeRegressionLine.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/linearRegressionLine.js +8 -3
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/linearRegressionLine.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/stack/stackCornerRadius.js +2 -3
- package/dist/esm/pipeline/spec/chart/pipes/stack/stackCornerRadius.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/index.d.ts +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/index.js +2 -2
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipDualAxis.d.ts +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipDualAxis.js +16 -2
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipDualAxis.js.map +1 -1
- package/dist/esm/pipeline/utils/measures/find.d.ts +1 -0
- package/dist/esm/pipeline/utils/measures/find.js +13 -1
- package/dist/esm/pipeline/utils/measures/find.js.map +1 -1
- package/dist/esm/theme/common/axes.js +4 -4
- package/dist/esm/theme/common/axes.js.map +1 -1
- package/dist/esm/theme/common/boxPlot.d.ts +5 -0
- package/dist/esm/theme/common/boxPlot.js +15 -0
- package/dist/esm/theme/common/boxPlot.js.map +1 -0
- package/dist/esm/theme/common/crosshair.js +4 -4
- package/dist/esm/theme/common/crosshair.js.map +1 -1
- package/dist/esm/theme/common/table.js +2 -0
- package/dist/esm/theme/common/table.js.map +1 -1
- package/dist/esm/theme/dark/dark.js +4 -1
- package/dist/esm/theme/dark/dark.js.map +1 -1
- package/dist/esm/theme/light/light.js +4 -1
- package/dist/esm/theme/light/light.js.map +1 -1
- package/dist/esm/types/advancedVSeed.d.ts +358 -0
- package/dist/esm/types/chartType/boxplot/boxplot.d.ts +9 -1
- package/dist/esm/types/chartType/boxplot/zBoxplot.d.ts +316 -0
- package/dist/esm/types/chartType/boxplot/zBoxplot.js +3 -1
- package/dist/esm/types/chartType/boxplot/zBoxplot.js.map +1 -1
- package/dist/esm/types/properties/config/boxplot.d.ts +21 -0
- package/dist/esm/types/properties/config/boxplot.js +8 -1
- package/dist/esm/types/properties/config/boxplot.js.map +1 -1
- package/dist/esm/types/properties/config/config.d.ts +21 -0
- package/dist/esm/types/properties/markStyle/boxPlotStyle.d.ts +148 -0
- package/dist/esm/types/properties/markStyle/boxPlotStyle.js +14 -0
- package/dist/esm/types/properties/markStyle/boxPlotStyle.js.map +1 -0
- package/dist/esm/types/properties/markStyle/index.d.ts +2 -0
- package/dist/esm/types/properties/markStyle/index.js +2 -0
- package/dist/esm/types/properties/markStyle/markStyle.d.ts +316 -0
- package/dist/esm/types/properties/markStyle/markStyle.js +5 -1
- package/dist/esm/types/properties/markStyle/markStyle.js.map +1 -1
- package/dist/esm/types/properties/markStyle/outlierStyle.d.ts +161 -0
- package/dist/esm/types/properties/markStyle/outlierStyle.js +22 -0
- package/dist/esm/types/properties/markStyle/outlierStyle.js.map +1 -0
- package/dist/esm/types/properties/theme/customTheme.d.ts +42 -0
- package/dist/esm/types/zVseed.d.ts +316 -0
- package/dist/umd/index.js +330 -99
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { selector } from "../../../../../dataSelector/index.js";
|
|
2
|
+
import { isEmpty, isNullish } from "remeda";
|
|
3
|
+
const outlierStyle_outlierStyle = (spec, context)=>{
|
|
4
|
+
const { advancedVSeed, vseed } = context;
|
|
5
|
+
const { markStyle, config } = advancedVSeed;
|
|
6
|
+
const { outlierStyle } = markStyle;
|
|
7
|
+
const theme = config?.[vseed.chartType]?.outlierStyle;
|
|
8
|
+
const result = {
|
|
9
|
+
...spec,
|
|
10
|
+
outlier: {
|
|
11
|
+
style: {
|
|
12
|
+
fill: theme?.pointColor
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
if (isNullish(outlierStyle) || isEmpty(outlierStyle)) return result;
|
|
17
|
+
const outlierStyles = Array.isArray(outlierStyle) ? outlierStyle : [
|
|
18
|
+
outlierStyle
|
|
19
|
+
];
|
|
20
|
+
const customMap = outlierStyles.reduce((result, style, index)=>{
|
|
21
|
+
const { pointBorderColor, pointBorderStyle, pointBorderWidth = 1, pointColor, pointColorOpacity, pointSize, pointVisible = true } = style;
|
|
22
|
+
const lineDash = 'dashed' === pointBorderStyle ? [
|
|
23
|
+
5,
|
|
24
|
+
2
|
|
25
|
+
] : 'dotted' === pointBorderStyle ? [
|
|
26
|
+
2,
|
|
27
|
+
5
|
|
28
|
+
] : [
|
|
29
|
+
0,
|
|
30
|
+
0
|
|
31
|
+
];
|
|
32
|
+
return {
|
|
33
|
+
...result,
|
|
34
|
+
[`custom${index + 1}`]: {
|
|
35
|
+
level: index + 1,
|
|
36
|
+
filter: (datum)=>{
|
|
37
|
+
if (selector(datum, style.selector)) return true;
|
|
38
|
+
return false;
|
|
39
|
+
},
|
|
40
|
+
style: {
|
|
41
|
+
visible: pointVisible,
|
|
42
|
+
size: pointSize,
|
|
43
|
+
fill: pointColor,
|
|
44
|
+
fillOpacity: pointColorOpacity,
|
|
45
|
+
innerBorder: {
|
|
46
|
+
stroke: pointBorderColor,
|
|
47
|
+
lineWidth: pointBorderWidth,
|
|
48
|
+
distance: (pointBorderWidth || 0) / 2,
|
|
49
|
+
lineDash: lineDash
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}, {});
|
|
55
|
+
return {
|
|
56
|
+
...result,
|
|
57
|
+
outlier: {
|
|
58
|
+
...result.outlier,
|
|
59
|
+
state: {
|
|
60
|
+
...customMap
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export { outlierStyle_outlierStyle as outlierStyle };
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=outlierStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/markStyle/outlierStyle.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/markStyle/outlierStyle.ts"],"sourcesContent":["import type { IBoxPlotChartSpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { Datum, OutlierStyle, VChartSpecPipe } from 'src/types'\nimport { isEmpty, isNullish } from 'remeda'\n\nexport const outlierStyle: VChartSpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const { markStyle, config } = advancedVSeed\n const { outlierStyle } = markStyle\n const theme = config?.[vseed.chartType as 'boxPlot']?.outlierStyle\n const result = {\n ...spec,\n outlier: {\n style: {\n fill: theme?.pointColor,\n },\n },\n } as IBoxPlotChartSpec\n\n if (isNullish(outlierStyle) || isEmpty(outlierStyle)) {\n return result\n }\n\n const outlierStyles = (Array.isArray(outlierStyle) ? outlierStyle : [outlierStyle]) as OutlierStyle[]\n\n const customMap = outlierStyles.reduce<object>((result, style, index) => {\n const {\n pointBorderColor,\n pointBorderStyle,\n pointBorderWidth = 1,\n pointColor,\n pointColorOpacity,\n pointSize,\n pointVisible = true,\n } = style\n\n const lineDash = pointBorderStyle === 'dashed' ? [5, 2] : pointBorderStyle === 'dotted' ? [2, 5] : [0, 0]\n return {\n ...result,\n [`custom${index + 1}`]: {\n // 优先级: 后者覆盖前者\n level: index + 1,\n filter: (datum: Datum) => {\n if (selector(datum, style.selector)) {\n return true\n }\n return false\n },\n style: {\n visible: pointVisible,\n size: pointSize,\n fill: pointColor,\n fillOpacity: pointColorOpacity,\n innerBorder: {\n stroke: pointBorderColor,\n lineWidth: pointBorderWidth,\n distance: (pointBorderWidth || 0) / 2,\n lineDash: lineDash,\n },\n },\n },\n }\n }, {})\n\n return {\n ...result,\n outlier: {\n ...result.outlier,\n state: {\n ...customMap,\n },\n },\n }\n}\n"],"names":["outlierStyle","spec","context","advancedVSeed","vseed","markStyle","config","theme","result","isNullish","isEmpty","outlierStyles","Array","customMap","style","index","pointBorderColor","pointBorderStyle","pointBorderWidth","pointColor","pointColorOpacity","pointSize","pointVisible","lineDash","datum","selector"],"mappings":";;AAKO,MAAMA,4BAA+B,CAACC,MAAMC;IACjD,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IACjC,MAAM,EAAEG,SAAS,EAAEC,MAAM,EAAE,GAAGH;IAC9B,MAAM,EAAEH,YAAY,EAAE,GAAGK;IACzB,MAAME,QAAQD,QAAQ,CAACF,MAAM,SAAS,CAAc,EAAE;IACtD,MAAMI,SAAS;QACb,GAAGP,IAAI;QACP,SAAS;YACP,OAAO;gBACL,MAAMM,OAAO;YACf;QACF;IACF;IAEA,IAAIE,UAAUT,iBAAiBU,QAAQV,eACrC,OAAOQ;IAGT,MAAMG,gBAAiBC,MAAM,OAAO,CAACZ,gBAAgBA,eAAe;QAACA;KAAa;IAElF,MAAMa,YAAYF,cAAc,MAAM,CAAS,CAACH,QAAQM,OAAOC;QAC7D,MAAM,EACJC,gBAAgB,EAChBC,gBAAgB,EAChBC,mBAAmB,CAAC,EACpBC,UAAU,EACVC,iBAAiB,EACjBC,SAAS,EACTC,eAAe,IAAI,EACpB,GAAGR;QAEJ,MAAMS,WAAWN,AAAqB,aAArBA,mBAAgC;YAAC;YAAG;SAAE,GAAGA,AAAqB,aAArBA,mBAAgC;YAAC;YAAG;SAAE,GAAG;YAAC;YAAG;SAAE;QACzG,OAAO;YACL,GAAGT,MAAM;YACT,CAAC,CAAC,MAAM,EAAEO,QAAQ,GAAG,CAAC,EAAE;gBAEtB,OAAOA,QAAQ;gBACf,QAAQ,CAACS;oBACP,IAAIC,SAASD,OAAOV,MAAM,QAAQ,GAChC,OAAO;oBAET,OAAO;gBACT;gBACA,OAAO;oBACL,SAASQ;oBACT,MAAMD;oBACN,MAAMF;oBACN,aAAaC;oBACb,aAAa;wBACX,QAAQJ;wBACR,WAAWE;wBACX,UAAWA,AAAAA,CAAAA,oBAAoB,KAAK;wBACpC,UAAUK;oBACZ;gBACF;YACF;QACF;IACF,GAAG,CAAC;IAEJ,OAAO;QACL,GAAGf,MAAM;QACT,SAAS;YACP,GAAGA,OAAO,OAAO;YACjB,OAAO;gBACL,GAAGK,SAAS;YACd;QACF;IACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/pipeFilter/areaStyleFilter.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/pipeFilter/areaStyleFilter.ts"],"sourcesContent":["import type { IAreaChartSpec } from '@visactor/vchart'\nimport type { VChartSpecPipe } from 'src/types'\n\nexport const areaStyleFilter = (pipe: VChartSpecPipe): VChartSpecPipe => {\n return (spec, context) => {\n if (spec.type === 'area') {\n return pipe(spec, context) as IAreaChartSpec\n }\n\n return spec\n }\n}\n"],"names":["areaStyleFilter","pipe","spec","context"],"mappings":"AAGO,MAAMA,kBAAkB,CAACC,OACvB,CAACC,MAAMC;QACZ,IAAID,AAAc,WAAdA,KAAK,IAAI,EACX,OAAOD,KAAKC,MAAMC;QAGpB,OAAOD;IACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/pipeFilter/barStyleFilter.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/pipeFilter/barStyleFilter.ts"],"sourcesContent":["import type { IBarChartSpec } from '@visactor/vchart'\nimport type { VChartSpecPipe } from 'src/types'\n\nexport const barStyleFilter = (pipe: VChartSpecPipe): VChartSpecPipe => {\n return (spec, context) => {\n if (spec.type === 'bar') {\n return pipe(spec, context) as IBarChartSpec\n }\n\n return spec\n }\n}\n"],"names":["barStyleFilter","pipe","spec","context"],"mappings":"AAGO,MAAMA,iBAAiB,CAACC,OACtB,CAACC,MAAMC;QACZ,IAAID,AAAc,UAAdA,KAAK,IAAI,EACX,OAAOD,KAAKC,MAAMC;QAGpB,OAAOD;IACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/pipeFilter/lineStyleFilter.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/pipeFilter/lineStyleFilter.ts"],"sourcesContent":["import type { ILineChartSpec } from '@visactor/vchart'\nimport type { VChartSpecPipe } from 'src/types'\n\nexport const lineStyleFilter = (pipe: VChartSpecPipe): VChartSpecPipe => {\n return (spec, context) => {\n if (spec.type === 'line') {\n return pipe(spec, context) as ILineChartSpec\n }\n\n return spec\n }\n}\n"],"names":["lineStyleFilter","pipe","spec","context"],"mappings":"AAGO,MAAMA,kBAAkB,CAACC,OACvB,CAACC,MAAMC;QACZ,IAAID,AAAc,WAAdA,KAAK,IAAI,EACX,OAAOD,KAAKC,MAAMC;QAGpB,OAAOD;IACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/pipeFilter/pointStyleFilter.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/pipeFilter/pointStyleFilter.ts"],"sourcesContent":["import type { ILineChartSpec } from '@visactor/vchart'\nimport type { VChartSpecPipe } from 'src/types'\n\nexport const pointStyleFilter = (pipe: VChartSpecPipe): VChartSpecPipe => {\n return (spec, context) => {\n if (spec.type === 'line' || spec.type === 'area') {\n return pipe(spec, context) as ILineChartSpec\n }\n\n return spec\n }\n}\n"],"names":["pointStyleFilter","pipe","spec","context"],"mappings":"AAGO,MAAMA,mBAAmB,CAACC,OACxB,CAACC,MAAMC;QACZ,IAAID,AAAc,WAAdA,KAAK,IAAI,IAAeA,AAAc,WAAdA,KAAK,IAAI,EACnC,OAAOD,KAAKC,MAAMC;QAGpB,OAAOD;IACT"}
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import { isNullish } from "remeda";
|
|
2
|
-
const defaultScatterFormatter = (val)=>{
|
|
3
|
-
if (isNullish(val)) return '';
|
|
4
|
-
if ('string' == typeof val) return val;
|
|
5
|
-
if (0 === val) return '0';
|
|
6
|
-
if (Math.abs(val) < 1) return val.toFixed(2);
|
|
7
|
-
return val === Math.floor(val) ? `${val}` : val.toFixed(1);
|
|
8
|
-
};
|
|
9
1
|
const dimensionLinkage = (spec, context)=>{
|
|
10
2
|
const { advancedVSeed, vseed } = context;
|
|
11
3
|
const { chartType } = vseed;
|
|
@@ -15,18 +7,24 @@ const dimensionLinkage = (spec, context)=>{
|
|
|
15
7
|
const labelHoverOnAxis = {};
|
|
16
8
|
const chartSpec = indicators?.[0]?.chartSpec;
|
|
17
9
|
const crosshair = chartSpec?.crosshair;
|
|
18
|
-
if (crosshair?.xField)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
10
|
+
if (crosshair?.xField) {
|
|
11
|
+
const labelFormat = crosshair.xField.label?.formatMethod;
|
|
12
|
+
labelHoverOnAxis.bottom = {
|
|
13
|
+
visible: config.showLabel ?? crosshair.xField.label?.visible ?? true,
|
|
14
|
+
background: crosshair.xField.label?.labelBackground,
|
|
15
|
+
textStyle: crosshair.xField.label?.style,
|
|
16
|
+
formatMethod: labelFormat ? (text)=>text || 0 === text ? labelFormat(text) : null : void 0
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (crosshair?.yField) {
|
|
20
|
+
const labelFormat = crosshair.yField.label?.formatMethod;
|
|
21
|
+
labelHoverOnAxis.left = {
|
|
22
|
+
visible: config.showLabel ?? crosshair.yField.label?.visible ?? true,
|
|
23
|
+
background: crosshair.yField.label?.labelBackground,
|
|
24
|
+
textStyle: crosshair.yField.label?.style,
|
|
25
|
+
formatMethod: labelFormat ? (text)=>text || 0 === text ? labelFormat(text) : null : void 0
|
|
26
|
+
};
|
|
27
|
+
}
|
|
30
28
|
if (indicators && indicators.length) indicators.forEach((ind)=>{
|
|
31
29
|
const crosshair = ind?.chartSpec?.crosshair;
|
|
32
30
|
if (crosshair?.xField) crosshair.xField.label = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/pivotChart/dimensionLinkage.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/pivotChart/dimensionLinkage.ts"],"sourcesContent":["import type { ICartesianCrosshairSpec, ILineChartSpec } from '@visactor/vchart'\nimport
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/pivotChart/dimensionLinkage.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/pivotChart/dimensionLinkage.ts"],"sourcesContent":["import type { ICartesianCrosshairSpec, ILineChartSpec } from '@visactor/vchart'\nimport type { DimensionLinkage, PivotChartSpecPipe } from 'src/types'\n\nexport const dimensionLinkage: PivotChartSpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n\n const config = (advancedVSeed.config?.[chartType as 'line']?.dimensionLinkage ?? {}) as DimensionLinkage\n\n if (config.enable === false) {\n return spec\n }\n\n const indicators = spec.indicators\n const labelHoverOnAxis = {}\n const chartSpec = (indicators as any)?.[0]?.chartSpec as ILineChartSpec\n const crosshair = chartSpec?.crosshair as ICartesianCrosshairSpec\n\n if (crosshair?.xField) {\n const labelFormat = crosshair.xField.label?.formatMethod\n ;(labelHoverOnAxis as any).bottom = {\n visible: config.showLabel ?? crosshair.xField.label?.visible ?? true,\n background: crosshair.xField.label?.labelBackground,\n textStyle: crosshair.xField.label?.style,\n formatMethod: labelFormat\n ? (text: string | string[] | number) => (text || text === 0 ? labelFormat(text) : null)\n : undefined,\n }\n }\n if (crosshair?.yField) {\n const labelFormat = crosshair.yField.label?.formatMethod\n ;(labelHoverOnAxis as any).left = {\n visible: config.showLabel ?? crosshair.yField.label?.visible ?? true,\n background: crosshair.yField.label?.labelBackground,\n textStyle: crosshair.yField.label?.style,\n formatMethod: labelFormat\n ? (text: string | string[] | number) => (text || text === 0 ? labelFormat(text) : null)\n : undefined,\n }\n }\n\n if (indicators && indicators.length) {\n indicators.forEach((ind) => {\n const crosshair = (ind as any)?.chartSpec?.crosshair as ICartesianCrosshairSpec\n\n if (crosshair?.xField) {\n crosshair.xField.label = { visible: false }\n }\n\n if (crosshair?.yField) {\n crosshair.yField.label = { visible: false }\n }\n })\n }\n\n spec.chartDimensionLinkage = {\n showTooltip: config.showTooltip ?? (chartSpec?.tooltip?.dimension?.visible as boolean) ?? true,\n heightLimitToShowTooltipForLastRow: 60,\n widthLimitToShowTooltipForLastColumn: 90,\n labelHoverOnAxis,\n }\n\n return spec\n}\n"],"names":["dimensionLinkage","spec","context","advancedVSeed","vseed","chartType","config","indicators","labelHoverOnAxis","chartSpec","crosshair","labelFormat","text","undefined","ind"],"mappings":"AAGO,MAAMA,mBAAuC,CAACC,MAAMC;IACzD,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IACjC,MAAM,EAAEG,SAAS,EAAE,GAAGD;IAEtB,MAAME,SAAUH,cAAc,MAAM,EAAE,CAACE,UAAoB,EAAE,oBAAoB,CAAC;IAElF,IAAIC,AAAkB,UAAlBA,OAAO,MAAM,EACf,OAAOL;IAGT,MAAMM,aAAaN,KAAK,UAAU;IA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xisStyle = (axisStyle)=>(spec, context)=>{
|
|
|
20
20
|
left: BAND_AXIS_INNER_OFFSET_IN_PIVOT,
|
|
21
21
|
right: BAND_AXIS_INNER_OFFSET_IN_PIVOT
|
|
22
22
|
};
|
|
23
|
+
} else if ('linear' === axis.type) {
|
|
24
|
+
if ('top' === axis.orient || 'bottom' === axis.orient) axis.label.flush = true;
|
|
23
25
|
}
|
|
24
26
|
});
|
|
25
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/pivotChart/pivotAxisStyle.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/pivotChart/pivotAxisStyle.ts"],"sourcesContent":["import type { ILineChartSpec } from '@visactor/vchart'\nimport { BAND_AXIS_INNER_OFFSET_IN_PIVOT } from 'src/pipeline/utils/constant'\nimport type { Config, VChartSpecPipe } from 'src/types'\n\nexport const pivotAxisStyle = (axisStyle: VChartSpecPipe): VChartSpecPipe => {\n return (spec, context) => {\n const result = axisStyle(spec, context) as ILineChartSpec\n\n if (result.axes) {\n const { advancedVSeed } = context\n const { config, chartType } = advancedVSeed\n const themConfig = (config?.[chartType] as Config['line'])?.pivotGrid ?? {}\n\n result.axes.forEach((axis: any) => {\n axis.domainLine = {\n visible: false,\n }\n\n if (themConfig.chartGridColor && axis.grid && axis.grid.visible && axis.grid.style) {\n axis.grid.style.stroke = themConfig.chartGridColor\n }\n\n if (themConfig.axisLabelColor && axis.label && axis.label.visible && axis.label.style) {\n axis.label.style.fill = themConfig.axisLabelColor\n }\n\n if (axis.type === 'band') {\n if (axis.orient === 'left' || axis.orient === 'right') {\n axis.innerOffset = {\n top: BAND_AXIS_INNER_OFFSET_IN_PIVOT,\n bottom: BAND_AXIS_INNER_OFFSET_IN_PIVOT,\n }\n } else if (axis.orient === 'top' || axis.orient === 'bottom') {\n axis.innerOffset = {\n left: BAND_AXIS_INNER_OFFSET_IN_PIVOT,\n right: BAND_AXIS_INNER_OFFSET_IN_PIVOT,\n }\n }\n }\n })\n }\n\n return result\n }\n}\n"],"names":["pivotAxisStyle","axisStyle","spec","context","result","advancedVSeed","config","chartType","themConfig","axis","BAND_AXIS_INNER_OFFSET_IN_PIVOT"],"mappings":";AAIO,MAAMA,iBAAiB,CAACC,YACtB,CAACC,MAAMC;QACZ,MAAMC,SAASH,UAAUC,MAAMC;QAE/B,IAAIC,OAAO,IAAI,EAAE;YACf,MAAM,EAAEC,aAAa,EAAE,GAAGF;YAC1B,MAAM,EAAEG,MAAM,EAAEC,SAAS,EAAE,GAAGF;YAC9B,MAAMG,aAAcF,QAAQ,CAACC,UAAU,EAAqB,aAAa,CAAC;YAE1EH,OAAO,IAAI,CAAC,OAAO,CAAC,CAACK;gBACnBA,KAAK,UAAU,GAAG;oBAChB,SAAS;gBACX;gBAEA,IAAID,WAAW,cAAc,IAAIC,KAAK,IAAI,IAAIA,KAAK,IAAI,CAAC,OAAO,IAAIA,KAAK,IAAI,CAAC,KAAK,EAChFA,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,GAAGD,WAAW,cAAc;gBAGpD,IAAIA,WAAW,cAAc,IAAIC,KAAK,KAAK,IAAIA,KAAK,KAAK,CAAC,OAAO,IAAIA,KAAK,KAAK,CAAC,KAAK,EACnFA,KAAK,KAAK,CAAC,KAAK,CAAC,IAAI,GAAGD,WAAW,cAAc;gBAGnD,IAAIC,AAAc,WAAdA,KAAK,IAAI,EACX;oBAAA,IAAIA,AAAgB,WAAhBA,KAAK,MAAM,IAAeA,AAAgB,YAAhBA,KAAK,MAAM,EACvCA,KAAK,WAAW,GAAG;wBACjB,KAAKC;wBACL,QAAQA;oBACV;yBACK,IAAID,AAAgB,UAAhBA,KAAK,MAAM,IAAcA,AAAgB,aAAhBA,KAAK,MAAM,EAC7CA,KAAK,WAAW,GAAG;wBACjB,MAAMC;wBACN,OAAOA;oBACT;gBACF;YAEJ;QACF;QAEA,
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/pivotChart/pivotAxisStyle.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/pivotChart/pivotAxisStyle.ts"],"sourcesContent":["import type { ILineChartSpec } from '@visactor/vchart'\nimport { BAND_AXIS_INNER_OFFSET_IN_PIVOT } from 'src/pipeline/utils/constant'\nimport type { Config, VChartSpecPipe } from 'src/types'\n\nexport const pivotAxisStyle = (axisStyle: VChartSpecPipe): VChartSpecPipe => {\n return (spec, context) => {\n const result = axisStyle(spec, context) as ILineChartSpec\n\n if (result.axes) {\n const { advancedVSeed } = context\n const { config, chartType } = advancedVSeed\n const themConfig = (config?.[chartType] as Config['line'])?.pivotGrid ?? {}\n\n result.axes.forEach((axis: any) => {\n axis.domainLine = {\n visible: false,\n }\n\n if (themConfig.chartGridColor && axis.grid && axis.grid.visible && axis.grid.style) {\n axis.grid.style.stroke = themConfig.chartGridColor\n }\n\n if (themConfig.axisLabelColor && axis.label && axis.label.visible && axis.label.style) {\n axis.label.style.fill = themConfig.axisLabelColor\n }\n\n if (axis.type === 'band') {\n if (axis.orient === 'left' || axis.orient === 'right') {\n axis.innerOffset = {\n top: BAND_AXIS_INNER_OFFSET_IN_PIVOT,\n bottom: BAND_AXIS_INNER_OFFSET_IN_PIVOT,\n }\n } else if (axis.orient === 'top' || axis.orient === 'bottom') {\n axis.innerOffset = {\n left: BAND_AXIS_INNER_OFFSET_IN_PIVOT,\n right: BAND_AXIS_INNER_OFFSET_IN_PIVOT,\n }\n }\n } else if (axis.type === 'linear') {\n if (axis.orient === 'top' || axis.orient === 'bottom') {\n axis.label.flush = true\n }\n }\n })\n }\n\n return result\n }\n}\n"],"names":["pivotAxisStyle","axisStyle","spec","context","result","advancedVSeed","config","chartType","themConfig","axis","BAND_AXIS_INNER_OFFSET_IN_PIVOT"],"mappings":";AAIO,MAAMA,iBAAiB,CAACC,YACtB,CAACC,MAAMC;QACZ,MAAMC,SAASH,UAAUC,MAAMC;QAE/B,IAAIC,OAAO,IAAI,EAAE;YACf,MAAM,EAAE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
0 === arg.col || noYAxis && 1 === arg.col ? outlineBorderLineWidth : 1
|
|
35
|
+
0 === arg.col || noYAxis && 1 === arg.col && arg.table.colCount <= 2 ? outlineBorderLineWidth : 1
|
|
36
36
|
];
|
|
37
37
|
},
|
|
38
38
|
bgColor: transparent,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/pivotChart/pivotGridStyle.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/pivotChart/pivotGridStyle.ts"],"sourcesContent":["import type { PivotChartConstructorOptions } from '@visactor/vtable'\nimport { isCombination, isPivot } from 'src/pipeline/utils'\nimport type { Config, PivotChartSpecPipe } from 'src/types'\nimport { isNullish } from 'remeda'\n\nexport const pivotGridStyle: PivotChartSpecPipe = (spec, context) => {\n const { vseed, advancedVSeed } = context\n const { config, chartType } = advancedVSeed\n const themConfig = (config?.[chartType] as Config['line'])?.pivotGrid ?? {}\n\n const onlyCombination = !isPivot(vseed) && isCombination(vseed)\n\n const result = { ...spec } as PivotChartConstructorOptions\n const transparent = 'rgba(0,0,0,0)'\n\n const borderColor = themConfig.borderColor ?? '#e3e5eb'\n const bodyFontColor = themConfig.bodyFontColor ?? '#141414'\n const headerFontColor = themConfig.headerFontColor ?? '#21252c'\n const headerBackgroundColor = themConfig.headerBackgroundColor ?? 'rgba(0,0,0,0)'\n const hoverHeaderBackgroundColor = onlyCombination\n ? transparent\n : (themConfig.hoverHeaderBackgroundColor ?? '#D9DDE4')\n const hoverHeaderInlineBackgroundColor = onlyCombination\n ? transparent\n : (themConfig.hoverHeaderInlineBackgroundColor ?? '#D9DDE455')\n const outlineBorderLineWidth = themConfig.outlineBorderLineWidth ?? 0\n const frameCornerRadius = themConfig.frameCornerRadius ?? 0\n\n if (!isNullish(themConfig.minChartWidth)) {\n result.defaultColWidth = themConfig.minChartWidth\n }\n\n if (!isNullish(themConfig.minChartHeight)) {\n result.defaultRowHeight = themConfig.minChartHeight\n }\n\n return {\n ...result,\n theme: {\n underlayBackgroundColor: transparent,\n bodyStyle: {\n borderColor,\n color: bodyFontColor,\n borderLineWidth: (arg: { row: number; col: number }) => {\n const noYAxis =\n chartType === 'pie' ||\n chartType === 'rose' ||\n chartType === 'donut' ||\n chartType === 'funnel' ||\n chartType === 'radar' ||\n chartType === 'roseParallel'\n\n return [\n arg.row === 0 ? outlineBorderLineWidth : 1,\n outlineBorderLineWidth,\n 0,\n arg.col === 0 || (noYAxis && arg.col === 1) ? outlineBorderLineWidth : 1,\n ]\n },\n bgColor: transparent,\n hover: {\n cellBgColor: 'transparent',\n },\n },\n headerStyle: {\n borderColor,\n fontSize: 12,\n // borderLineWidth: [outlineBorderLineWidth, outlineBorderLineWidth, 1, 1],\n borderLineWidth: (arg: { row: number; col: number }) => {\n return [outlineBorderLineWidth, outlineBorderLineWidth, 1, arg.col === 0 ? outlineBorderLineWidth : 1]\n },\n color: headerFontColor,\n textAlign: 'center',\n bgColor: headerBackgroundColor,\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n inlineRowBgColor: hoverHeaderInlineBackgroundColor || undefined,\n inlineColumnBgColor: hoverHeaderInlineBackgroundColor || undefined,\n },\n },\n rowHeaderStyle: {\n borderColor,\n fontSize: 12,\n color: headerFontColor,\n padding: [0, 12, 0, 4],\n borderLineWidth: (arg: { row: number }) => {\n return [arg.row === 0 ? outlineBorderLineWidth : 1, 1, 0, outlineBorderLineWidth]\n },\n bgColor: headerBackgroundColor,\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n inlineRowBgColor: hoverHeaderInlineBackgroundColor || undefined,\n inlineColumnBgColor: hoverHeaderInlineBackgroundColor || undefined,\n },\n },\n cornerHeaderStyle: {\n borderColor,\n textAlign: 'center',\n fontSize: 12,\n color: headerFontColor,\n padding: [0, 12, 0, 4],\n fontWeight: 'bold',\n borderLineWidth: [outlineBorderLineWidth, 1, 1, outlineBorderLineWidth],\n bgColor: headerBackgroundColor,\n frameStyle: {\n borderColor,\n },\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n inlineRowBgColor: hoverHeaderInlineBackgroundColor || undefined,\n inlineColumnBgColor: hoverHeaderInlineBackgroundColor || undefined,\n },\n },\n cornerLeftBottomCellStyle: {\n borderColor,\n borderLineWidth: [outlineBorderLineWidth, 0, outlineBorderLineWidth, outlineBorderLineWidth],\n bgColor: headerBackgroundColor,\n frameStyle: {\n borderColor,\n borderLineWidth: [1, 0, outlineBorderLineWidth, outlineBorderLineWidth],\n },\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n },\n },\n cornerRightTopCellStyle: {\n borderColor,\n borderLineWidth: [outlineBorderLineWidth, outlineBorderLineWidth, 1, 1],\n frameStyle: {\n borderColor,\n borderLineWidth: 0,\n },\n bgColor: headerBackgroundColor,\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n },\n },\n rightFrozenStyle: {\n borderColor,\n bgColor: headerBackgroundColor,\n borderLineWidth: (arg: { row: number }) => {\n return [arg.row === 0 ? outlineBorderLineWidth : 1, outlineBorderLineWidth, 0, 1]\n },\n frameStyle: {\n borderLineWidth: 0,\n },\n hover: {\n borderLineWidth: 0,\n cellBgColor: hoverHeaderBackgroundColor,\n },\n },\n cornerRightBottomCellStyle: {\n borderColor,\n bgColor: headerBackgroundColor,\n borderLineWidth: [1, outlineBorderLineWidth, outlineBorderLineWidth, 1],\n frameStyle: {\n borderColor,\n borderLineWidth: [1, outlineBorderLineWidth, outlineBorderLineWidth, 1],\n },\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n },\n },\n\n bottomFrozenStyle: {\n borderColor,\n borderLineWidth: [1, outlineBorderLineWidth, outlineBorderLineWidth, 1],\n bgColor: headerBackgroundColor,\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n },\n },\n selectionStyle: {\n cellBgColor: '',\n cellBorderColor: '',\n },\n frameStyle: {\n borderColor,\n cornerRadius: frameCornerRadius,\n borderLineWidth: outlineBorderLineWidth,\n },\n\n axisStyle: {\n leftAxisStyle: {\n cellPaddingLeft: 10,\n },\n bottomAxisStyle: {\n cellPaddingBottom: 4,\n },\n rightAxisStyle: {\n cellPaddingRight: 4,\n },\n },\n scrollStyle: {\n visible: 'scrolling',\n hoverOn: false,\n },\n },\n }\n}\n"],"names":["pivotGridStyle","spec","context","vseed","advancedVSeed","config","chartType","themConfig","onlyCombination","isPivot","isCombination","result","transparent","borderColor","bodyFontColor","headerFontColor","headerBackgroundColor","hoverHeaderBackgroundColor","hoverHeaderInlineBackgroundColor","outlineBorderLineWidth","frameCornerRadius","isNullish","arg","noYAxis","undefined"],"mappings":";;AAKO,MAAMA,iBAAqC,CAACC,MAAMC;IACvD,MAAM,EAAEC,KAAK,EAAEC,aAAa,EAAE,GAAGF;IACjC,MAAM,EAAEG,MAAM,EAAEC,SAAS,EAAE,GAAGF;IAC9B,MAAMG,aAAcF,QAAQ,CAACC,UAAU,EAAqB,aAAa,CAAC;IAE1E,MAAME,kBAAkB,CAACC,QAAQN,UAAUO,cAAcP;IAEzD,MAAMQ,SAAS;QAAE,GAAGV,IAAI;IAAC;IACzB,MAAMW,cAAc;IAEpB,MAAMC,cAAcN,WAAW,WAAW,IAAI;IAC9C,MAAMO,gBAAgBP,WAAW,aAAa,IAAI;IAClD,MAAMQ,kBAAkBR,WAAW,eAAe,IAAI;IACtD,MAAMS,wBAAwBT,WAAW,qBAAqB,IAAI;IAClE,MAAMU,6BAA6BT,kBAC/BI,cACCL,WAAW,0BAA0B,IAAI;IAC9C,MAAMW,mCAAmCV,kBACrCI,cACCL,WAAW,gCAAgC,IAAI;IACpD,MAAMY,yBAAyBZ,WAAW,sBAAsB,IAAI;IACpE,MAAMa,oBAAoBb,WAAW,iBAAiB,IAAI;IAE1D,IAAI,CAACc,UAAUd,WAAW,aAAa,GACrCI,OAAO,eAAe,GAAGJ,WAAW,aAAa;IAGnD,IAAI,CAACc,UAAUd,WAAW,cAAc,GACtCI,OAAO,gBAAgB,GAAGJ,WAAW,cAAc;IAGrD,OAAO;QAC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AAa;gBACX,SAAS;gBACT,SAAS;YACX;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/pivotChart/pivotGridStyle.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/pivotChart/pivotGridStyle.ts"],"sourcesContent":["import type { PivotChartConstructorOptions } from '@visactor/vtable'\nimport { isCombination, isPivot } from 'src/pipeline/utils'\nimport type { Config, PivotChartSpecPipe } from 'src/types'\nimport { isNullish } from 'remeda'\n\nexport const pivotGridStyle: PivotChartSpecPipe = (spec, context) => {\n const { vseed, advancedVSeed } = context\n const { config, chartType } = advancedVSeed\n const themConfig = (config?.[chartType] as Config['line'])?.pivotGrid ?? {}\n\n const onlyCombination = !isPivot(vseed) && isCombination(vseed)\n\n const result = { ...spec } as PivotChartConstructorOptions\n const transparent = 'rgba(0,0,0,0)'\n\n const borderColor = themConfig.borderColor ?? '#e3e5eb'\n const bodyFontColor = themConfig.bodyFontColor ?? '#141414'\n const headerFontColor = themConfig.headerFontColor ?? '#21252c'\n const headerBackgroundColor = themConfig.headerBackgroundColor ?? 'rgba(0,0,0,0)'\n const hoverHeaderBackgroundColor = onlyCombination\n ? transparent\n : (themConfig.hoverHeaderBackgroundColor ?? '#D9DDE4')\n const hoverHeaderInlineBackgroundColor = onlyCombination\n ? transparent\n : (themConfig.hoverHeaderInlineBackgroundColor ?? '#D9DDE455')\n const outlineBorderLineWidth = themConfig.outlineBorderLineWidth ?? 0\n const frameCornerRadius = themConfig.frameCornerRadius ?? 0\n\n if (!isNullish(themConfig.minChartWidth)) {\n result.defaultColWidth = themConfig.minChartWidth\n }\n\n if (!isNullish(themConfig.minChartHeight)) {\n result.defaultRowHeight = themConfig.minChartHeight\n }\n\n return {\n ...result,\n theme: {\n underlayBackgroundColor: transparent,\n bodyStyle: {\n borderColor,\n color: bodyFontColor,\n borderLineWidth: (arg: { row: number; col: number; table: any }) => {\n const noYAxis =\n chartType === 'pie' ||\n chartType === 'rose' ||\n chartType === 'donut' ||\n chartType === 'funnel' ||\n chartType === 'radar' ||\n chartType === 'roseParallel'\n\n return [\n arg.row === 0 ? outlineBorderLineWidth : 1,\n outlineBorderLineWidth,\n 0,\n arg.col === 0 || (noYAxis && arg.col === 1 && arg.table.colCount <= 2) ? outlineBorderLineWidth : 1,\n ]\n },\n bgColor: transparent,\n hover: {\n cellBgColor: 'transparent',\n },\n },\n headerStyle: {\n borderColor,\n fontSize: 12,\n // borderLineWidth: [outlineBorderLineWidth, outlineBorderLineWidth, 1, 1],\n borderLineWidth: (arg: { row: number; col: number }) => {\n return [outlineBorderLineWidth, outlineBorderLineWidth, 1, arg.col === 0 ? outlineBorderLineWidth : 1]\n },\n color: headerFontColor,\n textAlign: 'center',\n bgColor: headerBackgroundColor,\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n inlineRowBgColor: hoverHeaderInlineBackgroundColor || undefined,\n inlineColumnBgColor: hoverHeaderInlineBackgroundColor || undefined,\n },\n },\n rowHeaderStyle: {\n borderColor,\n fontSize: 12,\n color: headerFontColor,\n padding: [0, 12, 0, 4],\n borderLineWidth: (arg: { row: number }) => {\n return [arg.row === 0 ? outlineBorderLineWidth : 1, 1, 0, outlineBorderLineWidth]\n },\n bgColor: headerBackgroundColor,\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n inlineRowBgColor: hoverHeaderInlineBackgroundColor || undefined,\n inlineColumnBgColor: hoverHeaderInlineBackgroundColor || undefined,\n },\n },\n cornerHeaderStyle: {\n borderColor,\n textAlign: 'center',\n fontSize: 12,\n color: headerFontColor,\n padding: [0, 12, 0, 4],\n fontWeight: 'bold',\n borderLineWidth: [outlineBorderLineWidth, 1, 1, outlineBorderLineWidth],\n bgColor: headerBackgroundColor,\n frameStyle: {\n borderColor,\n },\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n inlineRowBgColor: hoverHeaderInlineBackgroundColor || undefined,\n inlineColumnBgColor: hoverHeaderInlineBackgroundColor || undefined,\n },\n },\n cornerLeftBottomCellStyle: {\n borderColor,\n borderLineWidth: [outlineBorderLineWidth, 0, outlineBorderLineWidth, outlineBorderLineWidth],\n bgColor: headerBackgroundColor,\n frameStyle: {\n borderColor,\n borderLineWidth: [1, 0, outlineBorderLineWidth, outlineBorderLineWidth],\n },\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n },\n },\n cornerRightTopCellStyle: {\n borderColor,\n borderLineWidth: [outlineBorderLineWidth, outlineBorderLineWidth, 1, 1],\n frameStyle: {\n borderColor,\n borderLineWidth: 0,\n },\n bgColor: headerBackgroundColor,\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n },\n },\n rightFrozenStyle: {\n borderColor,\n bgColor: headerBackgroundColor,\n borderLineWidth: (arg: { row: number }) => {\n return [arg.row === 0 ? outlineBorderLineWidth : 1, outlineBorderLineWidth, 0, 1]\n },\n frameStyle: {\n borderLineWidth: 0,\n },\n hover: {\n borderLineWidth: 0,\n cellBgColor: hoverHeaderBackgroundColor,\n },\n },\n cornerRightBottomCellStyle: {\n borderColor,\n bgColor: headerBackgroundColor,\n borderLineWidth: [1, outlineBorderLineWidth, outlineBorderLineWidth, 1],\n frameStyle: {\n borderColor,\n borderLineWidth: [1, outlineBorderLineWidth, outlineBorderLineWidth, 1],\n },\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n },\n },\n\n bottomFrozenStyle: {\n borderColor,\n borderLineWidth: [1, outlineBorderLineWidth, outlineBorderLineWidth, 1],\n bgColor: headerBackgroundColor,\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n },\n },\n selectionStyle: {\n cellBgColor: '',\n cellBorderColor: '',\n },\n frameStyle: {\n borderColor,\n cornerRadius: frameCornerRadius,\n borderLineWidth: outlineBorderLineWidth,\n },\n\n axisStyle: {\n leftAxisStyle: {\n cellPaddingLeft: 10,\n },\n bottomAxisStyle: {\n cellPaddingBottom: 4,\n },\n rightAxisStyle: {\n cellPaddingRight: 4,\n },\n },\n scrollStyle: {\n visible: 'scrolling',\n hoverOn: false,\n },\n },\n }\n}\n"],"names":["pivotGridStyle","spec","context","vseed","advancedVSeed","config","chartType","themConfig","onlyCombination","isPivot","isCombination","result","transparent","borderColor","bodyFontColor","headerFontColor","headerBackgroundColor","hoverHeaderBackgroundColor","hoverHeaderInlineBackgroundColor","outlineBorderLineWidth","frameCornerRadius","isNullish","arg","noYAxis","undefined"],"mappings":";;AAKO,MAAMA,iBAAqC,CAACC,MAAMC;IACvD,MAAM,EAAEC,KAAK,EAAEC,aAAa,EAAE,GAAGF;IACjC,MAAM,EAAEG,MAAM,EAAEC,SAAS,EAAE,GAAGF;IAC9B,MAAMG,aAAcF,QAAQ,CAACC,UAAU,EAAqB,aAAa,CAAC;IAE1E,MAAME,kBAAkB,CAACC,QAAQN,UAAUO,cAAcP;IAEzD,MAAMQ,SAAS;QAAE,GAAGV,IAAI;IAAC;IACzB,MAAMW,cAAc;IAEpB,MAAMC,cAAcN,WAAW,WAAW,IAAI;IAC9C,MAAMO,gBAAgBP,WAAW,aAAa,IAAI;IAClD,MAAMQ,kBAAkBR,WAAW,eAAe,IAAI;IACtD,MAAMS,wBAAwBT,WAAW,qBAAqB,IAAI;IAClE,MAAMU,6BAA6BT,kBAC/BI,cACCL,WAAW,0BAA0B,IAAI;IAC9C,MAAMW,mCAAmCV,kBACrCI,cACCL,WAAW,gCAAgC,IAAI;IACpD,MAAMY,yBAAyBZ,WAAW,sBAAsB,IAAI;IACpE,MAAMa,oBAAoBb,WAAW,iBAAiB,IAAI;IAE1D,IAAI,CAACc,UAAUd,WAAW,aAAa,GACrCI,OAAO,eAAe,GAAGJ,WAAW,aAAa;IAGnD,IAAI,CAACc,UAAUd,WAAW,cAAc,GACtCI,OAAO,gBAAgB,GAAGJ,WAAW,cAAc;IAGrD,OAAO;QACL,GAAGI,MAAM;QACT,OAAO;YACL,yBAAyBC;YACzB,WAAW;gBACTC;gBACA,OAAOC;gBACP,iBAAiB,CAACQ;oBAChB,MAAMC,UACJjB,AAAc,UAA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artPipeline)=>(spec, context)=>{
|
|
|
9
9
|
const colorItems = unique(datasetReshapeInfo.flatMap((d)=>d.unfoldInfo.colorItems));
|
|
10
10
|
const allMeasureIds = unique(datasetReshapeInfo.flatMap((d)=>Object.keys(d.foldInfo.foldMap || {})));
|
|
11
11
|
const indicators = datasetReshapeInfo.map((reshapeInfo, index)=>{
|
|
12
|
-
const measureGroup = measures?.find((d)
|
|
12
|
+
const measureGroup = measures?.find((d)=>`${d.id}` === reshapeInfo.id);
|
|
13
13
|
const subMeasuresId = (measureGroup?.children || []).map((d)=>d.id);
|
|
14
14
|
const invalideMeasuresIds = allMeasureIds.filter((id)=>!subMeasuresId.includes(id));
|
|
15
15
|
const newDataset = dataset[index];
|
|
@@ -37,7 +37,7 @@ const pivotIndicators = (chartPipeline)=>(spec, context)=>{
|
|
|
37
37
|
};
|
|
38
38
|
const chartSpec = execPipeline(chartPipeline, newContext, {});
|
|
39
39
|
return {
|
|
40
|
-
indicatorKey: reshapeInfo.id
|
|
40
|
+
indicatorKey: `${reshapeInfo.id}`,
|
|
41
41
|
title: measureGroup?.alias,
|
|
42
42
|
cellType: 'chart',
|
|
43
43
|
chartModule: 'vchart',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/pivotChart/pivotIndicators.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/pivotChart/pivotIndicators.ts"],"sourcesContent":["import type { PivotChartConstructorOptions } from '@visactor/vtable'\nimport { execPipeline } from '../../../../utils'\nimport type {\n Dataset,\n Encoding,\n MeasureGroup,\n PivotChartSpecPipe,\n SpecPipelineContext,\n VChartSpecPipe,\n} from 'src/types'\nimport { unique } from 'remeda'\n\nexport const pivotIndicators =\n (chartPipeline: VChartSpecPipe[]): PivotChartSpecPipe =>\n (spec, context): Partial<PivotChartConstructorOptions> => {\n const result = { ...spec } as PivotChartConstructorOptions\n const { advancedVSeed } = context\n const { measures, datasetReshapeInfo, dataset, encoding } = advancedVSeed\n\n const colorItems = unique(datasetReshapeInfo.flatMap((d) => d.unfoldInfo.colorItems))\n const allMeasureIds = unique(datasetReshapeInfo.flatMap((d) => Object.keys(d.foldInfo.foldMap || {})))\n\n const indicators = datasetReshapeInfo.map((reshapeInfo, index) => {\n const measureGroup = measures?.find((d) => d.id === reshapeInfo.id) as MeasureGroup\n const subMeasuresId = (measureGroup?.children || []).map((d) => d.id)\n const invalideMeasuresIds = allMeasureIds.filter((id) => !subMeasuresId.includes(id))\n\n const newDataset = dataset[index] as Dataset\n const newDatasetReshapeInfo = [\n {\n ...reshapeInfo,\n unfoldInfo: { ...reshapeInfo.unfoldInfo, colorItems },\n },\n ]\n const newContext: SpecPipelineContext = {\n ...context,\n advancedVSeed: {\n ...advancedVSeed,\n pivotAllDatasetReshapeInfo: datasetReshapeInfo,\n datasetReshapeInfo: newDatasetReshapeInfo,\n encoding: Object.keys(encoding).reduce((res, key) => {\n res[key as keyof Encoding] = encoding[key as keyof Encoding]?.filter((e) => {\n return !invalideMeasuresIds.includes(e)\n }) as string[]\n\n return res\n }, {} as Encoding),\n dataset: newDataset,\n },\n }\n\n const chartSpec = execPipeline(chartPipeline, newContext, {})\n return {\n indicatorKey: reshapeInfo.id
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/pivotChart/pivotIndicators.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/pivotChart/pivotIndicators.ts"],"sourcesContent":["import type { PivotChartConstructorOptions } from '@visactor/vtable'\nimport { execPipeline } from '../../../../utils'\nimport type {\n Dataset,\n Encoding,\n MeasureGroup,\n PivotChartSpecPipe,\n SpecPipelineContext,\n VChartSpecPipe,\n} from 'src/types'\nimport { unique } from 'remeda'\n\nexport const pivotIndicators =\n (chartPipeline: VChartSpecPipe[]): PivotChartSpecPipe =>\n (spec, context): Partial<PivotChartConstructorOptions> => {\n const result = { ...spec } as PivotChartConstructorOptions\n const { advancedVSeed } = context\n const { measures, datasetReshapeInfo, dataset, encoding } = advancedVSeed\n\n const colorItems = unique(datasetReshapeInfo.flatMap((d) => d.unfoldInfo.colorItems))\n const allMeasureIds = unique(datasetReshapeInfo.flatMap((d) => Object.keys(d.foldInfo.foldMap || {})))\n\n const indicators = datasetReshapeInfo.map((reshapeInfo, index) => {\n const measureGroup = measures?.find((d) => `${d.id}` === reshapeInfo.id) as MeasureGroup\n const subMeasuresId = (measureGroup?.children || []).map((d) => d.id)\n const invalideMeasuresIds = allMeasureIds.filter((id) => !subMeasuresId.includes(id))\n\n const newDataset = dataset[index] as Dataset\n const newDatasetReshapeInfo = [\n {\n ...reshapeInfo,\n unfoldInfo: { ...reshapeInfo.unfoldInfo, colorItems },\n },\n ]\n const newContext: SpecPipelineContext = {\n ...context,\n advancedVSeed: {\n ...advancedVSeed,\n pivotAllDatasetReshapeInfo: datasetReshapeInfo,\n datasetReshapeInfo: newDatasetReshapeInfo,\n encoding: Object.keys(encoding).reduce((res, key) => {\n res[key as keyof Encoding] = encoding[key as keyof Encoding]?.filter((e) => {\n return !invalideMeasuresIds.includes(e)\n }) as string[]\n\n return res\n }, {} as Encoding),\n dataset: newDataset,\n },\n }\n\n const chartSpec = execPipeline(chartPipeline, newContext, {})\n return {\n indicatorKey: `${reshapeInfo.id}`,\n title: measureGroup?.alias,\n cellType: 'chart',\n chartModule: 'vchart',\n chartSpec: chartSpec,\n style: {\n padding: [1, 1, 0, 1],\n },\n }\n })\n\n return {\n ...result,\n indicators: indicators,\n } as Partial<PivotChartConstructorOptions>\n }\n\nexport const pivotIndicatorsAsRow: PivotChartSpecPipe = (spec) => {\n const result = { ...spec } as PivotChartConstructorOptions\n\n return {\n ...result,\n indicatorsAsCol: false,\n }\n}\n\nexport const pivotIndicatorsAsCol: PivotChartSpecPipe = (spec) => {\n const result = { ...spec } as PivotChartConstructorOptions\n\n return {\n ...result,\n indicatorsAsCol: true,\n }\n}\n"],"names":["pivotIndicators","chartPipeline","spec","context","result","advancedVSeed","measures","datasetReshapeInfo","dataset","encoding","colorItems","unique","d","allMeasureIds","Object","indicators","reshapeInfo","index","measureGroup","subMeasuresId","invalideMeasuresIds","id","newDataset","newDatasetReshapeInfo","newContext","res","key","e","chartSpec","execPipeline","pivotIndicatorsAsRow","pivotIndicatorsAsCol"],"mappings":";;AAYO,MAAMA,kBACX,CAACC,gBACD,CAACC,MAAMC;QACL,MAAMC,SAAS;YAAE,GAAGF,IAAI;QAAC;QACzB,MAAM,EAAEG,aAAa,EAAE,GAAGF;QAC1B,MAAM,EAAEG,QAAQ,EAAEC,kBAAkB,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAGJ;QAE5D,MAAMK,aAAaC,OAAOJ,mBAAmB,OAAO,CAAC,CAACK,IAAMA,EAAE,UAAU,CAAC,UAAU;QACnF,MAAMC,gBAAgBF,OAAOJ,mBAAmB,OAAO,CAAC,CAACK,IAAME,OAAO,IAAI,CAACF,EAAE,QAAQ,CAAC,OAAO,IAAI,CAAC;QAElG,MAAMG,aAAaR,mBAAmB,GAAG,CAAC,CAACS,aAAaC;YACtD,MAAMC,eAAeZ,UAAU,KAAK,CAACM,IAAM,GAAGA,EAAE,EAAE,EAAE,KAAKI,YAAY,EAAE;YACvE,MAAMG,gBAAiBD,AAAAA,CAAAA,cAAc,YAAY,EAAC,EAAG,GAAG,CAAC,CAACN,IAAMA,EAAE,EAAE;YACpE,MAAMQ,sBAAsBP,cAAc,MAAM,CAAC,CAACQ,KAAO,CAACF,cAAc,QAAQ,CAACE;YAEjF,MAAMC,aAAad,OAAO,CAACS,MAAM;YACjC,MAAMM,wBAAwB;gBAC5B;oBACE,GAAGP,WAAW;oBACd,YAAY;wBAAE,GAAGA,YAAY,UAAU;wBAAEN;oBAAW;gBACtD;aACD;YACD,MAAMc,aAAkC;gBACtC,GAAGrB,OAAO;gBACV,eAAe;oBACb,GAAGE,aAAa;oBAChB,4BAA4BE;oBAC5B,oBAAoBgB;oBACpB,UAAUT,OAAO,IAAI,CAACL,UAAU,MAAM,CAAC,CAACgB,KAAKC;wBAC3CD,GAAG,CAACC,IAAsB,GAAGjB,QAAQ,CAACiB,IAAsB,EAAE,OAAO,CAACC,IAC7D,CAACP,oBAAoB,QAAQ,CAACO;wBAGvC,OAAOF;oBACT,GAAG,CAAC;oBACJ,SAASH;gBACX;YACF;YAEA,MAAMM,YAAYC,aAAa5B,eAAeuB,YAAY,CAAC;YAC3D,OAAO;gBACL,cAAc,GAAGR,YAAY,EAAE,EAAE;gBACjC,OAAOE,cAAc;gBACrB,UAAU;gBACV,aAAa;gBACb,WAAWU;gBACX,OAAO;oBACL,SAAS;wBAAC;wBAAG;wBAAG;wBAAG;qBAAE;gBACvB;YACF;QACF;QAEA,OAAO;YACL,GAAGxB,MAAM;YACT,YAAYW;QACd;IACF;AAEK,MAAMe,uBAA2C,CAAC5B;IACvD,MAAME,SAAS;QAAE,GAAGF,IAAI;IAAC;IAEzB,OAAO;QACL,GAAGE,MAAM;QACT,iBAAiB;IACnB;AACF;AAEO,MAAM2B,uBAA2C,CAAC7B;IACvD,MAAME,SAAS;QAAE,GAAGF,IAAI;IAAC;IAEzB,OAAO;QACL,GAAGE,MAAM;QACT,iBAAiB;IACnB;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isNullish } from "remeda";
|
|
2
2
|
import { array, clamper, regressionPolynomial } from "@visactor/vutils";
|
|
3
|
-
import { defaultRegressionLineColor } from "./common.js";
|
|
3
|
+
import { defaultRegressionLineColor, getAlphaByConfidenceLevel } from "./common.js";
|
|
4
4
|
const columnPolynomialRegressionLine = (spec, context)=>{
|
|
5
5
|
const result = {
|
|
6
6
|
...spec
|
|
@@ -14,7 +14,7 @@ const columnPolynomialRegressionLine = (spec, context)=>{
|
|
|
14
14
|
lineList.forEach((line, lineIndex)=>{
|
|
15
15
|
if (false === line.enable) return;
|
|
16
16
|
const theme = lineTheme.linearRegressionLine ?? {};
|
|
17
|
-
const { color, lineWidth, lineDash, text, textColor, textFontSize, textFontWeight, confidenceIntervalOpacity, confidenceIntervalVisible = theme.confidenceIntervalVisible } = line;
|
|
17
|
+
const { color, lineWidth, lineDash, text, textColor, textFontSize, textFontWeight, confidenceIntervalOpacity, confidenceLevel = 0.95, confidenceIntervalVisible = theme.confidenceIntervalVisible } = line;
|
|
18
18
|
const childrenMarks = [];
|
|
19
19
|
result.extensionMark.push({
|
|
20
20
|
type: 'group',
|
|
@@ -43,7 +43,8 @@ const columnPolynomialRegressionLine = (spec, context)=>{
|
|
|
43
43
|
y: Math.max(...filteredData.map((d)=>d[fieldY]))
|
|
44
44
|
};
|
|
45
45
|
}), void 0, void 0, {
|
|
46
|
-
degree: line.degree ?? 2
|
|
46
|
+
degree: line.degree ?? 2,
|
|
47
|
+
alpha: getAlphaByConfidenceLevel(confidenceLevel)
|
|
47
48
|
});
|
|
48
49
|
const N = xValues.length;
|
|
49
50
|
const xAxisHelper = s.getXAxisHelper();
|
|
@@ -124,6 +125,7 @@ const columnPolynomialRegressionLine = (spec, context)=>{
|
|
|
124
125
|
interactive: false,
|
|
125
126
|
zIndex: 500,
|
|
126
127
|
dataId: spec.data?.id,
|
|
128
|
+
dataKey: ()=>`polynomialRegressionLine-label-${lineIndex}`,
|
|
127
129
|
style: {
|
|
128
130
|
textAlign: 'end',
|
|
129
131
|
fill: textColor ?? theme.textColor,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/regressionLine/columnRegressionLine.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/regressionLine/columnRegressionLine.ts"],"sourcesContent":["import type { IBarChartSpec, ICartesianSeries, IChart, IVChart } from '@visactor/vchart'\nimport { isNullish } from 'remeda'\nimport { array, clamper, regressionPolynomial } from '@visactor/vutils'\nimport type {\n Datum,\n VChartSpecPipe,\n RegressionLineConfig,\n LinearRegressionLine,\n PolynomialRegressionLine,\n} from 'src/types'\nimport { defaultRegressionLineColor } from './common'\n\nexport const columnPolynomialRegressionLine: VChartSpecPipe = (spec, context): Partial<IBarChartSpec> => {\n const result = { ...spec } as Partial<IBarChartSpec>\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.polynomialRegressionLine) {\n return result\n }\n\n const lineList = array(regressionLine.polynomialRegressionLine)\n\n if (!result.extensionMark) {\n result.extensionMark = []\n }\n\n lineList.forEach((line, lineIndex) => {\n if (line.enable === false) {\n return\n }\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.extensionMark as any[]).push({\n type: 'group',\n interactive: false,\n zIndex: 500,\n name: `polynomialRegressionLine-${lineIndex}`,\n dataId: (spec.data as any)?.id,\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\n if (rect.width === 0 || rect.height === 0) {\n return null\n }\n\n const yClamper = clamper(0, 0 + rect.height)\n const data = s.getViewData()?.latestData as Datum[]\n const fieldX = s.fieldX?.[0]\n const fieldY = s.fieldY?.[0]\n const xValues = s.getRawDataStatisticsByField(fieldX).values as string[]\n\n if (!fieldX || !fieldY || !data || data.length <= 2 || xValues.length <= 2) {\n return null\n }\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const { confidenceInterval, evaluateGrid } = regressionPolynomial(\n xValues.map((xVal, index: number) => {\n const filteredData = data.filter((d) => d[fieldX] === xVal)\n\n return {\n x: index,\n y: Math.max(...filteredData.map((d) => d[fieldY] as number)),\n }\n }),\n undefined,\n undefined,\n {\n degree: (line as PolynomialRegressionLine).degree ?? 2,\n },\n )\n const N = xValues.length\n const xAxisHelper = s.getXAxisHelper()\n const halfBandWidth = xAxisHelper ? xAxisHelper.getBandwidth!(0) / 2 : 0\n const lineData = evaluateGrid(N)\n const linePoints = lineData.map((datum: Datum, index: number) => {\n const d = { [fieldX]: xValues[index], [fieldY]: datum.y }\n return {\n x: s.dataToPositionX(d)! + halfBandWidth,\n y: yClamper(s.dataToPositionY(d)!),\n }\n })\n const result: {\n linePoints: { x: number; y: number }[]\n areaPoints?: { x: number; y: number; y1: number }[]\n color: string\n } = {\n linePoints,\n color: s.getOption().globalScale.getScale('color')?.scale(s.getSeriesKeys()[0]),\n }\n\n if (confidenceIntervalVisible) {\n const intervalData = confidenceInterval(N)\n\n result.areaPoints = intervalData.map((datum: Datum, index: number) => {\n const d = { [fieldX]: xValues[index], [fieldY]: datum.lower }\n return {\n x: s.dataToPositionX(d)! + halfBandWidth,\n y: yClamper(s.dataToPositionY(d)!),\n y1: yClamper(s.dataToPositionY({ [fieldY]: datum.upper })!),\n }\n })\n }\n\n return result\n }\n return null\n },\n },\n children: childrenMarks,\n })\n\n if (confidenceIntervalVisible) {\n childrenMarks.push({\n type: 'area',\n interactive: false,\n zIndex: 500,\n dataId: (spec.data as any)?.id,\n style: {\n lineWidth: lineWidth ?? theme.lineWidth,\n lineDash: lineDash ?? theme.lineDash,\n fillOpacity: confidenceIntervalOpacity ?? theme.confidenceIntervalOpacity,\n fill: 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.areaPoints\n }\n\n return []\n },\n },\n })\n }\n\n childrenMarks.push({\n type: 'line',\n interactive: false,\n zIndex: 500,\n dataId: (spec.data as any)?.id,\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 dataId: (spec.data as any)?.id,\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?.linePoints) {\n const points = parentNode.attribute.data.linePoints\n return points[points.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?.linePoints) {\n const points = parentNode.attribute.data.linePoints\n return points[points.length - 1]?.y\n }\n\n return undefined\n },\n },\n })\n }\n })\n\n return result\n}\n"],"names":["columnPolynomialRegressionLine","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","yClamper","clamper","data","fieldX","fieldY","xValues","confidenceInterval","evaluateGrid","regressionPolynomial","xVal","index","filteredData","d","Math","undefined","N","xAxisHelper","halfBandWidth","lineData","linePoints","intervalData","defaultRegressionLineColor","opt","parentNode","isNullish","points"],"mappings":";;;AAYO,MAAMA,iCAAiD,CAACC,MAAMC;IACnE,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAE,GAAGF;IAC1B,MAAM,EAAEG,SAAS,EAAEC,cAAc,EAAE,GAAGF;IACtC,MAAMG,YAAYH,cAAc,MAAM,CAACC,UAAuB,EAAE;IAEhE,IAAI,CAACC,kBAAkB,C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,SAAS;gBAClC,UAAUM,gBAAgBN,MAAM,YAAY;gBAC5C,YAAYO,kBAAkBP,MAAM,cAAc;gBAClD,MAAMI;gBACN,GAAG,CAACO,OAAYC,KAAU2B;oBACxB,MAAMC,aAAaD,IAAI,IAAI,EAAE,UAAU;oBAEvC,IAAIC,YAAY,WAAW,MAAM,YAAY;wBAC3C,MAAME,SAASF,WAAW,SAAS,CAAC,IAAI,CAAC,UAAU;wBACnD,OAAOE,MAAM,CAACA,OAAO,MAAM,GAAG,EAAE,EAAE;oBACpC;gBAGF;gBACA,GAAG,CAAC/B,OAAYC,KAAU2B;oBACxB,MAAMC,aAAaD,IAAI,IAAI,EAAE,UAAU;oBAEvC,IAAIC,YAAY,WAAW,MAAM,YAAY;wBAC3C,MAAME,SAASF,WAAW,SAAS,CAAC,IAAI,CAAC,UAAU;wBACnD,OAAOE,MAAM,CAACA,OAAO,MAAM,GAAG,EAAE,EAAE;oBACpC;gBAGF;YACF;QACF;IAEJ;IAEA,OAAOnD;AACT"}
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/regressionLine/columnRegressionLine.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/regressionLine/columnRegressionLine.ts"],"sourcesContent":["import type { IBarChartSpec, ICartesianSeries, IChart, IVChart } from '@visactor/vchart'\nimport { isNullish } from 'remeda'\nimport { array, clamper, regressionPolynomial } from '@visactor/vutils'\nimport type {\n Datum,\n VChartSpecPipe,\n RegressionLineConfig,\n LinearRegressionLine,\n PolynomialRegressionLine,\n} from 'src/types'\nimport { defaultRegressionLineColor, getAlphaByConfidenceLevel } from './common'\n\nexport const columnPolynomialRegressionLine: VChartSpecPipe = (spec, context): Partial<IBarChartSpec> => {\n const result = { ...spec } as Partial<IBarChartSpec>\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.polynomialRegressionLine) {\n return result\n }\n\n const lineList = array(regressionLine.polynomialRegressionLine)\n\n if (!result.extensionMark) {\n result.extensionMark = []\n }\n\n lineList.forEach((line, lineIndex) => {\n if (line.enable === false) {\n return\n }\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 confidenceLevel = 0.95,\n confidenceIntervalVisible = theme.confidenceIntervalVisible,\n } = line as LinearRegressionLine\n\n const childrenMarks: any[] = []\n\n ;(result.extensionMark as any[]).push({\n type: 'group',\n interactive: false,\n zIndex: 500,\n name: `polynomialRegressionLine-${lineIndex}`,\n dataId: (spec.data as any)?.id,\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\n if (rect.width === 0 || rect.height === 0) {\n return null\n }\n\n const yClamper = clamper(0, 0 + rect.height)\n const data = s.getViewData()?.latestData as Datum[]\n const fieldX = s.fieldX?.[0]\n const fieldY = s.fieldY?.[0]\n const xValues = s.getRawDataStatisticsByField(fieldX).values as string[]\n\n if (!fieldX || !fieldY || !data || data.length <= 2 || xValues.length <= 2) {\n return null\n }\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const { confidenceInterval, evaluateGrid } = regressionPolynomial(\n xValues.map((xVal, index: number) => {\n const filteredData = data.filter((d) => d[fieldX] === xVal)\n\n return {\n x: index,\n y: Math.max(...filteredData.map((d) => d[fieldY] as number)),\n }\n }),\n undefined,\n undefined,\n {\n degree: (line as PolynomialRegressionLine).degree ?? 2,\n alpha: getAlphaByConfidenceLevel(confidenceLevel),\n },\n )\n const N = xValues.length\n const xAxisHelper = s.getXAxisHelper()\n const halfBandWidth = xAxisHelper ? xAxisHelper.getBandwidth!(0) / 2 : 0\n const lineData = evaluateGrid(N)\n const linePoints = lineData.map((datum: Datum, index: number) => {\n const d = { [fieldX]: xValues[index], [fieldY]: datum.y }\n return {\n x: s.dataToPositionX(d)! + halfBandWidth,\n y: yClamper(s.dataToPositionY(d)!),\n }\n })\n const result: {\n linePoints: { x: number; y: number }[]\n areaPoints?: { x: number; y: number; y1: number }[]\n color: string\n } = {\n linePoints,\n color: s.getOption().globalScale.getScale('color')?.scale(s.getSeriesKeys()[0]),\n }\n\n if (confidenceIntervalVisible) {\n const intervalData = confidenceInterval(N)\n\n result.areaPoints = intervalData.map((datum: Datum, index: number) => {\n const d = { [fieldX]: xValues[index], [fieldY]: datum.lower }\n return {\n x: s.dataToPositionX(d)! + halfBandWidth,\n y: yClamper(s.dataToPositionY(d)!),\n y1: yClamper(s.dataToPositionY({ [fieldY]: datum.upper })!),\n }\n })\n }\n\n return result\n }\n return null\n },\n },\n children: childrenMarks,\n })\n\n if (confidenceIntervalVisible) {\n childrenMarks.push({\n type: 'area',\n interactive: false,\n zIndex: 500,\n dataId: (spec.data as any)?.id,\n style: {\n lineWidth: lineWidth ?? theme.lineWidth,\n lineDash: lineDash ?? theme.lineDash,\n fillOpacity: confidenceIntervalOpacity ?? theme.confidenceIntervalOpacity,\n fill: 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.areaPoints\n }\n\n return []\n },\n },\n })\n }\n\n childrenMarks.push({\n type: 'line',\n interactive: false,\n zIndex: 500,\n dataId: (spec.data as any)?.id,\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 dataId: (spec.data as any)?.id,\n dataKey: () => {\n return `polynomialRegressionLine-label-${lineIndex}`\n },\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?.linePoints) {\n const points = parentNode.attribute.data.linePoints\n return points[points.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?.linePoints) {\n const points = parentNode.attribute.data.linePoints\n return points[points.length - 1]?.y\n }\n\n return undefined\n },\n },\n })\n }\n })\n\n return result\n}\n"],"names":["columnPolynomialRegressionLine","spec","context","result","advancedVSeed","chartType","regressionLine","lineTheme","lineList","array","line","lineIndex","theme","color","lineWidth","lineDash","text","textColor","textFontSize","textFontWeight","confidenceIntervalOpacity","confidenceLevel","confidenceIntervalVisible","childrenMarks","datum","ctx","vchart","chart","s","rect","yClamper","clamper","data","fieldX","fieldY","xValues","confidenceInterval","evaluateGrid","regressionPolynomial","xVal","index","filteredData","d","Math","undefined","getAlphaByConfidenceLevel","N","xAxisHelper","halfBandWidth","lineData","linePoints","intervalData","defaultRegressionLineColor","opt","parentNode","isNullish","points"],"mappings":";;;AAYO,MAAMA,iCAAiD,CAACC,MAAMC;IACnE,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAE,GAAGF;IAC1B,MAAM,EAAEG,SAAS,EAAEC,cAAc,EAAE,GAAGF;IACtC,MAAMG,YAAYH,cAAc,MAAM,CAACC,UAAuB,EAAE;IAEhE,IAAI,CAACC,kBAAkB,CAACA,eAAe,wBAAwB,EAC7D,OAAOH;IAGT,MAAM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AEtD,OAAO;gBACL,WAAW;gBACX,MAAMM,aAAaL,MAAM,SAAS;gBAClC,UAAUM,gBAAgBN,MAAM,YAAY;gBAC5C,YAAYO,kBAAkBP,MAAM,cAAc;gBAClD,MAAMI;gBACN,GAAG,CAACQ,OAAYC,KAAU4B;oBACxB,MAAMC,aAAaD,IAAI,IAAI,EAAE,UAAU;oBAEvC,IAAIC,YAAY,WAAW,MAAM,YAAY;wBAC3C,MAAME,SAASF,WAAW,SAAS,CAAC,IAAI,CAAC,UAAU;wBACnD,OAAOE,MAAM,CAACA,OAAO,MAAM,GAAG,EAAE,EAAE;oBACpC;gBAGF;gBACA,GAAG,CAAChC,OAAYC,KAAU4B;oBACxB,MAAMC,aAAaD,IAAI,IAAI,EAAE,UAAU;oBAEvC,IAAIC,YAAY,WAAW,MAAM,YAAY;wBAC3C,MAAME,SAASF,WAAW,SAAS,CAAC,IAAI,CAAC,UAAU;wBACnD,OAAOE,MAAM,CAACA,OAAO,MAAM,GAAG,EAAE,EAAE;oBACpC;gBAGF;YACF;QACF;IAEJ;IAEA,OAAOrD;AACT"}
|
|
@@ -2,3 +2,4 @@ import type { Datum } from '@visactor/vchart';
|
|
|
2
2
|
export declare const defaultRegressionLineColor: (datum: Datum, ctx: any, opt: any) => string | undefined;
|
|
3
3
|
export declare const defaultRegressionLineLabelX: (datum: any, ctx: any, opt: any) => any;
|
|
4
4
|
export declare const defaultRegressionLineLabelY: (datum: any, ctx: any, opt: any) => any;
|
|
5
|
+
export declare const getAlphaByConfidenceLevel: (confidenceLevel?: number) => number;
|
|
@@ -16,6 +16,7 @@ const defaultRegressionLineLabelY = (datum, ctx, opt)=>{
|
|
|
16
16
|
return points[points.length - 1]?.y;
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
const getAlphaByConfidenceLevel = (confidenceLevel = 0.95)=>1 - Math.max(Math.min(1, confidenceLevel), 0);
|
|
20
|
+
export { defaultRegressionLineColor, defaultRegressionLineLabelX, defaultRegressionLineLabelY, getAlphaByConfidenceLevel };
|
|
20
21
|
|
|
21
22
|
//# sourceMappingURL=common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/regressionLine/common.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/regressionLine/common.ts"],"sourcesContent":["import type { Datum } from '@visactor/vchart'\n\nexport const defaultRegressionLineColor = (datum: Datum, ctx: any, opt: any): string | undefined => {\n const parentNode = opt.mark?._product?.parent\n if (parentNode?.attribute?.data) {\n return parentNode.attribute.data.color\n }\n return undefined\n}\n\nexport const defaultRegressionLineLabelX = (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data?.linePoints) {\n const points = parentNode.attribute.data.linePoints\n return points[points.length - 1]?.x\n }\n\n return undefined\n}\n\nexport const defaultRegressionLineLabelY = (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data?.linePoints) {\n const points = parentNode.attribute.data.linePoints\n return points[points.length - 1]?.y\n }\n\n return undefined\n}\n"],"names":["defaultRegressionLineColor","datum","ctx","opt","parentNode","defaultRegressionLineLabelX","points","defaultRegressionLineLabelY"],"mappings":"AAEO,MAAMA,6BAA6B,CAACC,OAAcC,KAAUC;IACjE,MAAMC,aAAaD,IAAI,IAAI,EAAE,UAAU;IACvC,IAAIC,YAAY,WAAW,MACzB,OAAOA,WAAW,SAAS,CAAC,IAAI,CAAC,KAAK;AAG1C;AAEO,MAAMC,8BAA8B,CAACJ,OAAYC,KAAUC;IAChE,MAAMC,aAAaD,IAAI,IAAI,EAAE,UAAU;IAEvC,IAAIC,YAAY,WAAW,MAAM,YAAY;QAC3C,MAAME,SAASF,WAAW,SAAS,CAAC,IAAI,CAAC,UAAU;QACnD,OAAOE,MAAM,CAACA,OAAO,MAAM,GAAG,EAAE,EAAE;IACpC;AAGF;AAEO,MAAMC,8BAA8B,CAACN,OAAYC,KAAUC;IAChE,MAAMC,aAAaD,IAAI,IAAI,EAAE,UAAU;IAEvC,IAAIC,YAAY,WAAW,MAAM,YAAY;QAC3C,MAAME,SAASF,WAAW,SAAS,CAAC,IAAI,CAAC,UAAU;QACnD,OAAOE,MAAM,CAACA,OAAO,MAAM,GAAG,EAAE,EAAE;IACpC;AAGF"}
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/regressionLine/common.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/regressionLine/common.ts"],"sourcesContent":["import type { Datum } from '@visactor/vchart'\n\nexport const defaultRegressionLineColor = (datum: Datum, ctx: any, opt: any): string | undefined => {\n const parentNode = opt.mark?._product?.parent\n if (parentNode?.attribute?.data) {\n return parentNode.attribute.data.color\n }\n return undefined\n}\n\nexport const defaultRegressionLineLabelX = (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data?.linePoints) {\n const points = parentNode.attribute.data.linePoints\n return points[points.length - 1]?.x\n }\n\n return undefined\n}\n\nexport const defaultRegressionLineLabelY = (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data?.linePoints) {\n const points = parentNode.attribute.data.linePoints\n return points[points.length - 1]?.y\n }\n\n return undefined\n}\n\nexport const getAlphaByConfidenceLevel = (confidenceLevel: number = 0.95) => {\n return 1 - Math.max(Math.min(1, confidenceLevel), 0)\n}\n"],"names":["defaultRegressionLineColor","datum","ctx","opt","parentNode","defaultRegressionLineLabelX","points","defaultRegressionLineLabelY","getAlphaByConfidenceLevel","confidenceLevel","Math"],"mappings":"AAEO,MAAMA,6BAA6B,CAACC,OAAcC,KAAUC;IACjE,MAAMC,aAAaD,IAAI,IAAI,EAAE,UAAU;IACvC,IAAIC,YAAY,WAAW,MACzB,OAAOA,WAAW,SAAS,CAAC,IAAI,CAAC,KAAK;AAG1C;AAEO,MAAMC,8BAA8B,CAACJ,OAAYC,KAAUC;IAChE,MAAMC,aAAaD,IAAI,IAAI,EAAE,UAAU;IAEvC,IAAIC,YAAY,WAAW,MAAM,YAAY;QAC3C,MAAME,SAASF,WAAW,SAAS,CAAC,IAAI,CAAC,UAAU;QACnD,OAAOE,MAAM,CAACA,OAAO,MAAM,GAAG,EAAE,EAAE;IACpC;AAGF;AAEO,MAAMC,8BAA8B,CAACN,OAAYC,KAAUC;IAChE,MAAMC,aAAaD,IAAI,IAAI,EAAE,UAAU;IAEvC,IAAIC,YAAY,WAAW,MAAM,YAAY;QAC3C,MAAME,SAASF,WAAW,SAAS,CAAC,IAAI,CAAC,UAAU;QACnD,OAAOE,MAAM,CAACA,OAAO,MAAM,GAAG,EAAE,EAAE;IACpC;AAGF;AAEO,MAAME,4BAA4B,CAACC,kBAA0B,IAAI,GAC/D,IAAIC,KAAK,GAAG,CAACA,KAAK,GAAG,CAAC,GAAGD,kBAAkB"}
|
|
@@ -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, 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.extensionMark) {\n result.extensionMark = []\n }\n\n lineList.forEach((line, lineIndex) => {\n if (line.enable === false) {\n return\n }\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.extensionMark as any[]).push({\n type: 'group',\n interactive: false,\n zIndex: 500,\n name: `ecdfRegressionLine-${lineIndex}`,\n dataId: (spec.data as any)?.id,\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\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)!,\n y: scaleR(ld.y as number),\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 dataId: (spec.data as any)?.id,\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 dataId: (spec.data as any)?.id,\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","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,aAAa,EACvBA,OAAO,aAAa,GAAG,EAAE;IAG3Ba,SAAS,OAAO,CAAC,CAACG,MAAMC;QACtB,IAAID,AAAgB,UAAhBA,KAAK,MAAM,EACb;QAEF,MAAME,QAASV,WAAW,sBAAsB,CAAC;QACjD,MAAM,EAAEW,KAAK,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,SAAS,EAAEC,YAAY,EAAEC,cAAc,EAAE,GAAGT;QAEtF,MAAMU,gBAAuB,EAAE;QAE7B1B,OAAO,aAAa,CAAW,IAAI,CAAC;YACpC,MAAM;YACN,aAAa;YACb,QAAQ;YACR,MAAM,CAAC,mBAAmB,EAAEiB,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AChB,SAAS;QACT,QAAQ;QACR,MAAM;QACN,MAAM;QACN,KAAK;QACL,KAAK;QACL,YAAY;YACV,GAAGyD,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,MAAMpC,OAAOqC,QAAQD,KAAKA,CAAC,CAAC,EAAE,GAAGA;gBACjC,OAAO,GAAI,CAAQ,MAAPpC,IAAS,EAAG,OAAO,CAAC,GAAG,CAAC,CAAC;YACvC;QACF;IACF;IAGF,OAAOtB;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.extensionMark) {\n result.extensionMark = []\n }\n\n lineList.forEach((line, lineIndex) => {\n if (line.enable === false) {\n return\n }\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.extensionMark as any[]).push({\n type: 'group',\n interactive: false,\n zIndex: 500,\n name: `ecdfRegressionLine-${lineIndex}`,\n dataId: (spec.data as any)?.id,\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\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)!,\n y: scaleR(ld.y as number),\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 dataId: (spec.data as any)?.id,\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 dataId: (spec.data as any)?.id,\n dataKey: () => {\n return `ecdfRegressionLine-label-${lineIndex}`\n },\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","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,aAAa,EACvBA,OAAO,aAAa,GAAG,EAAE;IAG3Ba,SAAS,OAAO,CAAC,CAACG,MAAMC;QACtB,IAAID,AAAgB,UAAhBA,KAAK,MAAM,EACb;QAEF,MAAME,QAASV,WAAW,sBAAsB,CAAC;QACjD,MAAM,EAAEW,KAAK,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,SAAS,EAAEC,YAAY,EAAEC,cAAc,EAAE,GAAGT;QAEtF,MAAMU,gBAAuB,EAAE;QAE7B1B,OAAO,aAAa,CAAW,IAAI,CAAC;YACpC,MAAM;YACN,aAAa;YACb,QAAQ;YACR,MAAM,CAAC,mBAAmB,EAAEiB,WAAW;YACvC,QAASnB,KAAK,IAAI,EAAU;YAC5B,OAAO;gBACL,MAAM,CAAC6B,OA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MAAM;QACN,MAAM;QACN,KAAK;QACL,KAAK;QACL,YAAY;YACV,GAAGyD,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,MAAMpC,OAAOqC,QAAQD,KAAKA,CAAC,CAAC,EAAE,GAAGA;gBACjC,OAAO,GAAI,CAAQ,MAAPpC,IAAS,EAAG,OAAO,CAAC,GAAG,CAAC,CAAC;YACvC;QACF;IACF;IAGF,OAAOtB;AACT"}
|
|
@@ -10,6 +10,7 @@ const kdeRegressionLine = (spec, context)=>{
|
|
|
10
10
|
const { chartType, encoding = {}, dimensions, regressionLine } = advancedVSeed;
|
|
11
11
|
const { dataset } = vseed;
|
|
12
12
|
const lineTheme = advancedVSeed.config[chartType]?.regressionLine;
|
|
13
|
+
const binValueType = advancedVSeed.config[chartType]?.binValueType;
|
|
13
14
|
if (!regressionLine || !regressionLine.kdeRegressionLine) return result;
|
|
14
15
|
const rowColumnFields = uniqueBy(dimensions.filter((dim)=>'row' === dim.encoding || 'column' === dim.encoding), (item)=>item.id);
|
|
15
16
|
const lineList = array(regressionLine.kdeRegressionLine).filter((kdeLine)=>false !== kdeLine.enable);
|
|
@@ -42,7 +43,10 @@ const kdeRegressionLine = (spec, context)=>{
|
|
|
42
43
|
});
|
|
43
44
|
const N = Math.max(3, Math.floor(simpleData.length / 4));
|
|
44
45
|
const lineData = res.evaluateGrid(N);
|
|
45
|
-
const scaleR = (k)=>
|
|
46
|
+
const scaleR = (k)=>{
|
|
47
|
+
if ('percentage' === binValueType) return scaleY.scale(k * res.bandwidth);
|
|
48
|
+
return scaleY.scale(k * simpleData.length * res.bandwidth);
|
|
49
|
+
};
|
|
46
50
|
const linePoints = lineData.map((ld)=>{
|
|
47
51
|
const d = {
|
|
48
52
|
[fieldX]: ld.x
|
|
@@ -83,6 +87,7 @@ const kdeRegressionLine = (spec, context)=>{
|
|
|
83
87
|
interactive: false,
|
|
84
88
|
zIndex: 500,
|
|
85
89
|
dataId: spec.data?.id,
|
|
90
|
+
dataKey: ()=>`kdeRegressionLine-label-${lineIndex}`,
|
|
86
91
|
style: {
|
|
87
92
|
textAlign: 'end',
|
|
88
93
|
fill: textColor ?? theme.textColor,
|