@visactor/vseed 0.1.39 → 0.1.41
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 +3028 -286
- package/dist/esm/pipeline/advanced/chart/pipeline/column.js +3 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/column.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/scatter.js +3 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/scatter.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/regressionLine/regressionLine.js +28 -1
- package/dist/esm/pipeline/advanced/chart/pipes/regressionLine/regressionLine.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithBoxplotEncoding.js +0 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithBoxplotEncoding.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/column.js +5 -3
- package/dist/esm/pipeline/spec/chart/pipeline/column.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/histogram.js +5 -3
- package/dist/esm/pipeline/spec/chart/pipeline/histogram.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/scatter.js +9 -3
- package/dist/esm/pipeline/spec/chart/pipeline/scatter.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/init/pivot.js +7 -2
- package/dist/esm/pipeline/spec/chart/pipes/init/pivot.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotGridStyle.js +3 -0
- package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotGridStyle.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/columnRegressionLine.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/columnRegressionLine.js +150 -0
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/columnRegressionLine.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/common.d.ts +4 -0
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/common.js +21 -0
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/common.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/ecdfRegressionLine.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/ecdfRegressionLine.js +98 -0
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/ecdfRegressionLine.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/index.d.ts +4 -1
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/index.js +4 -1
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/kdeRegressionLine.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/kdeRegressionLine.js +98 -0
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/kdeRegressionLine.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/linearRegressionLine.d.ts +16 -0
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/linearRegressionLine.js +159 -0
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/linearRegressionLine.js.map +1 -0
- package/dist/esm/theme/common/regressionLine.d.ts +8 -4
- package/dist/esm/theme/common/regressionLine.js +60 -8
- package/dist/esm/theme/common/regressionLine.js.map +1 -1
- package/dist/esm/theme/dark/dark.js +6 -4
- package/dist/esm/theme/dark/dark.js.map +1 -1
- package/dist/esm/theme/light/light.js +6 -4
- package/dist/esm/theme/light/light.js.map +1 -1
- package/dist/esm/types/advancedVSeed.d.ts +988 -37
- package/dist/esm/types/advancedVSeed.js +2 -2
- package/dist/esm/types/advancedVSeed.js.map +1 -1
- package/dist/esm/types/chartType/column/column.d.ts +6 -1
- package/dist/esm/types/chartType/column/zColumn.d.ts +25 -0
- package/dist/esm/types/chartType/column/zColumn.js +2 -1
- package/dist/esm/types/chartType/column/zColumn.js.map +1 -1
- package/dist/esm/types/chartType/histogram/histogram.d.ts +7 -3
- package/dist/esm/types/chartType/histogram/zHistogram.d.ts +19 -4
- package/dist/esm/types/chartType/histogram/zHistogram.js +3 -2
- package/dist/esm/types/chartType/histogram/zHistogram.js.map +1 -1
- package/dist/esm/types/chartType/scatter/scatter.d.ts +21 -1
- package/dist/esm/types/chartType/scatter/zScatter.d.ts +94 -0
- package/dist/esm/types/chartType/scatter/zScatter.js +5 -1
- package/dist/esm/types/chartType/scatter/zScatter.js.map +1 -1
- package/dist/esm/types/properties/config/area.d.ts +4 -0
- package/dist/esm/types/properties/config/bar.d.ts +6 -0
- package/dist/esm/types/properties/config/boxplot.d.ts +2 -0
- package/dist/esm/types/properties/config/column.d.ts +138 -2
- package/dist/esm/types/properties/config/column.js +6 -3
- package/dist/esm/types/properties/config/column.js.map +1 -1
- package/dist/esm/types/properties/config/config.d.ts +429 -9
- package/dist/esm/types/properties/config/dualAxis.d.ts +2 -0
- package/dist/esm/types/properties/config/funnel.d.ts +2 -0
- package/dist/esm/types/properties/config/heatmap.d.ts +2 -0
- package/dist/esm/types/properties/config/histogram.d.ts +131 -9
- package/dist/esm/types/properties/config/histogram.js +2 -2
- package/dist/esm/types/properties/config/histogram.js.map +1 -1
- package/dist/esm/types/properties/config/line.d.ts +2 -0
- package/dist/esm/types/properties/config/pie.d.ts +6 -0
- package/dist/esm/types/properties/config/pivotGrid/pivotGrid.d.ts +2 -0
- package/dist/esm/types/properties/config/pivotGrid/pivotGrid.js +3 -1
- package/dist/esm/types/properties/config/pivotGrid/pivotGrid.js.map +1 -1
- package/dist/esm/types/properties/config/rose.d.ts +4 -0
- package/dist/esm/types/properties/config/scatter.d.ts +132 -0
- package/dist/esm/types/properties/config/scatter.js +3 -1
- package/dist/esm/types/properties/config/scatter.js.map +1 -1
- package/dist/esm/types/properties/regressionLine/{histogramRegressionLine.d.ts → ecdfRegressionLine.d.ts} +2 -7
- package/dist/esm/types/properties/regressionLine/index.d.ts +7 -2
- package/dist/esm/types/properties/regressionLine/index.js +1 -1
- package/dist/esm/types/properties/regressionLine/kdeRegressionLine.d.ts +40 -0
- package/dist/esm/types/properties/regressionLine/kdeRegressionLine.js +0 -0
- package/dist/esm/types/properties/regressionLine/linearRegressionLine.d.ts +53 -0
- package/dist/esm/types/properties/regressionLine/linearRegressionLine.js +0 -0
- package/dist/esm/types/properties/regressionLine/logisticRegressionLine.d.ts +53 -0
- package/dist/esm/types/properties/regressionLine/logisticRegressionLine.js +0 -0
- package/dist/esm/types/properties/regressionLine/lowessRegressionLine.d.ts +53 -0
- package/dist/esm/types/properties/regressionLine/lowessRegressionLine.js +0 -0
- package/dist/esm/types/properties/regressionLine/polynomialRegressionLine.d.ts +57 -0
- package/dist/esm/types/properties/regressionLine/polynomialRegressionLine.js +0 -0
- package/dist/esm/types/properties/regressionLine/zRegressionLine.d.ts +199 -0
- package/dist/esm/types/properties/regressionLine/zRegressionLine.js +32 -0
- package/dist/esm/types/properties/regressionLine/zRegressionLine.js.map +1 -0
- package/dist/esm/types/properties/theme/customTheme.d.ts +858 -18
- package/dist/esm/types/zVseed.d.ts +138 -4
- package/dist/umd/index.js +1156 -134
- package/dist/umd/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/histogramRegressionLine.d.ts +0 -2
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/histogramRegressionLine.js +0 -126
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/histogramRegressionLine.js.map +0 -1
- package/dist/esm/types/properties/regressionLine/zHistogramRegressionLine.d.ts +0 -11
- package/dist/esm/types/properties/regressionLine/zHistogramRegressionLine.js +0 -17
- package/dist/esm/types/properties/regressionLine/zHistogramRegressionLine.js.map +0 -1
- /package/dist/esm/types/properties/regressionLine/{histogramRegressionLine.js → ecdfRegressionLine.js} +0 -0
package/dist/umd/index.js
CHANGED
|
@@ -85,11 +85,11 @@
|
|
|
85
85
|
isRadar: ()=>isRadar,
|
|
86
86
|
zSortLegend: ()=>zSortLegend,
|
|
87
87
|
pivotTableAdvancedPipeline: ()=>pivotTableAdvancedPipeline,
|
|
88
|
+
zLogisticRegressionLine: ()=>zLogisticRegressionLine,
|
|
88
89
|
zAnnotationHorizontalLine: ()=>zAnnotationHorizontalLine,
|
|
89
90
|
zYLinearAxis: ()=>zYLinearAxis,
|
|
90
91
|
zMarkStyle: ()=>zMarkStyle,
|
|
91
92
|
registerFunnel: ()=>registerFunnel,
|
|
92
|
-
zHistogramRegressionLine: ()=>zHistogramRegressionLine,
|
|
93
93
|
columnAdvancedPipeline: ()=>columnAdvancedPipeline,
|
|
94
94
|
zLabel: ()=>zLabel,
|
|
95
95
|
registerColumn: ()=>registerColumn,
|
|
@@ -138,6 +138,7 @@
|
|
|
138
138
|
registerAll: ()=>registerAll,
|
|
139
139
|
isVChart: ()=>isVChart,
|
|
140
140
|
registerBar: ()=>registerBar,
|
|
141
|
+
zPolynomialRegressionLine: ()=>zPolynomialRegressionLine,
|
|
141
142
|
zColor: ()=>zColor,
|
|
142
143
|
registerDonut: ()=>registerDonut,
|
|
143
144
|
BinStartMeasureId: ()=>BinStartMeasureId,
|
|
@@ -172,6 +173,7 @@
|
|
|
172
173
|
areaPercentAdvancedPipeline: ()=>areaPercentAdvancedPipeline,
|
|
173
174
|
zBackgroundColor: ()=>zBackgroundColor,
|
|
174
175
|
zAreaPercentConfig: ()=>zAreaPercentConfig,
|
|
176
|
+
zLowessRegressionLine: ()=>zLowessRegressionLine,
|
|
175
177
|
registerRadar: ()=>registerRadar,
|
|
176
178
|
zMeasure: ()=>zMeasure,
|
|
177
179
|
zLocale: ()=>zLocale,
|
|
@@ -193,6 +195,7 @@
|
|
|
193
195
|
isPivotTable: ()=>isPivotTable,
|
|
194
196
|
registerPie: ()=>registerPie,
|
|
195
197
|
zDimensionEncoding: ()=>zDimensionEncoding,
|
|
198
|
+
zEcdfRegressionLine: ()=>zEcdfRegressionLine,
|
|
196
199
|
zBarParallelConfig: ()=>zBarParallelConfig,
|
|
197
200
|
lineAdvancedPipeline: ()=>lineAdvancedPipeline,
|
|
198
201
|
FoldMeasureValue: ()=>FoldMeasureValue,
|
|
@@ -216,10 +219,12 @@
|
|
|
216
219
|
findFirstMeasure: ()=>findFirstMeasure,
|
|
217
220
|
scatterAdvancedPipeline: ()=>scatterAdvancedPipeline,
|
|
218
221
|
zFunnelTransform: ()=>zFunnelTransform,
|
|
222
|
+
zLinearRegressionLine: ()=>zLinearRegressionLine,
|
|
219
223
|
zRoseConfig: ()=>zRoseConfig,
|
|
220
224
|
zScatterMeasures: ()=>zScatterMeasures,
|
|
221
225
|
zAnnotation: ()=>zAnnotation,
|
|
222
226
|
selector: ()=>selector_selector,
|
|
227
|
+
zKdeRegressionLine: ()=>zKdeRegressionLine,
|
|
223
228
|
isMeasures: ()=>isMeasures,
|
|
224
229
|
zYBandAxis: ()=>zYBandAxis,
|
|
225
230
|
BinPercentageMeasureId: ()=>BinPercentageMeasureId,
|
|
@@ -232,6 +237,7 @@
|
|
|
232
237
|
registerHistogram: ()=>registerHistogram,
|
|
233
238
|
zRoseParallel: ()=>zRoseParallel,
|
|
234
239
|
MeasureName: ()=>MeasureName,
|
|
240
|
+
zRegressionLine: ()=>zRegressionLine,
|
|
235
241
|
zNumFormat: ()=>zNumFormat,
|
|
236
242
|
FoldYMeasureValue: ()=>FoldYMeasureValue,
|
|
237
243
|
zPivotTableConfig: ()=>zPivotTableConfig,
|
|
@@ -425,7 +431,7 @@
|
|
|
425
431
|
function C(t, ...o) {
|
|
426
432
|
let n = t, u = o.map((e)=>"lazy" in e ? chunk_3GOCSNFN_y(e) : void 0), p = 0;
|
|
427
433
|
for(; p < o.length;){
|
|
428
|
-
if (void 0 === u[p] || !
|
|
434
|
+
if (void 0 === u[p] || !chunk_3GOCSNFN_B(n)) {
|
|
429
435
|
let i = o[p];
|
|
430
436
|
n = i(n), p += 1;
|
|
431
437
|
continue;
|
|
@@ -467,7 +473,7 @@
|
|
|
467
473
|
items: []
|
|
468
474
|
});
|
|
469
475
|
}
|
|
470
|
-
function
|
|
476
|
+
function chunk_3GOCSNFN_B(t) {
|
|
471
477
|
return "string" == typeof t || "object" == typeof t && null !== t && Symbol.iterator in t;
|
|
472
478
|
}
|
|
473
479
|
function chunk_LFJW7BOT_y(t, i) {
|
|
@@ -2395,7 +2401,7 @@
|
|
|
2395
2401
|
if (chunk_BZNENX2T_r(obj)) return C(obj, chunk_3ZJAREUD_i((value)=>replaceNullToUndefined(value)));
|
|
2396
2402
|
return obj;
|
|
2397
2403
|
};
|
|
2398
|
-
const
|
|
2404
|
+
const line_lineConfig = (advancedVSeed, context)=>{
|
|
2399
2405
|
const { vseed } = context;
|
|
2400
2406
|
const { chartType } = vseed;
|
|
2401
2407
|
const result = {
|
|
@@ -2472,7 +2478,7 @@
|
|
|
2472
2478
|
]),
|
|
2473
2479
|
sortXBandAxis,
|
|
2474
2480
|
sortLegend_sortLegend,
|
|
2475
|
-
|
|
2481
|
+
line_lineConfig,
|
|
2476
2482
|
theme_theme,
|
|
2477
2483
|
markStyle_markStyle,
|
|
2478
2484
|
annotation_annotation
|
|
@@ -3981,9 +3987,14 @@
|
|
|
3981
3987
|
columns: [],
|
|
3982
3988
|
indicators: [],
|
|
3983
3989
|
records: [],
|
|
3984
|
-
widthMode: '
|
|
3990
|
+
widthMode: 'standard',
|
|
3991
|
+
autoFillWidth: true,
|
|
3985
3992
|
defaultHeaderColWidth: 'auto',
|
|
3986
|
-
|
|
3993
|
+
defaultColWidth: 200,
|
|
3994
|
+
heightMode: 'standard',
|
|
3995
|
+
autoFillHeight: true,
|
|
3996
|
+
defaultRowHeight: 100,
|
|
3997
|
+
defaultHeaderRowHeight: 'auto',
|
|
3987
3998
|
indicatorsAsCol: false,
|
|
3988
3999
|
select: {
|
|
3989
4000
|
highlightMode: 'cell',
|
|
@@ -4022,6 +4033,8 @@
|
|
|
4022
4033
|
const hoverHeaderInlineBackgroundColor = onlyCombination ? transparent : themConfig.hoverHeaderInlineBackgroundColor ?? '#D9DDE455';
|
|
4023
4034
|
const outlineBorderLineWidth = themConfig.outlineBorderLineWidth ?? 0;
|
|
4024
4035
|
const frameCornerRadius = themConfig.frameCornerRadius ?? 0;
|
|
4036
|
+
if (!chunk_JK3VNB42_n(themConfig.minChartWidth)) result.defaultColWidth = themConfig.minChartWidth;
|
|
4037
|
+
if (!chunk_JK3VNB42_n(themConfig.minChartHeight)) result.defaultRowHeight = themConfig.minChartHeight;
|
|
4025
4038
|
return {
|
|
4026
4039
|
...result,
|
|
4027
4040
|
theme: {
|
|
@@ -4673,6 +4686,38 @@
|
|
|
4673
4686
|
};
|
|
4674
4687
|
return result;
|
|
4675
4688
|
};
|
|
4689
|
+
const regressionLine_regressionLine = (advancedVSeed, context)=>{
|
|
4690
|
+
const { vseed } = context;
|
|
4691
|
+
let keys = [];
|
|
4692
|
+
if ('histogram' === vseed.chartType) keys = [
|
|
4693
|
+
'kdeRegressionLine',
|
|
4694
|
+
'ecdfRegressionLine'
|
|
4695
|
+
];
|
|
4696
|
+
else if ('scatter' === vseed.chartType) keys = [
|
|
4697
|
+
'linearRegressionLine',
|
|
4698
|
+
'lowessRegressionLine',
|
|
4699
|
+
'polynomialRegressionLine',
|
|
4700
|
+
'logisticRegressionLine'
|
|
4701
|
+
];
|
|
4702
|
+
else if ('column' === vseed.chartType) keys = [
|
|
4703
|
+
'polynomialRegressionLine'
|
|
4704
|
+
];
|
|
4705
|
+
if (keys.length) {
|
|
4706
|
+
const regressionLineConfig = {};
|
|
4707
|
+
let hasLine = false;
|
|
4708
|
+
keys.forEach((key)=>{
|
|
4709
|
+
if (vseed[key]) {
|
|
4710
|
+
hasLine = true;
|
|
4711
|
+
regressionLineConfig[key] = true === vseed[key] ? {} : vseed[key];
|
|
4712
|
+
}
|
|
4713
|
+
});
|
|
4714
|
+
return hasLine ? {
|
|
4715
|
+
...advancedVSeed,
|
|
4716
|
+
regressionLine: regressionLineConfig
|
|
4717
|
+
} : advancedVSeed;
|
|
4718
|
+
}
|
|
4719
|
+
return advancedVSeed;
|
|
4720
|
+
};
|
|
4676
4721
|
const columnAdvancedPipeline = [
|
|
4677
4722
|
initAdvancedVSeed_initAdvancedVSeed,
|
|
4678
4723
|
default_defaultMeasures_defaultMeasures,
|
|
@@ -4701,7 +4746,8 @@
|
|
|
4701
4746
|
columnConfig,
|
|
4702
4747
|
theme_theme,
|
|
4703
4748
|
markStyle_markStyle,
|
|
4704
|
-
annotation_annotation
|
|
4749
|
+
annotation_annotation,
|
|
4750
|
+
regressionLine_regressionLine
|
|
4705
4751
|
];
|
|
4706
4752
|
const initColumn = (spec, context)=>{
|
|
4707
4753
|
const result = {
|
|
@@ -5024,6 +5070,454 @@
|
|
|
5024
5070
|
markArea: markArea
|
|
5025
5071
|
};
|
|
5026
5072
|
};
|
|
5073
|
+
const isType_isType = (value, type)=>Object.prototype.toString.call(value) === `[object ${type}]`;
|
|
5074
|
+
const isType = isType_isType;
|
|
5075
|
+
const isArray_isArray = (value)=>Array.isArray ? Array.isArray(value) : isType(value, "Array");
|
|
5076
|
+
const common_isArray = isArray_isArray;
|
|
5077
|
+
const isValid = (value)=>null != value;
|
|
5078
|
+
const common_isValid = isValid;
|
|
5079
|
+
function array_array(arr) {
|
|
5080
|
+
return common_isValid(arr) ? common_isArray(arr) ? arr : [
|
|
5081
|
+
arr
|
|
5082
|
+
] : [];
|
|
5083
|
+
}
|
|
5084
|
+
function clamper(a, b) {
|
|
5085
|
+
let t;
|
|
5086
|
+
return a > b && (t = a, a = b, b = t), (x)=>Math.max(a, Math.min(b, x));
|
|
5087
|
+
}
|
|
5088
|
+
const isNil = (value)=>null == value;
|
|
5089
|
+
const common_isNil = isNil;
|
|
5090
|
+
function invNorm(p) {
|
|
5091
|
+
if (p <= 0 || p >= 1) return 0;
|
|
5092
|
+
const c1 = -0.00778489400243029, c2 = -0.322396458041136, c3 = -2.40075827716184, c4 = -2.54973253934373, c5 = 4.37466414146497, c6 = 2.93816398269878, d1 = .00778469570904146, d2 = .32246712907004, d3 = 2.445134137143, d4 = 3.75440866190742;
|
|
5093
|
+
let q, r;
|
|
5094
|
+
return p < .02425 ? (q = Math.sqrt(-2 * Math.log(p)), (((((c1 * q + c2) * q + c3) * q + c4) * q + c5) * q + c6) / ((((d1 * q + d2) * q + d3) * q + d4) * q + 1)) : p <= .97575 ? (q = p - .5, r = q * q, (((((-39.6968302866538 * r + 220.946098424521) * r - 275.928510446969) * r + 138.357751867269) * r - 30.6647980661472) * r + 2.50662827745924) * q / (((((-54.4760987982241 * r + 161.585836858041) * r - 155.698979859887) * r + 66.8013118877197) * r - 13.2806815528857) * r + 1)) : (q = Math.sqrt(-2 * Math.log(1 - p)), -(((((c1 * q + c2) * q + c3) * q + c4) * q + c5) * q + c6) / ((((d1 * q + d2) * q + d3) * q + d4) * q + 1));
|
|
5095
|
+
}
|
|
5096
|
+
function computeLinearCIComponents(data, x, y, predict) {
|
|
5097
|
+
let min = 1 / 0, max = -1 / 0, n = 0, sumX = 0;
|
|
5098
|
+
for(let i = 0; i < data.length; i++){
|
|
5099
|
+
const d = data[i];
|
|
5100
|
+
let dx = x(d), dy = y(d);
|
|
5101
|
+
!common_isNil(dx) && (dx *= 1) >= dx && !common_isNil(dy) && (dy *= 1) >= dy && (dx < min && (min = dx), dx > max && (max = dx), n++, sumX += dx);
|
|
5102
|
+
}
|
|
5103
|
+
if (0 === n) return {
|
|
5104
|
+
min: min,
|
|
5105
|
+
max: max,
|
|
5106
|
+
n: n,
|
|
5107
|
+
X: 0,
|
|
5108
|
+
SSE: 0,
|
|
5109
|
+
Sxx: 0
|
|
5110
|
+
};
|
|
5111
|
+
const X = sumX / n;
|
|
5112
|
+
let SSE = 0, Sxx = 0;
|
|
5113
|
+
for(let i = 0; i < data.length; i++){
|
|
5114
|
+
const d = data[i];
|
|
5115
|
+
let dx = x(d), dy = y(d);
|
|
5116
|
+
if (!common_isNil(dx) && (dx *= 1) >= dx && !common_isNil(dy) && (dy *= 1) >= dy) {
|
|
5117
|
+
const r = dy - predict(dx);
|
|
5118
|
+
SSE += r * r;
|
|
5119
|
+
const dxc = dx - X;
|
|
5120
|
+
Sxx += dxc * dxc;
|
|
5121
|
+
}
|
|
5122
|
+
}
|
|
5123
|
+
return {
|
|
5124
|
+
min: min,
|
|
5125
|
+
max: max,
|
|
5126
|
+
n: n,
|
|
5127
|
+
X: X,
|
|
5128
|
+
SSE: SSE,
|
|
5129
|
+
Sxx: Sxx
|
|
5130
|
+
};
|
|
5131
|
+
}
|
|
5132
|
+
function stdErrorsAt(px, comps) {
|
|
5133
|
+
const { n: n, X: X, Sxx: Sxx, SSE: SSE } = comps, s2 = n > 2 ? SSE / (n - 2) : 0;
|
|
5134
|
+
return {
|
|
5135
|
+
seMean: Sxx > 0 ? Math.sqrt(s2 * (1 / n + (px - X) * (px - X) / Sxx)) : Math.sqrt(s2 / n),
|
|
5136
|
+
sePred: Math.sqrt(s2 * (1 + 1 / n + (Sxx > 0 ? (px - X) * (px - X) / Sxx : 0)))
|
|
5137
|
+
};
|
|
5138
|
+
}
|
|
5139
|
+
function ordinaryLeastSquares(uX, uY, uXY, uX2) {
|
|
5140
|
+
const denom = uX2 - uX * uX;
|
|
5141
|
+
if (Math.abs(denom) < Number.EPSILON) return {
|
|
5142
|
+
a: uY,
|
|
5143
|
+
b: 0
|
|
5144
|
+
};
|
|
5145
|
+
const b = (uXY - uX * uY) / denom;
|
|
5146
|
+
return {
|
|
5147
|
+
a: uY - b * uX,
|
|
5148
|
+
b: b
|
|
5149
|
+
};
|
|
5150
|
+
}
|
|
5151
|
+
function visitPoints(data, x, y, callback) {
|
|
5152
|
+
for(let i = 0; i < data.length; i++){
|
|
5153
|
+
const d = data[i];
|
|
5154
|
+
let xi = x(d), yi = y(d);
|
|
5155
|
+
!common_isNil(xi) && (xi *= 1) >= xi && !common_isNil(yi) && (yi *= 1) >= yi && callback(xi, yi, i);
|
|
5156
|
+
}
|
|
5157
|
+
}
|
|
5158
|
+
function rSquared(data, x, y, uY, predict) {
|
|
5159
|
+
let ssr = 0, sst = 0;
|
|
5160
|
+
for(let i = 0; i < data.length; i++){
|
|
5161
|
+
const d = data[i];
|
|
5162
|
+
let yi = y(d);
|
|
5163
|
+
if (!common_isNil(yi) && (yi *= 1) >= yi) {
|
|
5164
|
+
const r = yi - predict(x(d));
|
|
5165
|
+
ssr += r * r;
|
|
5166
|
+
const t = yi - uY;
|
|
5167
|
+
sst += t * t;
|
|
5168
|
+
}
|
|
5169
|
+
}
|
|
5170
|
+
return 0 === sst ? 0 : 1 - ssr / sst;
|
|
5171
|
+
}
|
|
5172
|
+
function regressionLinear(data, x = (d)=>d.x, y = (d)=>d.y) {
|
|
5173
|
+
let n = 0, meanX = 0, meanY = 0, meanXY = 0, meanX2 = 0;
|
|
5174
|
+
visitPoints(data, x, y, (xi, yi)=>{
|
|
5175
|
+
n++, meanX += (xi - meanX) / n, meanY += (yi - meanY) / n, meanXY += (xi * yi - meanXY) / n, meanX2 += (xi * xi - meanX2) / n;
|
|
5176
|
+
});
|
|
5177
|
+
const { a: a, b: b } = ordinaryLeastSquares(meanX, meanY, meanXY, meanX2), predict = (xx)=>a + b * xx, comps = computeLinearCIComponents(data, x, y, predict);
|
|
5178
|
+
return {
|
|
5179
|
+
coef: {
|
|
5180
|
+
a: a,
|
|
5181
|
+
b: b
|
|
5182
|
+
},
|
|
5183
|
+
predict: predict,
|
|
5184
|
+
rSquared: rSquared(data, x, y, meanY, predict),
|
|
5185
|
+
evaluateGrid: function(N) {
|
|
5186
|
+
const out = [];
|
|
5187
|
+
if (0 === comps.n || N <= 0) return out;
|
|
5188
|
+
if (comps.min === comps.max) {
|
|
5189
|
+
for(let i = 0; i < N; i++)out.push({
|
|
5190
|
+
x: comps.min,
|
|
5191
|
+
y: predict(comps.min)
|
|
5192
|
+
});
|
|
5193
|
+
return out;
|
|
5194
|
+
}
|
|
5195
|
+
const step = (comps.max - comps.min) / (N - 1);
|
|
5196
|
+
for(let i = 0; i < N; i++){
|
|
5197
|
+
const px = i === N - 1 ? comps.max : comps.min + step * i;
|
|
5198
|
+
out.push({
|
|
5199
|
+
x: px,
|
|
5200
|
+
y: predict(px)
|
|
5201
|
+
});
|
|
5202
|
+
}
|
|
5203
|
+
return out;
|
|
5204
|
+
},
|
|
5205
|
+
confidenceInterval: function(N = 50, alpha = .05) {
|
|
5206
|
+
const out = [];
|
|
5207
|
+
if (0 === comps.n || N <= 0) return out;
|
|
5208
|
+
const z = invNorm(1 - alpha / 2);
|
|
5209
|
+
if (comps.min === comps.max) {
|
|
5210
|
+
const m = predict(comps.min), errs = stdErrorsAt(comps.min, comps);
|
|
5211
|
+
for(let i = 0; i < N; i++)out.push({
|
|
5212
|
+
x: comps.min,
|
|
5213
|
+
mean: m,
|
|
5214
|
+
lower: m - z * errs.seMean,
|
|
5215
|
+
upper: m + z * errs.seMean,
|
|
5216
|
+
predLower: m - z * errs.sePred,
|
|
5217
|
+
predUpper: m + z * errs.sePred
|
|
5218
|
+
});
|
|
5219
|
+
return out;
|
|
5220
|
+
}
|
|
5221
|
+
const step = (comps.max - comps.min) / (N - 1);
|
|
5222
|
+
for(let i = 0; i < N; i++){
|
|
5223
|
+
const px = i === N - 1 ? comps.max : comps.min + step * i, m = predict(px), errs = stdErrorsAt(px, comps);
|
|
5224
|
+
out.push({
|
|
5225
|
+
x: px,
|
|
5226
|
+
mean: m,
|
|
5227
|
+
lower: m - z * errs.seMean,
|
|
5228
|
+
upper: m + z * errs.seMean,
|
|
5229
|
+
predLower: m - z * errs.sePred,
|
|
5230
|
+
predUpper: m + z * errs.sePred
|
|
5231
|
+
});
|
|
5232
|
+
}
|
|
5233
|
+
return out;
|
|
5234
|
+
}
|
|
5235
|
+
};
|
|
5236
|
+
}
|
|
5237
|
+
function solveLinearSystem(A, b) {
|
|
5238
|
+
const n = b.length, M = new Array(n);
|
|
5239
|
+
for(let i = 0; i < n; i++)M[i] = A[i].slice(), M[i].push(b[i]);
|
|
5240
|
+
for(let k = 0; k < n; k++){
|
|
5241
|
+
let maxRow = k, maxVal = Math.abs(M[k][k]);
|
|
5242
|
+
for(let i = k + 1; i < n; i++){
|
|
5243
|
+
const v = Math.abs(M[i][k]);
|
|
5244
|
+
v > maxVal && (maxVal = v, maxRow = i);
|
|
5245
|
+
}
|
|
5246
|
+
if (maxRow !== k) {
|
|
5247
|
+
const tmp = M[k];
|
|
5248
|
+
M[k] = M[maxRow], M[maxRow] = tmp;
|
|
5249
|
+
}
|
|
5250
|
+
if (Math.abs(M[k][k]) < 1e-12) return new Array(n).fill(0);
|
|
5251
|
+
for(let j = k + 1; j <= n; j++)M[k][j] = M[k][j] / M[k][k];
|
|
5252
|
+
M[k][k] = 1;
|
|
5253
|
+
for(let i = 0; i < n; i++){
|
|
5254
|
+
if (i === k) continue;
|
|
5255
|
+
const factor = M[i][k];
|
|
5256
|
+
if (0 !== factor) {
|
|
5257
|
+
for(let j = k + 1; j <= n; j++)M[i][j] -= factor * M[k][j];
|
|
5258
|
+
M[i][k] = 0;
|
|
5259
|
+
}
|
|
5260
|
+
}
|
|
5261
|
+
}
|
|
5262
|
+
const x = new Array(n);
|
|
5263
|
+
for(let i = 0; i < n; i++)x[i] = M[i][n];
|
|
5264
|
+
return x;
|
|
5265
|
+
}
|
|
5266
|
+
function regressionPolynomial(data, x = (d)=>d.x, y = (d)=>d.y, options = {}) {
|
|
5267
|
+
var _a;
|
|
5268
|
+
let degree = null != (_a = options.degree) ? _a : 0;
|
|
5269
|
+
degree < 0 && (degree = 0);
|
|
5270
|
+
const m = degree + 1, sums = new Array(2 * degree + 1).fill(0);
|
|
5271
|
+
visitPoints(data, x, y, (dx, dy)=>{
|
|
5272
|
+
let xp = 1;
|
|
5273
|
+
for(let k = 0; k < sums.length; k++)sums[k] += xp, xp *= dx;
|
|
5274
|
+
});
|
|
5275
|
+
const A = new Array(m);
|
|
5276
|
+
for(let i = 0; i < m; i++){
|
|
5277
|
+
A[i] = new Array(m).fill(0);
|
|
5278
|
+
for(let j = 0; j < m; j++)A[i][j] = sums[i + j];
|
|
5279
|
+
}
|
|
5280
|
+
const B = new Array(m).fill(0);
|
|
5281
|
+
visitPoints(data, x, y, (dx, dy)=>{
|
|
5282
|
+
let xp = 1;
|
|
5283
|
+
for(let k = 0; k < m; k++)B[k] += dy * xp, xp *= dx;
|
|
5284
|
+
});
|
|
5285
|
+
const coef = solveLinearSystem(A, B), predict = (xx)=>{
|
|
5286
|
+
let xp = 1, v = 0;
|
|
5287
|
+
for(let k = 0; k < coef.length; k++)v += coef[k] * xp, xp *= xx;
|
|
5288
|
+
return v;
|
|
5289
|
+
};
|
|
5290
|
+
return {
|
|
5291
|
+
degree: degree,
|
|
5292
|
+
coef: coef,
|
|
5293
|
+
predict: predict,
|
|
5294
|
+
rSquared: rSquared(data, x, y, (()=>{
|
|
5295
|
+
let sum = 0, cnt = 0;
|
|
5296
|
+
return visitPoints(data, x, y, (_dx, dy)=>{
|
|
5297
|
+
sum += dy, cnt++;
|
|
5298
|
+
}), 0 === cnt ? 0 : sum / cnt;
|
|
5299
|
+
})(), predict),
|
|
5300
|
+
evaluateGrid (N) {
|
|
5301
|
+
const out = [];
|
|
5302
|
+
if (N <= 0) return out;
|
|
5303
|
+
let min = 1 / 0, max = -1 / 0;
|
|
5304
|
+
if (visitPoints(data, x, y, (dx)=>{
|
|
5305
|
+
common_isNil(dx) || (dx < min && (min = dx), dx > max && (max = dx));
|
|
5306
|
+
}), min === 1 / 0 || max === -1 / 0) return out;
|
|
5307
|
+
if (min === max) {
|
|
5308
|
+
const v = predict(min);
|
|
5309
|
+
for(let i = 0; i < N; i++)out.push({
|
|
5310
|
+
x: min,
|
|
5311
|
+
y: v
|
|
5312
|
+
});
|
|
5313
|
+
return out;
|
|
5314
|
+
}
|
|
5315
|
+
const step = (max - min) / (N - 1);
|
|
5316
|
+
for(let i = 0; i < N; i++){
|
|
5317
|
+
const px = i === N - 1 ? max : min + step * i;
|
|
5318
|
+
out.push({
|
|
5319
|
+
x: px,
|
|
5320
|
+
y: predict(px)
|
|
5321
|
+
});
|
|
5322
|
+
}
|
|
5323
|
+
return out;
|
|
5324
|
+
},
|
|
5325
|
+
confidenceInterval (N = 50, alpha = .05) {
|
|
5326
|
+
const out = [];
|
|
5327
|
+
if (N <= 0) return out;
|
|
5328
|
+
const comps = computeLinearCIComponents(data, x, y, predict);
|
|
5329
|
+
if (0 === comps.n) return out;
|
|
5330
|
+
const z = Math.abs(invNorm(1 - alpha / 2));
|
|
5331
|
+
if (comps.min === comps.max) {
|
|
5332
|
+
const v = predict(comps.min), errs = stdErrorsAt(comps.min, comps);
|
|
5333
|
+
for(let i = 0; i < N; i++)out.push({
|
|
5334
|
+
x: comps.min,
|
|
5335
|
+
mean: v,
|
|
5336
|
+
lower: v - z * errs.seMean,
|
|
5337
|
+
upper: v + z * errs.seMean,
|
|
5338
|
+
predLower: v - z * errs.sePred,
|
|
5339
|
+
predUpper: v + z * errs.sePred
|
|
5340
|
+
});
|
|
5341
|
+
return out;
|
|
5342
|
+
}
|
|
5343
|
+
const step = (comps.max - comps.min) / (N - 1);
|
|
5344
|
+
for(let i = 0; i < N; i++){
|
|
5345
|
+
const px = i === N - 1 ? comps.max : comps.min + step * i, yh = predict(px), errs = stdErrorsAt(px, comps);
|
|
5346
|
+
out.push({
|
|
5347
|
+
x: px,
|
|
5348
|
+
mean: yh,
|
|
5349
|
+
lower: yh - z * errs.seMean,
|
|
5350
|
+
upper: yh + z * errs.seMean,
|
|
5351
|
+
predLower: yh - z * errs.sePred,
|
|
5352
|
+
predUpper: yh + z * errs.sePred
|
|
5353
|
+
});
|
|
5354
|
+
}
|
|
5355
|
+
return out;
|
|
5356
|
+
}
|
|
5357
|
+
};
|
|
5358
|
+
}
|
|
5359
|
+
const defaultRegressionLineColor = (datum, ctx, opt)=>{
|
|
5360
|
+
const parentNode = opt.mark?._product?.parent;
|
|
5361
|
+
if (parentNode?.attribute?.data) return parentNode.attribute.data.color;
|
|
5362
|
+
};
|
|
5363
|
+
const defaultRegressionLineLabelX = (datum, ctx, opt)=>{
|
|
5364
|
+
const parentNode = opt.mark?._product?.parent;
|
|
5365
|
+
if (parentNode?.attribute?.data?.linePoints) {
|
|
5366
|
+
const points = parentNode.attribute.data.linePoints;
|
|
5367
|
+
return points[points.length - 1]?.x;
|
|
5368
|
+
}
|
|
5369
|
+
};
|
|
5370
|
+
const defaultRegressionLineLabelY = (datum, ctx, opt)=>{
|
|
5371
|
+
const parentNode = opt.mark?._product?.parent;
|
|
5372
|
+
if (parentNode?.attribute?.data?.linePoints) {
|
|
5373
|
+
const points = parentNode.attribute.data.linePoints;
|
|
5374
|
+
return points[points.length - 1]?.y;
|
|
5375
|
+
}
|
|
5376
|
+
};
|
|
5377
|
+
const columnPolynomialRegressionLine = (spec, context)=>{
|
|
5378
|
+
const result = {
|
|
5379
|
+
...spec
|
|
5380
|
+
};
|
|
5381
|
+
const { advancedVSeed } = context;
|
|
5382
|
+
const { chartType, regressionLine } = advancedVSeed;
|
|
5383
|
+
const lineTheme = advancedVSeed.config[chartType]?.regressionLine;
|
|
5384
|
+
if (!regressionLine || !regressionLine.polynomialRegressionLine) return result;
|
|
5385
|
+
const lineList = array_array(regressionLine.polynomialRegressionLine);
|
|
5386
|
+
if (!result.customMark) result.customMark = [];
|
|
5387
|
+
lineList.forEach((line, lineIndex)=>{
|
|
5388
|
+
const theme = lineTheme.linearRegressionLine ?? {};
|
|
5389
|
+
const { color, lineWidth, lineDash, text, textColor, textFontSize, textFontWeight, confidenceIntervalOpacity, confidenceIntervalVisible = theme.confidenceIntervalVisible } = line;
|
|
5390
|
+
const childrenMarks = [];
|
|
5391
|
+
result.customMark.push({
|
|
5392
|
+
type: 'group',
|
|
5393
|
+
interactive: false,
|
|
5394
|
+
zIndex: 500,
|
|
5395
|
+
name: `polynomialRegressionLine-${lineIndex}`,
|
|
5396
|
+
style: {
|
|
5397
|
+
data: (datum, ctx)=>{
|
|
5398
|
+
const vchart = ctx.vchart;
|
|
5399
|
+
const chart = vchart.getChart();
|
|
5400
|
+
const s = chart.getAllSeries()[0];
|
|
5401
|
+
if (s) {
|
|
5402
|
+
const rect = s.getRegion().getLayoutRect();
|
|
5403
|
+
if (0 === rect.width || 0 === rect.height) return null;
|
|
5404
|
+
const start = s.getRegion().getLayoutStartPoint();
|
|
5405
|
+
const yClamper = clamper(start.y, start.y + rect.height);
|
|
5406
|
+
const data = s.getViewData()?.latestData;
|
|
5407
|
+
const fieldX = s.fieldX?.[0];
|
|
5408
|
+
const fieldY = s.fieldY?.[0];
|
|
5409
|
+
const xValues = s.getRawDataStatisticsByField(fieldX).values;
|
|
5410
|
+
if (!fieldX || !fieldY || !data || data.length <= 2 || xValues.length <= 2) return null;
|
|
5411
|
+
const { confidenceInterval, evaluateGrid } = regressionPolynomial(xValues.map((xVal, index)=>{
|
|
5412
|
+
const filteredData = data.filter((d)=>d[fieldX] === xVal);
|
|
5413
|
+
return {
|
|
5414
|
+
x: index,
|
|
5415
|
+
y: Math.max(...filteredData.map((d)=>d[fieldY]))
|
|
5416
|
+
};
|
|
5417
|
+
}), void 0, void 0, {
|
|
5418
|
+
degree: line.degree ?? 2
|
|
5419
|
+
});
|
|
5420
|
+
const N = xValues.length;
|
|
5421
|
+
const xAxisHelper = s.getXAxisHelper();
|
|
5422
|
+
const halfBandWidth = xAxisHelper ? xAxisHelper.getBandwidth(0) / 2 : 0;
|
|
5423
|
+
const lineData = evaluateGrid(N);
|
|
5424
|
+
const linePoints = lineData.map((datum, index)=>{
|
|
5425
|
+
const d = {
|
|
5426
|
+
[fieldX]: xValues[index],
|
|
5427
|
+
[fieldY]: datum.y
|
|
5428
|
+
};
|
|
5429
|
+
return {
|
|
5430
|
+
x: s.dataToPositionX(d) + start.x + halfBandWidth,
|
|
5431
|
+
y: yClamper(s.dataToPositionY(d) + start.y)
|
|
5432
|
+
};
|
|
5433
|
+
});
|
|
5434
|
+
const result = {
|
|
5435
|
+
linePoints,
|
|
5436
|
+
color: s.getOption().globalScale.getScale('color')?.scale(s.getSeriesKeys()[0])
|
|
5437
|
+
};
|
|
5438
|
+
if (confidenceIntervalVisible) {
|
|
5439
|
+
const intervalData = confidenceInterval(N);
|
|
5440
|
+
result.areaPoints = intervalData.map((datum, index)=>{
|
|
5441
|
+
const d = {
|
|
5442
|
+
[fieldX]: xValues[index],
|
|
5443
|
+
[fieldY]: datum.lower
|
|
5444
|
+
};
|
|
5445
|
+
return {
|
|
5446
|
+
x: s.dataToPositionX(d) + start.x + halfBandWidth,
|
|
5447
|
+
y: yClamper(s.dataToPositionY(d) + start.y),
|
|
5448
|
+
y1: yClamper(s.dataToPositionY({
|
|
5449
|
+
[fieldY]: datum.upper
|
|
5450
|
+
}) + start.y)
|
|
5451
|
+
};
|
|
5452
|
+
});
|
|
5453
|
+
}
|
|
5454
|
+
return result;
|
|
5455
|
+
}
|
|
5456
|
+
return null;
|
|
5457
|
+
}
|
|
5458
|
+
},
|
|
5459
|
+
children: childrenMarks
|
|
5460
|
+
});
|
|
5461
|
+
if (confidenceIntervalVisible) childrenMarks.push({
|
|
5462
|
+
type: 'area',
|
|
5463
|
+
interactive: false,
|
|
5464
|
+
zIndex: 500,
|
|
5465
|
+
style: {
|
|
5466
|
+
lineWidth: lineWidth ?? theme.lineWidth,
|
|
5467
|
+
lineDash: lineDash ?? theme.lineDash,
|
|
5468
|
+
fillOpacity: confidenceIntervalOpacity ?? theme.confidenceIntervalOpacity,
|
|
5469
|
+
fill: color ?? defaultRegressionLineColor,
|
|
5470
|
+
points: (datum, ctx, opt)=>{
|
|
5471
|
+
const parentNode = opt.mark?._product?.parent;
|
|
5472
|
+
if (parentNode?.attribute?.data) return parentNode.attribute.data.areaPoints;
|
|
5473
|
+
return [];
|
|
5474
|
+
}
|
|
5475
|
+
}
|
|
5476
|
+
});
|
|
5477
|
+
childrenMarks.push({
|
|
5478
|
+
type: 'line',
|
|
5479
|
+
interactive: false,
|
|
5480
|
+
zIndex: 500,
|
|
5481
|
+
style: {
|
|
5482
|
+
lineWidth: lineWidth ?? theme.lineWidth,
|
|
5483
|
+
lineDash: lineDash ?? theme.lineDash,
|
|
5484
|
+
stroke: color ?? defaultRegressionLineColor,
|
|
5485
|
+
points: (datum, ctx, opt)=>{
|
|
5486
|
+
const parentNode = opt.mark?._product?.parent;
|
|
5487
|
+
if (parentNode?.attribute?.data) return parentNode.attribute.data.linePoints;
|
|
5488
|
+
return [];
|
|
5489
|
+
}
|
|
5490
|
+
}
|
|
5491
|
+
});
|
|
5492
|
+
if (!chunk_JK3VNB42_n(text)) childrenMarks.push({
|
|
5493
|
+
type: 'text',
|
|
5494
|
+
interactive: false,
|
|
5495
|
+
zIndex: 500,
|
|
5496
|
+
style: {
|
|
5497
|
+
textAlign: 'end',
|
|
5498
|
+
fill: textColor ?? theme.textColor,
|
|
5499
|
+
fontSize: textFontSize ?? theme.textFontSize,
|
|
5500
|
+
fontWeight: textFontWeight ?? theme.textFontWeight,
|
|
5501
|
+
text: text,
|
|
5502
|
+
x: (datum, ctx, opt)=>{
|
|
5503
|
+
const parentNode = opt.mark?._product?.parent;
|
|
5504
|
+
if (parentNode?.attribute?.data?.linePoints) {
|
|
5505
|
+
const points = parentNode.attribute.data.linePoints;
|
|
5506
|
+
return points[points.length - 1]?.x;
|
|
5507
|
+
}
|
|
5508
|
+
},
|
|
5509
|
+
y: (datum, ctx, opt)=>{
|
|
5510
|
+
const parentNode = opt.mark?._product?.parent;
|
|
5511
|
+
if (parentNode?.attribute?.data?.linePoints) {
|
|
5512
|
+
const points = parentNode.attribute.data.linePoints;
|
|
5513
|
+
return points[points.length - 1]?.y;
|
|
5514
|
+
}
|
|
5515
|
+
}
|
|
5516
|
+
}
|
|
5517
|
+
});
|
|
5518
|
+
});
|
|
5519
|
+
return result;
|
|
5520
|
+
};
|
|
5027
5521
|
const column = [
|
|
5028
5522
|
initColumn,
|
|
5029
5523
|
stackCornerRadius_stackCornerRadius,
|
|
@@ -5043,7 +5537,8 @@
|
|
|
5043
5537
|
annotationPoint_annotationPoint,
|
|
5044
5538
|
annotationVerticalLine_annotationVerticalLine,
|
|
5045
5539
|
annotationHorizontalLine_annotationHorizontalLine,
|
|
5046
|
-
annotationAreaBand
|
|
5540
|
+
annotationAreaBand,
|
|
5541
|
+
columnPolynomialRegressionLine
|
|
5047
5542
|
];
|
|
5048
5543
|
const pivotColumn = [
|
|
5049
5544
|
initPivot,
|
|
@@ -5067,7 +5562,8 @@
|
|
|
5067
5562
|
annotationPoint_annotationPoint,
|
|
5068
5563
|
annotationVerticalLine_annotationVerticalLine,
|
|
5069
5564
|
annotationHorizontalLine_annotationHorizontalLine,
|
|
5070
|
-
annotationAreaBand
|
|
5565
|
+
annotationAreaBand,
|
|
5566
|
+
columnPolynomialRegressionLine
|
|
5071
5567
|
]),
|
|
5072
5568
|
pivotRowDimensions,
|
|
5073
5569
|
pivotColumnDimensions,
|
|
@@ -5102,8 +5598,8 @@
|
|
|
5102
5598
|
};
|
|
5103
5599
|
return result;
|
|
5104
5600
|
};
|
|
5105
|
-
const areaConfig =
|
|
5106
|
-
const areaPercentConfig =
|
|
5601
|
+
const areaConfig = line_lineConfig;
|
|
5602
|
+
const areaPercentConfig = line_lineConfig;
|
|
5107
5603
|
const barConfig = columnConfig;
|
|
5108
5604
|
const barParallelConfig = columnConfig;
|
|
5109
5605
|
const barPercentConfig = columnConfig;
|
|
@@ -6638,7 +7134,8 @@
|
|
|
6638
7134
|
scatterConfig,
|
|
6639
7135
|
theme_theme,
|
|
6640
7136
|
markStyle_markStyle,
|
|
6641
|
-
annotation_annotation
|
|
7137
|
+
annotation_annotation,
|
|
7138
|
+
regressionLine_regressionLine
|
|
6642
7139
|
];
|
|
6643
7140
|
const initScatter = (spec, context)=>{
|
|
6644
7141
|
const result = {
|
|
@@ -6839,6 +7336,390 @@
|
|
|
6839
7336
|
};
|
|
6840
7337
|
return result;
|
|
6841
7338
|
};
|
|
7339
|
+
function tricube(u) {
|
|
7340
|
+
const uu = Math.abs(u);
|
|
7341
|
+
if (uu >= 1) return 0;
|
|
7342
|
+
const t = 1 - uu * uu * uu;
|
|
7343
|
+
return t * t * t;
|
|
7344
|
+
}
|
|
7345
|
+
function regressionLowess(data, x = (d)=>d.x, y = (d)=>d.y, options = {}) {
|
|
7346
|
+
const span = options.span || .3, degree = 0 === options.degree ? 0 : 1, iterations = null == options.iterations ? 2 : options.iterations, ptsX = [], ptsY = [];
|
|
7347
|
+
visitPoints(data, x, y, (dx, dy)=>{
|
|
7348
|
+
ptsX.push(dx), ptsY.push(dy);
|
|
7349
|
+
});
|
|
7350
|
+
const n = ptsX.length;
|
|
7351
|
+
function predictSingle(x0, robustWeights) {
|
|
7352
|
+
if (0 === n) return 0;
|
|
7353
|
+
const dists = [];
|
|
7354
|
+
for(let i = 0; i < n; i++)dists.push({
|
|
7355
|
+
idx: i,
|
|
7356
|
+
dist: Math.abs(ptsX[i] - x0)
|
|
7357
|
+
});
|
|
7358
|
+
dists.sort((a, b)=>a.dist - b.dist);
|
|
7359
|
+
const m = Math.max(2, Math.min(n, Math.floor(span * n))), maxDist = dists[m - 1].dist || 0, w = new Array(m);
|
|
7360
|
+
let sumw = 0;
|
|
7361
|
+
for(let i = 0; i < m; i++){
|
|
7362
|
+
const idx = dists[i].idx;
|
|
7363
|
+
let wi = tricube(0 === maxDist ? 0 : dists[i].dist / maxDist);
|
|
7364
|
+
robustWeights && null != robustWeights[idx] && (wi *= robustWeights[idx]), w[i] = wi, sumw += wi;
|
|
7365
|
+
}
|
|
7366
|
+
if (0 === sumw) return ptsY[dists[0].idx];
|
|
7367
|
+
if (0 === degree) {
|
|
7368
|
+
let s = 0;
|
|
7369
|
+
for(let i = 0; i < m; i++)s += w[i] * ptsY[dists[i].idx];
|
|
7370
|
+
return s / sumw;
|
|
7371
|
+
}
|
|
7372
|
+
let sw = 0, sx = 0, sy = 0, sxx = 0, sxy = 0;
|
|
7373
|
+
for(let i = 0; i < m; i++){
|
|
7374
|
+
const idx = dists[i].idx, xi = ptsX[idx], yi = ptsY[idx], wi = w[i];
|
|
7375
|
+
sw += wi, sx += wi * xi, sy += wi * yi, sxx += wi * xi * xi, sxy += wi * xi * yi;
|
|
7376
|
+
}
|
|
7377
|
+
const meanX = sx / sw, meanY = sy / sw, denom = sxx - sx * meanX, slope = Math.abs(denom) < 1e-12 ? 0 : (sxy - sx * meanY) / denom;
|
|
7378
|
+
return meanY - slope * meanX + slope * x0;
|
|
7379
|
+
}
|
|
7380
|
+
function predict(x0) {
|
|
7381
|
+
if (Array.isArray(x0)) {
|
|
7382
|
+
const out = [];
|
|
7383
|
+
for(let i = 0; i < x0.length; i++)out.push(predictSingle(x0[i]));
|
|
7384
|
+
return out;
|
|
7385
|
+
}
|
|
7386
|
+
return predictSingle(x0);
|
|
7387
|
+
}
|
|
7388
|
+
return {
|
|
7389
|
+
predict: predict,
|
|
7390
|
+
evaluate: predict,
|
|
7391
|
+
evaluateGrid: function(N) {
|
|
7392
|
+
const out = [];
|
|
7393
|
+
if (N <= 0) return out;
|
|
7394
|
+
if (0 === n) return out;
|
|
7395
|
+
let min = 1 / 0, max = -1 / 0;
|
|
7396
|
+
for(let i = 0; i < n; i++)ptsX[i] < min && (min = ptsX[i]), ptsX[i] > max && (max = ptsX[i]);
|
|
7397
|
+
if (min === max) {
|
|
7398
|
+
const v = predictSingle(min);
|
|
7399
|
+
for(let i = 0; i < N; i++)out.push({
|
|
7400
|
+
x: min,
|
|
7401
|
+
y: v
|
|
7402
|
+
});
|
|
7403
|
+
return out;
|
|
7404
|
+
}
|
|
7405
|
+
const step = (max - min) / (N - 1);
|
|
7406
|
+
let robustWeights;
|
|
7407
|
+
for(let iter = 0; iter < iterations; iter++){
|
|
7408
|
+
const fits = [];
|
|
7409
|
+
for(let i = 0; i < n; i++)fits.push(predictSingle(ptsX[i], robustWeights));
|
|
7410
|
+
const res = [];
|
|
7411
|
+
for(let i = 0; i < n; i++)res.push(Math.abs(ptsY[i] - fits[i]));
|
|
7412
|
+
const med = res.slice().sort((a, b)=>a - b)[Math.floor(n / 2)] || 0;
|
|
7413
|
+
robustWeights = new Array(n);
|
|
7414
|
+
for(let i = 0; i < n; i++){
|
|
7415
|
+
const u = 0 === med ? 0 : res[i] / (6 * med), w = Math.abs(u) >= 1 ? 0 : (1 - u * u) * (1 - u * u);
|
|
7416
|
+
robustWeights[i] = w;
|
|
7417
|
+
}
|
|
7418
|
+
}
|
|
7419
|
+
for(let i = 0; i < N; i++){
|
|
7420
|
+
const px = i === N - 1 ? max : min + step * i;
|
|
7421
|
+
out.push({
|
|
7422
|
+
x: px,
|
|
7423
|
+
y: predictSingle(px, robustWeights)
|
|
7424
|
+
});
|
|
7425
|
+
}
|
|
7426
|
+
return out;
|
|
7427
|
+
},
|
|
7428
|
+
confidenceInterval: function(N = 50, alpha = .05) {
|
|
7429
|
+
const out = [];
|
|
7430
|
+
if (N <= 0) return out;
|
|
7431
|
+
if (0 === n) return out;
|
|
7432
|
+
let min = 1 / 0, max = -1 / 0;
|
|
7433
|
+
for(let i = 0; i < n; i++)ptsX[i] < min && (min = ptsX[i]), ptsX[i] > max && (max = ptsX[i]);
|
|
7434
|
+
if (min === 1 / 0 || max === -1 / 0) return out;
|
|
7435
|
+
const comps = computeLinearCIComponents(data, x, y, (xx)=>predictSingle(xx));
|
|
7436
|
+
if (0 === comps.n) return out;
|
|
7437
|
+
const z = Math.abs(invNorm(1 - alpha / 2));
|
|
7438
|
+
if (comps.min === comps.max) {
|
|
7439
|
+
const v = predictSingle(comps.min), errs = stdErrorsAt(comps.min, comps);
|
|
7440
|
+
for(let i = 0; i < N; i++)out.push({
|
|
7441
|
+
x: comps.min,
|
|
7442
|
+
mean: v,
|
|
7443
|
+
lower: v - z * errs.seMean,
|
|
7444
|
+
upper: v + z * errs.seMean,
|
|
7445
|
+
predLower: v - z * errs.sePred,
|
|
7446
|
+
predUpper: v + z * errs.sePred
|
|
7447
|
+
});
|
|
7448
|
+
return out;
|
|
7449
|
+
}
|
|
7450
|
+
const step = (max - min) / (N - 1);
|
|
7451
|
+
for(let i = 0; i < N; i++){
|
|
7452
|
+
const px = i === N - 1 ? max : min + step * i, yh = predictSingle(px), errs = stdErrorsAt(px, comps);
|
|
7453
|
+
out.push({
|
|
7454
|
+
x: px,
|
|
7455
|
+
mean: yh,
|
|
7456
|
+
lower: yh - z * errs.seMean,
|
|
7457
|
+
upper: yh + z * errs.seMean,
|
|
7458
|
+
predLower: yh - z * errs.sePred,
|
|
7459
|
+
predUpper: yh + z * errs.sePred
|
|
7460
|
+
});
|
|
7461
|
+
}
|
|
7462
|
+
return out;
|
|
7463
|
+
}
|
|
7464
|
+
};
|
|
7465
|
+
}
|
|
7466
|
+
function regressionLogistic(data, x = (d)=>d.x, y = (d)=>d.y, options) {
|
|
7467
|
+
var _a, _b;
|
|
7468
|
+
const maxIter = null != (_a = null == options ? void 0 : options.maxIteration) ? _a : 25, tol = null != (_b = null == options ? void 0 : options.tol) ? _b : 1e-6, xs = [], ys = [];
|
|
7469
|
+
visitPoints(data, x, y, (dx, dy)=>{
|
|
7470
|
+
xs.push(dx), ys.push(dy ? 1 : 0);
|
|
7471
|
+
});
|
|
7472
|
+
const n = xs.length;
|
|
7473
|
+
if (0 === n) return {
|
|
7474
|
+
coef: [
|
|
7475
|
+
0,
|
|
7476
|
+
0
|
|
7477
|
+
],
|
|
7478
|
+
predict: (_x)=>0,
|
|
7479
|
+
evaluateGrid: (N)=>[],
|
|
7480
|
+
confidenceInterval: (N = 50)=>[]
|
|
7481
|
+
};
|
|
7482
|
+
let intercept = 0, beta = 0;
|
|
7483
|
+
for(let iter = 0; iter < maxIter; iter++){
|
|
7484
|
+
const p = new Array(n);
|
|
7485
|
+
let converged = !0;
|
|
7486
|
+
for(let i = 0; i < n; i++){
|
|
7487
|
+
const z = intercept + beta * xs[i], pi = 1 / (1 + Math.exp(-z));
|
|
7488
|
+
p[i] = pi;
|
|
7489
|
+
}
|
|
7490
|
+
let g0 = 0, g1 = 0, h00 = 0, h01 = 0, h11 = 0;
|
|
7491
|
+
for(let i = 0; i < n; i++){
|
|
7492
|
+
const wi = p[i] * (1 - p[i]), diff = ys[i] - p[i];
|
|
7493
|
+
g0 += diff, g1 += diff * xs[i], h00 += wi, h01 += wi * xs[i], h11 += wi * xs[i] * xs[i];
|
|
7494
|
+
}
|
|
7495
|
+
const det = h00 * h11 - h01 * h01;
|
|
7496
|
+
if (Math.abs(det) < 1e-12) break;
|
|
7497
|
+
const delta0 = (h11 * g0 - h01 * g1) / det, delta1 = (-h01 * g0 + h00 * g1) / det;
|
|
7498
|
+
if (intercept += delta0, beta += delta1, (Math.abs(delta0) > tol || Math.abs(delta1) > tol) && (converged = !1), converged) break;
|
|
7499
|
+
}
|
|
7500
|
+
const predict = (xx)=>{
|
|
7501
|
+
const z = intercept + beta * xx;
|
|
7502
|
+
return 1 / (1 + Math.exp(-z));
|
|
7503
|
+
};
|
|
7504
|
+
return {
|
|
7505
|
+
coef: [
|
|
7506
|
+
intercept,
|
|
7507
|
+
beta
|
|
7508
|
+
],
|
|
7509
|
+
predict: predict,
|
|
7510
|
+
evaluateGrid: function(N) {
|
|
7511
|
+
const out = [];
|
|
7512
|
+
if (N <= 0) return out;
|
|
7513
|
+
let min = 1 / 0, max = -1 / 0;
|
|
7514
|
+
if (visitPoints(data, x, y, (dx)=>{
|
|
7515
|
+
dx < min && (min = dx), dx > max && (max = dx);
|
|
7516
|
+
}), min === 1 / 0 || max === -1 / 0) return out;
|
|
7517
|
+
if (min === max) {
|
|
7518
|
+
const v = predict(min);
|
|
7519
|
+
for(let i = 0; i < N; i++)out.push({
|
|
7520
|
+
x: min,
|
|
7521
|
+
y: v
|
|
7522
|
+
});
|
|
7523
|
+
return out;
|
|
7524
|
+
}
|
|
7525
|
+
const step = (max - min) / (N - 1);
|
|
7526
|
+
for(let i = 0; i < N; i++){
|
|
7527
|
+
const px = i === N - 1 ? max : min + step * i;
|
|
7528
|
+
out.push({
|
|
7529
|
+
x: px,
|
|
7530
|
+
y: predict(px)
|
|
7531
|
+
});
|
|
7532
|
+
}
|
|
7533
|
+
return out;
|
|
7534
|
+
},
|
|
7535
|
+
confidenceInterval: function(N = 50, alpha = .05) {
|
|
7536
|
+
const out = [];
|
|
7537
|
+
if (N <= 0) return out;
|
|
7538
|
+
const comps = computeLinearCIComponents(data, x, y, predict);
|
|
7539
|
+
if (0 === comps.n) return out;
|
|
7540
|
+
const z = Math.abs(invNorm(1 - alpha / 2));
|
|
7541
|
+
if (comps.min === comps.max) {
|
|
7542
|
+
const v = predict(comps.min), errs = stdErrorsAt(comps.min, comps);
|
|
7543
|
+
for(let i = 0; i < N; i++)out.push({
|
|
7544
|
+
x: comps.min,
|
|
7545
|
+
mean: v,
|
|
7546
|
+
lower: v - z * errs.seMean,
|
|
7547
|
+
upper: v + z * errs.seMean,
|
|
7548
|
+
predLower: v - z * errs.sePred,
|
|
7549
|
+
predUpper: v + z * errs.sePred
|
|
7550
|
+
});
|
|
7551
|
+
return out;
|
|
7552
|
+
}
|
|
7553
|
+
const step = (comps.max - comps.min) / (N - 1);
|
|
7554
|
+
for(let i = 0; i < N; i++){
|
|
7555
|
+
const px = i === N - 1 ? comps.max : comps.min + step * i, yh = predict(px), errs = stdErrorsAt(px, comps);
|
|
7556
|
+
out.push({
|
|
7557
|
+
x: px,
|
|
7558
|
+
mean: yh,
|
|
7559
|
+
lower: yh - z * errs.seMean,
|
|
7560
|
+
upper: yh + z * errs.seMean,
|
|
7561
|
+
predLower: yh - z * errs.sePred,
|
|
7562
|
+
predUpper: yh + z * errs.sePred
|
|
7563
|
+
});
|
|
7564
|
+
}
|
|
7565
|
+
return out;
|
|
7566
|
+
}
|
|
7567
|
+
};
|
|
7568
|
+
}
|
|
7569
|
+
const generateRegressionLinePipe = (type, regressionFunction, getOptions)=>(spec, context)=>{
|
|
7570
|
+
const result = {
|
|
7571
|
+
...spec
|
|
7572
|
+
};
|
|
7573
|
+
const { advancedVSeed } = context;
|
|
7574
|
+
const { chartType, regressionLine } = advancedVSeed;
|
|
7575
|
+
const lineTheme = advancedVSeed.config[chartType]?.regressionLine;
|
|
7576
|
+
if (!regressionLine || !regressionLine[type]) return result;
|
|
7577
|
+
const lineList = array_array(regressionLine[type]);
|
|
7578
|
+
if (!result.customMark) result.customMark = [];
|
|
7579
|
+
lineList.forEach((line, lineIndex)=>{
|
|
7580
|
+
const theme = lineTheme.linearRegressionLine ?? {};
|
|
7581
|
+
const { color, lineWidth, lineDash, text, textColor, textFontSize, textFontWeight, confidenceIntervalOpacity, confidenceIntervalVisible = theme.confidenceIntervalVisible } = line;
|
|
7582
|
+
const childrenMarks = [];
|
|
7583
|
+
result.customMark.push({
|
|
7584
|
+
type: 'group',
|
|
7585
|
+
interactive: false,
|
|
7586
|
+
zIndex: 500,
|
|
7587
|
+
name: `${type}-${lineIndex}`,
|
|
7588
|
+
style: {
|
|
7589
|
+
data: (datum, ctx)=>{
|
|
7590
|
+
const vchart = ctx.vchart;
|
|
7591
|
+
const chart = vchart.getChart();
|
|
7592
|
+
const s = chart.getAllSeries()[0];
|
|
7593
|
+
if (s) {
|
|
7594
|
+
const rect = s.getRegion().getLayoutRect();
|
|
7595
|
+
const segments = [];
|
|
7596
|
+
if (0 === rect.width || 0 === rect.height) return segments;
|
|
7597
|
+
const start = s.getRegion().getLayoutStartPoint();
|
|
7598
|
+
const yClamper = clamper(start.y, start.y + rect.height);
|
|
7599
|
+
const colorAttrOptions = s.getColorAttribute();
|
|
7600
|
+
const groups = s.getSeriesKeys();
|
|
7601
|
+
const data = s.getViewData()?.latestData;
|
|
7602
|
+
const fieldX = s.fieldX?.[0];
|
|
7603
|
+
const fieldY = s.fieldY?.[0];
|
|
7604
|
+
if (!groups.length) groups.push(void 0);
|
|
7605
|
+
groups.forEach((group)=>{
|
|
7606
|
+
const groupData = data.filter((d)=>d[colorAttrOptions?.field] === group);
|
|
7607
|
+
if (!groupData.length) return;
|
|
7608
|
+
const { confidenceInterval, evaluateGrid } = regressionFunction(groupData, (datum)=>datum?.[fieldX], (datum)=>datum?.[fieldY], getOptions?.(line));
|
|
7609
|
+
const N = Math.max(3, Math.floor(groupData.length / 4));
|
|
7610
|
+
const mainColor = color ?? colorAttrOptions?.scale?.scale(group);
|
|
7611
|
+
const lineData = evaluateGrid(N);
|
|
7612
|
+
const linePoints = lineData.map((ld)=>{
|
|
7613
|
+
const d = {
|
|
7614
|
+
[fieldX]: ld.x,
|
|
7615
|
+
[fieldY]: ld.y
|
|
7616
|
+
};
|
|
7617
|
+
return {
|
|
7618
|
+
x: s.dataToPositionX(d) + start.x,
|
|
7619
|
+
y: yClamper(s.dataToPositionY(d) + start.y)
|
|
7620
|
+
};
|
|
7621
|
+
});
|
|
7622
|
+
segments.push({
|
|
7623
|
+
color: mainColor,
|
|
7624
|
+
linePoints
|
|
7625
|
+
});
|
|
7626
|
+
if (confidenceIntervalVisible) {
|
|
7627
|
+
const intervalData = confidenceInterval(N);
|
|
7628
|
+
const areaPoints = intervalData.map((datum)=>{
|
|
7629
|
+
const d = {
|
|
7630
|
+
[fieldX]: datum.x,
|
|
7631
|
+
[fieldY]: datum.lower
|
|
7632
|
+
};
|
|
7633
|
+
return {
|
|
7634
|
+
x: s.dataToPositionX(d) + start.x,
|
|
7635
|
+
y: yClamper(s.dataToPositionY(d) + start.y),
|
|
7636
|
+
y1: yClamper(s.dataToPositionY({
|
|
7637
|
+
[fieldY]: datum.upper
|
|
7638
|
+
}) + start.y)
|
|
7639
|
+
};
|
|
7640
|
+
});
|
|
7641
|
+
segments[segments.length - 1].areaPoints = areaPoints;
|
|
7642
|
+
}
|
|
7643
|
+
});
|
|
7644
|
+
return segments;
|
|
7645
|
+
}
|
|
7646
|
+
return [];
|
|
7647
|
+
}
|
|
7648
|
+
},
|
|
7649
|
+
children: childrenMarks
|
|
7650
|
+
});
|
|
7651
|
+
if (confidenceIntervalVisible) childrenMarks.push({
|
|
7652
|
+
type: 'area',
|
|
7653
|
+
interactive: false,
|
|
7654
|
+
zIndex: 500,
|
|
7655
|
+
style: {
|
|
7656
|
+
lineWidth: lineWidth ?? theme.lineWidth,
|
|
7657
|
+
lineDash: lineDash ?? theme.lineDash,
|
|
7658
|
+
fillOpacity: confidenceIntervalOpacity ?? theme.confidenceIntervalOpacity,
|
|
7659
|
+
fill: 'red',
|
|
7660
|
+
segments: (datum, ctx, opt)=>{
|
|
7661
|
+
const parentNode = opt.mark?._product?.parent;
|
|
7662
|
+
if (parentNode?.attribute?.data?.length) return parentNode.attribute.data.map((d)=>({
|
|
7663
|
+
points: d.areaPoints ?? [],
|
|
7664
|
+
fill: d.color
|
|
7665
|
+
}));
|
|
7666
|
+
return [];
|
|
7667
|
+
}
|
|
7668
|
+
}
|
|
7669
|
+
});
|
|
7670
|
+
childrenMarks.push({
|
|
7671
|
+
type: 'line',
|
|
7672
|
+
interactive: false,
|
|
7673
|
+
zIndex: 500,
|
|
7674
|
+
style: {
|
|
7675
|
+
lineWidth: lineWidth ?? theme.lineWidth,
|
|
7676
|
+
lineDash: lineDash ?? theme.lineDash,
|
|
7677
|
+
stroke: 'red',
|
|
7678
|
+
segments: (datum, ctx, opt)=>{
|
|
7679
|
+
const parentNode = opt.mark?._product?.parent;
|
|
7680
|
+
if (parentNode?.attribute?.data?.length) return parentNode.attribute.data.map((d)=>({
|
|
7681
|
+
points: d.linePoints,
|
|
7682
|
+
stroke: d.color
|
|
7683
|
+
}));
|
|
7684
|
+
return [];
|
|
7685
|
+
}
|
|
7686
|
+
}
|
|
7687
|
+
});
|
|
7688
|
+
if (!chunk_JK3VNB42_n(text)) childrenMarks.push({
|
|
7689
|
+
type: 'text',
|
|
7690
|
+
interactive: false,
|
|
7691
|
+
zIndex: 500,
|
|
7692
|
+
style: {
|
|
7693
|
+
textAlign: 'end',
|
|
7694
|
+
fill: textColor ?? theme.textColor,
|
|
7695
|
+
fontSize: textFontSize ?? theme.textFontSize,
|
|
7696
|
+
fontWeight: textFontWeight ?? theme.textFontWeight,
|
|
7697
|
+
text: text,
|
|
7698
|
+
x: (datum, ctx, opt)=>{
|
|
7699
|
+
const parentNode = opt.mark?._product?.parent;
|
|
7700
|
+
if (parentNode?.attribute?.data?.length) {
|
|
7701
|
+
const point = parentNode.attribute.data[parentNode.attribute.data.length - 1].linePoints;
|
|
7702
|
+
return point[point.length - 1]?.x;
|
|
7703
|
+
}
|
|
7704
|
+
},
|
|
7705
|
+
y: (datum, ctx, opt)=>{
|
|
7706
|
+
const parentNode = opt.mark?._product?.parent;
|
|
7707
|
+
if (parentNode?.attribute?.data?.length) {
|
|
7708
|
+
const point = parentNode.attribute.data[parentNode.attribute.data.length - 1].linePoints;
|
|
7709
|
+
return point[point.length - 1]?.y;
|
|
7710
|
+
}
|
|
7711
|
+
}
|
|
7712
|
+
}
|
|
7713
|
+
});
|
|
7714
|
+
});
|
|
7715
|
+
return result;
|
|
7716
|
+
};
|
|
7717
|
+
const linearRegressionLine = generateRegressionLinePipe('linearRegressionLine', regressionLinear);
|
|
7718
|
+
const lowessRegressionLine = generateRegressionLinePipe('lowessRegressionLine', regressionLowess);
|
|
7719
|
+
const polynomialRegressionLine = generateRegressionLinePipe('polynomialRegressionLine', regressionPolynomial, (lineConfig)=>({
|
|
7720
|
+
degree: lineConfig.degree ?? 2
|
|
7721
|
+
}));
|
|
7722
|
+
const logisticRegressionLine = generateRegressionLinePipe('logisticRegressionLine', regressionLogistic);
|
|
6842
7723
|
const scatter = [
|
|
6843
7724
|
initScatter,
|
|
6844
7725
|
colorAdapter(color_color, linearColor),
|
|
@@ -6858,7 +7739,11 @@
|
|
|
6858
7739
|
annotationPoint_annotationPoint,
|
|
6859
7740
|
annotationVerticalLine_annotationVerticalLine,
|
|
6860
7741
|
annotationHorizontalLine_annotationHorizontalLine,
|
|
6861
|
-
annotationArea_annotationArea
|
|
7742
|
+
annotationArea_annotationArea,
|
|
7743
|
+
linearRegressionLine,
|
|
7744
|
+
lowessRegressionLine,
|
|
7745
|
+
polynomialRegressionLine,
|
|
7746
|
+
logisticRegressionLine
|
|
6862
7747
|
];
|
|
6863
7748
|
const pivotScatter = [
|
|
6864
7749
|
initPivot,
|
|
@@ -6883,7 +7768,9 @@
|
|
|
6883
7768
|
annotationPoint_annotationPoint,
|
|
6884
7769
|
annotationVerticalLine_annotationVerticalLine,
|
|
6885
7770
|
annotationHorizontalLine_annotationHorizontalLine,
|
|
6886
|
-
annotationArea_annotationArea
|
|
7771
|
+
annotationArea_annotationArea,
|
|
7772
|
+
linearRegressionLine,
|
|
7773
|
+
lowessRegressionLine
|
|
6887
7774
|
]),
|
|
6888
7775
|
pivotRowDimensions,
|
|
6889
7776
|
pivotColumnDimensions,
|
|
@@ -9425,12 +10312,6 @@
|
|
|
9425
10312
|
...tooltip
|
|
9426
10313
|
]);
|
|
9427
10314
|
};
|
|
9428
|
-
const isType_isType = (value, type)=>Object.prototype.toString.call(value) === `[object ${type}]`;
|
|
9429
|
-
const isType = isType_isType;
|
|
9430
|
-
const isArray = (value)=>Array.isArray ? Array.isArray(value) : isType(value, "Array");
|
|
9431
|
-
const common_isArray = isArray;
|
|
9432
|
-
const isNil = (value)=>null == value;
|
|
9433
|
-
const common_isNil = isNil;
|
|
9434
10315
|
const clamp_clamp = function(input, min, max) {
|
|
9435
10316
|
return input < min ? min : input > max ? max : input;
|
|
9436
10317
|
};
|
|
@@ -9662,7 +10543,6 @@
|
|
|
9662
10543
|
datasets.push(newDatasets);
|
|
9663
10544
|
datasetReshapeInfo.push(reshapeInfo);
|
|
9664
10545
|
});
|
|
9665
|
-
console.log(datasets);
|
|
9666
10546
|
return {
|
|
9667
10547
|
...result,
|
|
9668
10548
|
dataset: datasets,
|
|
@@ -10252,11 +11132,6 @@
|
|
|
10252
11132
|
datasetReshapeInfo: datasetReshapeInfo
|
|
10253
11133
|
};
|
|
10254
11134
|
};
|
|
10255
|
-
const regressionLine = (advancedVSeed, context)=>{
|
|
10256
|
-
const { vseed } = context;
|
|
10257
|
-
if ('histogramRegressionLine' in vseed && 'histogram' === vseed.chartType) advancedVSeed.histogramRegressionLine = vseed.histogramRegressionLine;
|
|
10258
|
-
return advancedVSeed;
|
|
10259
|
-
};
|
|
10260
11135
|
const histogramAdvancedPipeline = [
|
|
10261
11136
|
initAdvancedVSeed_initAdvancedVSeed,
|
|
10262
11137
|
default_defaultMeasures_defaultMeasures,
|
|
@@ -10285,7 +11160,7 @@
|
|
|
10285
11160
|
theme_theme,
|
|
10286
11161
|
markStyle_markStyle,
|
|
10287
11162
|
annotation_annotation,
|
|
10288
|
-
|
|
11163
|
+
regressionLine_regressionLine
|
|
10289
11164
|
];
|
|
10290
11165
|
const initHistogram = (spec)=>{
|
|
10291
11166
|
const result = {
|
|
@@ -10488,6 +11363,97 @@
|
|
|
10488
11363
|
}
|
|
10489
11364
|
};
|
|
10490
11365
|
}
|
|
11366
|
+
const kdeRegressionLine = (spec, context)=>{
|
|
11367
|
+
const result = {
|
|
11368
|
+
...spec
|
|
11369
|
+
};
|
|
11370
|
+
const { advancedVSeed, vseed } = context;
|
|
11371
|
+
const { chartType, encoding = {}, dimensions, regressionLine } = advancedVSeed;
|
|
11372
|
+
const { dataset } = vseed;
|
|
11373
|
+
const lineTheme = advancedVSeed.config[chartType]?.regressionLine;
|
|
11374
|
+
if (!regressionLine || !regressionLine.kdeRegressionLine) return result;
|
|
11375
|
+
const rowColumnFields = T(dimensions.filter((dim)=>'row' === dim.encoding || 'column' === dim.encoding), (item)=>item.id);
|
|
11376
|
+
const lineList = array_array(regressionLine.kdeRegressionLine);
|
|
11377
|
+
if (!result.customMark) result.customMark = [];
|
|
11378
|
+
lineList.forEach((line, lineIndex)=>{
|
|
11379
|
+
const theme = lineTheme.kdeRegressionLine ?? {};
|
|
11380
|
+
const { color, lineWidth, lineDash, text, textColor, textFontSize, textFontWeight } = line;
|
|
11381
|
+
const childrenMarks = [];
|
|
11382
|
+
result.customMark.push({
|
|
11383
|
+
type: 'group',
|
|
11384
|
+
interactive: false,
|
|
11385
|
+
zIndex: 500,
|
|
11386
|
+
name: `kdeRegressionLine-${lineIndex}`,
|
|
11387
|
+
style: {
|
|
11388
|
+
data: (datum, ctx)=>{
|
|
11389
|
+
const vchart = ctx.vchart;
|
|
11390
|
+
const chart = vchart.getChart();
|
|
11391
|
+
const series = chart.getAllSeries().filter((s)=>'bar' === s.type);
|
|
11392
|
+
if (series && series.length) {
|
|
11393
|
+
const s = series[0];
|
|
11394
|
+
const region = s.getRegion().getLayoutStartPoint();
|
|
11395
|
+
const fieldX = s.fieldX?.[0];
|
|
11396
|
+
const scaleY = s.getYAxisHelper().getScale?.(0);
|
|
11397
|
+
const viewData = s.getViewData()?.latestData;
|
|
11398
|
+
if (!dataset || !dataset.length || !viewData || !viewData.length || !scaleY) return null;
|
|
11399
|
+
const simpleData = dataset.filter((entry)=>rowColumnFields.length ? rowColumnFields.every((dim)=>entry[dim.id] === viewData[0][dim.id]) : true).map((d)=>d[encoding.value?.[0]]);
|
|
11400
|
+
const res = kde_kde(simpleData, {
|
|
11401
|
+
bandwidth: Math.abs(viewData[0][BinEndMeasureId] - viewData[0][BinStartMeasureId])
|
|
11402
|
+
});
|
|
11403
|
+
const N = Math.max(3, Math.floor(simpleData.length / 4));
|
|
11404
|
+
const lineData = res.evaluateGrid(N);
|
|
11405
|
+
const scaleR = (k)=>scaleY.scale(k * simpleData.length * res.bandwidth);
|
|
11406
|
+
const linePoints = lineData.map((ld)=>{
|
|
11407
|
+
const d = {
|
|
11408
|
+
[fieldX]: ld.x
|
|
11409
|
+
};
|
|
11410
|
+
return {
|
|
11411
|
+
x: s.dataToPositionX(d) + region.x,
|
|
11412
|
+
y: scaleR(ld.y) + region.y
|
|
11413
|
+
};
|
|
11414
|
+
});
|
|
11415
|
+
return {
|
|
11416
|
+
linePoints,
|
|
11417
|
+
color: color ?? s.getOption().globalScale.getScale('color')?.scale(s.getSeriesKeys()[0])
|
|
11418
|
+
};
|
|
11419
|
+
}
|
|
11420
|
+
return null;
|
|
11421
|
+
}
|
|
11422
|
+
},
|
|
11423
|
+
children: childrenMarks
|
|
11424
|
+
});
|
|
11425
|
+
childrenMarks.push({
|
|
11426
|
+
type: 'line',
|
|
11427
|
+
interactive: false,
|
|
11428
|
+
zIndex: 500,
|
|
11429
|
+
style: {
|
|
11430
|
+
lineWidth: lineWidth ?? theme.lineWidth,
|
|
11431
|
+
lineDash: lineDash ?? theme.lineDash,
|
|
11432
|
+
stroke: color ?? defaultRegressionLineColor,
|
|
11433
|
+
points: (datum, ctx, opt)=>{
|
|
11434
|
+
const parentNode = opt.mark?._product?.parent;
|
|
11435
|
+
if (parentNode?.attribute?.data) return parentNode.attribute.data.linePoints;
|
|
11436
|
+
return [];
|
|
11437
|
+
}
|
|
11438
|
+
}
|
|
11439
|
+
});
|
|
11440
|
+
if (!chunk_JK3VNB42_n(text)) childrenMarks.push({
|
|
11441
|
+
type: 'text',
|
|
11442
|
+
interactive: false,
|
|
11443
|
+
zIndex: 500,
|
|
11444
|
+
style: {
|
|
11445
|
+
textAlign: 'end',
|
|
11446
|
+
fill: textColor ?? theme.textColor,
|
|
11447
|
+
fontSize: textFontSize ?? theme.textFontSize,
|
|
11448
|
+
fontWeight: textFontWeight ?? theme.textFontWeight,
|
|
11449
|
+
text: text,
|
|
11450
|
+
x: defaultRegressionLineLabelX,
|
|
11451
|
+
y: defaultRegressionLineLabelY
|
|
11452
|
+
}
|
|
11453
|
+
});
|
|
11454
|
+
});
|
|
11455
|
+
return result;
|
|
11456
|
+
};
|
|
10491
11457
|
function ecdf(data) {
|
|
10492
11458
|
const n = data.length, sorted = data.slice().sort((a, b)=>a - b);
|
|
10493
11459
|
function evaluateSingle(x) {
|
|
@@ -10533,44 +11499,29 @@
|
|
|
10533
11499
|
n: n
|
|
10534
11500
|
};
|
|
10535
11501
|
}
|
|
10536
|
-
const
|
|
10537
|
-
switch(type){
|
|
10538
|
-
case 'kde':
|
|
10539
|
-
return kde_kde(data, kdeOptions);
|
|
10540
|
-
case 'ecdf':
|
|
10541
|
-
return ecdf(data);
|
|
10542
|
-
}
|
|
10543
|
-
};
|
|
10544
|
-
const histogramRegressionLine_histogramRegressionLine = (spec, context)=>{
|
|
11502
|
+
const ecdfRegressionLine = (spec, context)=>{
|
|
10545
11503
|
const result = {
|
|
10546
11504
|
...spec
|
|
10547
11505
|
};
|
|
10548
11506
|
const { advancedVSeed, vseed } = context;
|
|
10549
|
-
const { chartType, encoding = {}, dimensions,
|
|
11507
|
+
const { chartType, encoding = {}, dimensions, regressionLine } = advancedVSeed;
|
|
10550
11508
|
const { dataset } = vseed;
|
|
10551
|
-
const
|
|
10552
|
-
if (!
|
|
11509
|
+
const lineTheme = advancedVSeed.config[chartType]?.regressionLine;
|
|
11510
|
+
if (!regressionLine || !regressionLine.ecdfRegressionLine) return result;
|
|
10553
11511
|
const rowColumnFields = T(dimensions.filter((dim)=>'row' === dim.encoding || 'column' === dim.encoding), (item)=>item.id);
|
|
10554
|
-
const lineList =
|
|
10555
|
-
histogramRegressionLine
|
|
10556
|
-
];
|
|
11512
|
+
const lineList = array_array(regressionLine.ecdfRegressionLine);
|
|
10557
11513
|
if (!result.customMark) result.customMark = [];
|
|
10558
|
-
lineList.forEach((line)=>{
|
|
10559
|
-
const
|
|
11514
|
+
lineList.forEach((line, lineIndex)=>{
|
|
11515
|
+
const theme = lineTheme?.ecdfRegressionLine ?? {};
|
|
11516
|
+
const { color, lineWidth, lineDash, text, textColor, textFontSize, textFontWeight } = line;
|
|
11517
|
+
const childrenMarks = [];
|
|
10560
11518
|
result.customMark.push({
|
|
10561
|
-
type: '
|
|
11519
|
+
type: 'group',
|
|
10562
11520
|
interactive: false,
|
|
10563
11521
|
zIndex: 500,
|
|
11522
|
+
name: `ecdfRegressionLine-${lineIndex}`,
|
|
10564
11523
|
style: {
|
|
10565
|
-
|
|
10566
|
-
lineDash: lineDash ?? theme?.lineDash,
|
|
10567
|
-
stroke: color ?? ((datum, ctx)=>{
|
|
10568
|
-
const vchart = ctx.vchart;
|
|
10569
|
-
const chart = vchart.getChart();
|
|
10570
|
-
const series = chart.getAllSeries().filter((s)=>'bar' === s.type);
|
|
10571
|
-
return series.length ? series[0].getOption().globalScale.getScale('color')?.scale(series[0].getSeriesKeys()[0]) : void 0;
|
|
10572
|
-
}),
|
|
10573
|
-
points: (datum, ctx)=>{
|
|
11524
|
+
data: (datum, ctx)=>{
|
|
10574
11525
|
const vchart = ctx.vchart;
|
|
10575
11526
|
const chart = vchart.getChart();
|
|
10576
11527
|
const series = chart.getAllSeries().filter((s)=>'bar' === s.type);
|
|
@@ -10580,18 +11531,16 @@
|
|
|
10580
11531
|
const fieldX = s.fieldX?.[0];
|
|
10581
11532
|
const scaleY = s.getYAxisHelper().getScale?.(0);
|
|
10582
11533
|
const viewData = s.getViewData()?.latestData;
|
|
10583
|
-
if (!dataset || !dataset.length || !viewData || !viewData.length || !scaleY) return;
|
|
11534
|
+
if (!dataset || !dataset.length || !viewData || !viewData.length || !scaleY) return null;
|
|
10584
11535
|
const simpleData = dataset.filter((entry)=>rowColumnFields.length ? rowColumnFields.every((dim)=>entry[dim.id] === viewData[0][dim.id]) : true).map((d)=>d[encoding.value?.[0]]);
|
|
10585
|
-
const res =
|
|
10586
|
-
bandwidth: Math.abs(viewData[0][BinEndMeasureId] - viewData[0][BinStartMeasureId])
|
|
10587
|
-
} : void 0);
|
|
11536
|
+
const res = ecdf(simpleData);
|
|
10588
11537
|
const N = Math.max(3, Math.floor(simpleData.length / 4));
|
|
10589
11538
|
const lineData = res.evaluateGrid(N);
|
|
10590
11539
|
const yRange = scaleY.range();
|
|
10591
11540
|
const y0 = yRange[0];
|
|
10592
11541
|
const y1 = yRange[yRange.length - 1];
|
|
10593
|
-
const scaleR =
|
|
10594
|
-
|
|
11542
|
+
const scaleR = (e)=>y0 + (y1 - y0) * e;
|
|
11543
|
+
const linePoints = lineData.map((ld)=>{
|
|
10595
11544
|
const d = {
|
|
10596
11545
|
[fieldX]: ld.x
|
|
10597
11546
|
};
|
|
@@ -10600,54 +11549,43 @@
|
|
|
10600
11549
|
y: scaleR(ld.y) + region.y
|
|
10601
11550
|
};
|
|
10602
11551
|
});
|
|
11552
|
+
return {
|
|
11553
|
+
linePoints,
|
|
11554
|
+
color: color ?? s.getOption().globalScale.getScale('color')?.scale(s.getSeriesKeys()[0])
|
|
11555
|
+
};
|
|
10603
11556
|
}
|
|
11557
|
+
return null;
|
|
11558
|
+
}
|
|
11559
|
+
},
|
|
11560
|
+
children: childrenMarks
|
|
11561
|
+
});
|
|
11562
|
+
childrenMarks.push({
|
|
11563
|
+
type: 'line',
|
|
11564
|
+
interactive: false,
|
|
11565
|
+
zIndex: 500,
|
|
11566
|
+
style: {
|
|
11567
|
+
lineWidth: lineWidth ?? theme.lineWidth,
|
|
11568
|
+
lineDash: lineDash ?? theme.lineDash,
|
|
11569
|
+
stroke: color ?? defaultRegressionLineColor,
|
|
11570
|
+
points: (datum, ctx, opt)=>{
|
|
11571
|
+
const parentNode = opt.mark?._product?.parent;
|
|
11572
|
+
if (parentNode?.attribute?.data) return parentNode.attribute.data.linePoints;
|
|
10604
11573
|
return [];
|
|
10605
11574
|
}
|
|
10606
11575
|
}
|
|
10607
11576
|
});
|
|
10608
|
-
if (!chunk_JK3VNB42_n(text))
|
|
11577
|
+
if (!chunk_JK3VNB42_n(text)) childrenMarks.push({
|
|
10609
11578
|
type: 'text',
|
|
10610
11579
|
interactive: false,
|
|
10611
11580
|
zIndex: 500,
|
|
10612
11581
|
style: {
|
|
10613
11582
|
textAlign: 'end',
|
|
10614
|
-
fill: textColor ?? theme
|
|
10615
|
-
fontSize: textFontSize ?? theme
|
|
10616
|
-
fontWeight: textFontWeight ?? theme
|
|
11583
|
+
fill: textColor ?? theme.textColor,
|
|
11584
|
+
fontSize: textFontSize ?? theme.textFontSize,
|
|
11585
|
+
fontWeight: textFontWeight ?? theme.textFontWeight,
|
|
10617
11586
|
text: text,
|
|
10618
|
-
x:
|
|
10619
|
-
|
|
10620
|
-
const chart = vchart.getChart();
|
|
10621
|
-
const series = chart.getAllSeries().filter((s)=>'bar' === s.type);
|
|
10622
|
-
if (series && series.length) {
|
|
10623
|
-
const s = series[0];
|
|
10624
|
-
const startPoint = s.getRegion().getLayoutStartPoint();
|
|
10625
|
-
const fieldX = s.fieldX[0];
|
|
10626
|
-
const fieldX2 = s.fieldX2;
|
|
10627
|
-
const scaleY = s.getYAxisHelper().getScale?.(0);
|
|
10628
|
-
const viewData = s.getViewData()?.latestData;
|
|
10629
|
-
if (!dataset || !dataset.length || !viewData || !viewData.length || !scaleY) return;
|
|
10630
|
-
const maxX = Math.max.apply(null, viewData.map((d)=>Math.max(d[fieldX], d[fieldX2])));
|
|
10631
|
-
return startPoint.x + s.dataToPositionX({
|
|
10632
|
-
[fieldX]: maxX
|
|
10633
|
-
});
|
|
10634
|
-
}
|
|
10635
|
-
},
|
|
10636
|
-
y: (datum, ctx)=>{
|
|
10637
|
-
const vchart = ctx.vchart;
|
|
10638
|
-
const chart = vchart.getChart();
|
|
10639
|
-
const series = chart.getAllSeries().filter((s)=>'bar' === s.type);
|
|
10640
|
-
if (series && series.length) {
|
|
10641
|
-
const s = series[0];
|
|
10642
|
-
const startPoint = s.getRegion().getLayoutStartPoint();
|
|
10643
|
-
const fieldY = s.fieldY[0];
|
|
10644
|
-
const viewData = s.getViewData()?.latestData;
|
|
10645
|
-
if (!viewData || !viewData.length) return;
|
|
10646
|
-
return 'ecdf' === type ? startPoint.y + 12 : startPoint.y + s.dataToPositionY({
|
|
10647
|
-
[fieldY]: viewData[viewData.length - 1]?.[fieldY]
|
|
10648
|
-
});
|
|
10649
|
-
}
|
|
10650
|
-
}
|
|
11587
|
+
x: defaultRegressionLineLabelX,
|
|
11588
|
+
y: defaultRegressionLineLabelY
|
|
10651
11589
|
}
|
|
10652
11590
|
});
|
|
10653
11591
|
});
|
|
@@ -10670,7 +11608,8 @@
|
|
|
10670
11608
|
annotationVerticalLine_annotationVerticalLine,
|
|
10671
11609
|
annotationHorizontalLine_annotationHorizontalLine,
|
|
10672
11610
|
annotationAreaBand,
|
|
10673
|
-
|
|
11611
|
+
kdeRegressionLine,
|
|
11612
|
+
ecdfRegressionLine
|
|
10674
11613
|
];
|
|
10675
11614
|
const pivotHistogram = [
|
|
10676
11615
|
initPivot,
|
|
@@ -10692,7 +11631,8 @@
|
|
|
10692
11631
|
annotationVerticalLine_annotationVerticalLine,
|
|
10693
11632
|
annotationHorizontalLine_annotationHorizontalLine,
|
|
10694
11633
|
annotationAreaBand,
|
|
10695
|
-
|
|
11634
|
+
kdeRegressionLine,
|
|
11635
|
+
ecdfRegressionLine
|
|
10696
11636
|
]),
|
|
10697
11637
|
pivotRowDimensions,
|
|
10698
11638
|
pivotColumnDimensions,
|
|
@@ -11123,18 +12063,70 @@
|
|
|
11123
12063
|
const getDarkHeatmapCellTheme = ()=>({
|
|
11124
12064
|
stroke: '#404349'
|
|
11125
12065
|
});
|
|
11126
|
-
const
|
|
12066
|
+
const getDefaultRegressionLine = ()=>({
|
|
11127
12067
|
lineWidth: 2,
|
|
11128
12068
|
textFontSize: 12,
|
|
11129
12069
|
textFontWeight: 400
|
|
11130
12070
|
});
|
|
11131
|
-
const
|
|
11132
|
-
|
|
11133
|
-
|
|
12071
|
+
const getLightRegressionLine = ()=>({
|
|
12072
|
+
kdeRegressionLine: {
|
|
12073
|
+
...getDefaultRegressionLine(),
|
|
12074
|
+
textColor: '#364159'
|
|
12075
|
+
},
|
|
12076
|
+
ecdfRegressionLine: {
|
|
12077
|
+
...getDefaultRegressionLine(),
|
|
12078
|
+
textColor: '#364159'
|
|
12079
|
+
},
|
|
12080
|
+
linearRegressionLine: {
|
|
12081
|
+
...getDefaultRegressionLine(),
|
|
12082
|
+
textColor: '#364159',
|
|
12083
|
+
confidenceIntervalOpacity: 0.2
|
|
12084
|
+
},
|
|
12085
|
+
lowessRegressionLine: {
|
|
12086
|
+
...getDefaultRegressionLine(),
|
|
12087
|
+
textColor: '#364159',
|
|
12088
|
+
confidenceIntervalOpacity: 0.2
|
|
12089
|
+
},
|
|
12090
|
+
polynomialRegressionLine: {
|
|
12091
|
+
...getDefaultRegressionLine(),
|
|
12092
|
+
textColor: '#364159',
|
|
12093
|
+
confidenceIntervalOpacity: 0.2
|
|
12094
|
+
},
|
|
12095
|
+
logisticRegressionLine: {
|
|
12096
|
+
...getDefaultRegressionLine(),
|
|
12097
|
+
textColor: '#364159',
|
|
12098
|
+
confidenceIntervalOpacity: 0.2
|
|
12099
|
+
}
|
|
11134
12100
|
});
|
|
11135
|
-
const
|
|
11136
|
-
|
|
11137
|
-
|
|
12101
|
+
const getDarkRegressionLine = ()=>({
|
|
12102
|
+
kdeRegressionLine: {
|
|
12103
|
+
...getDefaultRegressionLine(),
|
|
12104
|
+
textColor: '#FFFFFF'
|
|
12105
|
+
},
|
|
12106
|
+
ecdfRegressionLine: {
|
|
12107
|
+
...getDefaultRegressionLine(),
|
|
12108
|
+
textColor: '#FFFFFF'
|
|
12109
|
+
},
|
|
12110
|
+
linearRegressionLine: {
|
|
12111
|
+
...getDefaultRegressionLine(),
|
|
12112
|
+
textColor: '#FFFFFF',
|
|
12113
|
+
confidenceIntervalOpacity: 0.2
|
|
12114
|
+
},
|
|
12115
|
+
lowessRegressionLine: {
|
|
12116
|
+
...getDefaultRegressionLine(),
|
|
12117
|
+
textColor: '#FFFFFF',
|
|
12118
|
+
confidenceIntervalOpacity: 0.2
|
|
12119
|
+
},
|
|
12120
|
+
polynomialRegressionLine: {
|
|
12121
|
+
...getDefaultRegressionLine(),
|
|
12122
|
+
textColor: '#FFFFFF',
|
|
12123
|
+
confidenceIntervalOpacity: 0.2
|
|
12124
|
+
},
|
|
12125
|
+
logisticRegressionLine: {
|
|
12126
|
+
...getDefaultRegressionLine(),
|
|
12127
|
+
textColor: '#FFFFFF',
|
|
12128
|
+
confidenceIntervalOpacity: 0.2
|
|
12129
|
+
}
|
|
11138
12130
|
});
|
|
11139
12131
|
const lightTheme = ()=>{
|
|
11140
12132
|
const linearAxis = getLightLinearAxis();
|
|
@@ -11186,7 +12178,8 @@
|
|
|
11186
12178
|
0
|
|
11187
12179
|
],
|
|
11188
12180
|
pivotGrid: getLightPivotChartGridConfig(),
|
|
11189
|
-
annotation: getLightAnnotation()
|
|
12181
|
+
annotation: getLightAnnotation(),
|
|
12182
|
+
regressionLine: getLightRegressionLine()
|
|
11190
12183
|
},
|
|
11191
12184
|
columnParallel: {
|
|
11192
12185
|
...baseConfig,
|
|
@@ -11307,7 +12300,8 @@
|
|
|
11307
12300
|
showValuePercent: false
|
|
11308
12301
|
},
|
|
11309
12302
|
pivotGrid: getLightPivotChartGridConfig(),
|
|
11310
|
-
annotation: getLightAnnotation()
|
|
12303
|
+
annotation: getLightAnnotation(),
|
|
12304
|
+
regressionLine: getLightRegressionLine()
|
|
11311
12305
|
},
|
|
11312
12306
|
dualAxis: {
|
|
11313
12307
|
...baseConfig,
|
|
@@ -11390,7 +12384,7 @@
|
|
|
11390
12384
|
crosshairRect,
|
|
11391
12385
|
pivotGrid: getLightPivotChartGridConfig(),
|
|
11392
12386
|
annotation: getLightAnnotation(),
|
|
11393
|
-
|
|
12387
|
+
regressionLine: getLightRegressionLine()
|
|
11394
12388
|
},
|
|
11395
12389
|
boxPlot: {
|
|
11396
12390
|
...baseConfig,
|
|
@@ -11453,7 +12447,8 @@
|
|
|
11453
12447
|
0
|
|
11454
12448
|
],
|
|
11455
12449
|
pivotGrid: getDarkPivotChartGridConfig(),
|
|
11456
|
-
annotation: getDarkAnnotation()
|
|
12450
|
+
annotation: getDarkAnnotation(),
|
|
12451
|
+
regressionLine: getDarkRegressionLine()
|
|
11457
12452
|
},
|
|
11458
12453
|
columnParallel: {
|
|
11459
12454
|
...baseConfig,
|
|
@@ -11568,7 +12563,8 @@
|
|
|
11568
12563
|
showValuePercent: false
|
|
11569
12564
|
},
|
|
11570
12565
|
pivotGrid: getDarkPivotChartGridConfig(),
|
|
11571
|
-
annotation: getDarkAnnotation()
|
|
12566
|
+
annotation: getDarkAnnotation(),
|
|
12567
|
+
regressionLine: getDarkRegressionLine()
|
|
11572
12568
|
},
|
|
11573
12569
|
dualAxis: {
|
|
11574
12570
|
...baseConfig,
|
|
@@ -11651,7 +12647,7 @@
|
|
|
11651
12647
|
crosshairRect: crosshairRect,
|
|
11652
12648
|
pivotGrid: getDarkPivotChartGridConfig(),
|
|
11653
12649
|
annotation: getDarkAnnotation(),
|
|
11654
|
-
|
|
12650
|
+
regressionLine: getDarkRegressionLine()
|
|
11655
12651
|
},
|
|
11656
12652
|
boxPlot: {
|
|
11657
12653
|
...baseConfig,
|
|
@@ -15722,7 +16718,9 @@
|
|
|
15722
16718
|
hoverHeaderBackgroundColor: schemas_string().nullish(),
|
|
15723
16719
|
hoverHeaderInlineBackgroundColor: schemas_string().nullish(),
|
|
15724
16720
|
outlineBorderLineWidth: schemas_number().nullish(),
|
|
15725
|
-
frameCornerRadius: schemas_number().nullish()
|
|
16721
|
+
frameCornerRadius: schemas_number().nullish(),
|
|
16722
|
+
minChartWidth: schemas_number().nullish(),
|
|
16723
|
+
minChartHeight: schemas_number().nullish()
|
|
15726
16724
|
});
|
|
15727
16725
|
const zLineConfig = schemas_object({
|
|
15728
16726
|
backgroundColor: zBackgroundColor.nullish(),
|
|
@@ -15744,7 +16742,35 @@
|
|
|
15744
16742
|
]);
|
|
15745
16743
|
const zBarMaxWidth = schemas_number().or(schemas_string());
|
|
15746
16744
|
const zBarGapInGroup = schemas_number().or(schemas_string());
|
|
15747
|
-
const
|
|
16745
|
+
const zEcdfRegressionLine = schemas_object({
|
|
16746
|
+
color: schemas_string().nullish(),
|
|
16747
|
+
lineWidth: schemas_number().nullish(),
|
|
16748
|
+
lineDash: schemas_array(schemas_number()).nullish(),
|
|
16749
|
+
text: schemas_string().nullish(),
|
|
16750
|
+
textColor: schemas_string().nullish(),
|
|
16751
|
+
textFontSize: schemas_number().nullish(),
|
|
16752
|
+
textFontWeight: schemas_number().nullish()
|
|
16753
|
+
});
|
|
16754
|
+
const zKdeRegressionLine = zEcdfRegressionLine.extend({});
|
|
16755
|
+
const zLinearRegressionLine = zEcdfRegressionLine.extend({
|
|
16756
|
+
confidenceIntervalVisible: schemas_boolean().nullish(),
|
|
16757
|
+
confidenceIntervalColor: schemas_string().nullish(),
|
|
16758
|
+
confidenceIntervalOpacity: schemas_number().nullish()
|
|
16759
|
+
});
|
|
16760
|
+
const zLogisticRegressionLine = zLinearRegressionLine.extend({});
|
|
16761
|
+
const zLowessRegressionLine = zLinearRegressionLine.extend({});
|
|
16762
|
+
const zPolynomialRegressionLine = zLinearRegressionLine.extend({
|
|
16763
|
+
degree: schemas_number().nullish()
|
|
16764
|
+
});
|
|
16765
|
+
const zRegressionLine = schemas_object({
|
|
16766
|
+
ecdfRegressionLine: zEcdfRegressionLine.or(schemas_array(zEcdfRegressionLine)).nullish(),
|
|
16767
|
+
kdeRegressionLine: zKdeRegressionLine.or(schemas_array(zKdeRegressionLine)).nullish(),
|
|
16768
|
+
linearRegressionLine: zLinearRegressionLine.or(schemas_array(zLinearRegressionLine)).nullish(),
|
|
16769
|
+
lowessRegressionLine: zLowessRegressionLine.or(schemas_array(zLowessRegressionLine)).nullish(),
|
|
16770
|
+
polynomialRegressionLine: zPolynomialRegressionLine.or(schemas_array(zPolynomialRegressionLine)).nullish(),
|
|
16771
|
+
logisticRegressionLine: zLogisticRegressionLine.or(schemas_array(zLogisticRegressionLine)).nullish()
|
|
16772
|
+
});
|
|
16773
|
+
const zColumnParallelConfig = schemas_object({
|
|
15748
16774
|
backgroundColor: zBackgroundColor.nullish(),
|
|
15749
16775
|
label: zLabel.nullish(),
|
|
15750
16776
|
color: zColor.nullish(),
|
|
@@ -15759,8 +16785,10 @@
|
|
|
15759
16785
|
pivotGrid: zPivotChartGridConfig.nullish(),
|
|
15760
16786
|
annotation: zAnnotationConfig.nullish()
|
|
15761
16787
|
});
|
|
15762
|
-
const
|
|
15763
|
-
|
|
16788
|
+
const zColumnConfig = zColumnParallelConfig.extend({
|
|
16789
|
+
regressionLine: zRegressionLine.nullish()
|
|
16790
|
+
});
|
|
16791
|
+
const zColumnPercentConfig = zColumnParallelConfig.extend({});
|
|
15764
16792
|
const zBarConfig = schemas_object({
|
|
15765
16793
|
backgroundColor: zBackgroundColor.nullish(),
|
|
15766
16794
|
label: zLabel.nullish(),
|
|
@@ -15801,7 +16829,8 @@
|
|
|
15801
16829
|
size: schemas_number().or(schemas_array(schemas_number())).nullish(),
|
|
15802
16830
|
sizeRange: schemas_number().or(schemas_array(schemas_number())).nullish(),
|
|
15803
16831
|
pivotGrid: zPivotChartGridConfig.nullish(),
|
|
15804
|
-
annotation: zAnnotationConfig.nullish()
|
|
16832
|
+
annotation: zAnnotationConfig.nullish(),
|
|
16833
|
+
regressionLine: zRegressionLine.nullish()
|
|
15805
16834
|
});
|
|
15806
16835
|
const zDualAxisConfig = schemas_object({
|
|
15807
16836
|
backgroundColor: zBackgroundColor.nullish(),
|
|
@@ -15887,19 +16916,6 @@
|
|
|
15887
16916
|
annotation: zAnnotationConfig.nullish(),
|
|
15888
16917
|
whiskers: zWhiskersConfig.nullish()
|
|
15889
16918
|
});
|
|
15890
|
-
const zHistogramRegressionLine = schemas_object({
|
|
15891
|
-
type: union([
|
|
15892
|
-
literal('kde'),
|
|
15893
|
-
literal('ecdf')
|
|
15894
|
-
]).nullish(),
|
|
15895
|
-
color: schemas_string().nullish(),
|
|
15896
|
-
lineWidth: schemas_number().nullish(),
|
|
15897
|
-
lineDash: schemas_array(schemas_number()).nullish(),
|
|
15898
|
-
text: schemas_string().nullish(),
|
|
15899
|
-
textColor: schemas_string().nullish(),
|
|
15900
|
-
textFontSize: schemas_number().nullish(),
|
|
15901
|
-
textFontWeight: schemas_number().nullish()
|
|
15902
|
-
});
|
|
15903
16919
|
const zHistogramConfig = schemas_object({
|
|
15904
16920
|
backgroundColor: zBackgroundColor.nullish(),
|
|
15905
16921
|
label: zLabel.nullish(),
|
|
@@ -15915,7 +16931,7 @@
|
|
|
15915
16931
|
binCount: schemas_number().positive().nullish(),
|
|
15916
16932
|
binStep: schemas_number().positive().nullish(),
|
|
15917
16933
|
binValueType: literal('count').or(literal('percentage')).nullish(),
|
|
15918
|
-
|
|
16934
|
+
regressionLine: zRegressionLine.nullish()
|
|
15919
16935
|
});
|
|
15920
16936
|
const zConfig = schemas_object({
|
|
15921
16937
|
table: zTableConfig.nullish(),
|
|
@@ -16190,6 +17206,7 @@
|
|
|
16190
17206
|
annotationVerticalLine: schemas_array(zAnnotationVerticalLine).or(zAnnotationVerticalLine).nullish(),
|
|
16191
17207
|
annotationHorizontalLine: schemas_array(zAnnotationHorizontalLine).or(zAnnotationHorizontalLine).nullish(),
|
|
16192
17208
|
annotationArea: schemas_array(zAnnotationArea).or(zAnnotationArea).nullish(),
|
|
17209
|
+
polynomialRegressionLine: schemas_array(zPolynomialRegressionLine).or(zPolynomialRegressionLine).or(schemas_boolean()).nullish(),
|
|
16193
17210
|
locale: zLocale.nullish()
|
|
16194
17211
|
});
|
|
16195
17212
|
const zColumnParallel = schemas_object({
|
|
@@ -16385,6 +17402,10 @@
|
|
|
16385
17402
|
annotationVerticalLine: schemas_array(zAnnotationVerticalLine).or(zAnnotationVerticalLine).nullish(),
|
|
16386
17403
|
annotationHorizontalLine: schemas_array(zAnnotationHorizontalLine).or(zAnnotationHorizontalLine).nullish(),
|
|
16387
17404
|
annotationArea: schemas_array(zAnnotationArea).or(zAnnotationArea).nullish(),
|
|
17405
|
+
linearRegressionLine: schemas_array(zLinearRegressionLine).or(zLinearRegressionLine).or(schemas_boolean()).nullish(),
|
|
17406
|
+
lowessRegressionLine: schemas_array(zLowessRegressionLine).or(zLowessRegressionLine).or(schemas_boolean()).nullish(),
|
|
17407
|
+
polynomialRegressionLine: schemas_array(zPolynomialRegressionLine).or(zPolynomialRegressionLine).or(schemas_boolean()).nullish(),
|
|
17408
|
+
logisticRegressionLine: schemas_array(zLogisticRegressionLine).or(zLogisticRegressionLine).or(schemas_boolean()).nullish(),
|
|
16388
17409
|
locale: zLocale.nullish()
|
|
16389
17410
|
});
|
|
16390
17411
|
const zDualAxis = schemas_object({
|
|
@@ -16442,7 +17463,8 @@
|
|
|
16442
17463
|
annotationVerticalLine: schemas_array(zAnnotationVerticalLine).or(zAnnotationVerticalLine).nullish(),
|
|
16443
17464
|
annotationHorizontalLine: schemas_array(zAnnotationHorizontalLine).or(zAnnotationHorizontalLine).nullish(),
|
|
16444
17465
|
annotationArea: schemas_array(zAnnotationArea).or(zAnnotationArea).nullish(),
|
|
16445
|
-
|
|
17466
|
+
ecdfRegressionLine: schemas_array(zEcdfRegressionLine).or(zEcdfRegressionLine).or(schemas_boolean()).nullish(),
|
|
17467
|
+
kdeRegressionLine: schemas_array(zKdeRegressionLine).or(zKdeRegressionLine).or(schemas_boolean()).nullish(),
|
|
16446
17468
|
locale: zLocale.nullish()
|
|
16447
17469
|
});
|
|
16448
17470
|
const zRose = schemas_object({
|
|
@@ -16604,7 +17626,7 @@
|
|
|
16604
17626
|
customTheme: zCustomThemeConfig,
|
|
16605
17627
|
annotation: zAnnotation,
|
|
16606
17628
|
locale: zLocale,
|
|
16607
|
-
|
|
17629
|
+
regressionLine: zRegressionLine
|
|
16608
17630
|
});
|
|
16609
17631
|
return __webpack_exports__;
|
|
16610
17632
|
})());
|