@visactor/vseed 0.1.14 → 0.1.15
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 +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/builder/builder/builder.d.ts +1113 -9
- package/dist/esm/pipeline/spec/chart/pipeline/heatmap.js +1 -3
- package/dist/esm/pipeline/spec/chart/pipeline/heatmap.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/scatter.js +3 -3
- package/dist/esm/pipeline/spec/chart/pipeline/scatter.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/xLinear.js +9 -3
- package/dist/esm/pipeline/spec/chart/pipes/axes/xLinear.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinear.js +9 -3
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinear.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinearPrimary.js +8 -3
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinearPrimary.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinearSecondary.js +8 -3
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinearSecondary.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/label/index.d.ts +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/label/index.js +2 -2
- package/dist/esm/pipeline/spec/chart/pipes/label/label.d.ts +5 -1
- package/dist/esm/pipeline/spec/chart/pipes/label/label.js +40 -32
- package/dist/esm/pipeline/spec/chart/pipes/label/label.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/label/labelDualAxis.js +15 -52
- package/dist/esm/pipeline/spec/chart/pipes/label/labelDualAxis.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/label/{labelColorInversion.d.ts → labelScatter.d.ts} +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/label/labelScatter.js +19 -0
- package/dist/esm/pipeline/spec/chart/pipes/label/labelScatter.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/series/series.js +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/series/series.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltip.d.ts +3 -3
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltip.js +13 -30
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltip.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipDualAxis.js +6 -6
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipDualAxis.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipHeatmap.js +6 -18
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipHeatmap.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipScatter.js +6 -18
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipScatter.js.map +1 -1
- package/dist/esm/pipeline/spec/table/pipes/columns/measuresToColumns.js +8 -11
- package/dist/esm/pipeline/spec/table/pipes/columns/measuresToColumns.js.map +1 -1
- package/dist/esm/pipeline/spec/table/pipes/indicators/pivotIndicators.js +8 -13
- package/dist/esm/pipeline/spec/table/pipes/indicators/pivotIndicators.js.map +1 -1
- package/dist/esm/pipeline/utils/constant.d.ts +1 -0
- package/dist/esm/pipeline/utils/constant.js +2 -1
- package/dist/esm/pipeline/utils/constant.js.map +1 -1
- package/dist/esm/pipeline/utils/format/createFormatter.d.ts +1 -1
- package/dist/esm/pipeline/utils/format/createFormatter.js +3 -2
- package/dist/esm/pipeline/utils/format/createFormatter.js.map +1 -1
- package/dist/esm/pipeline/utils/format/createFormatterByMeasure.d.ts +2 -0
- package/dist/esm/pipeline/utils/format/createFormatterByMeasure.js +13 -0
- package/dist/esm/pipeline/utils/format/createFormatterByMeasure.js.map +1 -0
- package/dist/esm/pipeline/utils/format/createNumFormatter.d.ts +1 -1
- package/dist/esm/pipeline/utils/format/createNumFormatter.js.map +1 -1
- package/dist/esm/pipeline/utils/format/index.d.ts +1 -0
- package/dist/esm/pipeline/utils/format/index.js +1 -0
- package/dist/esm/theme/dark.js +5 -1
- package/dist/esm/theme/dark.js.map +1 -1
- package/dist/esm/theme/light.js +23 -4
- package/dist/esm/theme/light.js.map +1 -1
- package/dist/esm/types/advancedVSeed.d.ts +947 -17
- package/dist/esm/types/chartType/area/zArea.d.ts +60 -0
- package/dist/esm/types/chartType/areaPercent/zAreaPercent.d.ts +60 -0
- package/dist/esm/types/chartType/bar/zBar.d.ts +60 -0
- package/dist/esm/types/chartType/barParallel/zBarParallel.d.ts +60 -0
- package/dist/esm/types/chartType/barPercent/zBarPercent.d.ts +60 -0
- package/dist/esm/types/chartType/column/zColumn.d.ts +60 -0
- package/dist/esm/types/chartType/columnParallel/zColumnParallel.d.ts +60 -0
- package/dist/esm/types/chartType/columnPercent/zColumnPercent.d.ts +60 -0
- package/dist/esm/types/chartType/donut/zDonut.d.ts +30 -0
- package/dist/esm/types/chartType/dualAxis/zDualAxis.d.ts +270 -0
- package/dist/esm/types/chartType/funnel/zFunnel.d.ts +30 -0
- package/dist/esm/types/chartType/heatmap/zHeatmap.d.ts +30 -0
- package/dist/esm/types/chartType/line/zLine.d.ts +60 -0
- package/dist/esm/types/chartType/pie/zPie.d.ts +30 -0
- package/dist/esm/types/chartType/pivotTable/zPivotTable.d.ts +30 -0
- package/dist/esm/types/chartType/radar/zRadar.d.ts +30 -0
- package/dist/esm/types/chartType/rose/zRose.d.ts +30 -0
- package/dist/esm/types/chartType/roseParallel/zRoseParallel.d.ts +30 -0
- package/dist/esm/types/chartType/scatter/zScatter.d.ts +210 -0
- package/dist/esm/types/chartType/table/zTable.d.ts +30 -0
- package/dist/esm/types/properties/config/axes/bandAxis.d.ts +146 -3
- package/dist/esm/types/properties/config/axes/index.d.ts +0 -2
- package/dist/esm/types/properties/config/axes/index.js +0 -1
- package/dist/esm/types/properties/config/axes/linearAxis.d.ts +149 -3
- package/dist/esm/types/properties/config/axes/zLinearAxis.d.ts +60 -0
- package/dist/esm/types/properties/config/axes/zLinearAxis.js +2 -0
- package/dist/esm/types/properties/config/axes/zLinearAxis.js.map +1 -1
- package/dist/esm/types/properties/config/config.d.ts +916 -16
- package/dist/esm/types/properties/config/label/label.d.ts +2 -2
- package/dist/esm/types/properties/config/label/zLabel.js +1 -1
- package/dist/esm/types/properties/config/label/zLabel.js.map +1 -1
- package/dist/esm/types/properties/format/numFormat.js.map +1 -0
- package/dist/esm/types/properties/index.d.ts +1 -0
- package/dist/esm/types/properties/index.js +1 -0
- package/dist/esm/types/properties/measures/index.d.ts +0 -1
- package/dist/esm/types/properties/measures/index.js +0 -1
- package/dist/esm/types/properties/measures/measures.d.ts +6 -2
- package/dist/esm/types/properties/measures/zDualMeasures.d.ts +240 -0
- package/dist/esm/types/properties/measures/zMeasures.d.ts +90 -0
- package/dist/esm/types/properties/measures/zMeasures.js +2 -1
- package/dist/esm/types/properties/measures/zMeasures.js.map +1 -1
- package/dist/esm/types/properties/measures/zScatterMeasures.d.ts +240 -0
- package/dist/esm/types/properties/theme/customTheme.d.ts +916 -16
- package/dist/esm/types/zVseed.d.ts +1389 -99
- package/dist/umd/index.js +181 -252
- package/dist/umd/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/label/labelColorInversion.js +0 -13
- package/dist/esm/pipeline/spec/chart/pipes/label/labelColorInversion.js.map +0 -1
- package/dist/esm/types/properties/config/axes/axis.d.ts +0 -208
- package/dist/esm/types/properties/config/axes/axis.js +0 -0
- package/dist/esm/types/properties/config/axes/zAxis.d.ts +0 -47
- package/dist/esm/types/properties/config/axes/zAxis.js +0 -54
- package/dist/esm/types/properties/config/axes/zAxis.js.map +0 -1
- package/dist/esm/types/properties/measures/format/numFormat.js.map +0 -1
- /package/dist/esm/types/properties/{measures/format → format}/formatter.d.ts +0 -0
- /package/dist/esm/types/properties/{measures/format → format}/formatter.js +0 -0
- /package/dist/esm/types/properties/{measures/format → format}/index.d.ts +0 -0
- /package/dist/esm/types/properties/{measures/format → format}/index.js +0 -0
- /package/dist/esm/types/properties/{measures/format → format}/numFormat.d.ts +0 -0
- /package/dist/esm/types/properties/{measures/format → format}/numFormat.js +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
import { annotationArea, annotationHorizontalLine, annotationPoint, annotationVerticalLine, backgroundColor, cellStyle, color, colorAdapter, colorCellStyleFill, colorLegend, datasetPivot, datasetXY, discreteLegend, initPivot, label,
|
1
|
+
import { annotationArea, annotationHorizontalLine, annotationPoint, annotationVerticalLine, backgroundColor, cellStyle, color, colorAdapter, colorCellStyleFill, colorLegend, datasetPivot, datasetXY, discreteLegend, initPivot, label, linearColor, pivotAdapter, pivotColorLegend, pivotColumnDimensions, pivotDiscreteLegend, pivotGridStyle, pivotIndicators, pivotIndicatorsAsRow, pivotRowDimensions, tooltipHeatmap } from "../pipes/index.js";
|
2
2
|
import { initHeatmap } from "../pipes/init/heatmap.js";
|
3
3
|
const heatmap = [
|
4
4
|
initHeatmap,
|
@@ -6,7 +6,6 @@ const heatmap = [
|
|
6
6
|
datasetXY,
|
7
7
|
colorAdapter(color, linearColor),
|
8
8
|
label,
|
9
|
-
labelColorInversion,
|
10
9
|
colorAdapter(discreteLegend, colorLegend),
|
11
10
|
colorCellStyleFill(cellStyle),
|
12
11
|
tooltipHeatmap,
|
@@ -26,7 +25,6 @@ const pivotHeatmap = [
|
|
26
25
|
datasetXY,
|
27
26
|
colorAdapter(color, linearColor),
|
28
27
|
label,
|
29
|
-
labelColorInversion,
|
30
28
|
discreteLegend,
|
31
29
|
tooltipHeatmap,
|
32
30
|
colorCellStyleFill(cellStyle),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipeline/heatmap.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipeline/heatmap.ts"],"sourcesContent":["import type { SpecPipeline } from 'src/types'\nimport {\n datasetXY,\n backgroundColor,\n label,\n tooltipHeatmap,\n initPivot,\n datasetPivot,\n pivotIndicators,\n pivotAdapter,\n pivotIndicatorsAsRow,\n pivotGridStyle,\n pivotColumnDimensions,\n pivotRowDimensions,\n annotationPoint,\n annotationVerticalLine,\n annotationHorizontalLine,\n annotationArea,\n
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipeline/heatmap.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipeline/heatmap.ts"],"sourcesContent":["import type { SpecPipeline } from 'src/types'\nimport {\n datasetXY,\n backgroundColor,\n label,\n tooltipHeatmap,\n initPivot,\n datasetPivot,\n pivotIndicators,\n pivotAdapter,\n pivotIndicatorsAsRow,\n pivotGridStyle,\n pivotColumnDimensions,\n pivotRowDimensions,\n annotationPoint,\n annotationVerticalLine,\n annotationHorizontalLine,\n annotationArea,\n discreteLegend,\n color,\n colorAdapter,\n linearColor,\n colorLegend,\n cellStyle,\n colorCellStyleFill,\n pivotDiscreteLegend,\n pivotColorLegend,\n} from '../pipes'\nimport { initHeatmap } from '../pipes/init/heatmap'\n\nconst heatmap: SpecPipeline = [\n initHeatmap,\n backgroundColor,\n datasetXY,\n colorAdapter(color, linearColor),\n label,\n colorAdapter(discreteLegend, colorLegend),\n colorCellStyleFill(cellStyle),\n tooltipHeatmap,\n annotationPoint,\n annotationVerticalLine,\n annotationHorizontalLine,\n annotationArea,\n]\n\nconst pivotHeatmap: SpecPipeline = [\n initPivot,\n pivotGridStyle,\n pivotIndicatorsAsRow,\n datasetPivot,\n pivotIndicators([\n initHeatmap,\n backgroundColor,\n datasetXY,\n colorAdapter(color, linearColor),\n label,\n discreteLegend,\n tooltipHeatmap,\n colorCellStyleFill(cellStyle),\n annotationPoint,\n annotationVerticalLine,\n annotationHorizontalLine,\n annotationArea,\n ]),\n pivotRowDimensions,\n pivotColumnDimensions,\n colorAdapter(pivotDiscreteLegend, pivotColorLegend),\n]\n\nexport const heatmapSpecPipeline: SpecPipeline = [pivotAdapter(heatmap, pivotHeatmap)]\n"],"names":["heatmap","initHeatmap","backgroundColor","datasetXY","colorAdapter","color","linearColor","label","discreteLegend","colorLegend","colorCellStyleFill","cellStyle","tooltipHeatmap","annotationPoint","annotationVerticalLine","annotationHorizontalLine","annotationArea","pivotHeatmap","initPivot","pivotGridStyle","pivotIndicatorsAsRow","datasetPivot","pivotIndicators","pivotRowDimensions","pivotColumnDimensions","pivotDiscreteLegend","pivotColorLegend","heatmapSpecPipeline","pivotAdapter"],"mappings":";;AA8BA,MAAMA,UAAwB;IAC5BC;IACAC;IACAC;IACAC,aAAaC,OAAOC;IACpBC;IACAH,aAAaI,gBAAgBC;IAC7BC,mBAAmBC;IACnBC;IACAC;IACAC;IACAC;IACAC;CACD;AAED,MAAMC,eAA6B;IACjCC;IACAC;IACAC;IACAC;IACAC,gBAAgB;QACdrB;QACAC;QACAC;QACAC,aAAaC,OAAOC;QACpBC;QACAC;QACAI;QACAF,mBAAmBC;QACnBE;QACAC;QACAC;QACAC;KACD;IACDO;IACAC;IACApB,aAAaqB,qBAAqBC;CACnC;AAEM,MAAMC,sBAAoC;IAACC,aAAa5B,SAASiB;CAAc"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { annotationArea, annotationHorizontalLine, annotationPoint, annotationVerticalLine, backgroundColor, color, colorAdapter, colorLegend, colorPointStyleFill, datasetPivot, datasetScatter, discreteLegend, horizontalCrosshairLine, initPivot, initScatter,
|
1
|
+
import { annotationArea, annotationHorizontalLine, annotationPoint, annotationVerticalLine, backgroundColor, color, colorAdapter, colorLegend, colorPointStyleFill, datasetPivot, datasetScatter, discreteLegend, horizontalCrosshairLine, initPivot, initScatter, labelScatter, linearColor, pivotAdapter, pivotColorLegend, pivotColumnDimensions, pivotDiscreteLegend, pivotGridStyle, pivotIndicators, pivotIndicatorsAsRow, pivotRowDimensions, pointStateHover, pointStyle, progressive, tooltipScatter, verticalCrosshairLine, xLinear, yLinear } from "../pipes/index.js";
|
2
2
|
const scatter = [
|
3
3
|
initScatter,
|
4
4
|
colorAdapter(color, linearColor),
|
@@ -7,7 +7,7 @@ const scatter = [
|
|
7
7
|
progressive,
|
8
8
|
xLinear,
|
9
9
|
yLinear,
|
10
|
-
|
10
|
+
labelScatter,
|
11
11
|
tooltipScatter,
|
12
12
|
colorAdapter(discreteLegend, colorLegend),
|
13
13
|
verticalCrosshairLine,
|
@@ -32,7 +32,7 @@ const pivotScatter = [
|
|
32
32
|
progressive,
|
33
33
|
xLinear,
|
34
34
|
yLinear,
|
35
|
-
|
35
|
+
labelScatter,
|
36
36
|
tooltipScatter,
|
37
37
|
verticalCrosshairLine,
|
38
38
|
horizontalCrosshairLine,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipeline/scatter.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipeline/scatter.ts"],"sourcesContent":["import type { SpecPipeline } from 'src/types'\nimport {\n yLinear,\n backgroundColor,\n
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipeline/scatter.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipeline/scatter.ts"],"sourcesContent":["import type { SpecPipeline } from 'src/types'\nimport {\n yLinear,\n backgroundColor,\n tooltipScatter,\n discreteLegend,\n color,\n initPivot,\n datasetPivot,\n pivotDiscreteLegend,\n pivotIndicators,\n pivotAdapter,\n pivotIndicatorsAsRow,\n pivotGridStyle,\n pivotColumnDimensions,\n pivotRowDimensions,\n annotationPoint,\n annotationVerticalLine,\n annotationHorizontalLine,\n annotationArea,\n pointStyle,\n verticalCrosshairLine,\n xLinear,\n horizontalCrosshairLine,\n pointStateHover,\n initScatter,\n progressive,\n datasetScatter,\n linearColor,\n colorAdapter,\n colorPointStyleFill,\n colorLegend,\n pivotColorLegend,\n labelScatter,\n} from '../pipes'\n\nconst scatter: SpecPipeline = [\n initScatter,\n colorAdapter(color, linearColor),\n backgroundColor,\n datasetScatter,\n progressive,\n xLinear,\n yLinear,\n labelScatter,\n tooltipScatter,\n colorAdapter(discreteLegend, colorLegend),\n verticalCrosshairLine,\n horizontalCrosshairLine,\n colorPointStyleFill(pointStyle),\n pointStateHover,\n annotationPoint,\n annotationVerticalLine,\n annotationHorizontalLine,\n annotationArea,\n]\n\nconst pivotScatter: SpecPipeline = [\n initPivot,\n pivotGridStyle,\n pivotIndicatorsAsRow,\n datasetPivot,\n pivotIndicators([\n initScatter,\n colorAdapter(color, linearColor),\n backgroundColor,\n datasetScatter,\n progressive,\n xLinear,\n yLinear,\n labelScatter,\n tooltipScatter,\n verticalCrosshairLine,\n horizontalCrosshairLine,\n colorPointStyleFill(pointStyle),\n pointStateHover,\n annotationPoint,\n annotationVerticalLine,\n annotationHorizontalLine,\n annotationArea,\n ]),\n pivotRowDimensions,\n pivotColumnDimensions,\n colorAdapter(pivotDiscreteLegend, pivotColorLegend),\n]\n\nexport const scatterSpecPipeline: SpecPipeline = [pivotAdapter(scatter, pivotScatter)]\n"],"names":["scatter","initScatter","colorAdapter","color","linearColor","backgroundColor","datasetScatter","progressive","xLinear","yLinear","labelScatter","tooltipScatter","discreteLegend","colorLegend","verticalCrosshairLine","horizontalCrosshairLine","colorPointStyleFill","pointStyle","pointStateHover","annotationPoint","annotationVerticalLine","annotationHorizontalLine","annotationArea","pivotScatter","initPivot","pivotGridStyle","pivotIndicatorsAsRow","datasetPivot","pivotIndicators","pivotRowDimensions","pivotColumnDimensions","pivotDiscreteLegend","pivotColorLegend","scatterSpecPipeline","pivotAdapter"],"mappings":";AAoCA,MAAMA,UAAwB;IAC5BC;IACAC,aAAaC,OAAOC;IACpBC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAT,aAAaU,gBAAgBC;IAC7BC;IACAC;IACAC,oBAAoBC;IACpBC;IACAC;IACAC;IACAC;IACAC;CACD;AAED,MAAMC,eAA6B;IACjCC;IACAC;IACAC;IACAC;IACAC,gBAAgB;QACd3B;QACAC,aAAaC,OAAOC;QACpBC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAG;QACAC;QACAC,oBAAoBC;QACpBC;QACAC;QACAC;QACAC;QACAC;KACD;IACDO;IACAC;IACA5B,aAAa6B,qBAAqBC;CACnC;AAEM,MAAMC,sBAAoC;IAACC,aAAalC,SAASuB;CAAc"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { LINEAR_AXIS_INNER_OFFSET_TOP } from "../../../../utils/constant.js";
|
2
|
-
import { autoFormatter } from "../../../../utils/index.js";
|
2
|
+
import { autoFormatter, createNumFormatter } from "../../../../utils/index.js";
|
3
|
+
import { isEmpty } from "remeda";
|
3
4
|
const xLinear = (spec, context)=>{
|
4
5
|
const result = {
|
5
6
|
...spec
|
@@ -20,7 +21,8 @@ const xLinear = (spec, context)=>{
|
|
20
21
|
];
|
21
22
|
return result;
|
22
23
|
}
|
23
|
-
const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10 } = config;
|
24
|
+
const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10, autoFormat = true, numFormat = {} } = config;
|
25
|
+
const formatter = createNumFormatter(numFormat, locale);
|
24
26
|
const linearAxis = {
|
25
27
|
visible,
|
26
28
|
type: log ? 'log' : 'linear',
|
@@ -33,7 +35,11 @@ const xLinear = (spec, context)=>{
|
|
33
35
|
min,
|
34
36
|
label: {
|
35
37
|
visible: label?.visible,
|
36
|
-
formatMethod: (value)=>
|
38
|
+
formatMethod: (value)=>{
|
39
|
+
if (!isEmpty(numFormat)) return formatter(value);
|
40
|
+
if (autoFormat) return autoFormatter(value, locale);
|
41
|
+
return value;
|
42
|
+
},
|
37
43
|
style: {
|
38
44
|
fill: label?.labelColor,
|
39
45
|
angle: label?.labelAngle,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/axes/xLinear.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/axes/xLinear.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport { LINEAR_AXIS_INNER_OFFSET_TOP } from '../../../../utils/constant'\nimport type { SpecPipe, XLinearAxis } from 'src/types'\nimport { autoFormatter } from '../../../../utils'\n\nexport const xLinear: SpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n const { locale } = advancedVSeed\n const config = advancedVSeed.config?.[chartType as 'bar']?.xAxis as XLinearAxis\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: 'bottom',\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 } = config\n\n const linearAxis = {\n visible,\n type: log ? 'log' : 'linear',\n base: logBase,\n orient: 'bottom',\n nice,\n zero: log ? false : zero,\n inverse,\n max,\n min,\n label: {\n visible: label?.visible,\n formatMethod: (value: string) => {\n return autoFormatter(value, locale)\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,\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 right: LINEAR_AXIS_INNER_OFFSET_TOP,\n // left: LINEAR_AXIS_INNER_OFFSET_TOP,\n },\n }\n\n result.axes = [...result.axes, linearAxis] as ISpec['axes']\n\n return result\n}\n"],"names":["xLinear","spec","context","result","advancedVSeed","vseed","chartType","locale","config","visible","label","tick","title","grid","line","zero","nice","inverse","max","min","log","logBase","linearAxis","value","autoFormatter","LINEAR_AXIS_INNER_OFFSET_TOP"],"mappings":"
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/axes/xLinear.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/axes/xLinear.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport { LINEAR_AXIS_INNER_OFFSET_TOP } from '../../../../utils/constant'\nimport type { SpecPipe, XLinearAxis } from 'src/types'\nimport { autoFormatter, createNumFormatter } from '../../../../utils'\nimport { isEmpty } from 'remeda'\n\nexport const xLinear: SpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n const { locale } = advancedVSeed\n const config = advancedVSeed.config?.[chartType as 'bar']?.xAxis as XLinearAxis\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: 'bottom',\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 = true,\n numFormat = {},\n } = config\n\n const formatter = createNumFormatter(numFormat, locale)\n\n const linearAxis = {\n visible,\n type: log ? 'log' : 'linear',\n base: logBase,\n orient: 'bottom',\n nice,\n zero: log ? false : zero,\n inverse,\n max,\n min,\n label: {\n visible: label?.visible,\n formatMethod: (value: string) => {\n if (!isEmpty(numFormat)) {\n return formatter(value)\n }\n if (autoFormat) {\n return autoFormatter(value, locale)\n }\n return value\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,\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 right: LINEAR_AXIS_INNER_OFFSET_TOP,\n // left: LINEAR_AXIS_INNER_OFFSET_TOP,\n },\n }\n\n result.axes = [...result.axes, linearAxis] as ISpec['axes']\n\n return result\n}\n"],"names":["xLinear","spec","context","result","advancedVSeed","vseed","chartType","locale","config","visible","label","tick","title","grid","line","zero","nice","inverse","max","min","log","logBase","autoFormat","numFormat","formatter","createNumFormatter","linearAxis","value","isEmpty","autoFormatter","LINEAR_AXIS_INNER_OFFSET_TOP"],"mappings":";;;AAMO,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,MAAM,EAAE,GAAGH;IACnB,MAAMI,SAASJ,cAAc,MAAM,EAAE,CAACE,UAAmB,EAAE;IAE3D,IAAI,CAACH,OAAO,IAAI,EACdA,OAAO,IAAI,GAAG,EAAE;IAGlB,IAAI,CAACK,QAAQ;QACXL,OAAO,IAAI,GAAG;eACTA,OAAO,IAAI;YACd;gBACE,SAAS;gBACT,MAAM;gBACN,QAAQ;YACV;SACD;QACD,OAAOA;IACT;IAEA,MAAM,EACJM,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,aAAa,IAAI,EACjBC,YAAY,CAAC,CAAC,EACf,GAAGf;IAEJ,MAAMgB,YAAYC,mBAAmBF,WAAWhB;IAEhD,MAAMmB,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;gBACb,IAAI,CAACC,QAAQL,YACX,OAAOC,UAAUG;gBAEnB,IAAIL,YACF,OAAOO,cAAcF,OAAOpB;gBAE9B,OAAOoB;YACT;YACA,OAAO;gBACL,MAAMjB,OAAO;gBACb,OAAOA,OAAO;gBACd,UAAUA,OAAO;gBACjB,YAAYA,OAAO;YACrB;QACF;QACA,OAAO;YACL,SAASE,OAAO;YAChB,MAAMA,OAAO;YACb,OAAO;gBACL,MAAMA,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,OAAOgB;QAET;IACF;IAEA3B,OAAO,IAAI,GAAG;WAAIA,OAAO,IAAI;QAAEuB;KAAW;IAE1C,OAAOvB;AACT"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { LINEAR_AXIS_INNER_OFFSET_TOP } from "../../../../utils/constant.js";
|
2
|
-
import { autoFormatter } from "../../../../utils/index.js";
|
2
|
+
import { autoFormatter, createNumFormatter } from "../../../../utils/index.js";
|
3
|
+
import { isEmpty } from "remeda";
|
3
4
|
const yLinear = (spec, context)=>{
|
4
5
|
const result = {
|
5
6
|
...spec
|
@@ -20,7 +21,8 @@ const yLinear = (spec, context)=>{
|
|
20
21
|
];
|
21
22
|
return result;
|
22
23
|
}
|
23
|
-
const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10 } = config;
|
24
|
+
const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10, autoFormat = true, numFormat = {} } = config;
|
25
|
+
const formatter = createNumFormatter(numFormat);
|
24
26
|
const linearAxis = {
|
25
27
|
visible,
|
26
28
|
type: log ? 'log' : 'linear',
|
@@ -33,7 +35,11 @@ const yLinear = (spec, context)=>{
|
|
33
35
|
min,
|
34
36
|
label: {
|
35
37
|
visible: label?.visible,
|
36
|
-
formatMethod: (value)=>
|
38
|
+
formatMethod: (value)=>{
|
39
|
+
if (!isEmpty(numFormat)) return formatter(value);
|
40
|
+
if (autoFormat) return autoFormatter(value, locale);
|
41
|
+
return value;
|
42
|
+
},
|
37
43
|
style: {
|
38
44
|
fill: label?.labelColor,
|
39
45
|
angle: label?.labelAngle,
|
@@ -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 { autoFormatter } from '../../../../utils'\nimport type { SpecPipe, YLinearAxis } from 'src/types'\n\nexport const yLinear: SpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n const { locale } = 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 } = config\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 autoFormatter(value, locale)\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,\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","locale","config","visible","label","tick","title","grid","line","zero","nice","inverse","max","min","log","logBase","linearAxis","value","autoFormatter","LINEAR_AXIS_INNER_OFFSET_TOP"],"mappings":"
|
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 { autoFormatter, createNumFormatter } from '../../../../utils'\nimport type { SpecPipe, YLinearAxis } from 'src/types'\nimport { isEmpty } from 'remeda'\n\nexport const yLinear: SpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n const { locale } = 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 = true,\n numFormat = {},\n } = config\n\n const formatter = createNumFormatter(numFormat)\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 if (!isEmpty(numFormat)) {\n return formatter(value)\n }\n if (autoFormat) {\n return autoFormatter(value, locale)\n }\n return value\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,\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","locale","config","visible","label","tick","title","grid","line","zero","nice","inverse","max","min","log","logBase","autoFormat","numFormat","formatter","createNumFormatter","linearAxis","value","isEmpty","autoFormatter","LINEAR_AXIS_INNER_OFFSET_TOP"],"mappings":";;;AAMO,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,MAAM,EAAE,GAAGH;IACnB,MAAMI,SAASJ,cAAc,MAAM,EAAE,CAACE,UAAsB,EAAE;IAE9D,IAAI,CAACH,OAAO,IAAI,EACdA,OAAO,IAAI,GAAG,EAAE;IAGlB,IAAI,CAACK,QAAQ;QACXL,OAAO,IAAI,GAAG;eACTA,OAAO,IAAI;YACd;gBACE,SAAS;gBACT,MAAM;gBACN,QAAQ;YACV;SACD;QACD,OAAOA;IACT;IAEA,MAAM,EACJM,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,aAAa,IAAI,EACjBC,YAAY,CAAC,CAAC,EACf,GAAGf;IAEJ,MAAMgB,YAAYC,mBAAmBF;IACrC,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;gBACb,IAAI,CAACC,QAAQL,YACX,OAAOC,UAAUG;gBAEnB,IAAIL,YACF,OAAOO,cAAcF,OAAOpB;gBAE9B,OAAOoB;YACT;YACA,OAAO;gBACL,MAAMjB,OAAO;gBACb,OAAOA,OAAO;gBACd,UAAUA,OAAO;gBACjB,YAAYA,OAAO;YACrB;QACF;QACA,OAAO;YACL,SAASE,OAAO;YAChB,MAAMA,OAAO;YACb,OAAO;gBACL,MAAMA,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;IAEA3B,OAAO,IAAI,GAAG;WAAIA,OAAO,IAAI;QAAEuB;KAAW;IAE1C,OAAOvB;AACT"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { LINEAR_AXIS_INNER_OFFSET_TOP } from "../../../../utils/constant.js";
|
2
|
-
import { autoFormatter } from "../../../../utils/index.js";
|
2
|
+
import { autoFormatter, createNumFormatter } from "../../../../utils/index.js";
|
3
3
|
import { isEmpty, isNullish } from "remeda";
|
4
4
|
const yLinearPrimary = (spec, context)=>{
|
5
5
|
const result = {
|
@@ -35,7 +35,8 @@ const yLinearPrimary = (spec, context)=>{
|
|
35
35
|
];
|
36
36
|
return result;
|
37
37
|
}
|
38
|
-
const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10 } = yAxisConfig;
|
38
|
+
const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10, autoFormat = true, numFormat = {} } = yAxisConfig;
|
39
|
+
const formatter = createNumFormatter(numFormat, locale);
|
39
40
|
const linearAxis = {
|
40
41
|
visible: isEmptySecondary ? false : visible,
|
41
42
|
id,
|
@@ -50,7 +51,11 @@ const yLinearPrimary = (spec, context)=>{
|
|
50
51
|
min,
|
51
52
|
label: {
|
52
53
|
visible: label?.visible,
|
53
|
-
formatMethod: (value)=>
|
54
|
+
formatMethod: (value)=>{
|
55
|
+
if (!isEmpty(numFormat)) return formatter(value);
|
56
|
+
if (autoFormat) return autoFormatter(value, locale);
|
57
|
+
return value;
|
58
|
+
},
|
54
59
|
style: {
|
55
60
|
fill: label?.labelColor,
|
56
61
|
angle: label?.labelAngle,
|
@@ -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 { autoFormatter } from '../../../../utils'\nimport type { SpecPipe, YLinearAxis } from 'src/types'\nimport { isEmpty, isNullish } from 'remeda'\n\nexport const yLinearPrimary: SpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n const { locale, datasetReshapeInfo } = 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 } = yAxisConfig\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 autoFormatter(value, locale)\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,\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","locale","datasetReshapeInfo","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","linearAxis","value","autoFormatter","LINEAR_AXIS_INNER_O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,KAAK,EACLC,IAAI,EACJC,IAAI,EAEJC,IAAI,EACJC,IAAI,EACJC,OAAO,EACPC,GAAG,EACHC,GAAG,EACHC,GAAG,EACHC,UAAU,EAAE,
|
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 { autoFormatter, createNumFormatter } from '../../../../utils'\nimport type { SpecPipe, YLinearAxis } from 'src/types'\nimport { isEmpty, isNullish } from 'remeda'\n\nexport const yLinearPrimary: SpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n const { locale, datasetReshapeInfo } = 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 = true,\n numFormat = {},\n } = yAxisConfig\n\n const formatter = createNumFormatter(numFormat, locale)\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 if (!isEmpty(numFormat)) {\n return formatter(value)\n }\n if (autoFormat) {\n return autoFormatter(value, locale)\n }\n return value\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,\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","locale","datasetReshapeInfo","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","linearAxis","value","autoFormatter","LINEAR_AXIS_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_INNER_OFFSET_TOP } from "../../../../utils/constant.js";
|
2
|
-
import { autoFormatter } from "../../../../utils/index.js";
|
2
|
+
import { autoFormatter, createNumFormatter } from "../../../../utils/index.js";
|
3
3
|
import { isEmpty, isNullish } from "remeda";
|
4
4
|
const yLinearSecondary = (spec, context)=>{
|
5
5
|
const result = {
|
@@ -41,7 +41,8 @@ const yLinearSecondary = (spec, context)=>{
|
|
41
41
|
];
|
42
42
|
return result;
|
43
43
|
}
|
44
|
-
const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10 } = yAxisConfig;
|
44
|
+
const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10, numFormat = {}, autoFormat = true } = yAxisConfig;
|
45
|
+
const formatter = createNumFormatter(numFormat, locale);
|
45
46
|
const linearAxis = {
|
46
47
|
visible: isEmptySecondary ? false : visible,
|
47
48
|
id,
|
@@ -57,7 +58,11 @@ const yLinearSecondary = (spec, context)=>{
|
|
57
58
|
min,
|
58
59
|
label: {
|
59
60
|
visible: label?.visible,
|
60
|
-
formatMethod: (value)=>
|
61
|
+
formatMethod: (value)=>{
|
62
|
+
if (!isEmpty(numFormat)) return formatter(value);
|
63
|
+
if (autoFormat) return autoFormatter(value, locale);
|
64
|
+
return value;
|
65
|
+
},
|
61
66
|
style: {
|
62
67
|
fill: label?.labelColor,
|
63
68
|
angle: label?.labelAngle,
|
@@ -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 { autoFormatter } from '../../../../utils'\nimport type { SpecPipe, YLinearAxis } from 'src/types'\nimport { isEmpty, isNullish } from 'remeda'\n\nexport const yLinearSecondary: SpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n const { locale, datasetReshapeInfo } = 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 } = yAxisConfig\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 autoFormatter(value, locale)\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,\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","locale","datasetReshapeInfo","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","linearAxis","value","autoFormatter","LINEAR_AXIS_INNER_OFFSET_TOP"],"mappings":";;;AAMO,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,MAAM,EAAEC,kBAAkB,EAAE,GAAGJ;IACvC,MAAM,EAAEK,KAAK,EAAE,IAAIC,aAAa,EAAEC,YAAY,EAAE,GAAGH,kBAAkB,CAAC,EAAE;IAExE,MAAMI,iBAAiBR,cAAc,MAAM,EAAE,CAACE,UAAwB,EAAE;IACxE,MAAMO,cAAcC,MAAM,OAAO,CAACF,kBAAkBA,cAAc,CAACH,MAAM,IAAIG,cAAc,CAAC,EAAE,GAAGA;IACjG,MAAMG,aAAaX,cAAc,MAAM,EAAE,CAACE,UAAwB,EAAE;IACpE,MAAMU,mBAAmBF,MAAM,OAAO,CAACC,cAAcA,UAAU,CAACN,MAAM,IAAIM,UAAU,CAAC,EAAE,GAAGA;IAE1F,IAAIE,UAAUN,cAAc,CAAC,EAAE,GAC7B,OAAOR;IAGT,MAAMe,mBAAmBC,QAAQR,cAAc,CAAC,EAAE,CAAC;IACnD,MAAMS,gBAAgBD,QAAQR,cAAc,CAAC,EAAE,CAAC,YAAY,CAACO;IAE7D,MAAMG,OAAO;QACX,QAAQ,GAAGX,cAAc,aAAa,CAAC;QACvC,WAAW;IACb;IAEA,MAAMY,KAAK,GAAGZ,cAAc,eAAe,CAAC;IAC5C,MAAMa,YAAY;QAAC,GAAGb,cAAc,eAAe,CAAC;QAAE,GAAGA,cAAc,iBAAiB,CAAC;KAAC;IAC1F,MAAMc,WAAWR,mBAAmBO,YAAYA,SAAS,CAAC,EAAE;IAC5D,IAAI,CAACpB,OAAO,IAAI,EACdA,OAAO,IAAI,GAAG,EAAE;IAGlB,IAAI,CAACU,aAAa;QAChBV,OAAO,IAAI,GAAG;eACTA,OAAO,IAAI;YACd;gBACE,SAAS;gBACTmB;gBACAE;gBACA,MAAM;gBACN,QAAQ;gBACRH;YACF;SACD;QACD,OAAOlB;IACT;IAEA,MAAM,EACJsB,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,
|
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 { autoFormatter, createNumFormatter } from '../../../../utils'\nimport type { SpecPipe, YLinearAxis } from 'src/types'\nimport { isEmpty, isNullish } from 'remeda'\n\nexport const yLinearSecondary: SpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n const { locale, datasetReshapeInfo } = 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 = true,\n } = yAxisConfig\n\n const formatter = createNumFormatter(numFormat, locale)\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 if (!isEmpty(numFormat)) {\n return formatter(value)\n }\n if (autoFormat) {\n return autoFormatter(value, locale)\n }\n return value\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,\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","locale","datasetReshapeInfo","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","autoFormatter","LINEAR_AXIS_INNER_OFFSET_TOP"],"mappings":";;;AAMO,MAAMA,mBAA6B,CAACC,MAAMC;IAC/C,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAEC,KAAK,EAAE,GAAGH;IACjC,MA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";
|
2
|
-
import { labelColorInversion } from "./labelColorInversion.js";
|
3
2
|
import { labelPrimary, labelSecondary } from "./labelDualAxis.js";
|
4
|
-
|
3
|
+
import { labelScatter } from "./labelScatter.js";
|
4
|
+
export { label, labelPrimary, labelScatter, labelSecondary };
|
@@ -1,2 +1,6 @@
|
|
1
|
-
import type {
|
1
|
+
import type { ILineLikeLabelSpec } from '@visactor/vchart/esm/series/mixin/interface';
|
2
|
+
import type { Dimensions, Encoding, FoldInfo, Formatter, Label, Measure, Measures, NumFormat, SpecPipe } from '../../../../../types';
|
2
3
|
export declare const label: SpecPipe;
|
4
|
+
export declare const generateMeasureValue: (value: number | string, measure?: Measure, labelAutoFormat?: boolean, numFormat?: NumFormat) => string | number;
|
5
|
+
export declare const generateMeasurePercent: (value: number | string, sum: number, formatter: Formatter) => string;
|
6
|
+
export declare const buildLabel: (label: Label, vseedMeasures: Measures | undefined, vseedDimensions: Dimensions | undefined, advancedVSeedMeasures: Measures, encoding: Encoding, foldInfoList: FoldInfo[]) => ILineLikeLabelSpec;
|
@@ -1,36 +1,62 @@
|
|
1
|
-
import {
|
1
|
+
import { createFormatter, createFormatterByMeasure, findMeasureById } from "../../../../utils/index.js";
|
2
2
|
import { isEmpty, merge, uniqueBy } from "remeda";
|
3
|
-
import { intl } from "../../../../../i18n/index.js";
|
4
3
|
const label_label = (spec, context)=>{
|
5
4
|
const result = {
|
6
5
|
...spec
|
7
6
|
};
|
8
7
|
const { advancedVSeed, vseed } = context;
|
9
|
-
const {
|
8
|
+
const { datasetReshapeInfo } = advancedVSeed;
|
10
9
|
const { chartType, encoding } = advancedVSeed;
|
11
10
|
const baseConfig = advancedVSeed.config[chartType];
|
11
|
+
const foldInfo = datasetReshapeInfo[0].foldInfo;
|
12
12
|
if (!baseConfig || isEmpty(baseConfig.label)) return result;
|
13
|
-
const { measureId, measureValue, statistics } = datasetReshapeInfo[0].foldInfo;
|
14
13
|
const { label } = baseConfig;
|
14
|
+
result.label = buildLabel(label, vseed.measures, vseed.dimensions, advancedVSeed.measures, encoding, [
|
15
|
+
foldInfo
|
16
|
+
]);
|
17
|
+
return result;
|
18
|
+
};
|
19
|
+
const generateMeasureValue = (value, measure, labelAutoFormat = true, numFormat = {})=>{
|
20
|
+
if (!measure) return value;
|
21
|
+
const format = merge(numFormat, measure.numFormat || measure.format);
|
22
|
+
const mergedMeasure = {
|
23
|
+
...measure,
|
24
|
+
numFormat: format,
|
25
|
+
autoFormat: labelAutoFormat || measure.autoFormat
|
26
|
+
};
|
27
|
+
const formatter = createFormatterByMeasure(mergedMeasure);
|
28
|
+
return formatter(value);
|
29
|
+
};
|
30
|
+
const generateMeasurePercent = (value, sum, formatter)=>{
|
31
|
+
if (null == value) return String(value);
|
32
|
+
const num = Number(value);
|
33
|
+
if (Number.isNaN(num)) return String(value);
|
34
|
+
const percentValue = num / sum;
|
35
|
+
return formatter(percentValue);
|
36
|
+
};
|
37
|
+
const buildLabel = (label, vseedMeasures = [], vseedDimensions = [], advancedVSeedMeasures, encoding, foldInfoList)=>{
|
15
38
|
const { enable, wrap, showValue, showValuePercent, labelOverlap, labelColorSmartInvert, labelColor, labelFontSize, labelFontWeight, labelBackgroundColor, labelPosition, autoFormat = true, numFormat = {} } = label;
|
16
|
-
const labelDims = uniqueBy((
|
17
|
-
const labelMeas = uniqueBy((
|
39
|
+
const labelDims = uniqueBy((vseedDimensions || []).filter((item)=>encoding.label?.includes(item.id)), (item)=>item.id);
|
40
|
+
const labelMeas = uniqueBy((vseedMeasures || []).filter((item)=>encoding.label?.includes(item.id)), (item)=>item.id);
|
18
41
|
const percentFormat = merge(numFormat, {
|
19
42
|
type: 'percent'
|
20
43
|
});
|
21
44
|
const percentFormatter = createFormatter(percentFormat);
|
22
|
-
result
|
45
|
+
const result = {
|
23
46
|
visible: enable,
|
24
47
|
formatMethod: (_, datum)=>{
|
25
48
|
const result = [];
|
26
49
|
const dimLabels = labelDims.map((item)=>item.alias || item.id);
|
27
50
|
const meaLabels = labelMeas.map((item)=>generateMeasureValue(datum[item.id], item, autoFormat, numFormat));
|
28
|
-
const measure = findMeasureById(measures, datum[measureId]);
|
29
|
-
const measureValueLabel = generateMeasureValue(datum[measureValue], measure, autoFormat, numFormat);
|
30
|
-
const measurePercentLabel = generateMeasurePercent(datum[measureValue], statistics.sum, percentFormatter);
|
31
51
|
result.push(...dimLabels);
|
32
|
-
|
33
|
-
|
52
|
+
foldInfoList.forEach((foldInfo)=>{
|
53
|
+
const { measureId, measureValue, statistics } = foldInfo;
|
54
|
+
const measure = findMeasureById(advancedVSeedMeasures, datum[measureId]);
|
55
|
+
const measureValueLabel = generateMeasureValue(datum[measureValue], measure, autoFormat, numFormat);
|
56
|
+
const measurePercentLabel = generateMeasurePercent(datum[measureValue], statistics.sum, percentFormatter);
|
57
|
+
if (showValue) result.push(measureValueLabel);
|
58
|
+
if (showValuePercent) result.push(measurePercentLabel);
|
59
|
+
});
|
34
60
|
result.push(...meaLabels);
|
35
61
|
if (wrap) return result;
|
36
62
|
return result.join(' ');
|
@@ -44,30 +70,12 @@ const label_label = (spec, context)=>{
|
|
44
70
|
},
|
45
71
|
smartInvert: labelColorSmartInvert
|
46
72
|
};
|
47
|
-
if (labelOverlap) result.
|
73
|
+
if (labelOverlap) result.overlap = {
|
48
74
|
hideOnHit: true,
|
49
75
|
clampForce: true
|
50
76
|
};
|
51
77
|
return result;
|
52
78
|
};
|
53
|
-
|
54
|
-
if (!measure) return value;
|
55
|
-
const format = merge(numFormat, measure.format);
|
56
|
-
const autoFormat = labelAutoFormat || measure.autoFormat;
|
57
|
-
if (!isEmpty(format)) {
|
58
|
-
const formatter = createFormatter(format);
|
59
|
-
return formatter(value);
|
60
|
-
}
|
61
|
-
if (autoFormat) return autoFormatter(value, intl.getLocale());
|
62
|
-
return String(value);
|
63
|
-
};
|
64
|
-
const generateMeasurePercent = (value, sum, formatter)=>{
|
65
|
-
if (null == value) return String(value);
|
66
|
-
const num = Number(value);
|
67
|
-
if (Number.isNaN(num)) return String(value);
|
68
|
-
const percentValue = num / sum;
|
69
|
-
return formatter(percentValue);
|
70
|
-
};
|
71
|
-
export { label_label as label };
|
79
|
+
export { buildLabel, generateMeasurePercent, generateMeasureValue, label_label as label };
|
72
80
|
|
73
81
|
//# sourceMappingURL=label.js.map
|
@@ -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 {
|
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 = true,\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 = true,\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,QAA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;IAGnB,MAAME,gBAA2B9B,MAAMF,WAAW;QAChD,MAAM;IACR;IAEA,MAAMiC,mBAAmBC,gBAAgBF;IAEzC,MAAM9C,SAAS;QACb,SAAS8B;QACT,cAAc,CAACmB,GAAGC;YAChB,MAAMlD,SAAS,EAAE;YAEjB,MAAMmD,YAAYT,UAAU,GAAG,CAAC,CAACE,OAASA,KAAK,KAAK,IAAIA,KAAK,EAAE;YAC/D,MAAMQ,YAAYP,UAAU,GAAG,CAAC,CAACD,OAC/BlC,qBAAqBwC,KAAK,CAACN,KAAK,EAAE,CAAC,EAAqBA,MAAMH,YAAY3B;YAG5Ed,OAAO,IAAI,IAAImD;YAEftB,aAAa,OAAO,CAAC,CAACtB;gBACpB,MAAM,EAAE8C,SAAS,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"}
|
@@ -1,74 +1,37 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
1
|
+
import { isNullish } from "remeda";
|
2
|
+
import { buildLabel } from "./label.js";
|
3
|
+
import { DUAL_AXIS_LABEL_Z_INDEX } from "../../../../utils/constant.js";
|
3
4
|
const labelPrimary = (spec, context)=>{
|
4
5
|
const result = {
|
5
6
|
...spec
|
6
7
|
};
|
7
|
-
const { advancedVSeed } = context;
|
8
|
-
const {
|
8
|
+
const { advancedVSeed, vseed } = context;
|
9
|
+
const { datasetReshapeInfo, encoding } = advancedVSeed;
|
9
10
|
const { chartType } = advancedVSeed;
|
10
11
|
const baseConfig = advancedVSeed.config[chartType];
|
11
12
|
if (!baseConfig || !baseConfig.label) return result;
|
12
13
|
const foldInfoList = datasetReshapeInfo[0].foldInfoList;
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
result.label =
|
17
|
-
visible: enable,
|
18
|
-
formatMethod: (value, datum)=>{
|
19
|
-
const result = [];
|
20
|
-
const formatValue = (value)=>{
|
21
|
-
const id = datum[measureId];
|
22
|
-
const measure = findMeasureById(measures, id);
|
23
|
-
if (!measure) return value;
|
24
|
-
const { format = {}, autoFormat = true } = measure;
|
25
|
-
if (!isEmpty(format)) {
|
26
|
-
const formatter = createFormatter(format);
|
27
|
-
return formatter(value);
|
28
|
-
}
|
29
|
-
if (autoFormat) return autoFormatter(value, locale);
|
30
|
-
return String(value);
|
31
|
-
};
|
32
|
-
result.push(formatValue(datum[measureValue]));
|
33
|
-
return result.join(' ');
|
34
|
-
}
|
35
|
-
};
|
14
|
+
result.label = buildLabel(baseConfig.label, vseed.measures, vseed.dimensions, advancedVSeed.measures, encoding, [
|
15
|
+
foldInfoList[0]
|
16
|
+
]);
|
17
|
+
result.label.zIndex = DUAL_AXIS_LABEL_Z_INDEX;
|
36
18
|
return result;
|
37
19
|
};
|
38
20
|
const labelSecondary = (spec, context)=>{
|
39
21
|
const result = {
|
40
22
|
...spec
|
41
23
|
};
|
42
|
-
const { advancedVSeed } = context;
|
43
|
-
const {
|
24
|
+
const { advancedVSeed, vseed } = context;
|
25
|
+
const { datasetReshapeInfo, encoding } = advancedVSeed;
|
44
26
|
const { chartType } = advancedVSeed;
|
45
27
|
const baseConfig = advancedVSeed.config[chartType];
|
46
28
|
if (!baseConfig || !baseConfig.label) return result;
|
47
29
|
if (isNullish(datasetReshapeInfo[0].foldInfoList?.[1])) return result;
|
48
30
|
const foldInfoList = datasetReshapeInfo[0].foldInfoList;
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
result.label =
|
53
|
-
visible: enable,
|
54
|
-
formatMethod: (value, datum)=>{
|
55
|
-
const result = [];
|
56
|
-
const formatValue = (value)=>{
|
57
|
-
const id = datum[measureId];
|
58
|
-
const measure = findMeasureById(measures, id);
|
59
|
-
if (!measure) return value;
|
60
|
-
const { format = {}, autoFormat = true } = measure;
|
61
|
-
if (!isEmpty(format)) {
|
62
|
-
const formatter = createFormatter(format);
|
63
|
-
return formatter(value);
|
64
|
-
}
|
65
|
-
if (autoFormat) return autoFormatter(value, locale);
|
66
|
-
return String(value);
|
67
|
-
};
|
68
|
-
result.push(formatValue(datum[measureValue]));
|
69
|
-
return result.join(' ');
|
70
|
-
}
|
71
|
-
};
|
31
|
+
result.label = buildLabel(baseConfig.label, vseed.measures, vseed.dimensions, advancedVSeed.measures, encoding, [
|
32
|
+
foldInfoList[1]
|
33
|
+
]);
|
34
|
+
result.label.zIndex = DUAL_AXIS_LABEL_Z_INDEX;
|
72
35
|
return result;
|
73
36
|
};
|
74
37
|
export { labelPrimary, labelSecondary };
|