@visactor/vseed 0.1.15 → 0.1.17
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 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/builder/builder/buildAdvanced.js +1 -1
- package/dist/esm/builder/builder/buildAdvanced.js.map +1 -1
- package/dist/esm/builder/builder/buildSpec.js +2 -3
- package/dist/esm/builder/builder/buildSpec.js.map +1 -1
- package/dist/esm/dataReshape/foldMeasures.d.ts +1 -0
- package/dist/esm/dataReshape/foldMeasures.js +5 -1
- package/dist/esm/dataReshape/foldMeasures.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/area.js +5 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/area.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/areaPercent.js +5 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/areaPercent.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/bar.js +5 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/bar.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/barParallel.js +5 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/barParallel.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/barPercent.js +5 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/barPercent.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/column.js +5 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/column.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/columnParallel.js +5 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/columnParallel.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/columnPercent.js +5 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/columnPercent.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/donut.js +5 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/donut.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/dualAxis.js +5 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/dualAxis.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/funnel.js +5 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/funnel.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/heatmap.js +5 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/heatmap.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/line.js +5 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/line.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/pie.js +5 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/pie.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/radar.js +5 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/radar.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/rose.js +5 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/rose.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/roseParallel.js +5 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/roseParallel.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/scatter.js +6 -2
- package/dist/esm/pipeline/advanced/chart/pipeline/scatter.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/config/config.d.ts +0 -1
- package/dist/esm/pipeline/advanced/chart/pipes/config/config.js +1 -2
- package/dist/esm/pipeline/advanced/chart/pipes/config/config.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/config/index.d.ts +1 -0
- package/dist/esm/pipeline/advanced/chart/pipes/config/index.js +1 -0
- package/dist/esm/pipeline/advanced/chart/pipes/config/scatter.d.ts +2 -0
- package/dist/esm/pipeline/advanced/chart/pipes/config/scatter.js +32 -0
- package/dist/esm/pipeline/advanced/chart/pipes/config/scatter.js.map +1 -0
- package/dist/esm/pipeline/advanced/chart/pipes/default/defaultDimensions.js +4 -3
- package/dist/esm/pipeline/advanced/chart/pipes/default/defaultDimensions.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/default/defaultMeasures.js +12 -9
- package/dist/esm/pipeline/advanced/chart/pipes/default/defaultMeasures.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/encoding/scatter.js +1 -0
- package/dist/esm/pipeline/advanced/chart/pipes/encoding/scatter.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/init/initAdvancedVSeed.js +2 -0
- package/dist/esm/pipeline/advanced/chart/pipes/init/initAdvancedVSeed.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/measures/deleteEncodingForMeasure.d.ts +2 -0
- package/dist/esm/pipeline/advanced/chart/pipes/measures/deleteEncodingForMeasure.js +12 -0
- package/dist/esm/pipeline/advanced/chart/pipes/measures/deleteEncodingForMeasure.js.map +1 -0
- package/dist/esm/pipeline/advanced/chart/pipes/measures/index.d.ts +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/measures/index.js +2 -2
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithDualEncoding.js +4 -6
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithDualEncoding.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithEncoding.js +2 -5
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithEncoding.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithScatterEncoding.js +2 -4
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithScatterEncoding.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithDualEncoding.js +4 -6
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithDualEncoding.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithEncoding.js +2 -5
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithEncoding.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithScatterEncoding.js +2 -4
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithScatterEncoding.js.map +1 -1
- package/dist/esm/pipeline/advanced/table/pipes/default/defaultDimensions.js +13 -7
- package/dist/esm/pipeline/advanced/table/pipes/default/defaultDimensions.js.map +1 -1
- package/dist/esm/pipeline/advanced/table/pipes/default/defaultMeasures.js +13 -9
- package/dist/esm/pipeline/advanced/table/pipes/default/defaultMeasures.js.map +1 -1
- package/dist/esm/pipeline/advanced/table/pipes/init/initAdvancedVSeed.js +2 -0
- package/dist/esm/pipeline/advanced/table/pipes/init/initAdvancedVSeed.js.map +1 -1
- package/dist/esm/pipeline/advanced/table/pipes/reshape/reshapePivotTable.js +2 -1
- package/dist/esm/pipeline/advanced/table/pipes/reshape/reshapePivotTable.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/axes/format/linearFormat.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/axes/format/linearFormat.js +11 -0
- package/dist/esm/pipeline/spec/chart/pipes/axes/format/linearFormat.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/axes/title/defaultTitleText.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/axes/title/defaultTitleText.js +14 -0
- package/dist/esm/pipeline/spec/chart/pipes/axes/title/defaultTitleText.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/axes/xBand.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/xBand.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/xLinear.js +8 -11
- package/dist/esm/pipeline/spec/chart/pipes/axes/xLinear.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yBand.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yBand.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinear.js +7 -10
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinear.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinearPrimary.js +8 -10
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinearPrimary.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinearSecondary.js +8 -10
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinearSecondary.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/label/label.js +2 -2
- package/dist/esm/pipeline/spec/chart/pipes/label/label.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/size/index.d.ts +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/size/index.js +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/size/scatterSize.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/size/scatterSize.js +22 -0
- package/dist/esm/pipeline/spec/chart/pipes/size/scatterSize.js.map +1 -0
- package/dist/esm/pipeline/utils/format/createFormatterByMeasure.js +4 -3
- package/dist/esm/pipeline/utils/format/createFormatterByMeasure.js.map +1 -1
- package/dist/esm/pipeline/utils/format/createNumFormatter.js +4 -1
- package/dist/esm/pipeline/utils/format/createNumFormatter.js.map +1 -1
- package/dist/esm/pipeline/utils/index.d.ts +1 -0
- package/dist/esm/pipeline/utils/index.js +1 -0
- package/dist/esm/pipeline/utils/valid/checkVSeed.d.ts +2 -0
- package/dist/esm/pipeline/utils/valid/checkVSeed.js +11 -0
- package/dist/esm/pipeline/utils/valid/checkVSeed.js.map +1 -0
- package/dist/esm/pipeline/utils/valid/index.d.ts +1 -0
- package/dist/esm/pipeline/utils/valid/index.js +2 -0
- package/dist/esm/types/chartType/dualAxis/zDualAxis.d.ts +10 -40
- package/dist/esm/types/chartType/scatter/scatter.d.ts +14 -0
- package/dist/esm/types/chartType/scatter/zScatter.d.ts +12 -40
- package/dist/esm/types/chartType/scatter/zScatter.js +2 -0
- package/dist/esm/types/chartType/scatter/zScatter.js.map +1 -1
- package/dist/esm/types/properties/config/axes/linearAxis.d.ts +3 -3
- package/dist/esm/types/properties/config/label/label.d.ts +2 -2
- package/dist/esm/types/properties/measures/dualMeasures.d.ts +2 -2
- package/dist/esm/types/properties/measures/scatterMeasures.d.ts +2 -2
- package/dist/esm/types/properties/measures/zDualMeasures.d.ts +20 -80
- package/dist/esm/types/properties/measures/zDualMeasures.js +7 -1
- package/dist/esm/types/properties/measures/zDualMeasures.js.map +1 -1
- package/dist/esm/types/properties/measures/zScatterMeasures.d.ts +20 -80
- package/dist/esm/types/properties/measures/zScatterMeasures.js +8 -2
- package/dist/esm/types/properties/measures/zScatterMeasures.js.map +1 -1
- package/dist/esm/types/zVseed.d.ts +22 -80
- package/dist/umd/index.js +316 -183
- package/dist/umd/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/measures/deleteTooltipAndLabelMeasure.d.ts +0 -2
- package/dist/esm/pipeline/advanced/chart/pipes/measures/deleteTooltipAndLabelMeasure.js +0 -12
- package/dist/esm/pipeline/advanced/chart/pipes/measures/deleteTooltipAndLabelMeasure.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/axes/yLinear.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/axes/yLinear.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport { LINEAR_AXIS_INNER_OFFSET_TOP } from '../../../../utils/constant'\nimport {
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/axes/yLinear.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/axes/yLinear.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport { LINEAR_AXIS_INNER_OFFSET_TOP } from '../../../../utils/constant'\nimport { createNumFormatter } from '../../../../utils'\nimport type { SpecPipe, YLinearAxis } from 'src/types'\nimport { createLinearFormat } from './format/linearFormat'\nimport { defaultTitleText } from './title/defaultTitleText'\n\nexport const yLinear: SpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n const { measures, dimensions, encoding } = advancedVSeed\n const config = advancedVSeed.config?.[chartType as 'column']?.yAxis as YLinearAxis\n\n if (!result.axes) {\n result.axes = []\n }\n\n if (!config) {\n result.axes = [\n ...result.axes,\n {\n visible: true,\n type: 'linear',\n orient: 'left',\n },\n ] as ISpec['axes']\n return result\n }\n\n const {\n visible = true,\n label,\n tick,\n title,\n grid,\n line,\n\n zero,\n nice,\n inverse,\n max,\n min,\n log,\n logBase = 10,\n autoFormat,\n numFormat = {},\n } = config\n\n const formatter = createNumFormatter(numFormat)\n\n const linearAxis = {\n visible,\n type: log ? 'log' : 'linear',\n base: logBase,\n orient: 'left',\n nice,\n zero: log ? false : zero,\n inverse,\n max,\n min,\n label: {\n visible: label?.visible,\n formatMethod: (value: string) => {\n return createLinearFormat(value, autoFormat, numFormat, formatter)\n },\n style: {\n fill: label?.labelColor,\n angle: label?.labelAngle,\n fontSize: label?.labelFontSize,\n fontWeight: label?.labelFontWeight,\n },\n },\n title: {\n visible: title?.visible,\n text: title?.titleText || defaultTitleText(measures, dimensions, encoding.y as string[]),\n style: {\n fill: title?.titleColor,\n fontSize: title?.titleFontSize,\n fontWeight: title?.titleFontWeight,\n },\n },\n tick: {\n visible: tick?.visible,\n tickSize: tick?.tickSize,\n inside: tick?.tickInside,\n style: {\n stroke: tick?.tickColor,\n },\n },\n grid: {\n visible: grid?.visible,\n style: {\n lineWidth: grid?.gridWidth,\n stroke: grid?.gridColor,\n },\n },\n domainLine: {\n visible: line?.visible,\n style: {\n lineWidth: line?.lineWidth,\n stroke: line?.lineColor,\n },\n },\n innerOffset: {\n top: LINEAR_AXIS_INNER_OFFSET_TOP,\n // bottom: LINEAR_AXIS_INNER_OFFSET_TOP,\n },\n }\n\n result.axes = [...result.axes, linearAxis] as ISpec['axes']\n\n return result\n}\n"],"names":["yLinear","spec","context","result","advancedVSeed","vseed","chartType","measures","dimensions","encoding","config","visible","label","tick","title","grid","line","zero","nice","inverse","max","min","log","logBase","autoFormat","numFormat","formatter","createNumFormatter","linearAxis","value","createLinearFormat","defaultTitleText","LINEAR_AXIS_INNER_OFFSET_TOP"],"mappings":";;;;AAOO,MAAMA,UAAoB,CAACC,MAAMC;IACtC,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAEC,KAAK,EAAE,GAAGH;IACjC,MAAM,EAAEI,SAAS,EAAE,GAAGD;IACtB,MAAM,EAAEE,QAAQ,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAGL;IAC3C,MAAMM,SAASN,cAAc,MAAM,EAAE,CAACE,UAAsB,EAAE;IAE9D,IAAI,CAACH,OAAO,IAAI,EACdA,OAAO,IAAI,GAAG,EAAE;IAGlB,IAAI,CAACO,QAAQ;QACXP,OAAO,IAAI,GAAG;eACTA,OAAO,IAAI;YACd;gBACE,SAAS;gBACT,MAAM;gBACN,QAAQ;YACV;SACD;QACD,OAAOA;IACT;IAEA,MAAM,EACJQ,UAAU,IAAI,EACdC,KAAK,EACLC,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,IAAI,EAEJC,IAAI,EACJC,IAAI,EACJC,OAAO,EACPC,GAAG,EACHC,GAAG,EACHC,GAAG,EACHC,UAAU,EAAE,EACZC,UAAU,EACVC,YAAY,CAAC,CAAC,EACf,GAAGf;IAEJ,MAAMgB,YAAYC,mBAAmBF;IAErC,MAAMG,aAAa;QACjBjB;QACA,MAAMW,MAAM,QAAQ;QACpB,MAAMC;QACN,QAAQ;QACRL;QACA,MAAMI,MAAM,QAAQL;QACpBE;QACAC;QACAC;QACA,OAAO;YACL,SAAST,OAAO;YAChB,cAAc,CAACiB,QACNC,mBAAmBD,OAAOL,YAAYC,WAAWC;YAE1D,OAAO;gBACL,MAAMd,OAAO;gBACb,OAAOA,OAAO;gBACd,UAAUA,OAAO;gBACjB,YAAYA,OAAO;YACrB;QACF;QACA,OAAO;YACL,SAASE,OAAO;YAChB,MAAMA,OAAO,aAAaiB,iBAAiBxB,UAAUC,YAAYC,SAAS,CAAC;YAC3E,OAAO;gBACL,MAAMK,OAAO;gBACb,UAAUA,OAAO;gBACjB,YAAYA,OAAO;YACrB;QACF;QACA,MAAM;YACJ,SAASD,MAAM;YACf,UAAUA,MAAM;YAChB,QAAQA,MAAM;YACd,OAAO;gBACL,QAAQA,MAAM;YAChB;QACF;QACA,MAAM;YACJ,SAASE,MAAM;YACf,OAAO;gBACL,WAAWA,MAAM;gBACjB,QAAQA,MAAM;YAChB;QACF;QACA,YAAY;YACV,SAASC,MAAM;YACf,OAAO;gBACL,WAAWA,MAAM;gBACjB,QAAQA,MAAM;YAChB;QACF;QACA,aAAa;YACX,KAAKgB;QAEP;IACF;IAEA7B,OAAO,IAAI,GAAG;WAAIA,OAAO,IAAI;QAAEyB;KAAW;IAE1C,OAAOzB;AACT"}
|
@@ -1,13 +1,15 @@
|
|
1
1
|
import { LINEAR_AXIS_INNER_OFFSET_TOP } from "../../../../utils/constant.js";
|
2
|
-
import {
|
2
|
+
import { createNumFormatter } from "../../../../utils/index.js";
|
3
3
|
import { isEmpty, isNullish } from "remeda";
|
4
|
+
import { createLinearFormat } from "./format/linearFormat.js";
|
5
|
+
import { defaultTitleText } from "./title/defaultTitleText.js";
|
4
6
|
const yLinearPrimary = (spec, context)=>{
|
5
7
|
const result = {
|
6
8
|
...spec
|
7
9
|
};
|
8
10
|
const { advancedVSeed, vseed } = context;
|
9
11
|
const { chartType } = vseed;
|
10
|
-
const {
|
12
|
+
const { datasetReshapeInfo, encoding, measures, dimensions } = advancedVSeed;
|
11
13
|
const { index, id: reshapeInfoId, foldInfoList } = datasetReshapeInfo[0];
|
12
14
|
const primaryYAxis = advancedVSeed.config?.[chartType]?.primaryYAxis;
|
13
15
|
const yAxisConfig = Array.isArray(primaryYAxis) ? primaryYAxis[index] || primaryYAxis[0] : primaryYAxis;
|
@@ -35,8 +37,8 @@ const yLinearPrimary = (spec, context)=>{
|
|
35
37
|
];
|
36
38
|
return result;
|
37
39
|
}
|
38
|
-
const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10, autoFormat
|
39
|
-
const formatter = createNumFormatter(numFormat
|
40
|
+
const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10, autoFormat, numFormat = {} } = yAxisConfig;
|
41
|
+
const formatter = createNumFormatter(numFormat);
|
40
42
|
const linearAxis = {
|
41
43
|
visible: isEmptySecondary ? false : visible,
|
42
44
|
id,
|
@@ -51,11 +53,7 @@ const yLinearPrimary = (spec, context)=>{
|
|
51
53
|
min,
|
52
54
|
label: {
|
53
55
|
visible: label?.visible,
|
54
|
-
formatMethod: (value)=>
|
55
|
-
if (!isEmpty(numFormat)) return formatter(value);
|
56
|
-
if (autoFormat) return autoFormatter(value, locale);
|
57
|
-
return value;
|
58
|
-
},
|
56
|
+
formatMethod: (value)=>createLinearFormat(value, autoFormat, numFormat, formatter),
|
59
57
|
style: {
|
60
58
|
fill: label?.labelColor,
|
61
59
|
angle: label?.labelAngle,
|
@@ -65,7 +63,7 @@ const yLinearPrimary = (spec, context)=>{
|
|
65
63
|
},
|
66
64
|
title: {
|
67
65
|
visible: title?.visible,
|
68
|
-
text: title?.titleText,
|
66
|
+
text: title?.titleText || defaultTitleText(measures, dimensions, encoding.y),
|
69
67
|
style: {
|
70
68
|
fill: title?.titleColor,
|
71
69
|
fontSize: title?.titleFontSize,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/axes/yLinearPrimary.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/axes/yLinearPrimary.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport { LINEAR_AXIS_INNER_OFFSET_TOP } from '../../../../utils/constant'\nimport {
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/axes/yLinearPrimary.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/axes/yLinearPrimary.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport { LINEAR_AXIS_INNER_OFFSET_TOP } from '../../../../utils/constant'\nimport { createNumFormatter } from '../../../../utils'\nimport type { SpecPipe, YLinearAxis } from 'src/types'\nimport { isEmpty, isNullish } from 'remeda'\nimport { createLinearFormat } from './format/linearFormat'\nimport { defaultTitleText } from './title/defaultTitleText'\n\nexport const yLinearPrimary: SpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n const { datasetReshapeInfo, encoding, measures, dimensions } = advancedVSeed\n const { index, id: reshapeInfoId, foldInfoList } = datasetReshapeInfo[0]\n // TODO: default config missing\n const primaryYAxis = advancedVSeed.config?.[chartType as 'dualAxis']?.primaryYAxis as YLinearAxis | YLinearAxis[]\n const yAxisConfig = Array.isArray(primaryYAxis) ? primaryYAxis[index] || primaryYAxis[0] : primaryYAxis\n const alignTicks = advancedVSeed.config?.[chartType as 'dualAxis']?.alignTicks as boolean | boolean[]\n const alignTicksConfig = Array.isArray(alignTicks) ? alignTicks[index] || alignTicks[0] : alignTicks\n\n if (isNullish(foldInfoList?.[0])) {\n return result\n }\n\n const isEmptySecondary = isEmpty(foldInfoList?.[0].foldMap)\n\n const id = `${reshapeInfoId}-primary-axis`\n const seriesIds = [`${reshapeInfoId}-primary-series`, `${reshapeInfoId}-secondary-series`]\n const seriesId = alignTicksConfig ? seriesIds : seriesIds[0]\n\n if (!result.axes) {\n result.axes = []\n }\n\n if (!yAxisConfig) {\n result.axes = [\n ...result.axes,\n {\n visible: true,\n id,\n seriesId,\n type: 'linear',\n orient: 'left',\n },\n ] as ISpec['axes']\n return result\n }\n\n const {\n visible = true,\n label,\n tick,\n title,\n grid,\n line,\n\n zero,\n nice,\n inverse,\n max,\n min,\n log,\n logBase = 10,\n\n autoFormat,\n numFormat = {},\n } = yAxisConfig\n\n const formatter = createNumFormatter(numFormat)\n\n const linearAxis = {\n visible: isEmptySecondary ? false : visible,\n id,\n seriesId,\n\n type: log ? 'log' : 'linear',\n base: logBase,\n orient: 'left',\n nice,\n zero: log ? false : zero,\n inverse,\n max,\n min,\n label: {\n visible: label?.visible,\n formatMethod: (value: string) => {\n return createLinearFormat(value, autoFormat, numFormat, formatter)\n },\n style: {\n fill: label?.labelColor,\n angle: label?.labelAngle,\n fontSize: label?.labelFontSize,\n fontWeight: label?.labelFontWeight,\n },\n },\n title: {\n visible: title?.visible,\n text: title?.titleText || defaultTitleText(measures, dimensions, encoding.y as string[]),\n style: {\n fill: title?.titleColor,\n fontSize: title?.titleFontSize,\n fontWeight: title?.titleFontWeight,\n },\n },\n tick: {\n visible: tick?.visible,\n tickSize: tick?.tickSize,\n inside: tick?.tickInside,\n style: {\n stroke: tick?.tickColor,\n },\n },\n grid: {\n visible: grid?.visible,\n style: {\n lineWidth: grid?.gridWidth,\n stroke: grid?.gridColor,\n },\n },\n domainLine: {\n visible: line?.visible,\n style: {\n lineWidth: line?.lineWidth,\n stroke: line?.lineColor,\n },\n },\n innerOffset: {\n top: LINEAR_AXIS_INNER_OFFSET_TOP,\n // bottom: LINEAR_AXIS_INNER_OFFSET_TOP,\n },\n }\n\n result.axes = [...result.axes, linearAxis] as ISpec['axes']\n\n return result\n}\n"],"names":["yLinearPrimary","spec","context","result","advancedVSeed","vseed","chartType","datasetReshapeInfo","encoding","measures","dimensions","index","reshapeInfoId","foldInfoList","primaryYAxis","yAxisConfig","Array","alignTicks","alignTicksConfig","isNullish","isEmptySecondary","isEmpty","id","seriesIds","seriesId","visible","label","tick","title","grid","line","zero","nice","inverse","max","min","log","logBase","autoFormat","numFormat","formatter","createNumFormatter","lin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15 @@
|
|
1
1
|
import { LINEAR_AXIS_INNER_OFFSET_TOP } from "../../../../utils/constant.js";
|
2
|
-
import {
|
2
|
+
import { createNumFormatter } from "../../../../utils/index.js";
|
3
3
|
import { isEmpty, isNullish } from "remeda";
|
4
|
+
import { createLinearFormat } from "./format/linearFormat.js";
|
5
|
+
import { defaultTitleText } from "./title/defaultTitleText.js";
|
4
6
|
const yLinearSecondary = (spec, context)=>{
|
5
7
|
const result = {
|
6
8
|
...spec
|
7
9
|
};
|
8
10
|
const { advancedVSeed, vseed } = context;
|
9
11
|
const { chartType } = vseed;
|
10
|
-
const {
|
12
|
+
const { datasetReshapeInfo, measures, dimensions, encoding } = advancedVSeed;
|
11
13
|
const { index, id: reshapeInfoId, foldInfoList } = datasetReshapeInfo[0];
|
12
14
|
const secondaryYAxis = advancedVSeed.config?.[chartType]?.secondaryYAxis;
|
13
15
|
const yAxisConfig = Array.isArray(secondaryYAxis) ? secondaryYAxis[index] || secondaryYAxis[0] : secondaryYAxis;
|
@@ -41,8 +43,8 @@ const yLinearSecondary = (spec, context)=>{
|
|
41
43
|
];
|
42
44
|
return result;
|
43
45
|
}
|
44
|
-
const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10, numFormat = {}, autoFormat
|
45
|
-
const formatter = createNumFormatter(numFormat
|
46
|
+
const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10, numFormat = {}, autoFormat } = yAxisConfig;
|
47
|
+
const formatter = createNumFormatter(numFormat);
|
46
48
|
const linearAxis = {
|
47
49
|
visible: isEmptySecondary ? false : visible,
|
48
50
|
id,
|
@@ -58,11 +60,7 @@ const yLinearSecondary = (spec, context)=>{
|
|
58
60
|
min,
|
59
61
|
label: {
|
60
62
|
visible: label?.visible,
|
61
|
-
formatMethod: (value)=>
|
62
|
-
if (!isEmpty(numFormat)) return formatter(value);
|
63
|
-
if (autoFormat) return autoFormatter(value, locale);
|
64
|
-
return value;
|
65
|
-
},
|
63
|
+
formatMethod: (value)=>createLinearFormat(value, autoFormat, numFormat, formatter),
|
66
64
|
style: {
|
67
65
|
fill: label?.labelColor,
|
68
66
|
angle: label?.labelAngle,
|
@@ -72,7 +70,7 @@ const yLinearSecondary = (spec, context)=>{
|
|
72
70
|
},
|
73
71
|
title: {
|
74
72
|
visible: title?.visible,
|
75
|
-
text: title?.titleText,
|
73
|
+
text: title?.titleText || defaultTitleText(measures, dimensions, encoding.y),
|
76
74
|
style: {
|
77
75
|
fill: title?.titleColor,
|
78
76
|
fontSize: title?.titleFontSize,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/axes/yLinearSecondary.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/axes/yLinearSecondary.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport { LINEAR_AXIS_INNER_OFFSET_TOP } from '../../../../utils/constant'\nimport {
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/axes/yLinearSecondary.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/axes/yLinearSecondary.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport { LINEAR_AXIS_INNER_OFFSET_TOP } from '../../../../utils/constant'\nimport { createNumFormatter } from '../../../../utils'\nimport type { SpecPipe, YLinearAxis } from 'src/types'\nimport { isEmpty, isNullish } from 'remeda'\nimport { createLinearFormat } from './format/linearFormat'\nimport { defaultTitleText } from './title/defaultTitleText'\n\nexport const yLinearSecondary: SpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n const { datasetReshapeInfo, measures, dimensions, encoding } = advancedVSeed\n const { index, id: reshapeInfoId, foldInfoList } = datasetReshapeInfo[0]\n // TODO: default config missing\n const secondaryYAxis = advancedVSeed.config?.[chartType as 'dualAxis']?.secondaryYAxis as YLinearAxis | YLinearAxis[]\n const yAxisConfig = Array.isArray(secondaryYAxis) ? secondaryYAxis[index] || secondaryYAxis[0] : secondaryYAxis\n const alignTicks = advancedVSeed.config?.[chartType as 'dualAxis']?.alignTicks as boolean | boolean[]\n const alignTicksConfig = Array.isArray(alignTicks) ? alignTicks[index] || alignTicks[0] : alignTicks\n\n if (isNullish(foldInfoList?.[1])) {\n return result\n }\n\n const isEmptySecondary = isEmpty(foldInfoList?.[1].foldMap)\n const onlySecondary = isEmpty(foldInfoList?.[0].foldMap) && !isEmptySecondary\n\n const sync = {\n axisId: `${reshapeInfoId}-primary-axis`,\n zeroAlign: true,\n }\n\n const id = `${reshapeInfoId}-secondary-axis`\n const seriesIds = [`${reshapeInfoId}-primary-series`, `${reshapeInfoId}-secondary-series`]\n const seriesId = alignTicksConfig ? seriesIds : seriesIds[1]\n if (!result.axes) {\n result.axes = []\n }\n\n if (!yAxisConfig) {\n result.axes = [\n ...result.axes,\n {\n visible: true,\n id,\n seriesId,\n type: 'linear',\n orient: 'right',\n sync,\n },\n ] as ISpec['axes']\n return result\n }\n\n const {\n visible = true,\n label,\n tick,\n title,\n grid,\n line,\n\n zero,\n nice,\n inverse,\n max,\n min,\n log,\n logBase = 10,\n numFormat = {},\n autoFormat,\n } = yAxisConfig\n\n const formatter = createNumFormatter(numFormat)\n\n const linearAxis = {\n visible: isEmptySecondary ? false : visible,\n id,\n seriesId,\n sync,\n type: log ? 'log' : 'linear',\n base: logBase,\n orient: 'right',\n nice,\n zero: log ? false : zero,\n inverse,\n max,\n min,\n label: {\n visible: label?.visible,\n formatMethod: (value: string) => {\n return createLinearFormat(value, autoFormat, numFormat, formatter)\n },\n style: {\n fill: label?.labelColor,\n angle: label?.labelAngle,\n fontSize: label?.labelFontSize,\n fontWeight: label?.labelFontWeight,\n },\n },\n title: {\n visible: title?.visible,\n text: title?.titleText || defaultTitleText(measures, dimensions, encoding.y as string[]),\n style: {\n fill: title?.titleColor,\n fontSize: title?.titleFontSize,\n fontWeight: title?.titleFontWeight,\n },\n },\n tick: {\n visible: tick?.visible,\n tickSize: tick?.tickSize,\n inside: tick?.tickInside,\n style: {\n stroke: tick?.tickColor,\n },\n },\n grid: {\n visible: onlySecondary ? true : grid?.visible,\n style: {\n lineWidth: grid?.gridWidth,\n stroke: grid?.gridColor,\n },\n },\n domainLine: {\n visible: line?.visible,\n style: {\n lineWidth: line?.lineWidth,\n stroke: line?.lineColor,\n },\n },\n innerOffset: {\n top: LINEAR_AXIS_INNER_OFFSET_TOP,\n // bottom: LINEAR_AXIS_INNER_OFFSET_TOP,\n },\n }\n\n result.axes = [...result.axes, linearAxis] as ISpec['axes']\n\n return result\n}\n"],"names":["yLinearSecondary","spec","context","result","advancedVSeed","vseed","chartType","datasetReshapeInfo","measures","dimensions","encoding","index","reshapeInfoId","foldInfoList","secondaryYAxis","yAxisConfig","Array","alignTicks","alignTicksConfig","isNullish","isEmptySecondary","isEmpty","onlySecondary","sync","id","seriesIds","seriesId","visible","label","tick","title","grid","line","zero","nice","inverse","max","min","log","logBase","numFormat","autoFormat","formatter","createNumFormatter","linearAxis","value","createLinearFormat","defaultTitleText","LINEAR_AXIS_INNER_OFFSET_TOP"],"mappings":";;;;;AAQO,MAAMA,mBAA6B,CAACC,MAAMC;IAC/C,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAEC,KAAK,EAAE,GAAGH;IACjC,MAAM,EAAEI,SAAS,EAAE,GAAGD;IACtB,MAAM,EAAEE,kBAAkB,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAGN;IAC/D,MAAM,EAAEO,KAAK,EAAE,IAAIC,aAAa,EAAEC,YAAY,EAAE,GAAGN,kBAAkB,CAAC,EAAE;IAExE,MAAMO,iBAAiBV,cAAc,MAAM,EAAE,CAACE,UAAwB,EAAE;IACxE,MAAMS,cAAcC,MAAM,OAAO,CAACF,kBAAkBA,cAAc,CAACH,MAAM,IAAIG,cAAc,CAAC,EAAE,GAAGA;IACjG,MAAMG,aAAab,cAAc,MAAM,EAA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;YACL,SAAST,OAAO;YAChB,cAAc,CAACiB,QACNC,mBAAmBD,OAAOJ,YAAYD,WAAWE;YAE1D,OAAO;gBACL,MAAMd,OAAO;gBACb,OAAOA,OAAO;gBACd,UAAUA,OAAO;gBACjB,YAAYA,OAAO;YACrB;QACF;QACA,OAAO;YACL,SAASE,OAAO;YAChB,MAAMA,OAAO,aAAaiB,iBAAiBvC,UAAUC,YAAYC,SAAS,CAAC;YAC3E,OAAO;gBACL,MAAMoB,OAAO;gBACb,UAAUA,OAAO;gBACjB,YAAYA,OAAO;YACrB;QACF;QACA,MAAM;YACJ,SAASD,MAAM;YACf,UAAUA,MAAM;YAChB,QAAQA,MAAM;YACd,OAAO;gBACL,QAAQA,MAAM;YAChB;QACF;QACA,MAAM;YACJ,SAASP,gBAAgB,OAAOS,MAAM;YACtC,OAAO;gBACL,WAAWA,MAAM;gBACjB,QAAQA,MAAM;YAChB;QACF;QACA,YAAY;YACV,SAASC,MAAM;YACf,OAAO;gBACL,WAAWA,MAAM;gBACjB,QAAQA,MAAM;YAChB;QACF;QACA,aAAa;YACX,KAAKgB;QAEP;IACF;IAEA7C,OAAO,IAAI,GAAG;WAAIA,OAAO,IAAI;QAAEyC;KAAW;IAE1C,OAAOzC;AACT"}
|
@@ -16,7 +16,7 @@ const label_label = (spec, context)=>{
|
|
16
16
|
]);
|
17
17
|
return result;
|
18
18
|
};
|
19
|
-
const generateMeasureValue = (value, measure, labelAutoFormat
|
19
|
+
const generateMeasureValue = (value, measure, labelAutoFormat, numFormat = {})=>{
|
20
20
|
if (!measure) return value;
|
21
21
|
const format = merge(numFormat, measure.numFormat || measure.format);
|
22
22
|
const mergedMeasure = {
|
@@ -35,7 +35,7 @@ const generateMeasurePercent = (value, sum, formatter)=>{
|
|
35
35
|
return formatter(percentValue);
|
36
36
|
};
|
37
37
|
const buildLabel = (label, vseedMeasures = [], vseedDimensions = [], advancedVSeedMeasures, encoding, foldInfoList)=>{
|
38
|
-
const { enable, wrap, showValue, showValuePercent, labelOverlap, labelColorSmartInvert, labelColor, labelFontSize, labelFontWeight, labelBackgroundColor, labelPosition, autoFormat
|
38
|
+
const { enable, wrap, showValue, showValuePercent, labelOverlap, labelColorSmartInvert, labelColor, labelFontSize, labelFontWeight, labelBackgroundColor, labelPosition, autoFormat, numFormat = {} } = label;
|
39
39
|
const labelDims = uniqueBy((vseedDimensions || []).filter((item)=>encoding.label?.includes(item.id)), (item)=>item.id);
|
40
40
|
const labelMeas = uniqueBy((vseedMeasures || []).filter((item)=>encoding.label?.includes(item.id)), (item)=>item.id);
|
41
41
|
const percentFormat = merge(numFormat, {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/label/label.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/label/label.ts"],"sourcesContent":["import type { ILineChartSpec } from '@visactor/vchart'\nimport type { ILineLikeLabelSpec } from '@visactor/vchart/esm/series/mixin/interface'\nimport { createFormatter, createFormatterByMeasure, findMeasureById } from '../../../../utils'\nimport type {\n Datum,\n Dimensions,\n Encoding,\n FoldInfo,\n Formatter,\n Label,\n Measure,\n Measures,\n NumFormat,\n SpecPipe,\n} from 'src/types'\nimport { isEmpty, merge, uniqueBy } from 'remeda'\n\nexport const label: SpecPipe = (spec, context) => {\n const result = { ...spec } as ILineChartSpec\n const { advancedVSeed, vseed } = context\n const { datasetReshapeInfo } = advancedVSeed\n const { chartType, encoding } = advancedVSeed\n const baseConfig = advancedVSeed.config[chartType] as { label: Label }\n const foldInfo = datasetReshapeInfo[0].foldInfo as FoldInfo\n if (!baseConfig || isEmpty(baseConfig.label)) {\n return result\n }\n\n const { label } = baseConfig\n\n result.label = buildLabel(label, vseed.measures, vseed.dimensions, advancedVSeed.measures, encoding as Encoding, [\n foldInfo,\n ])\n\n return result\n}\n\nexport const generateMeasureValue = (\n value: number | string,\n measure?: Measure,\n labelAutoFormat
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/label/label.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/label/label.ts"],"sourcesContent":["import type { ILineChartSpec } from '@visactor/vchart'\nimport type { ILineLikeLabelSpec } from '@visactor/vchart/esm/series/mixin/interface'\nimport { createFormatter, createFormatterByMeasure, findMeasureById } from '../../../../utils'\nimport type {\n Datum,\n Dimensions,\n Encoding,\n FoldInfo,\n Formatter,\n Label,\n Measure,\n Measures,\n NumFormat,\n SpecPipe,\n} from 'src/types'\nimport { isEmpty, merge, uniqueBy } from 'remeda'\n\nexport const label: SpecPipe = (spec, context) => {\n const result = { ...spec } as ILineChartSpec\n const { advancedVSeed, vseed } = context\n const { datasetReshapeInfo } = advancedVSeed\n const { chartType, encoding } = advancedVSeed\n const baseConfig = advancedVSeed.config[chartType] as { label: Label }\n const foldInfo = datasetReshapeInfo[0].foldInfo as FoldInfo\n if (!baseConfig || isEmpty(baseConfig.label)) {\n return result\n }\n\n const { label } = baseConfig\n\n result.label = buildLabel(label, vseed.measures, vseed.dimensions, advancedVSeed.measures, encoding as Encoding, [\n foldInfo,\n ])\n\n return result\n}\n\nexport const generateMeasureValue = (\n value: number | string,\n measure?: Measure,\n labelAutoFormat?: boolean,\n numFormat: NumFormat = {},\n) => {\n if (!measure) {\n return value\n }\n\n const format = merge(numFormat, measure.numFormat || measure.format)\n const mergedMeasure = { ...measure, numFormat: format, autoFormat: labelAutoFormat || measure.autoFormat }\n\n const formatter = createFormatterByMeasure(mergedMeasure)\n return formatter(value)\n}\n\nexport const generateMeasurePercent = (value: number | string, sum: number, formatter: Formatter) => {\n if (value === undefined || value === null) return String(value)\n const num = Number(value)\n if (Number.isNaN(num)) return String(value)\n\n const percentValue = num / sum\n return formatter(percentValue)\n}\n\nexport const buildLabel = (\n label: Label,\n vseedMeasures: Measures = [],\n vseedDimensions: Dimensions = [],\n advancedVSeedMeasures: Measures,\n encoding: Encoding,\n foldInfoList: FoldInfo[],\n) => {\n const {\n enable,\n wrap,\n showValue,\n showValuePercent,\n labelOverlap,\n labelColorSmartInvert,\n labelColor,\n labelFontSize,\n labelFontWeight,\n labelBackgroundColor,\n labelPosition,\n autoFormat,\n numFormat = {},\n } = label\n\n const labelDims = uniqueBy(\n (vseedDimensions || []).filter((item) => encoding.label?.includes(item.id)),\n (item) => item.id,\n )\n const labelMeas = uniqueBy(\n (vseedMeasures || []).filter((item) => encoding.label?.includes(item.id)),\n (item) => item.id,\n )\n\n const percentFormat: NumFormat = merge(numFormat, {\n type: 'percent',\n } as NumFormat)\n\n const percentFormatter = createFormatter(percentFormat)\n\n const result = {\n visible: enable,\n formatMethod: (_, datum: Datum) => {\n const result = []\n\n const dimLabels = labelDims.map((item) => item.alias || item.id)\n const meaLabels = labelMeas.map((item) =>\n generateMeasureValue(datum[item.id] as number | string, item, autoFormat, numFormat),\n )\n\n result.push(...dimLabels)\n\n foldInfoList.forEach((foldInfo) => {\n const { measureId, measureValue, statistics } = foldInfo\n const measure = findMeasureById(advancedVSeedMeasures, datum[measureId] as string)\n const measureValueLabel = generateMeasureValue(\n datum[measureValue] as number | string,\n measure,\n autoFormat,\n numFormat,\n )\n const measurePercentLabel = generateMeasurePercent(\n datum[measureValue] as number | string,\n statistics.sum,\n percentFormatter,\n )\n if (showValue) {\n result.push(measureValueLabel)\n }\n if (showValuePercent) {\n result.push(measurePercentLabel)\n }\n })\n\n result.push(...meaLabels)\n\n if (wrap) {\n return result\n }\n return result.join(' ')\n },\n position: labelPosition,\n style: {\n fill: labelColor,\n fontSize: labelFontSize,\n fontWeight: labelFontWeight,\n background: labelBackgroundColor,\n },\n smartInvert: labelColorSmartInvert,\n } as ILineLikeLabelSpec\n\n if (labelOverlap) {\n result.overlap = {\n hideOnHit: true,\n clampForce: true,\n }\n }\n\n return result\n}\n"],"names":["label","spec","context","result","advancedVSeed","vseed","datasetReshapeInfo","chartType","encoding","baseConfig","foldInfo","isEmpty","buildLabel","generateMeasureValue","value","measure","labelAutoFormat","numFormat","format","merge","mergedMeasure","formatter","createFormatterByMeasure","generateMeasurePercent","sum","String","num","Number","percentValue","vseedMeasures","vseedDimensions","advancedVSeedMeasures","foldInfoList","enable","wrap","showValue","showValuePercent","labelOverlap","labelColorSmartInvert","labelColor","labelFontSize","labelFontWeight","labelBackgroundColor","labelPosition","autoFormat","labelDims","uniqueBy","item","labelMeas","percentFormat","percentFormatter","createFormatter","_","datum","dimLabels","meaLabels","measureId","measureValue","statistics","findMeasureById","measureValueLabel","measurePercentLabel"],"mappings":";;AAiBO,MAAMA,cAAkB,CAACC,MAAMC;IACpC,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAEC,KAAK,EAAE,GAAGH;IACjC,MAAM,EAAEI,kBAAkB,EAAE,GAAGF;IAC/B,MAAM,EAAEG,SAAS,EAAEC,QAAQ,EAAE,GAAGJ;IAChC,MAAMK,aAAaL,cAAc,MAAM,CAACG,UAAU;IAClD,MAAMG,WAAWJ,kBAAkB,CAAC,EAAE,CAAC,QAAQ;IAC/C,IAAI,CAACG,cAAcE,QAAQF,WAAW,KAAK,GACzC,OAAON;IAGT,MAAM,EAAEH,KAAK,EAAE,GAAGS;IAElBN,OAAO,KAAK,GAAGS,WAAWZ,OAAOK,MAAM,QAAQ,EAAEA,MAAM,UAAU,EAAED,cAAc,QAAQ,EAAEI,UAAsB;QAC/GE;KACD;IAED,OAAOP;AACT;AAEO,MAAMU,uBAAuB,CAClCC,OACAC,SACAC,iBACAC,YAAuB,CAAC,CAAC;IAEzB,IAAI,CAACF,SACH,OAAOD;IAGT,MAAMI,SAASC,MAAMF,WAAWF,QAAQ,SAAS,IAAIA,QAAQ,MAAM;IACnE,MAAMK,gBAAgB;QAAE,GAAGL,OAAO;QAAE,WAAWG;QAAQ,YAAYF,mBAAmBD,QAAQ,UAAU;IAAC;IAEzG,MAAMM,YAAYC,yBAAyBF;IAC3C,OAAOC,UAAUP;AACnB;AAEO,MAAMS,yBAAyB,CAACT,OAAwBU,KAAaH;IAC1E,IAAIP,QAAAA,OAAuC,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AAS,EAAEC,YAAY,EAAEC,UAAU,EAAE,GAAGhD;gBAChD,MAAMK,UAAU4C,gBAAgB5B,uBAAuBsB,KAAK,CAACG,UAAU;gBACvE,MAAMI,oBAAoB/C,qBACxBwC,KAAK,CAACI,aAAa,EACnB1C,SACA6B,YACA3B;gBAEF,MAAM4C,sBAAsBtC,uBAC1B8B,KAAK,CAACI,aAAa,EACnBC,WAAW,GAAG,EACdR;gBAEF,IAAIf,WACFhC,OAAO,IAAI,CAACyD;gBAEd,IAAIxB,kBACFjC,OAAO,IAAI,CAAC0D;YAEhB;YAEA1D,OAAO,IAAI,IAAIoD;YAEf,IAAIrB,MACF,OAAO/B;YAET,OAAOA,OAAO,IAAI,CAAC;QACrB;QACA,UAAUwC;QACV,OAAO;YACL,MAAMJ;YACN,UAAUC;YACV,YAAYC;YACZ,YAAYC;QACd;QACA,aAAaJ;IACf;IAEA,IAAID,cACFlC,OAAO,OAAO,GAAG;QACf,WAAW;QACX,YAAY;IACd;IAGF,OAAOA;AACT"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { scatterSize } from './scatterSize';
|
@@ -0,0 +1,22 @@
|
|
1
|
+
const scatterSize = (spec, context)=>{
|
2
|
+
const result = {
|
3
|
+
...spec
|
4
|
+
};
|
5
|
+
const { advancedVSeed } = context;
|
6
|
+
const { chartType, encoding } = advancedVSeed;
|
7
|
+
const baseConfig = advancedVSeed.config[chartType];
|
8
|
+
if (!baseConfig || !baseConfig.sizeRange && !baseConfig.size) return result;
|
9
|
+
const size = baseConfig.size ?? baseConfig.sizeRange;
|
10
|
+
result.size = {
|
11
|
+
type: 'linear',
|
12
|
+
range: Array.isArray(size) ? size : [
|
13
|
+
size,
|
14
|
+
size
|
15
|
+
]
|
16
|
+
};
|
17
|
+
result.sizeField = encoding?.size?.[0] || void 0;
|
18
|
+
return result;
|
19
|
+
};
|
20
|
+
export { scatterSize };
|
21
|
+
|
22
|
+
//# sourceMappingURL=scatterSize.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/size/scatterSize.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/size/scatterSize.ts"],"sourcesContent":["import type { IScatterChartSpec } from '@visactor/vchart'\nimport type { SpecPipe } from 'src/types'\n\nexport const scatterSize: SpecPipe = (spec, context) => {\n const result = { ...spec } as IScatterChartSpec\n const { advancedVSeed } = context\n const { chartType, encoding } = advancedVSeed\n const baseConfig = advancedVSeed.config[chartType] as {\n sizeRange: number | number[]\n size?: number | number[]\n }\n\n if (!baseConfig || (!baseConfig.sizeRange && !baseConfig.size)) {\n return result\n }\n\n const size = baseConfig.size ?? baseConfig.sizeRange\n\n result.size = {\n type: 'linear',\n range: Array.isArray(size) ? size : [size, size],\n } as IScatterChartSpec['size']\n\n result.sizeField = encoding?.size?.[0] || undefined\n\n return result\n}\n"],"names":["scatterSize","spec","context","result","advancedVSeed","chartType","encoding","baseConfig","size","Array","undefined"],"mappings":"AAGO,MAAMA,cAAwB,CAACC,MAAMC;IAC1C,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAE,GAAGF;IAC1B,MAAM,EAAEG,SAAS,EAAEC,QAAQ,EAAE,GAAGF;IAChC,MAAMG,aAAaH,cAAc,MAAM,CAACC,UAAU;IAKlD,IAAI,CAACE,cAAe,CAACA,WAAW,SAAS,IAAI,CAACA,WAAW,IAAI,EAC3D,OAAOJ;IAGT,MAAMK,OAAOD,WAAW,IAAI,IAAIA,WAAW,SAAS;IAEpDJ,OAAO,IAAI,GAAG;QACZ,MAAM;QACN,OAAOM,MAAM,OAAO,CAACD,QAAQA,OAAO;YAACA;YAAMA;SAAK;IAClD;IAEAL,OAAO,SAAS,GAAGG,UAAU,MAAM,CAAC,EAAE,IAAII;IAE1C,OAAOP;AACT"}
|
@@ -1,11 +1,12 @@
|
|
1
1
|
import { autoFormatter, createFormatter } from "./createFormatter.js";
|
2
|
-
import { isEmpty } from "remeda";
|
2
|
+
import { isEmpty, isNullish } from "remeda";
|
3
3
|
const createFormatterByMeasure = (measure)=>{
|
4
4
|
if (!measure) return (v)=>String(v);
|
5
|
-
const { numFormat, format, autoFormat
|
5
|
+
const { numFormat, format, autoFormat } = measure;
|
6
6
|
const formatterFormat = numFormat || format || {};
|
7
|
+
if (true === autoFormat) return autoFormatter;
|
8
|
+
if (isNullish(autoFormat) && isEmpty(formatterFormat)) return autoFormatter;
|
7
9
|
if (!isEmpty(formatterFormat)) return createFormatter(formatterFormat);
|
8
|
-
if (autoFormat) return autoFormatter;
|
9
10
|
return (v)=>String(v);
|
10
11
|
};
|
11
12
|
export { createFormatterByMeasure };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pipeline/utils/format/createFormatterByMeasure.js","sources":["webpack://@visactor/vseed/./src/pipeline/utils/format/createFormatterByMeasure.ts"],"sourcesContent":["import type { Formatter, Measure } from 'src/types'\nimport { autoFormatter, createFormatter } from './createFormatter'\nimport { isEmpty } from 'remeda'\n\nexport const createFormatterByMeasure = (measure?: Measure): Formatter => {\n if (!measure) {\n return (v) => String(v)\n }\n const { numFormat, format, autoFormat
|
1
|
+
{"version":3,"file":"pipeline/utils/format/createFormatterByMeasure.js","sources":["webpack://@visactor/vseed/./src/pipeline/utils/format/createFormatterByMeasure.ts"],"sourcesContent":["import type { Formatter, Measure } from 'src/types'\nimport { autoFormatter, createFormatter } from './createFormatter'\nimport { isEmpty, isNullish } from 'remeda'\n\nexport const createFormatterByMeasure = (measure?: Measure): Formatter => {\n if (!measure) {\n return (v) => String(v)\n }\n const { numFormat, format, autoFormat } = measure\n\n const formatterFormat = numFormat || format || {}\n\n if (autoFormat === true) {\n return autoFormatter\n }\n\n if (isNullish(autoFormat) && isEmpty(formatterFormat)) {\n return autoFormatter\n }\n\n if (!isEmpty(formatterFormat)) {\n return createFormatter(formatterFormat)\n }\n\n return (v) => String(v)\n}\n"],"names":["createFormatterByMeasure","measure","v","String","numFormat","format","autoFormat","formatterFormat","autoFormatter","isNullish","isEmpty","createFormatter"],"mappings":";;AAIO,MAAMA,2BAA2B,CAACC;IACvC,IAAI,CAACA,SACH,OAAO,CAACC,IAAMC,OAAOD;IAEvB,MAAM,EAAEE,SAAS,EAAEC,MAAM,EAAEC,UAAU,EAAE,GAAGL;IAE1C,MAAMM,kBAAkBH,aAAaC,UAAU,CAAC;IAEhD,IAAIC,AAAe,SAAfA,YACF,OAAOE;IAGT,IAAIC,UAAUH,eAAeI,QAAQH,kBACnC,OAAOC;IAGT,IAAI,CAACE,QAAQH,kBACX,OAAOI,gBAAgBJ;IAGzB,OAAO,CAACL,IAAMC,OAAOD;AACvB"}
|
@@ -20,7 +20,10 @@ const createNumFormatter = (format, locale = intl.getLocale())=>{
|
|
20
20
|
numFormatterOptions.maximumSignificantDigits = significantDigits;
|
21
21
|
}
|
22
22
|
}
|
23
|
-
const numFormatter = new Intl.NumberFormat(locale,
|
23
|
+
const numFormatter = new Intl.NumberFormat(locale, {
|
24
|
+
...numFormatterOptions,
|
25
|
+
useGrouping: thousandSeparator
|
26
|
+
});
|
24
27
|
return (value)=>{
|
25
28
|
let num = Number(value);
|
26
29
|
let typeSymbol = '';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pipeline/utils/format/createNumFormatter.js","sources":["webpack://@visactor/vseed/./src/pipeline/utils/format/createNumFormatter.ts"],"sourcesContent":["import { isNumber } from 'remeda'\nimport { intl } from '../../../i18n'\nimport type { Formatter, Locale, NumFormat } from 'src/types'\n\nexport const createNumFormatter = (format?: Partial<NumFormat>, locale: Locale = intl.getLocale()): Formatter => {\n const {\n type = 'number',\n ratio = 1,\n symbol = '',\n thousandSeparator = true,\n prefix = '',\n suffix = '',\n\n fractionDigits = 2,\n significantDigits,\n roundingMode = 'halfExpand',\n roundingPriority = 'auto',\n } = format || {}\n\n const numFormatterOptions: Intl.NumberFormatOptions = {\n style: 'decimal',\n notation: type === 'scientific' ? 'scientific' : 'standard',\n // @ts-expect-error roundingMode is not in NumberFormatOptions\n roundingMode,\n roundingPriority,\n }\n\n if (isNumber(fractionDigits)) {\n if (fractionDigits >= 0) {\n numFormatterOptions.minimumFractionDigits = fractionDigits\n numFormatterOptions.maximumFractionDigits = fractionDigits\n }\n }\n if (isNumber(significantDigits) && significantDigits > 0) {\n if (significantDigits > 0) {\n numFormatterOptions.minimumSignificantDigits = significantDigits\n numFormatterOptions.maximumSignificantDigits = significantDigits\n }\n }\n\n const numFormatter = new Intl.NumberFormat(locale, numFormatterOptions)\n\n return (value?: number | string) => {\n let num = Number(value)\n let typeSymbol = ''\n if (Number.isNaN(num)) {\n return String(value)\n }\n\n // apply ratio for percent/permille\n if (type === 'percent') {\n num *= 100\n typeSymbol = '%'\n } else if (type === 'permille') {\n num *= 1000\n typeSymbol = '‰'\n } else if (type === 'number') {\n num = num / (ratio || 1)\n }\n\n // format value\n let numStr = numFormatter.format(num)\n\n // add thousand separator\n if (thousandSeparator) {\n const parts = numStr.split('.')\n parts[0] = parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',')\n numStr = parts.join('.')\n }\n\n // add symbol, typeSymbol, prefix and suffix\n return `${prefix}${numStr}${typeSymbol}${symbol}${suffix}`\n }\n}\n\nexport const autoNumFormatter = (value?: number | string, locale: Locale = intl.getLocale()): string => {\n if (value === undefined || value === null) return String(value)\n const num = Number(value)\n if (Number.isNaN(num)) return String(value)\n\n const numFormatterOptions: Intl.NumberFormatOptions = {\n style: 'decimal',\n notation: 'compact',\n }\n numFormatterOptions.minimumFractionDigits = 0\n numFormatterOptions.maximumFractionDigits = 2\n\n const numFormatter = new Intl.NumberFormat(locale, { ...numFormatterOptions })\n\n return numFormatter.format(Number(value))\n}\n"],"names":["createNumFormatter","format","locale","intl","type","ratio","symbol","thousandSeparator","prefix","suffix","fractionDigits","significantDigits","roundingMode","roundingPriority","numFormatterOptions","isNumber","numFormatter","Intl","value","num","Number","typeSymbol","String","numStr","parts","autoNumFormatter"],"mappings":";;AAIO,MAAMA,qBAAqB,CAACC,QAA6BC,SAAiBC,KAAK,SAAS,EAAE;IAC/F,MAAM,EACJC,OAAO,QAAQ,EACfC,QAAQ,CAAC,EACTC,SAAS,EAAE,EACXC,oBAAoB,IAAI,EACxBC,SAAS,EAAE,EACXC,SAAS,EAAE,EAEXC,iBAAiB,CAAC,EAClBC,iBAAiB,EACjBC,eAAe,YAAY,EAC3BC,mBAAmB,MAAM,EAC1B,GAAGZ,UAAU,CAAC;IAEf,MAAMa,sBAAgD;QACpD,OAAO;QACP,UAAUV,AAAS,iBAATA,OAAwB,eAAe;QAEjDQ;QACAC;IACF;IAEA,IAAIE,SAASL,iBACX;QAAA,IAAIA,kBAAkB,GAAG;YACvBI,oBAAoB,qBAAqB,GAAGJ;YAC5CI,oBAAoB,qBAAqB,GAAGJ;QAC9C;IAAA;IAEF,IAAIK,SAASJ,sBAAsBA,oBAAoB,GACrD;QAAA,IAAIA,oBAAoB,GAAG;YACzBG,oBAAoB,wBAAwB,GAAGH;YAC/CG,oBAAoB,wBAAwB,GAAGH;QACjD;IAAA;IAGF,MAAMK,eAAe,IAAIC,KAAK,YAAY,CAACf,
|
1
|
+
{"version":3,"file":"pipeline/utils/format/createNumFormatter.js","sources":["webpack://@visactor/vseed/./src/pipeline/utils/format/createNumFormatter.ts"],"sourcesContent":["import { isNumber } from 'remeda'\nimport { intl } from '../../../i18n'\nimport type { Formatter, Locale, NumFormat } from 'src/types'\n\nexport const createNumFormatter = (format?: Partial<NumFormat>, locale: Locale = intl.getLocale()): Formatter => {\n const {\n type = 'number',\n ratio = 1,\n symbol = '',\n thousandSeparator = true,\n prefix = '',\n suffix = '',\n\n fractionDigits = 2,\n significantDigits,\n roundingMode = 'halfExpand',\n roundingPriority = 'auto',\n } = format || {}\n\n const numFormatterOptions: Intl.NumberFormatOptions = {\n style: 'decimal',\n notation: type === 'scientific' ? 'scientific' : 'standard',\n // @ts-expect-error roundingMode is not in NumberFormatOptions\n roundingMode,\n roundingPriority,\n }\n\n if (isNumber(fractionDigits)) {\n if (fractionDigits >= 0) {\n numFormatterOptions.minimumFractionDigits = fractionDigits\n numFormatterOptions.maximumFractionDigits = fractionDigits\n }\n }\n if (isNumber(significantDigits) && significantDigits > 0) {\n if (significantDigits > 0) {\n numFormatterOptions.minimumSignificantDigits = significantDigits\n numFormatterOptions.maximumSignificantDigits = significantDigits\n }\n }\n\n const numFormatter = new Intl.NumberFormat(locale, { ...numFormatterOptions, useGrouping: thousandSeparator })\n\n return (value?: number | string) => {\n let num = Number(value)\n let typeSymbol = ''\n if (Number.isNaN(num)) {\n return String(value)\n }\n\n // apply ratio for percent/permille\n if (type === 'percent') {\n num *= 100\n typeSymbol = '%'\n } else if (type === 'permille') {\n num *= 1000\n typeSymbol = '‰'\n } else if (type === 'number') {\n num = num / (ratio || 1)\n }\n\n // format value\n let numStr = numFormatter.format(num)\n\n // add thousand separator\n if (thousandSeparator) {\n const parts = numStr.split('.')\n parts[0] = parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',')\n numStr = parts.join('.')\n }\n\n // add symbol, typeSymbol, prefix and suffix\n return `${prefix}${numStr}${typeSymbol}${symbol}${suffix}`\n }\n}\n\nexport const autoNumFormatter = (value?: number | string, locale: Locale = intl.getLocale()): string => {\n if (value === undefined || value === null) return String(value)\n const num = Number(value)\n if (Number.isNaN(num)) return String(value)\n\n const numFormatterOptions: Intl.NumberFormatOptions = {\n style: 'decimal',\n notation: 'compact',\n }\n numFormatterOptions.minimumFractionDigits = 0\n numFormatterOptions.maximumFractionDigits = 2\n\n const numFormatter = new Intl.NumberFormat(locale, { ...numFormatterOptions })\n\n return numFormatter.format(Number(value))\n}\n"],"names":["createNumFormatter","format","locale","intl","type","ratio","symbol","thousandSeparator","prefix","suffix","fractionDigits","significantDigits","roundingMode","roundingPriority","numFormatterOptions","isNumber","numFormatter","Intl","value","num","Number","typeSymbol","String","numStr","parts","autoNumFormatter"],"mappings":";;AAIO,MAAMA,qBAAqB,CAACC,QAA6BC,SAA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AGA,OAAO,GAAGhB,SAASe,SAASF,aAAaf,SAASG,QAAQ;IAC5D;AACF;AAEO,MAAMgB,mBAAmB,CAACP,OAAyBhB,SAAiBC,KAAK,SAAS,EAAE;IACzF,IAAIe,QAAAA,OAAuC,OAAOI,OAAOJ;IACzD,MAAMC,MAAMC,OAAOF;IACnB,IAAIE,OAAO,KAAK,CAACD,MAAM,OAAOG,OAAOJ;IAErC,MAAMJ,sBAAgD;QACpD,OAAO;QACP,UAAU;IACZ;IACAA,oBAAoB,qBAAqB,GAAG;IAC5CA,oBAAoB,qBAAqB,GAAG;IAE5C,MAAME,eAAe,IAAIC,KAAK,YAAY,CAACf,QAAQ;QAAE,GAAGY,mBAAmB;IAAC;IAE5E,OAAOE,aAAa,MAAM,CAACI,OAAOF;AACpC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { isEmpty } from "remeda";
|
2
|
+
const checkVSeed = (vseed)=>{
|
3
|
+
const { chartType, dataset, dimensions, measures } = vseed;
|
4
|
+
if (!chartType) throw new Error('chartType is required');
|
5
|
+
if (!dataset || isEmpty(dataset)) throw new Error('dataset is required, and must be an array');
|
6
|
+
if (dimensions && !Array.isArray(dimensions)) throw new Error('dimensions must be an array');
|
7
|
+
if (measures && !Array.isArray(measures)) throw new Error('measures must be an array');
|
8
|
+
};
|
9
|
+
export { checkVSeed };
|
10
|
+
|
11
|
+
//# sourceMappingURL=checkVSeed.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"pipeline/utils/valid/checkVSeed.js","sources":["webpack://@visactor/vseed/./src/pipeline/utils/valid/checkVSeed.ts"],"sourcesContent":["import { isEmpty } from 'remeda'\nimport type { VSeed } from 'src/types'\n\nexport const checkVSeed = (vseed: VSeed) => {\n const { chartType, dataset, dimensions, measures } = vseed\n if (!chartType) {\n throw new Error('chartType is required')\n }\n if (!dataset || isEmpty(dataset)) {\n throw new Error('dataset is required, and must be an array')\n }\n if (dimensions && !Array.isArray(dimensions)) {\n throw new Error('dimensions must be an array')\n }\n if (measures && !Array.isArray(measures)) {\n throw new Error('measures must be an array')\n }\n}\n"],"names":["checkVSeed","vseed","chartType","dataset","dimensions","measures","Error","isEmpty","Array"],"mappings":";AAGO,MAAMA,aAAa,CAACC;IACzB,MAAM,EAAEC,SAAS,EAAEC,OAAO,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAGJ;IACrD,IAAI,CAACC,WACH,MAAM,IAAII,MAAM;IAElB,IAAI,CAACH,WAAWI,QAAQJ,UACtB,MAAM,IAAIG,MAAM;IAElB,IAAIF,cAAc,CAACI,MAAM,OAAO,CAACJ,aAC/B,MAAM,IAAIE,MAAM;IAElB,IAAID,YAAY,CAACG,MAAM,OAAO,CAACH,WAC7B,MAAM,IAAIC,MAAM;AAEpB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { checkVSeed } from './checkVSeed';
|
@@ -100,10 +100,7 @@ export declare const zDualAxis: z.ZodObject<{
|
|
100
100
|
dualMeasures: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
101
101
|
id: z.ZodString;
|
102
102
|
primaryMeasures: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodObject<{
|
103
|
-
|
104
|
-
alias: z.ZodOptional<z.ZodString>;
|
105
|
-
autoFormat: z.ZodDefault<z.ZodBoolean>;
|
106
|
-
numFormat: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
103
|
+
format: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
107
104
|
type: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
108
105
|
number: "number";
|
109
106
|
percent: "percent";
|
@@ -133,7 +130,10 @@ export declare const zDualAxis: z.ZodObject<{
|
|
133
130
|
halfEven: "halfEven";
|
134
131
|
}>>>;
|
135
132
|
}, z.core.$strip>>>;
|
136
|
-
|
133
|
+
id: z.ZodString;
|
134
|
+
alias: z.ZodOptional<z.ZodString>;
|
135
|
+
autoFormat: z.ZodDefault<z.ZodBoolean>;
|
136
|
+
numFormat: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
137
137
|
type: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
138
138
|
number: "number";
|
139
139
|
percent: "percent";
|
@@ -163,26 +163,8 @@ export declare const zDualAxis: z.ZodObject<{
|
|
163
163
|
halfEven: "halfEven";
|
164
164
|
}>>>;
|
165
165
|
}, z.core.$strip>>>;
|
166
|
-
encoding: z.ZodOptional<z.ZodEnum<{
|
167
|
-
column: "column";
|
168
|
-
xAxis: "xAxis";
|
169
|
-
yAxis: "yAxis";
|
170
|
-
angle: "angle";
|
171
|
-
color: "color";
|
172
|
-
detail: "detail";
|
173
|
-
tooltip: "tooltip";
|
174
|
-
label: "label";
|
175
|
-
primaryYAxis: "primaryYAxis";
|
176
|
-
secondaryYAxis: "secondaryYAxis";
|
177
|
-
radius: "radius";
|
178
|
-
size: "size";
|
179
|
-
}>>;
|
180
|
-
parentId: z.ZodOptional<z.ZodString>;
|
181
166
|
}, z.core.$strip>>, z.ZodObject<{
|
182
|
-
|
183
|
-
alias: z.ZodOptional<z.ZodString>;
|
184
|
-
autoFormat: z.ZodDefault<z.ZodBoolean>;
|
185
|
-
numFormat: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
167
|
+
format: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
186
168
|
type: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
187
169
|
number: "number";
|
188
170
|
percent: "percent";
|
@@ -212,7 +194,10 @@ export declare const zDualAxis: z.ZodObject<{
|
|
212
194
|
halfEven: "halfEven";
|
213
195
|
}>>>;
|
214
196
|
}, z.core.$strip>>>;
|
215
|
-
|
197
|
+
id: z.ZodString;
|
198
|
+
alias: z.ZodOptional<z.ZodString>;
|
199
|
+
autoFormat: z.ZodDefault<z.ZodBoolean>;
|
200
|
+
numFormat: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
216
201
|
type: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
217
202
|
number: "number";
|
218
203
|
percent: "percent";
|
@@ -242,21 +227,6 @@ export declare const zDualAxis: z.ZodObject<{
|
|
242
227
|
halfEven: "halfEven";
|
243
228
|
}>>>;
|
244
229
|
}, z.core.$strip>>>;
|
245
|
-
encoding: z.ZodOptional<z.ZodEnum<{
|
246
|
-
column: "column";
|
247
|
-
xAxis: "xAxis";
|
248
|
-
yAxis: "yAxis";
|
249
|
-
angle: "angle";
|
250
|
-
color: "color";
|
251
|
-
detail: "detail";
|
252
|
-
tooltip: "tooltip";
|
253
|
-
label: "label";
|
254
|
-
primaryYAxis: "primaryYAxis";
|
255
|
-
secondaryYAxis: "secondaryYAxis";
|
256
|
-
radius: "radius";
|
257
|
-
size: "size";
|
258
|
-
}>>;
|
259
|
-
parentId: z.ZodOptional<z.ZodString>;
|
260
230
|
}, z.core.$strip>]>>;
|
261
231
|
secondaryMeasures: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodObject<{
|
262
232
|
id: z.ZodString;
|
@@ -126,6 +126,20 @@ export interface Scatter {
|
|
126
126
|
* ]
|
127
127
|
*/
|
128
128
|
scatterMeasures?: ScatterMeasures;
|
129
|
+
/**
|
130
|
+
* @description 散点图指标的大小, 用于定义散点图中数据点的大小 或 大小范围
|
131
|
+
* - 若大小范围是一个数字, 例如10, 表示数据点的大小范围固定为10
|
132
|
+
* - 若大小范围是一个长度为2的数组, 例如[10, 40], 表示数据点的大小范围在10到40之间
|
133
|
+
* - 与sizeRange互斥, 优先级低于 size
|
134
|
+
*/
|
135
|
+
size?: number | number[];
|
136
|
+
/**
|
137
|
+
* @description 散点图指标的大小范围, 用于定义散点图中数据点的大小范围,
|
138
|
+
* - 若大小范围是一个长度为2的数组, 例如[10, 40], 表示数据点的大小范围在10到40之间
|
139
|
+
* - 若大小范围是一个数字, 例如10, 表示数据点的大小范围固定为10
|
140
|
+
* - 与sizeRange互斥, 优先级高于 size
|
141
|
+
*/
|
142
|
+
sizeRange?: number | number[];
|
129
143
|
/**
|
130
144
|
* 图表的背景颜色
|
131
145
|
* @default transparent 默认为透明背景
|