@visactor/vseed 0.2.3 → 0.2.5
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/pipeline/spec/chart/pipeline/histogram.js +3 -3
- package/dist/esm/pipeline/spec/chart/pipeline/histogram.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/{axisStyle.js → bandAxisStyle.js} +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/bandAxisStyle.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/axes/heatmapBandAxis.js +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/heatmapBandAxis.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/histogramXLinear.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/axes/histogramXLinear.js +50 -0
- package/dist/esm/pipeline/spec/chart/pipes/axes/histogramXLinear.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/axes/index.d.ts +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/axes/index.js +2 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/linearAxisStyle.d.ts +14 -0
- package/dist/esm/pipeline/spec/chart/pipes/axes/linearAxisStyle.js +78 -0
- package/dist/esm/pipeline/spec/chart/pipes/axes/linearAxisStyle.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/axes/xBand.js +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/xBand.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/xLinear.js +14 -68
- package/dist/esm/pipeline/spec/chart/pipes/axes/xLinear.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yBand.js +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yBand.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinear.js +14 -68
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinear.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinearPrimary.js +13 -59
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinearPrimary.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinearSecondary.js +16 -57
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinearSecondary.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/pivotChart/dimensionLinkage.js +2 -2
- package/dist/esm/pipeline/spec/chart/pipes/pivotChart/dimensionLinkage.js.map +1 -1
- package/dist/esm/types/properties/config/crosshair/crosshair.d.ts +36 -0
- package/dist/esm/types/zVseed.d.ts +1 -1
- package/dist/umd/index.js +142 -217
- package/dist/umd/index.js.map +1 -1
- package/package.json +12 -12
- package/dist/esm/pipeline/spec/chart/pipes/axes/axisStyle.js.map +0 -1
- /package/dist/esm/pipeline/spec/chart/pipes/axes/{axisStyle.d.ts → bandAxisStyle.d.ts} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { annotationAreaBand, annotationHorizontalLine, annotationPointOfHistogram, annotationVerticalLine, backgroundColor, barStyle, color, colorAdapter, colorBarStyleFill, colorLegend, datasetHistogram, datasetPivot, dimensionLinkage, discreteLegend, ecdfRegressionLine, histogramVerticalCrosshairRect, initHistogram, initPivot, kdeRegressionLine, label, linearColor, pivotAdapter, pivotAxisStyle, pivotColorLegend, pivotColumnDimensions, pivotDiscreteLegend, pivotGridStyle, pivotIndicators, pivotRowDimensions, pivotTitle, progressive, tooltipHistogram,
|
|
1
|
+
import { annotationAreaBand, annotationHorizontalLine, annotationPointOfHistogram, annotationVerticalLine, backgroundColor, barStyle, color, colorAdapter, colorBarStyleFill, colorLegend, datasetHistogram, datasetPivot, dimensionLinkage, discreteLegend, ecdfRegressionLine, histogramVerticalCrosshairRect, histogramXLinear, initHistogram, initPivot, kdeRegressionLine, label, linearColor, pivotAdapter, pivotAxisStyle, pivotColorLegend, pivotColumnDimensions, pivotDiscreteLegend, pivotGridStyle, pivotIndicators, pivotRowDimensions, pivotTitle, progressive, tooltipHistogram, yLinear } from "../pipes/index.js";
|
|
2
2
|
const histogram = [
|
|
3
3
|
initHistogram,
|
|
4
4
|
colorAdapter(color, linearColor),
|
|
5
5
|
backgroundColor,
|
|
6
6
|
datasetHistogram,
|
|
7
7
|
progressive,
|
|
8
|
-
|
|
8
|
+
histogramXLinear,
|
|
9
9
|
yLinear,
|
|
10
10
|
label,
|
|
11
11
|
tooltipHistogram,
|
|
@@ -29,7 +29,7 @@ const pivotHistogram = [
|
|
|
29
29
|
backgroundColor,
|
|
30
30
|
datasetHistogram,
|
|
31
31
|
progressive,
|
|
32
|
-
|
|
32
|
+
histogramXLinear,
|
|
33
33
|
pivotAxisStyle(yLinear),
|
|
34
34
|
label,
|
|
35
35
|
tooltipHistogram,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipeline/histogram.js","sources":["../../../../../../src/pipeline/spec/chart/pipeline/histogram.ts"],"sourcesContent":["import type { PivotChartSpecPipeline, VChartSpecPipeline } from 'src/types'\nimport {\n label,\n
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipeline/histogram.js","sources":["../../../../../../src/pipeline/spec/chart/pipeline/histogram.ts"],"sourcesContent":["import type { PivotChartSpecPipeline, VChartSpecPipeline } from 'src/types'\nimport {\n label,\n backgroundColor,\n discreteLegend,\n color,\n pivotAdapter,\n initPivot,\n datasetPivot,\n pivotIndicators,\n pivotDiscreteLegend,\n pivotGridStyle,\n pivotColumnDimensions,\n pivotRowDimensions,\n barStyle,\n annotationPointOfHistogram,\n annotationVerticalLine,\n annotationHorizontalLine,\n annotationAreaBand,\n datasetHistogram,\n progressive,\n colorAdapter,\n linearColor,\n colorLegend,\n colorBarStyleFill,\n pivotColorLegend,\n initHistogram,\n yLinear,\n histogramVerticalCrosshairRect,\n tooltipHistogram,\n kdeRegressionLine,\n ecdfRegressionLine,\n pivotTitle,\n pivotAxisStyle,\n dimensionLinkage,\n histogramXLinear,\n} from '../pipes'\n\nconst histogram: VChartSpecPipeline = [\n initHistogram,\n colorAdapter(color, linearColor),\n backgroundColor,\n datasetHistogram,\n progressive,\n histogramXLinear,\n yLinear,\n label,\n tooltipHistogram,\n colorAdapter(discreteLegend, colorLegend),\n histogramVerticalCrosshairRect,\n colorBarStyleFill(barStyle),\n annotationPointOfHistogram,\n annotationVerticalLine,\n annotationHorizontalLine,\n annotationAreaBand,\n kdeRegressionLine,\n ecdfRegressionLine,\n]\n\nconst pivotHistogram: PivotChartSpecPipeline = [\n initPivot,\n pivotGridStyle,\n datasetPivot,\n pivotIndicators([\n initHistogram,\n colorAdapter(color, linearColor),\n backgroundColor,\n datasetHistogram,\n progressive,\n histogramXLinear,\n pivotAxisStyle(yLinear),\n label,\n tooltipHistogram,\n colorBarStyleFill(barStyle),\n histogramVerticalCrosshairRect,\n annotationPointOfHistogram,\n annotationVerticalLine,\n annotationHorizontalLine,\n annotationAreaBand,\n kdeRegressionLine,\n ecdfRegressionLine,\n ]),\n pivotRowDimensions,\n pivotColumnDimensions,\n pivotTitle,\n colorAdapter(pivotDiscreteLegend, pivotColorLegend),\n dimensionLinkage,\n]\n\nexport const histogramSpecPipeline = [pivotAdapter(histogram, pivotHistogram)]\n"],"names":["histogram","initHistogram","colorAdapter","color","linearColor","backgroundColor","datasetHistogram","progressive","histogramXLinear","yLinear","label","tooltipHistogram","discreteLegend","colorLegend","histogramVerticalCrosshairRect","colorBarStyleFill","barStyle","annotationPointOfHistogram","annotationVerticalLine","annotationHorizontalLine","annotationAreaBand","kdeRegressionLine","ecdfRegressionLine","pivotHistogram","initPivot","pivotGridStyle","datasetPivot","pivotIndicators","pivotAxisStyle","pivotRowDimensions","pivotColumnDimensions","pivotTitle","pivotDiscreteLegend","pivotColorLegend","dimensionLinkage","histogramSpecPipeline","pivotAdapter"],"mappings":";AAsCA,MAAMA,YAAgC;IACpCC;IACAC,aAAaC,OAAOC;IACpBC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAT,aAAaU,gBAAgBC;IAC7BC;IACAC,kBAAkBC;IAClBC;IACAC;IACAC;IACAC;IACAC;IACAC;CACD;AAED,MAAMC,iBAAyC;IAC7CC;IACAC;IACAC;IACAC,gBAAgB;QACd1B;QACAC,aAAaC,OAAOC;QACpBC;QACAC;QACAC;QACAC;QACAoB,eAAenB;QACfC;QACAC;QACAI,kBAAkBC;QAClBF;QACAG;QACAC;QACAC;QACAC;QACAC;QACAC;KACD;IACDO;IACAC;IACAC;IACA7B,aAAa8B,qBAAqBC;IAClCC;CACD;AAEM,MAAMC,wBAAwB;IAACC,aAAapC,WAAWuB;CAAgB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/axes/bandAxisStyle.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/axes/bandAxisStyle.ts"],"sourcesContent":["import type { ICartesianBandAxisSpec } from '@visactor/vchart'\nimport type { XBandAxis } from 'src/types'\nimport { AXIS_LABEL_SPACE } from 'src/pipeline/utils'\n\nexport const bandAxisStyle = (config: XBandAxis) => {\n const {\n visible = true,\n label,\n tick,\n title,\n grid,\n line,\n labelAutoHide,\n labelAutoHideGap,\n labelAutoLimit,\n labelAutoLimitLength = 80,\n labelAutoRotate,\n labelAutoRotateAngleRange,\n } = config\n\n return {\n type: 'band',\n sampling: !(labelAutoHide || labelAutoRotate || labelAutoLimit),\n visible,\n hover: true,\n label: {\n visible: label?.visible,\n flush: true,\n space: AXIS_LABEL_SPACE,\n style: {\n maxLineWidth: labelAutoLimitLength,\n fill: label?.labelColor,\n angle: label?.labelAngle,\n fontSize: label?.labelFontSize,\n fontWeight: label?.labelFontWeight,\n },\n\n // 防重叠相关\n minGap: labelAutoHideGap,\n autoHide: labelAutoHide,\n autoHideMethod: 'greedy',\n autoHideSeparation: labelAutoHideGap,\n autoLimit: labelAutoLimit,\n autoRotate: labelAutoRotate,\n autoRotateAngle: labelAutoRotateAngleRange,\n lastVisible: true,\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 lineDash: grid?.gridLineDash,\n },\n },\n domainLine: {\n visible: line?.visible,\n style: {\n lineWidth: line?.lineWidth,\n stroke: line?.lineColor,\n },\n },\n } as Partial<ICartesianBandAxisSpec>\n}\n"],"names":["bandAxisStyle","config","visible","label","tick","title","grid","line","labelAutoHide","labelAutoHideGap","labelAutoLimit","labelAutoLimitLength","labelAutoRotate","labelAutoRotateAngleRange","AXIS_LABEL_SPACE"],"mappings":";AAIO,MAAMA,gBAAgB,CAACC;IAC5B,MAAM,EACJC,UAAU,IAAI,EACdC,KAAK,EACLC,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,IAAI,EACJC,aAAa,EACbC,gBAAgB,EAChBC,cAAc,EACdC,uBAAuB,EAAE,EACzBC,eAAe,EACfC,yBAAyB,EAC1B,GAAGZ;IAEJ,OAAO;QACL,MAAM;QACN,UAAU,CAAEO,CAAAA,iBAAiBI,mBAAmBF,cAAa;QAC7DR;QACA,OAAO;QACP,OAAO;YACL,SAASC,OAAO;YAChB,OAAO;YACP,OAAOW;YACP,OAAO;gBACL,cAAcH;gBACd,MAAMR,OAAO;gBACb,OAAOA,OAAO;gBACd,UAAUA,OAAO;gBACjB,YAAYA,OAAO;YACrB;YAGA,QAAQM;YACR,UAAUD;YACV,gBAAgB;YAChB,oBAAoBC;YACpB,WAAWC;YACX,YAAYE;YACZ,iBAAiBC;YACjB,aAAa;QACf;QACA,OAAO;YACL,SAASR,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;gBACd,UAAUA,MAAM;YAClB;QACF;QACA,YAAY;YACV,SAASC,MAAM;YACf,OAAO;gBACL,WAAWA,MAAM;gBACjB,QAAQA,MAAM;YAChB;QACF;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/axes/heatmapBandAxis.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/axes/heatmapBandAxis.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport type { VChartSpecPipe, XBandAxis, YBandAxis } from 'src/types'\nimport { bandAxisStyle } from './
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/axes/heatmapBandAxis.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/axes/heatmapBandAxis.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport type { VChartSpecPipe, XBandAxis, YBandAxis } from 'src/types'\nimport { bandAxisStyle } from './bandAxisStyle'\n\nexport const heatmapBandAxis: VChartSpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n const xAxisConfig = (advancedVSeed.config?.[chartType as 'heatmap']?.xAxis ?? {}) as XBandAxis\n const yAxisConfig = (advancedVSeed.config?.[chartType as 'heatmap']?.yAxis ?? {}) as YBandAxis\n const xBandAxis = bandAxisStyle(xAxisConfig)\n const yBandAxis = bandAxisStyle(yAxisConfig)\n\n xBandAxis.orient = 'bottom'\n xBandAxis.bandPadding = 0\n yBandAxis.orient = 'left'\n yBandAxis.bandPadding = 0\n\n result.axes = [xBandAxis, yBandAxis]\n\n return result\n}\n"],"names":["heatmapBandAxis","spec","context","result","advancedVSeed","vseed","chartType","xAxisConfig","yAxisConfig","xBandAxis","bandAxisStyle","yBandAxis"],"mappings":";AAIO,MAAMA,kBAAkC,CAACC,MAAMC;IACpD,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAEC,KAAK,EAAE,GAAGH;IACjC,MAAM,EAAEI,SAAS,EAAE,GAAGD;IACtB,MAAME,cAAeH,cAAc,MAAM,EAAE,CAACE,UAAuB,EAAE,SAAS,CAAC;IAC/E,MAAME,cAAeJ,cAAc,MAAM,EAAE,CAACE,UAAuB,EAAE,SAAS,CAAC;IAC/E,MAAMG,YAAYC,cAAcH;IAChC,MAAMI,YAAYD,cAAcF;IAEhCC,UAAU,MAAM,GAAG;IACnBA,UAAU,WAAW,GAAG;IACxBE,UAAU,MAAM,GAAG;IACnBA,UAAU,WAAW,GAAG;IAExBR,OAAO,IAAI,GAAG;QAACM;QAAWE;KAAU;IAEpC,OAAOR;AACT"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createNumFormatter, isAreaPercent, isBarPercent, isColumnPercent, isPivotChart } from "../../../../utils/index.js";
|
|
2
|
+
import { createLinearFormat, createLinearPercentFormat } from "./format/linearFormat.js";
|
|
3
|
+
import { defaultTitleText } from "./title/defaultTitleText.js";
|
|
4
|
+
import { linearAxisStyle } from "./linearAxisStyle.js";
|
|
5
|
+
import { BinEndMeasureId, BinStartMeasureId } from "../../../../../dataReshape/constant.js";
|
|
6
|
+
import { unique } from "remeda";
|
|
7
|
+
const histogramXLinear = (spec, context)=>{
|
|
8
|
+
const result = {
|
|
9
|
+
...spec
|
|
10
|
+
};
|
|
11
|
+
const { advancedVSeed, vseed } = context;
|
|
12
|
+
const { encoding, dimensions, measures, dataset } = advancedVSeed;
|
|
13
|
+
const { chartType } = vseed;
|
|
14
|
+
const config = advancedVSeed.config?.[chartType]?.xAxis ?? {};
|
|
15
|
+
if (!result.axes) result.axes = [];
|
|
16
|
+
const isPivot = isPivotChart(vseed);
|
|
17
|
+
const { autoFormat, numFormat = {} } = config;
|
|
18
|
+
const formatter = createNumFormatter(numFormat);
|
|
19
|
+
const percentFormatter = createNumFormatter({
|
|
20
|
+
type: 'percent'
|
|
21
|
+
});
|
|
22
|
+
const formatMethod = (value)=>{
|
|
23
|
+
if (isBarPercent(vseed) || isColumnPercent(vseed) || isAreaPercent(vseed)) return createLinearPercentFormat(value, autoFormat, numFormat, formatter, percentFormatter);
|
|
24
|
+
return createLinearFormat(value, autoFormat, numFormat, formatter);
|
|
25
|
+
};
|
|
26
|
+
const titleText = config.title?.titleText || defaultTitleText(measures, dimensions, encoding.x);
|
|
27
|
+
const linearAxis = linearAxisStyle({
|
|
28
|
+
...config,
|
|
29
|
+
orient: 'bottom',
|
|
30
|
+
formatMethod,
|
|
31
|
+
titleText,
|
|
32
|
+
isPivot
|
|
33
|
+
});
|
|
34
|
+
linearAxis.tick.tickMode = ()=>{
|
|
35
|
+
const binValues = [];
|
|
36
|
+
dataset.forEach((entry)=>{
|
|
37
|
+
binValues.push(entry[BinStartMeasureId]);
|
|
38
|
+
binValues.push(entry[BinEndMeasureId]);
|
|
39
|
+
});
|
|
40
|
+
return unique(binValues);
|
|
41
|
+
};
|
|
42
|
+
result.axes = [
|
|
43
|
+
...result.axes,
|
|
44
|
+
linearAxis
|
|
45
|
+
];
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
export { histogramXLinear };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=histogramXLinear.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/axes/histogramXLinear.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/axes/histogramXLinear.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport type { Datum, VChartSpecPipe, XLinearAxis } from 'src/types'\nimport { createNumFormatter, isAreaPercent, isBarPercent, isColumnPercent, isPivotChart } from 'src/pipeline/utils'\nimport { createLinearFormat, createLinearPercentFormat } from './format/linearFormat'\nimport { defaultTitleText } from './title/defaultTitleText'\nimport { linearAxisStyle } from './linearAxisStyle'\nimport { BinEndMeasureId, BinStartMeasureId } from 'src/dataReshape/constant'\nimport { unique } from 'remeda'\n\nexport const histogramXLinear: VChartSpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { encoding, dimensions, measures, dataset } = advancedVSeed\n const { chartType } = vseed\n const config = (advancedVSeed.config?.[chartType as 'bar']?.xAxis ?? {}) as XLinearAxis\n\n if (!result.axes) {\n result.axes = []\n }\n const isPivot = isPivotChart(vseed)\n\n const { autoFormat, numFormat = {} } = config\n\n const formatter = createNumFormatter(numFormat)\n const percentFormatter = createNumFormatter({\n type: 'percent',\n })\n\n const formatMethod = (value: string) => {\n if (isBarPercent(vseed) || isColumnPercent(vseed) || isAreaPercent(vseed)) {\n return createLinearPercentFormat(value, autoFormat, numFormat, formatter, percentFormatter)\n }\n return createLinearFormat(value, autoFormat, numFormat, formatter)\n }\n\n const titleText = config.title?.titleText || defaultTitleText(measures, dimensions, encoding.x as string[])\n\n const linearAxis = linearAxisStyle({\n ...config,\n orient: 'bottom',\n formatMethod,\n titleText,\n isPivot,\n })\n\n linearAxis.tick.tickMode = () => {\n const binValues: number[] = []\n\n dataset.forEach((entry: Datum) => {\n binValues.push((entry as any)[BinStartMeasureId] as number)\n binValues.push((entry as any)[BinEndMeasureId] as number)\n })\n\n return unique(binValues)\n }\n\n result.axes = [...result.axes, linearAxis] as ISpec['axes']\n\n return result\n}\n"],"names":["histogramXLinear","spec","context","result","advancedVSeed","vseed","encoding","dimensions","measures","dataset","chartType","config","isPivot","isPivotChart","autoFormat","numFormat","formatter","createNumFormatter","percentFormatter","formatMethod","value","isBarPercent","isColumnPercent","isAreaPercent","createLinearPercentFormat","createLinearFormat","titleText","defaultTitleText","linearAxis","linearAxisStyle","binValues","entry","BinStartMeasureId","BinEndMeasureId","unique"],"mappings":";;;;;;AASO,MAAMA,mBAAmC,CAACC,MAAMC;IACrD,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAEC,KAAK,EAAE,GAAGH;IACjC,MAAM,EAAEI,QAAQ,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,OAAO,EAAE,GAAGL;IACpD,MAAM,EAAEM,SAAS,EAAE,GAAGL;IACtB,MAAMM,SAAUP,cAAc,MAAM,EAAE,CAACM,UAAmB,EAAE,SAAS,CAAC;IAEtE,IAAI,CAACP,OAAO,IAAI,EACdA,OAAO,IAAI,GAAG,EAAE;IAElB,MAAMS,UAAUC,aAAaR;IAE7B,MAAM,EAAES,UAAU,EAAEC,YAAY,CAAC,CAAC,EAAE,GAAGJ;IAEvC,MAAMK,YAAYC,mBAAmBF;IACrC,MAAMG,mBAAmBD,mBAAmB;QAC1C,MAAM;IACR;IAEA,MAAME,eAAe,CAACC;QACpB,IAAIC,aAAahB,UAAUiB,gBAAgBjB,UAAUkB,cAAclB,QACjE,OAAOmB,0BAA0BJ,OAAON,YAAYC,WAAWC,WAAWE;QAE5E,OAAOO,mBAAmBL,OAAON,YAAYC,WAAWC;IAC1D;IAEA,MAAMU,YAAYf,OAAO,KAAK,EAAE,aAAagB,iBAAiBnB,UAAUD,YAAYD,SAAS,CAAC;IAE9F,MAAMsB,aAAaC,gBAAgB;QACjC,GAAGlB,MAAM;QACT,QAAQ;QACRQ;QACAO;QACAd;IACF;IAEAgB,WAAW,IAAI,CAAC,QAAQ,GAAG;QACzB,MAAME,YAAsB,EAAE;QAE9BrB,QAAQ,OAAO,CAAC,CAACsB;YACfD,UAAU,IAAI,CAAEC,KAAa,CAACC,kBAAkB;YAChDF,UAAU,IAAI,CAAEC,KAAa,CAACE,gBAAgB;QAChD;QAEA,OAAOC,OAAOJ;IAChB;IAEA3B,OAAO,IAAI,GAAG;WAAIA,OAAO,IAAI;QAAEyB;KAAW;IAE1C,OAAOzB;AACT"}
|
|
@@ -8,4 +8,5 @@ import { radiusAxis } from "./radius.js";
|
|
|
8
8
|
import { radarAngleAxis } from "./radarAngle.js";
|
|
9
9
|
import { radarRadiusAxis } from "./radarRadius.js";
|
|
10
10
|
import { heatmapBandAxis } from "./heatmapBandAxis.js";
|
|
11
|
-
|
|
11
|
+
import { histogramXLinear } from "./histogramXLinear.js";
|
|
12
|
+
export { heatmapBandAxis, histogramXLinear, radarAngleAxis, radarRadiusAxis, radiusAxis, xBand, xLinear, yBand, yLinear, yLinearPrimary, yLinearSecondary };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { YLinearAxis } from '../../../../../types';
|
|
2
|
+
export interface LinearAxisStyleConfig extends YLinearAxis {
|
|
3
|
+
orient: 'left' | 'right' | 'top' | 'bottom';
|
|
4
|
+
formatMethod?: (value: string) => string;
|
|
5
|
+
titleText?: string;
|
|
6
|
+
id?: string;
|
|
7
|
+
seriesId?: string | string[];
|
|
8
|
+
sync?: {
|
|
9
|
+
axisId: string;
|
|
10
|
+
zeroAlign: boolean;
|
|
11
|
+
};
|
|
12
|
+
isPivot?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const linearAxisStyle: (config: LinearAxisStyleConfig) => any;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { AXIS_LABEL_SPACE, LINEAR_AXIS_INNER_OFFSET_TOP } from "../../../../utils/index.js";
|
|
2
|
+
const linearAxisStyle = (config)=>{
|
|
3
|
+
const { orient, visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10, formatMethod, titleText, id, seriesId, sync, isPivot = false } = config;
|
|
4
|
+
const axisConfig = {
|
|
5
|
+
...isPivot ? {
|
|
6
|
+
range: {
|
|
7
|
+
min,
|
|
8
|
+
max
|
|
9
|
+
}
|
|
10
|
+
} : {
|
|
11
|
+
min,
|
|
12
|
+
max
|
|
13
|
+
},
|
|
14
|
+
visible,
|
|
15
|
+
type: log ? 'log' : 'linear',
|
|
16
|
+
base: logBase,
|
|
17
|
+
orient,
|
|
18
|
+
nice,
|
|
19
|
+
zero: log ? false : zero,
|
|
20
|
+
inverse,
|
|
21
|
+
label: {
|
|
22
|
+
space: AXIS_LABEL_SPACE,
|
|
23
|
+
visible: label?.visible,
|
|
24
|
+
formatMethod,
|
|
25
|
+
style: {
|
|
26
|
+
fill: label?.labelColor,
|
|
27
|
+
angle: label?.labelAngle,
|
|
28
|
+
fontSize: label?.labelFontSize,
|
|
29
|
+
fontWeight: label?.labelFontWeight
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
title: {
|
|
33
|
+
visible: title?.visible,
|
|
34
|
+
text: titleText,
|
|
35
|
+
style: {
|
|
36
|
+
fill: title?.titleColor,
|
|
37
|
+
fontSize: title?.titleFontSize,
|
|
38
|
+
fontWeight: title?.titleFontWeight
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
tick: {
|
|
42
|
+
visible: tick?.visible,
|
|
43
|
+
tickSize: tick?.tickSize,
|
|
44
|
+
inside: tick?.tickInside,
|
|
45
|
+
style: {
|
|
46
|
+
stroke: tick?.tickColor
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
grid: {
|
|
50
|
+
visible: grid?.visible,
|
|
51
|
+
style: {
|
|
52
|
+
lineWidth: grid?.gridWidth,
|
|
53
|
+
stroke: grid?.gridColor,
|
|
54
|
+
lineDash: grid?.gridLineDash
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
domainLine: {
|
|
58
|
+
visible: line?.visible,
|
|
59
|
+
style: {
|
|
60
|
+
lineWidth: line?.lineWidth,
|
|
61
|
+
stroke: line?.lineColor
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
if ('bottom' === orient || 'top' === orient) axisConfig.innerOffset = {
|
|
66
|
+
right: LINEAR_AXIS_INNER_OFFSET_TOP
|
|
67
|
+
};
|
|
68
|
+
else axisConfig.innerOffset = {
|
|
69
|
+
top: LINEAR_AXIS_INNER_OFFSET_TOP
|
|
70
|
+
};
|
|
71
|
+
if (id) axisConfig.id = id;
|
|
72
|
+
if (seriesId) axisConfig.seriesId = seriesId;
|
|
73
|
+
if (sync) axisConfig.sync = sync;
|
|
74
|
+
return axisConfig;
|
|
75
|
+
};
|
|
76
|
+
export { linearAxisStyle };
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=linearAxisStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/axes/linearAxisStyle.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/axes/linearAxisStyle.ts"],"sourcesContent":["import type { YLinearAxis } from 'src/types'\nimport { AXIS_LABEL_SPACE, LINEAR_AXIS_INNER_OFFSET_TOP } from 'src/pipeline/utils'\n\nexport interface LinearAxisStyleConfig extends YLinearAxis {\n orient: 'left' | 'right' | 'top' | 'bottom'\n formatMethod?: (value: string) => string\n titleText?: string\n id?: string\n seriesId?: string | string[]\n sync?: {\n axisId: string\n zeroAlign: boolean\n }\n isPivot?: boolean\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const linearAxisStyle = (config: LinearAxisStyleConfig): any => {\n const {\n orient,\n visible = true,\n label,\n tick,\n title,\n grid,\n line,\n zero,\n nice,\n inverse,\n max,\n min,\n log,\n logBase = 10,\n formatMethod,\n titleText,\n id,\n seriesId,\n sync,\n isPivot = false,\n } = config\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const axisConfig: any = {\n ...(isPivot\n ? {\n range: {\n min,\n max,\n },\n }\n : {\n min,\n max,\n }),\n visible,\n type: log ? 'log' : 'linear',\n base: logBase,\n orient,\n nice,\n zero: log ? false : zero,\n inverse,\n label: {\n space: AXIS_LABEL_SPACE,\n visible: label?.visible,\n formatMethod,\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: 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 lineDash: grid?.gridLineDash,\n },\n },\n domainLine: {\n visible: line?.visible,\n style: {\n lineWidth: line?.lineWidth,\n stroke: line?.lineColor,\n },\n },\n }\n\n // Add innerOffset based on orientation\n if (orient === 'bottom' || orient === 'top') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n axisConfig.innerOffset = {\n right: LINEAR_AXIS_INNER_OFFSET_TOP,\n }\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n axisConfig.innerOffset = {\n top: LINEAR_AXIS_INNER_OFFSET_TOP,\n }\n }\n\n // Add optional fields\n if (id) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n axisConfig.id = id\n }\n if (seriesId) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n axisConfig.seriesId = seriesId\n }\n if (sync) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n axisConfig.sync = sync\n }\n\n return axisConfig\n}\n"],"names":["linearAxisStyle","config","orient","visible","label","tick","title","grid","line","zero","nice","inverse","max","min","log","logBase","formatMethod","titleText","id","seriesId","sync","isPivot","axisConfig","AXIS_LABEL_SPACE","LINEAR_AXIS_INNER_OFFSET_TOP"],"mappings":";AAiBO,MAAMA,kBAAkB,CAACC;IAC9B,MAAM,EACJC,MAAM,EACNC,UAAU,IAAI,EACdC,KAAK,EACLC,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,IAAI,EACJC,IAAI,EACJC,IAAI,EACJC,OAAO,EACPC,GAAG,EACHC,GAAG,EACHC,GAAG,EACHC,UAAU,EAAE,EACZC,YAAY,EACZC,SAAS,EACTC,EAAE,EACFC,QAAQ,EACRC,IAAI,EACJC,UAAU,KAAK,EAChB,GAAGpB;IAGJ,MAAMqB,aAAkB;QACtB,GAAID,UACA;YACE,OAAO;gBACLR;gBACAD;YACF;QACF,IACA;YACEC;YACAD;QACF,CAAC;QACLT;QACA,MAAMW,MAAM,QAAQ;QACpB,MAAMC;QACNb;QACAQ;QACA,MAAMI,MAAM,QAAQL;QACpBE;QACA,OAAO;YACL,OAAOY;YACP,SAASnB,OAAO;YAChBY;YACA,OAAO;gBACL,MAAMZ,OAAO;gBACb,OAAOA,OAAO;gBACd,UAAUA,OAAO;gBACjB,YAAYA,OAAO;YACrB;QACF;QACA,OAAO;YACL,SAASE,OAAO;YAChB,MAAMW;YACN,OAAO;gBACL,MAAMX,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;gBACd,UAAUA,MAAM;YAClB;QACF;QACA,YAAY;YACV,SAASC,MAAM;YACf,OAAO;gBACL,WAAWA,MAAM;gBACjB,QAAQA,MAAM;YAChB;QACF;IACF;IAGA,IAAIN,AAAW,aAAXA,UAAuBA,AAAW,UAAXA,QAEzBoB,WAAW,WAAW,GAAG;QACvB,OAAOE;IACT;SAGAF,WAAW,WAAW,GAAG;QACvB,KAAKE;IACP;IAIF,IAAIN,IAEFI,WAAW,EAAE,GAAGJ;IAElB,IAAIC,UAEFG,WAAW,QAAQ,GAAGH;IAExB,IAAIC,MAEFE,WAAW,IAAI,GAAGF;IAGpB,OAAOE;AACT"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defaultTitleText } from "./title/defaultTitleText.js";
|
|
2
2
|
import { MeasureId } from "../../../../../dataReshape/index.js";
|
|
3
3
|
import { isArray, isNull } from "@visactor/vutils";
|
|
4
|
-
import { bandAxisStyle } from "./
|
|
4
|
+
import { bandAxisStyle } from "./bandAxisStyle.js";
|
|
5
5
|
const xBand = (spec, context)=>{
|
|
6
6
|
const result = {
|
|
7
7
|
...spec
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/axes/xBand.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/axes/xBand.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport type { VChartSpecPipe, XBandAxis } from 'src/types'\nimport { defaultTitleText } from './title/defaultTitleText'\nimport { MeasureId } from 'src/dataReshape'\nimport { isArray, isNull } from '@visactor/vutils'\nimport { bandAxisStyle } from './
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/axes/xBand.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/axes/xBand.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport type { VChartSpecPipe, XBandAxis } from 'src/types'\nimport { defaultTitleText } from './title/defaultTitleText'\nimport { MeasureId } from 'src/dataReshape'\nimport { isArray, isNull } from '@visactor/vutils'\nimport { bandAxisStyle } from './bandAxisStyle'\n\nexport const xBand: VChartSpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n const { measures, dimensions, encoding, datasetReshapeInfo, pivotAllDatasetReshapeInfo } = advancedVSeed\n const config = (advancedVSeed.config?.[chartType as 'column']?.xAxis ?? {}) as XBandAxis\n\n if (!result.axes) {\n result.axes = []\n }\n\n const { labelAutoLimitLength = 80 } = config\n\n const onlyMeasureId = (encoding.x || []).filter((v) => v !== MeasureId).length === 0\n const bandAxis = bandAxisStyle(config)\n\n bandAxis.orient = 'bottom'\n bandAxis.maxHeight = labelAutoLimitLength + 60\n bandAxis.paddingInner = [0.15, 0.1]\n bandAxis.paddingOuter = [0.075, 0.1]\n\n if (isNull(bandAxis.title?.text)) {\n bandAxis.title.text = defaultTitleText(measures, dimensions, encoding.x as string[])\n }\n\n if (onlyMeasureId && bandAxis.label) {\n const allDatasetReshapeInfo = pivotAllDatasetReshapeInfo || datasetReshapeInfo\n const colorIdMap = allDatasetReshapeInfo.reduce<Record<string, { id: string; alias: string }>>((prev, cur) => {\n return { ...prev, ...cur.unfoldInfo.colorIdMap }\n }, {})\n\n bandAxis.label.formatMethod = (text: string | string[]) => {\n return isArray(text) ? text : (colorIdMap[String(text)]?.alias ?? text)\n }\n }\n\n result.axes = [...result.axes, bandAxis] as ISpec['axes']\n return result\n}\n"],"names":["xBand","spec","context","result","advancedVSeed","vseed","chartType","measures","dimensions","encoding","datasetReshapeInfo","pivotAllDatasetReshapeInfo","config","labelAutoLimitLength","onlyMeasureId","v","MeasureId","bandAxis","bandAxisStyle","isNull","defaultTitleText","allDatasetReshapeInfo","colorIdMap","prev","cur","text","isArray","String"],"mappings":";;;;AAOO,MAAMA,QAAwB,CAACC,MAAMC;IAC1C,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,EAAEC,kBAAkB,EAAEC,0BAA0B,EAAE,GAAGP;IAC3F,MAAMQ,SAAUR,cAAc,MAAM,EAAE,CAACE,UAAsB,EAAE,SAAS,CAAC;IAEzE,IAAI,CAACH,OAAO,IAAI,EACdA,OAAO,IAAI,GAAG,EAAE;IAGlB,MAAM,EAAEU,uBAAuB,EAAE,EAAE,GAAGD;IAEtC,MAAME,gBAAiBL,AAA4D,MAA5DA,AAAAA,CAAAA,SAAS,CAAC,IAAI,EAAC,EAAG,MAAM,CAAC,CAACM,IAAMA,MAAMC,WAAW,MAAM;IAC9E,MAAMC,WAAWC,cAAcN;IAE/BK,SAAS,MAAM,GAAG;IAClBA,SAAS,SAAS,GAAGJ,uBAAuB;IAC5CI,SAAS,YAAY,GAAG;QAAC;QAAM;KAAI;IACnCA,SAAS,YAAY,GAAG;QAAC;QAAO;KAAI;IAEpC,IAAIE,OAAOF,SAAS,KAAK,EAAE,OACzBA,SAAS,KAAK,CAAC,IAAI,GAAGG,iBAAiBb,UAAUC,YAAYC,SAAS,CAAC;IAGzE,IAAIK,iBAAiBG,SAAS,KAAK,EAAE;QACnC,MAAMI,wBAAwBV,8BAA8BD;QAC5D,MAAMY,aAAaD,sBAAsB,MAAM,CAAgD,CAACE,MAAMC,MAC7F;gBAAE,GAAGD,IAAI;gBAAE,GAAGC,IAAI,UAAU,CAAC,UAAU;YAAC,IAC9C,CAAC;QAEJP,SAAS,KAAK,CAAC,YAAY,GAAG,CAACQ,OACtBC,QAAQD,QAAQA,OAAQH,UAAU,CAACK,OAAOF,MAAM,EAAE,SAASA;IAEtE;IAEAtB,OAAO,IAAI,GAAG;WAAIA,OAAO,IAAI;QAAEc;KAAS;IACxC,OAAOd;AACT"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createNumFormatter, isAreaPercent, isBarPercent, isColumnPercent, isPivotChart } from "../../../../utils/index.js";
|
|
2
2
|
import { createLinearFormat, createLinearPercentFormat } from "./format/linearFormat.js";
|
|
3
3
|
import { defaultTitleText } from "./title/defaultTitleText.js";
|
|
4
|
+
import { linearAxisStyle } from "./linearAxisStyle.js";
|
|
4
5
|
const xLinear = (spec, context)=>{
|
|
5
6
|
const result = {
|
|
6
7
|
...spec
|
|
@@ -11,78 +12,23 @@ const xLinear = (spec, context)=>{
|
|
|
11
12
|
const config = advancedVSeed.config?.[chartType]?.xAxis ?? {};
|
|
12
13
|
if (!result.axes) result.axes = [];
|
|
13
14
|
const isPivot = isPivotChart(vseed);
|
|
14
|
-
const {
|
|
15
|
+
const { autoFormat, numFormat = {} } = config;
|
|
15
16
|
const formatter = createNumFormatter(numFormat);
|
|
16
17
|
const percentFormatter = createNumFormatter({
|
|
17
18
|
type: 'percent'
|
|
18
19
|
});
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
min,
|
|
23
|
-
max
|
|
24
|
-
}
|
|
25
|
-
} : {
|
|
26
|
-
min,
|
|
27
|
-
max
|
|
28
|
-
},
|
|
29
|
-
visible,
|
|
30
|
-
type: log ? 'log' : 'linear',
|
|
31
|
-
base: logBase,
|
|
32
|
-
orient: 'bottom',
|
|
33
|
-
nice,
|
|
34
|
-
zero: log ? false : zero,
|
|
35
|
-
inverse,
|
|
36
|
-
label: {
|
|
37
|
-
space: AXIS_LABEL_SPACE,
|
|
38
|
-
visible: label?.visible,
|
|
39
|
-
formatMethod: (value)=>{
|
|
40
|
-
if (isBarPercent(vseed) || isColumnPercent(vseed) || isAreaPercent(vseed)) return createLinearPercentFormat(value, autoFormat, numFormat, formatter, percentFormatter);
|
|
41
|
-
return createLinearFormat(value, autoFormat, numFormat, formatter);
|
|
42
|
-
},
|
|
43
|
-
style: {
|
|
44
|
-
fill: label?.labelColor,
|
|
45
|
-
angle: label?.labelAngle,
|
|
46
|
-
fontSize: label?.labelFontSize,
|
|
47
|
-
fontWeight: label?.labelFontWeight
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
title: {
|
|
51
|
-
visible: title?.visible,
|
|
52
|
-
text: title?.titleText || defaultTitleText(measures, dimensions, encoding.x),
|
|
53
|
-
style: {
|
|
54
|
-
fill: title?.titleColor,
|
|
55
|
-
fontSize: title?.titleFontSize,
|
|
56
|
-
fontWeight: title?.titleFontWeight
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
tick: {
|
|
60
|
-
visible: tick?.visible,
|
|
61
|
-
tickSize: tick?.tickSize,
|
|
62
|
-
inside: tick?.tickInside,
|
|
63
|
-
style: {
|
|
64
|
-
stroke: tick?.tickColor
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
grid: {
|
|
68
|
-
visible: grid?.visible,
|
|
69
|
-
style: {
|
|
70
|
-
lineWidth: grid?.gridWidth,
|
|
71
|
-
stroke: grid?.gridColor,
|
|
72
|
-
lineDash: grid?.gridLineDash
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
domainLine: {
|
|
76
|
-
visible: line?.visible,
|
|
77
|
-
style: {
|
|
78
|
-
lineWidth: line?.lineWidth,
|
|
79
|
-
stroke: line?.lineColor
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
innerOffset: {
|
|
83
|
-
right: LINEAR_AXIS_INNER_OFFSET_TOP
|
|
84
|
-
}
|
|
20
|
+
const formatMethod = (value)=>{
|
|
21
|
+
if (isBarPercent(vseed) || isColumnPercent(vseed) || isAreaPercent(vseed)) return createLinearPercentFormat(value, autoFormat, numFormat, formatter, percentFormatter);
|
|
22
|
+
return createLinearFormat(value, autoFormat, numFormat, formatter);
|
|
85
23
|
};
|
|
24
|
+
const titleText = config.title?.titleText || defaultTitleText(measures, dimensions, encoding.x);
|
|
25
|
+
const linearAxis = linearAxisStyle({
|
|
26
|
+
...config,
|
|
27
|
+
orient: 'bottom',
|
|
28
|
+
formatMethod,
|
|
29
|
+
titleText,
|
|
30
|
+
isPivot
|
|
31
|
+
});
|
|
86
32
|
result.axes = [
|
|
87
33
|
...result.axes,
|
|
88
34
|
linearAxis
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/axes/xLinear.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/axes/xLinear.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport type { VChartSpecPipe, XLinearAxis } from 'src/types'\nimport {
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/axes/xLinear.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/axes/xLinear.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport type { VChartSpecPipe, XLinearAxis } from 'src/types'\nimport { createNumFormatter, isAreaPercent, isBarPercent, isColumnPercent, isPivotChart } from 'src/pipeline/utils'\nimport { createLinearFormat, createLinearPercentFormat } from './format/linearFormat'\nimport { defaultTitleText } from './title/defaultTitleText'\nimport { linearAxisStyle } from './linearAxisStyle'\n\nexport const xLinear: VChartSpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { encoding, dimensions, measures } = advancedVSeed\n const { chartType } = vseed\n const config = (advancedVSeed.config?.[chartType as 'bar']?.xAxis ?? {}) as XLinearAxis\n\n if (!result.axes) {\n result.axes = []\n }\n const isPivot = isPivotChart(vseed)\n\n const { autoFormat, numFormat = {} } = config\n\n const formatter = createNumFormatter(numFormat)\n const percentFormatter = createNumFormatter({\n type: 'percent',\n })\n\n const formatMethod = (value: string) => {\n if (isBarPercent(vseed) || isColumnPercent(vseed) || isAreaPercent(vseed)) {\n return createLinearPercentFormat(value, autoFormat, numFormat, formatter, percentFormatter)\n }\n return createLinearFormat(value, autoFormat, numFormat, formatter)\n }\n\n const titleText = config.title?.titleText || defaultTitleText(measures, dimensions, encoding.x as string[])\n\n const linearAxis = linearAxisStyle({\n ...config,\n orient: 'bottom',\n formatMethod,\n titleText,\n isPivot,\n })\n\n result.axes = [...result.axes, linearAxis] as ISpec['axes']\n\n return result\n}\n"],"names":["xLinear","spec","context","result","advancedVSeed","vseed","encoding","dimensions","measures","chartType","config","isPivot","isPivotChart","autoFormat","numFormat","formatter","createNumFormatter","percentFormatter","formatMethod","value","isBarPercent","isColumnPercent","isAreaPercent","createLinearPercentFormat","createLinearFormat","titleText","defaultTitleText","linearAxis","linearAxisStyle"],"mappings":";;;;AAOO,MAAMA,UAA0B,CAACC,MAAMC;IAC5C,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAEC,KAAK,EAAE,GAAGH;IACjC,MAAM,EAAEI,QAAQ,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAGJ;IAC3C,MAAM,EAAEK,SAAS,EAAE,GAAGJ;IACtB,MAAMK,SAAUN,cAAc,MAAM,EAAE,CAACK,UAAmB,EAAE,SAAS,CAAC;IAEtE,IAAI,CAACN,OAAO,IAAI,EACdA,OAAO,IAAI,GAAG,EAAE;IAElB,MAAMQ,UAAUC,aAAaP;IAE7B,MAAM,EAAEQ,UAAU,EAAEC,YAAY,CAAC,CAAC,EAAE,GAAGJ;IAEvC,MAAMK,YAAYC,mBAAmBF;IACrC,MAAMG,mBAAmBD,mBAAmB;QAC1C,MAAM;IACR;IAEA,MAAME,eAAe,CAACC;QACpB,IAAIC,aAAaf,UAAUgB,gBAAgBhB,UAAUiB,cAAcjB,QACjE,OAAOkB,0BAA0BJ,OAAON,YAAYC,WAAWC,WAAWE;QAE5E,OAAOO,mBAAmBL,OAAON,YAAYC,WAAWC;IAC1D;IAEA,MAAMU,YAAYf,OAAO,KAAK,EAAE,aAAagB,iBAAiBlB,UAAUD,YAAYD,SAAS,CAAC;IAE9F,MAAMqB,aAAaC,gBAAgB;QACjC,GAAGlB,MAAM;QACT,QAAQ;QACRQ;QACAO;QACAd;IACF;IAEAR,OAAO,IAAI,GAAG;WAAIA,OAAO,IAAI;QAAEwB;KAAW;IAE1C,OAAOxB;AACT"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defaultTitleText } from "./title/defaultTitleText.js";
|
|
2
2
|
import { MeasureId } from "../../../../../dataReshape/index.js";
|
|
3
3
|
import { isArray, isNull } from "@visactor/vutils";
|
|
4
|
-
import { bandAxisStyle } from "./
|
|
4
|
+
import { bandAxisStyle } from "./bandAxisStyle.js";
|
|
5
5
|
const yBand = (spec, context)=>{
|
|
6
6
|
const result = {
|
|
7
7
|
...spec
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/axes/yBand.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/axes/yBand.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport type { VChartSpecPipe, XBandAxis } from 'src/types'\nimport { defaultTitleText } from './title/defaultTitleText'\nimport { MeasureId } from 'src/dataReshape'\nimport { isArray, isNull } from '@visactor/vutils'\nimport { bandAxisStyle } from './
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/axes/yBand.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/axes/yBand.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport type { VChartSpecPipe, XBandAxis } from 'src/types'\nimport { defaultTitleText } from './title/defaultTitleText'\nimport { MeasureId } from 'src/dataReshape'\nimport { isArray, isNull } from '@visactor/vutils'\nimport { bandAxisStyle } from './bandAxisStyle'\n\nexport const yBand: VChartSpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n const { measures, dimensions, encoding, datasetReshapeInfo, pivotAllDatasetReshapeInfo } = advancedVSeed\n const config = (advancedVSeed.config?.[chartType as 'bar']?.yAxis ?? {}) as XBandAxis\n\n if (!result.axes) {\n result.axes = []\n }\n\n const { labelAutoLimitLength = 80 } = config\n\n const onlyMeasureId = (encoding.y || []).filter((v) => v !== MeasureId).length === 0\n\n const bandAxis = bandAxisStyle(config)\n\n bandAxis.type = 'band'\n bandAxis.orient = 'left'\n bandAxis.maxWidth = labelAutoLimitLength + 60\n if (bandAxis.label) {\n bandAxis.label.containerAlign = 'right'\n }\n bandAxis.paddingInner = [0.15, 0.1]\n bandAxis.paddingOuter = [0.075, 0.1]\n\n if (isNull(bandAxis.title?.text)) {\n bandAxis.title.text = defaultTitleText(measures, dimensions, encoding.y as string[])\n }\n if (onlyMeasureId && bandAxis.label) {\n const allDatasetReshapeInfo = pivotAllDatasetReshapeInfo || datasetReshapeInfo\n const colorIdMap = allDatasetReshapeInfo.reduce<Record<string, { id: string; alias: string }>>((prev, cur) => {\n return { ...prev, ...cur.unfoldInfo.colorIdMap }\n }, {})\n\n bandAxis.label.formatMethod = (text: string | string[]) => {\n return isArray(text) ? text : (colorIdMap[String(text)]?.alias ?? text)\n }\n }\n\n result.axes = [...result.axes, bandAxis] as ISpec['axes']\n return result\n}\n"],"names":["yBand","spec","context","result","advancedVSeed","vseed","chartType","measures","dimensions","encoding","datasetReshapeInfo","pivotAllDatasetReshapeInfo","config","labelAutoLimitLength","onlyMeasureId","v","MeasureId","bandAxis","bandAxisStyle","isNull","defaultTitleText","allDatasetReshapeInfo","colorIdMap","prev","cur","text","isArray","String"],"mappings":";;;;AAOO,MAAMA,QAAwB,CAACC,MAAMC;IAC1C,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,EAAEC,kBAAkB,EAAEC,0BAA0B,EAAE,GAAGP;IAC3F,MAAMQ,SAAUR,cAAc,MAAM,EAAE,CAACE,UAAmB,EAAE,SAAS,CAAC;IAEtE,IAAI,CAACH,OAAO,IAAI,EACdA,OAAO,IAAI,GAAG,EAAE;IAGlB,MAAM,EAAEU,uBAAuB,EAAE,EAAE,GAAGD;IAEtC,MAAME,gBAAiBL,AAA4D,MAA5DA,AAAAA,CAAAA,SAAS,CAAC,IAAI,EAAC,EAAG,MAAM,CAAC,CAACM,IAAMA,MAAMC,WAAW,MAAM;IAE9E,MAAMC,WAAWC,cAAcN;IAE/BK,SAAS,IAAI,GAAG;IAChBA,SAAS,MAAM,GAAG;IAClBA,SAAS,QAAQ,GAAGJ,uBAAuB;IAC3C,IAAII,SAAS,KAAK,EAChBA,SAAS,KAAK,CAAC,cAAc,GAAG;IAElCA,SAAS,YAAY,GAAG;QAAC;QAAM;KAAI;IACnCA,SAAS,YAAY,GAAG;QAAC;QAAO;KAAI;IAEpC,IAAIE,OAAOF,SAAS,KAAK,EAAE,OACzBA,SAAS,KAAK,CAAC,IAAI,GAAGG,iBAAiBb,UAAUC,YAAYC,SAAS,CAAC;IAEzE,IAAIK,iBAAiBG,SAAS,KAAK,EAAE;QACnC,MAAMI,wBAAwBV,8BAA8BD;QAC5D,MAAMY,aAAaD,sBAAsB,MAAM,CAAgD,CAACE,MAAMC,MAC7F;gBAAE,GAAGD,IAAI;gBAAE,GAAGC,IAAI,UAAU,CAAC,UAAU;YAAC,IAC9C,CAAC;QAEJP,SAAS,KAAK,CAAC,YAAY,GAAG,CAACQ,OACtBC,QAAQD,QAAQA,OAAQH,UAAU,CAACK,OAAOF,MAAM,EAAE,SAASA;IAEtE;IAEAtB,OAAO,IAAI,GAAG;WAAIA,OAAO,IAAI;QAAEc;KAAS;IACxC,OAAOd;AACT"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createNumFormatter, isAreaPercent, isBarPercent, isColumnPercent, isPivotChart } from "../../../../utils/index.js";
|
|
2
2
|
import { createLinearFormat, createLinearPercentFormat } from "./format/linearFormat.js";
|
|
3
3
|
import { defaultTitleText } from "./title/defaultTitleText.js";
|
|
4
|
+
import { linearAxisStyle } from "./linearAxisStyle.js";
|
|
4
5
|
const yLinear = (spec, context)=>{
|
|
5
6
|
const result = {
|
|
6
7
|
...spec
|
|
@@ -11,78 +12,23 @@ const yLinear = (spec, context)=>{
|
|
|
11
12
|
const config = advancedVSeed.config?.[chartType]?.yAxis ?? {};
|
|
12
13
|
if (!result.axes) result.axes = [];
|
|
13
14
|
const isPivot = isPivotChart(vseed);
|
|
14
|
-
const {
|
|
15
|
+
const { autoFormat, numFormat = {} } = config;
|
|
15
16
|
const formatter = createNumFormatter(numFormat);
|
|
16
17
|
const percentFormatter = createNumFormatter({
|
|
17
18
|
type: 'percent'
|
|
18
19
|
});
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
min,
|
|
23
|
-
max
|
|
24
|
-
}
|
|
25
|
-
} : {
|
|
26
|
-
min,
|
|
27
|
-
max
|
|
28
|
-
},
|
|
29
|
-
visible,
|
|
30
|
-
type: log ? 'log' : 'linear',
|
|
31
|
-
base: logBase,
|
|
32
|
-
orient: 'left',
|
|
33
|
-
nice,
|
|
34
|
-
zero: log ? false : zero,
|
|
35
|
-
inverse,
|
|
36
|
-
label: {
|
|
37
|
-
space: AXIS_LABEL_SPACE,
|
|
38
|
-
visible: label?.visible,
|
|
39
|
-
formatMethod: (value)=>{
|
|
40
|
-
if (isBarPercent(vseed) || isColumnPercent(vseed) || isAreaPercent(vseed)) return createLinearPercentFormat(value, autoFormat, numFormat, formatter, percentFormatter);
|
|
41
|
-
return createLinearFormat(value, autoFormat, numFormat, formatter);
|
|
42
|
-
},
|
|
43
|
-
style: {
|
|
44
|
-
fill: label?.labelColor,
|
|
45
|
-
angle: label?.labelAngle,
|
|
46
|
-
fontSize: label?.labelFontSize,
|
|
47
|
-
fontWeight: label?.labelFontWeight
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
title: {
|
|
51
|
-
visible: title?.visible,
|
|
52
|
-
text: title?.titleText || defaultTitleText(measures, dimensions, encoding.y),
|
|
53
|
-
style: {
|
|
54
|
-
fill: title?.titleColor,
|
|
55
|
-
fontSize: title?.titleFontSize,
|
|
56
|
-
fontWeight: title?.titleFontWeight
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
tick: {
|
|
60
|
-
visible: tick?.visible,
|
|
61
|
-
tickSize: tick?.tickSize,
|
|
62
|
-
inside: tick?.tickInside,
|
|
63
|
-
style: {
|
|
64
|
-
stroke: tick?.tickColor
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
grid: {
|
|
68
|
-
visible: grid?.visible,
|
|
69
|
-
style: {
|
|
70
|
-
lineWidth: grid?.gridWidth,
|
|
71
|
-
stroke: grid?.gridColor,
|
|
72
|
-
lineDash: grid?.gridLineDash
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
domainLine: {
|
|
76
|
-
visible: line?.visible,
|
|
77
|
-
style: {
|
|
78
|
-
lineWidth: line?.lineWidth,
|
|
79
|
-
stroke: line?.lineColor
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
innerOffset: {
|
|
83
|
-
top: LINEAR_AXIS_INNER_OFFSET_TOP
|
|
84
|
-
}
|
|
20
|
+
const formatMethod = (value)=>{
|
|
21
|
+
if (isBarPercent(vseed) || isColumnPercent(vseed) || isAreaPercent(vseed)) return createLinearPercentFormat(value, autoFormat, numFormat, formatter, percentFormatter);
|
|
22
|
+
return createLinearFormat(value, autoFormat, numFormat, formatter);
|
|
85
23
|
};
|
|
24
|
+
const titleText = config.title?.titleText || defaultTitleText(measures, dimensions, encoding.y);
|
|
25
|
+
const linearAxis = linearAxisStyle({
|
|
26
|
+
...config,
|
|
27
|
+
orient: 'left',
|
|
28
|
+
formatMethod,
|
|
29
|
+
titleText,
|
|
30
|
+
isPivot
|
|
31
|
+
});
|
|
86
32
|
result.axes = [
|
|
87
33
|
...result.axes,
|
|
88
34
|
linearAxis
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/axes/yLinear.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/axes/yLinear.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport {
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/axes/yLinear.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/axes/yLinear.ts"],"sourcesContent":["import type { ISpec } from '@visactor/vchart'\nimport { createNumFormatter, isAreaPercent, isBarPercent, isColumnPercent, isPivotChart } from 'src/pipeline/utils'\nimport type { VChartSpecPipe, YLinearAxis } from 'src/types'\nimport { createLinearFormat, createLinearPercentFormat } from './format/linearFormat'\nimport { defaultTitleText } from './title/defaultTitleText'\nimport { linearAxisStyle } from './linearAxisStyle'\n\nexport const yLinear: VChartSpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n const { measures, dimensions, encoding } = advancedVSeed\n const config = (advancedVSeed.config?.[chartType as 'column']?.yAxis ?? {}) as YLinearAxis\n\n if (!result.axes) {\n result.axes = []\n }\n const isPivot = isPivotChart(vseed)\n\n const { autoFormat, numFormat = {} } = config\n\n const formatter = createNumFormatter(numFormat)\n const percentFormatter = createNumFormatter({\n type: 'percent',\n })\n\n const formatMethod = (value: string) => {\n if (isBarPercent(vseed) || isColumnPercent(vseed) || isAreaPercent(vseed)) {\n return createLinearPercentFormat(value, autoFormat, numFormat, formatter, percentFormatter)\n }\n return createLinearFormat(value, autoFormat, numFormat, formatter)\n }\n\n const titleText = config.title?.titleText || defaultTitleText(measures, dimensions, encoding.y as string[])\n\n const linearAxis = linearAxisStyle({\n ...config,\n orient: 'left',\n formatMethod,\n titleText,\n isPivot,\n })\n\n result.axes = [...result.axes, linearAxis] as ISpec['axes']\n\n return result\n}\n"],"names":["yLinear","spec","context","result","advancedVSeed","vseed","chartType","measures","dimensions","encoding","config","isPivot","isPivotChart","autoFormat","numFormat","formatter","createNumFormatter","percentFormatter","formatMethod","value","isBarPercent","isColumnPercent","isAreaPercent","createLinearPercentFormat","createLinearFormat","titleText","defaultTitleText","linearAxis","linearAxisStyle"],"mappings":";;;;AAOO,MAAMA,UAA0B,CAACC,MAAMC;IAC5C,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAEC,KAAK,EAAE,GAAGH;IACjC,MAAM,EAAEI,SAAS,EAAE,GAAGD;IACtB,MAAM,EAAEE,QAAQ,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAGL;IAC3C,MAAMM,SAAUN,cAAc,MAAM,EAAE,CAACE,UAAsB,EAAE,SAAS,CAAC;IAEzE,IAAI,CAACH,OAAO,IAAI,EACdA,OAAO,IAAI,GAAG,EAAE;IAElB,MAAMQ,UAAUC,aAAaP;IAE7B,MAAM,EAAEQ,UAAU,EAAEC,YAAY,CAAC,CAAC,EAAE,GAAGJ;IAEvC,MAAMK,YAAYC,mBAAmBF;IACrC,MAAMG,mBAAmBD,mBAAmB;QAC1C,MAAM;IACR;IAEA,MAAME,eAAe,CAACC;QACpB,IAAIC,aAAaf,UAAUgB,gBAAgBhB,UAAUiB,cAAcjB,QACjE,OAAOkB,0BAA0BJ,OAAON,YAAYC,WAAWC,WAAWE;QAE5E,OAAOO,mBAAmBL,OAAON,YAAYC,WAAWC;IAC1D;IAEA,MAAMU,YAAYf,OAAO,KAAK,EAAE,aAAagB,iBAAiBnB,UAAUC,YAAYC,SAAS,CAAC;IAE9F,MAAMkB,aAAaC,gBAAgB;QACjC,GAAGlB,MAAM;QACT,QAAQ;QACRQ;QACAO;QACAd;IACF;IAEAR,OAAO,IAAI,GAAG;WAAIA,OAAO,IAAI;QAAEwB;KAAW;IAE1C,OAAOxB;AACT"}
|