@visactor/vseed 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/builder/builder/advanced/colorItems.d.ts +1 -0
- package/dist/esm/builder/builder/advanced/colorItems.js +21 -1
- package/dist/esm/builder/builder/advanced/colorItems.js.map +1 -1
- package/dist/esm/builder/builder/buildSpec.js.map +1 -1
- package/dist/esm/builder/builder/builder.d.ts +4 -0
- package/dist/esm/builder/builder/builder.js +2 -1
- package/dist/esm/builder/builder/builder.js.map +1 -1
- package/dist/esm/dataSelector/selector.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/animation/bar.js +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/animation/bar.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/animation/lineOrArea.d.ts +4 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/radar.d.ts +4 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/index.d.ts +1 -60
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/index.js +2 -44
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/index.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/pointAtmosphere.d.ts +65 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/pointAtmosphere.js +56 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/pointAtmosphere.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationArea.js +2 -2
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationArea.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationAreaBand.js +2 -2
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationAreaBand.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationDifferenceLine.js +63 -18
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationDifferenceLine.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationHorizontalLine.js +7 -13
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationHorizontalLine.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPointCommon.js +2 -2
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPointCommon.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationVerticalLine.js +9 -15
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationVerticalLine.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/annotation/utils.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/annotation/utils.js +15 -1
- package/dist/esm/pipeline/spec/chart/pipes/annotation/utils.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/stack/stackCornerRadius.js +18 -39
- package/dist/esm/pipeline/spec/chart/pipes/stack/stackCornerRadius.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/stack/stackCornerRadiusUtils.d.ts +4 -0
- package/dist/esm/pipeline/spec/chart/pipes/stack/stackCornerRadiusUtils.js +50 -0
- package/dist/esm/pipeline/spec/chart/pipes/stack/stackCornerRadiusUtils.js.map +1 -0
- package/dist/esm/pipeline/utils/sandbox/execute.js.map +1 -1
- package/dist/esm/theme/tokenTheme.d.ts +6 -0
- package/dist/esm/theme/tokenTheme.js +36 -7
- package/dist/esm/theme/tokenTheme.js.map +1 -1
- package/dist/esm/types/builder/builder.d.ts +1 -0
- package/dist/esm/types/builder/builder.js.map +1 -1
- package/dist/esm/types/chartType/area/zArea.d.ts +10 -0
- package/dist/esm/types/chartType/bar/zBar.d.ts +10 -0
- package/dist/esm/types/chartType/barParallel/zBarParallel.d.ts +10 -0
- package/dist/esm/types/chartType/column/zColumn.d.ts +10 -0
- package/dist/esm/types/chartType/columnParallel/zColumnParallel.d.ts +10 -0
- package/dist/esm/types/chartType/line/zLine.d.ts +10 -0
- package/dist/esm/types/properties/annotation/annotation.d.ts +10 -0
- package/dist/esm/types/properties/annotation/annotationDifferenceLine.d.ts +4 -0
- package/dist/esm/types/properties/annotation/zAnnotationDifferenceLine.d.ts +5 -0
- package/dist/esm/types/properties/annotation/zAnnotationDifferenceLine.js +6 -1
- package/dist/esm/types/properties/annotation/zAnnotationDifferenceLine.js.map +1 -1
- package/dist/esm/types/properties/config/annotation/annotation.d.ts +32 -5
- package/dist/esm/types/properties/config/annotation/zAnnotation.d.ts +30 -4
- package/dist/esm/types/properties/config/annotation/zAnnotation.js +11 -1
- package/dist/esm/types/properties/config/annotation/zAnnotation.js.map +1 -1
- package/dist/esm/types/properties/config/area.d.ts +30 -4
- package/dist/esm/types/properties/config/bar.d.ts +45 -6
- package/dist/esm/types/properties/config/boxplot.d.ts +15 -2
- package/dist/esm/types/properties/config/column.d.ts +45 -6
- package/dist/esm/types/properties/config/config.d.ts +285 -38
- package/dist/esm/types/properties/config/dualAxis.d.ts +15 -2
- package/dist/esm/types/properties/config/histogram.d.ts +15 -2
- package/dist/esm/types/properties/config/line.d.ts +15 -2
- package/dist/esm/types/properties/config/race.d.ts +90 -12
- package/dist/esm/types/properties/config/scatter.d.ts +15 -2
- package/dist/esm/types/properties/theme/customTheme.d.ts +570 -76
- package/dist/umd/index.js +332 -184
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isArray, isNumber, isString } from "remeda";
|
|
2
2
|
import { ANNOTATION_Z_INDEX } from "../../../../utils/constant.js";
|
|
3
|
-
import { resolveAnnotationValue } from "./utils.js";
|
|
3
|
+
import { getAnnotationLineDash, resolveAnnotationValue } from "./utils.js";
|
|
4
4
|
const annotationHorizontalLine_annotationHorizontalLine = (spec, context)=>{
|
|
5
5
|
const { advancedVSeed, vseed } = context;
|
|
6
6
|
const { annotation, config } = advancedVSeed;
|
|
@@ -19,7 +19,10 @@ const annotationHorizontalLine_annotationHorizontalLine = (spec, context)=>{
|
|
|
19
19
|
insideEnd: 'insideEndTop'
|
|
20
20
|
};
|
|
21
21
|
const markLine = annotationHorizontalLineList.flatMap((annotationHorizontalLine)=>{
|
|
22
|
-
const { yValue, dynamicFilter, text = '', textPosition = 'insideEnd', textColor = theme?.textColor ?? '#ffffff', textFontSize = theme?.textFontSize ?? 12, textFontWeight = theme?.textFontWeight ?? 400, textAlign = 'right', textBaseline = 'bottom', lineColor = theme?.lineColor ?? '#212121',
|
|
22
|
+
const { yValue, dynamicFilter, text = '', textPosition = 'insideEnd', textColor = theme?.textColor ?? '#ffffff', textFontSize = theme?.textFontSize ?? 12, textFontWeight = theme?.textFontWeight ?? 400, textAlign = 'right', textBaseline = 'bottom', lineColor = theme?.lineColor ?? '#212121', lineVisible = theme?.lineStyle ?? true, lineWidth = theme?.lineWidth ?? 1, textBackgroundVisible = theme?.textBackgroundVisible ?? true, textBackgroundColor = theme?.textBackgroundColor ?? '#212121', textBackgroundBorderColor = theme?.textBackgroundBorderColor ?? '#212121', textBackgroundBorderRadius = theme?.textBackgroundBorderRadius ?? 4, textBackgroundBorderWidth = theme?.textBackgroundBorderWidth ?? 1, textBackgroundPadding = theme?.textBackgroundPadding ?? 2 } = annotationHorizontalLine;
|
|
23
|
+
const lineStyle = annotationHorizontalLine.lineStyle ?? theme?.lineStyle ?? 'dashed';
|
|
24
|
+
const lineDash = getAnnotationLineDash(lineStyle, annotationHorizontalLine.lineStyle ? void 0 : theme?.lineDash);
|
|
25
|
+
const textBackgroundOpacity = theme?.textBackgroundOpacity;
|
|
23
26
|
const generateOneMarkLine = (y)=>({
|
|
24
27
|
y,
|
|
25
28
|
autoRange: true,
|
|
@@ -29,15 +32,7 @@ const annotationHorizontalLine_annotationHorizontalLine = (spec, context)=>{
|
|
|
29
32
|
visible: lineVisible,
|
|
30
33
|
stroke: lineColor,
|
|
31
34
|
lineWidth: lineWidth,
|
|
32
|
-
lineDash
|
|
33
|
-
5,
|
|
34
|
-
2
|
|
35
|
-
] : 'dotted' === lineStyle ? [
|
|
36
|
-
2,
|
|
37
|
-
5
|
|
38
|
-
] : [
|
|
39
|
-
0
|
|
40
|
-
]
|
|
35
|
+
lineDash
|
|
41
36
|
}
|
|
42
37
|
},
|
|
43
38
|
label: {
|
|
@@ -45,7 +40,6 @@ const annotationHorizontalLine_annotationHorizontalLine = (spec, context)=>{
|
|
|
45
40
|
text: text,
|
|
46
41
|
position: positionMap[textPosition || 'insideEnd'],
|
|
47
42
|
style: {
|
|
48
|
-
opacity: 0.95,
|
|
49
43
|
visible: true,
|
|
50
44
|
dy: 4,
|
|
51
45
|
stroke: textBackgroundColor,
|
|
@@ -60,7 +54,7 @@ const annotationHorizontalLine_annotationHorizontalLine = (spec, context)=>{
|
|
|
60
54
|
visible: textBackgroundVisible,
|
|
61
55
|
padding: textBackgroundPadding,
|
|
62
56
|
style: {
|
|
63
|
-
opacity: 0.95,
|
|
57
|
+
opacity: textBackgroundOpacity ?? 0.95,
|
|
64
58
|
dy: 4,
|
|
65
59
|
cornerRadius: textBackgroundBorderRadius,
|
|
66
60
|
fill: textBackgroundColor,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationHorizontalLine.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/annotationHorizontalLine.ts"],"sourcesContent":["import type { ILineChartSpec, IMarkLineSpec } from '@visactor/vchart'\nimport type { VChartSpecPipe } from 'src/types'\nimport { isArray, isNumber, isString } from 'remeda'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport { resolveAnnotationValue } from './utils'\n\nexport const annotationHorizontalLine: VChartSpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const { annotation, config } = advancedVSeed\n\n if (!annotation || !annotation.annotationHorizontalLine) {\n return spec\n }\n const theme = config?.[vseed.chartType as 'column']?.annotation?.annotationHorizontalLine\n const { annotationHorizontalLine } = annotation\n const annotationHorizontalLineList = Array.isArray(annotationHorizontalLine)\n ? annotationHorizontalLine\n : [annotationHorizontalLine]\n\n const positionMap = {\n outsideStart: 'start',\n outsideEnd: 'end',\n outsideMiddle: 'middle',\n insideStart: 'insideStartTop',\n insideMiddle: 'insideMiddleTop',\n insideEnd: 'insideEndTop',\n }\n\n const markLine = annotationHorizontalLineList.flatMap((annotationHorizontalLine) => {\n const {\n yValue,\n dynamicFilter,\n text = '',\n textPosition = 'insideEnd',\n textColor = theme?.textColor ?? '#ffffff',\n textFontSize = theme?.textFontSize ?? 12,\n textFontWeight = theme?.textFontWeight ?? 400,\n textAlign = 'right',\n textBaseline = 'bottom',\n\n lineColor = theme?.lineColor ?? '#212121',\n
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationHorizontalLine.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/annotationHorizontalLine.ts"],"sourcesContent":["import type { ILineChartSpec, IMarkLineSpec } from '@visactor/vchart'\nimport type { VChartSpecPipe } from 'src/types'\nimport { isArray, isNumber, isString } from 'remeda'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport { getAnnotationLineDash, resolveAnnotationValue } from './utils'\n\nexport const annotationHorizontalLine: VChartSpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const { annotation, config } = advancedVSeed\n\n if (!annotation || !annotation.annotationHorizontalLine) {\n return spec\n }\n const theme = config?.[vseed.chartType as 'column']?.annotation?.annotationHorizontalLine\n const { annotationHorizontalLine } = annotation\n const annotationHorizontalLineList = Array.isArray(annotationHorizontalLine)\n ? annotationHorizontalLine\n : [annotationHorizontalLine]\n\n const positionMap = {\n outsideStart: 'start',\n outsideEnd: 'end',\n outsideMiddle: 'middle',\n insideStart: 'insideStartTop',\n insideMiddle: 'insideMiddleTop',\n insideEnd: 'insideEndTop',\n }\n\n const markLine = annotationHorizontalLineList.flatMap((annotationHorizontalLine) => {\n const {\n yValue,\n dynamicFilter,\n text = '',\n textPosition = 'insideEnd',\n textColor = theme?.textColor ?? '#ffffff',\n textFontSize = theme?.textFontSize ?? 12,\n textFontWeight = theme?.textFontWeight ?? 400,\n textAlign = 'right',\n textBaseline = 'bottom',\n\n lineColor = theme?.lineColor ?? '#212121',\n lineVisible = theme?.lineStyle ?? true,\n lineWidth = theme?.lineWidth ?? 1,\n\n textBackgroundVisible = theme?.textBackgroundVisible ?? true,\n textBackgroundColor = theme?.textBackgroundColor ?? '#212121',\n textBackgroundBorderColor = theme?.textBackgroundBorderColor ?? '#212121',\n textBackgroundBorderRadius = theme?.textBackgroundBorderRadius ?? 4,\n textBackgroundBorderWidth = theme?.textBackgroundBorderWidth ?? 1,\n textBackgroundPadding = theme?.textBackgroundPadding ?? 2,\n } = annotationHorizontalLine\n const lineStyle = annotationHorizontalLine.lineStyle ?? theme?.lineStyle ?? 'dashed'\n const lineDash = getAnnotationLineDash(lineStyle, annotationHorizontalLine.lineStyle ? undefined : theme?.lineDash)\n const textBackgroundOpacity = theme?.textBackgroundOpacity\n\n const generateOneMarkLine = (y: string | number) => {\n return {\n y,\n autoRange: true,\n zIndex: ANNOTATION_Z_INDEX,\n line: {\n style: {\n visible: lineVisible,\n stroke: lineColor,\n lineWidth: lineWidth,\n lineDash,\n },\n },\n label: {\n confine: true,\n text: text,\n position: (positionMap as any)[textPosition || 'insideEnd'],\n style: {\n visible: true,\n dy: 4,\n stroke: textBackgroundColor,\n lineWidth: 1,\n textAlign: textAlign,\n textBaseline: textBaseline,\n fill: textColor,\n fontSize: textFontSize,\n fontWeight: textFontWeight,\n },\n labelBackground: {\n visible: textBackgroundVisible,\n padding: textBackgroundPadding,\n style: {\n opacity: textBackgroundOpacity ?? 0.95,\n dy: 4,\n cornerRadius: textBackgroundBorderRadius,\n fill: textBackgroundColor,\n stroke: textBackgroundBorderColor,\n lineWidth: textBackgroundBorderWidth,\n fillOpacity: 1,\n },\n },\n },\n startSymbol: {\n visible: theme?.startSymbolVisible ?? true,\n symbolType: theme?.startSymbolType ?? 'triangleDown',\n size: 5 + (lineWidth || 1),\n style: {\n dx: 3,\n fill: lineColor,\n },\n },\n endSymbol: {\n visible: theme?.endSymbolVisible ?? false,\n symbolType: theme?.endSymbolType ?? 'arrow',\n size: 10 + (lineWidth || 1),\n style: {\n dx: -4,\n fill: lineColor,\n },\n },\n }\n }\n\n const finalYValue = resolveAnnotationValue({\n dynamicFilter,\n fallback: dynamicFilter?.fallback as string | number | undefined,\n defaultValue: yValue,\n })\n\n if (isArray(finalYValue) || isString(finalYValue) || isNumber(finalYValue)) {\n const yValueArr = Array.isArray(finalYValue) ? finalYValue : [finalYValue]\n return yValueArr.map(generateOneMarkLine)\n }\n\n return []\n }) as IMarkLineSpec[]\n const specMarkLine = ((spec as ILineChartSpec).markLine as IMarkLineSpec[]) || []\n const newMarkLine = [...specMarkLine, ...(markLine || [])]\n return {\n ...spec,\n markLine: newMarkLine,\n }\n}\n"],"names":["annotationHorizontalLine","spec","context","advancedVSeed","vseed","annotation","config","theme","annotationHorizontalLineList","Array","positionMap","markLine","yValue","dynamicFilter","text","textPosition","textColor","textFontSize","textFontWeight","textAlign","textBaseline","lineColor","lineVisible","lineWidth","textBackgroundVisible","textBackgroundColor","textBackgroundBorderColor","textBackgroundBorderRadius","textBackgroundBorderWidth","textBackgroundPadding","lineStyle","lineDash","getAnnotationLineDash","undefined","textBackgroundOpacity","generateOneMarkLine","y","ANNOTATION_Z_INDEX","finalYValue","resolveAnnotationValue","isArray","isString","isNumber","yValueArr","specMarkLine","newMarkLine"],"mappings":";;;AAMO,MAAMA,oDAA2C,CAACC,MAAMC;IAC7D,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IACjC,MAAM,EAAEG,UAAU,EAAEC,MAAM,EAAE,GAAGH;IAE/B,IAAI,CAACE,cAAc,CAACA,WAAW,wBAAwB,EACrD,OAAOJ;IAET,MAAMM,QAAQD,QAAQ,CAACF,MAAM,SAAS,CAAa,EAAE,YAAY;IACjE,MAAM,EAAEJ,wBAAwB,E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AI;wBACJ,QAAQU;wBACR,WAAW;wBACX,WAAWN;wBACX,cAAcC;wBACd,MAAMJ;wBACN,UAAUC;wBACV,YAAYC;oBACd;oBACA,iBAAiB;wBACf,SAASM;wBACT,SAASK;wBACT,OAAO;4BACL,SAASK,yBAAyB;4BAClC,IAAI;4BACJ,cAAcP;4BACd,MAAMF;4BACN,QAAQC;4BACR,WAAWE;4BACX,aAAa;wBACf;oBACF;gBACF;gBACA,aAAa;oBACX,SAASrB,OAAO,sBAAsB;oBACtC,YAAYA,OAAO,mBAAmB;oBACtC,MAAM,IAAKgB,CAAAA,aAAa;oBACxB,OAAO;wBACL,IAAI;wBACJ,MAAMF;oBACR;gBACF;gBACA,WAAW;oBACT,SAASd,OAAO,oBAAoB;oBACpC,YAAYA,OAAO,iBAAiB;oBACpC,MAAM,KAAMgB,CAAAA,aAAa;oBACzB,OAAO;wBACL,IAAI;wBACJ,MAAMF;oBACR;gBACF;YACF;QAGF,MAAMiB,cAAcC,uBAAuB;YACzC1B;YACA,UAAUA,eAAe;YACzB,cAAcD;QAChB;QAEA,IAAI4B,QAAQF,gBAAgBG,SAASH,gBAAgBI,SAASJ,cAAc;YAC1E,MAAMK,YAAYlC,MAAM,OAAO,CAAC6B,eAAeA,cAAc;gBAACA;aAAY;YAC1E,OAAOK,UAAU,GAAG,CAACR;QACvB;QAEA,OAAO,EAAE;IACX;IACA,MAAMS,eAAiB3C,KAAwB,QAAQ,IAAwB,EAAE;IACjF,MAAM4C,cAAc;WAAID;WAAkBjC,YAAY,EAAE;KAAE;IAC1D,OAAO;QACL,GAAGV,IAAI;QACP,UAAU4C;IACZ;AACF"}
|
|
@@ -48,6 +48,7 @@ const generateAnnotationPointPipe = (options)=>{
|
|
|
48
48
|
};
|
|
49
49
|
const markPoint = annotationPointList.flatMap((annotationPoint)=>{
|
|
50
50
|
const { selector: selectorPoint, measureId, dynamicFilter, text = '', textColor = theme?.textColor ?? '#ffffff', textFontSize = theme?.textFontSize ?? 12, textFontWeight = theme?.textFontWeight ?? 400, textAlign = defaultStyle.textAlign, textBaseline = defaultStyle.textBaseline, textBackgroundBorderColor = theme?.textBackgroundBorderColor, textBackgroundBorderRadius = theme?.textBackgroundBorderRadius ?? 4, textBackgroundBorderWidth = theme?.textBackgroundBorderWidth ?? 1, textBackgroundColor = theme?.textBackgroundColor ?? '#212121', textBackgroundPadding = theme?.textBackgroundPadding ?? 2, textBackgroundVisible = theme?.textBackgroundVisible ?? true, offsetX = theme?.offsetX ?? 0, offsetY = theme?.offsetY ?? 0 } = annotationPoint;
|
|
51
|
+
const textBackgroundOpacity = theme?.textBackgroundOpacity;
|
|
51
52
|
const dataset = advancedVSeed.dataset.flat();
|
|
52
53
|
const selectedData = selectorPoint || dynamicFilter ? findSelectedDatas({
|
|
53
54
|
dataset,
|
|
@@ -75,7 +76,7 @@ const generateAnnotationPointPipe = (options)=>{
|
|
|
75
76
|
visible: textBackgroundVisible,
|
|
76
77
|
padding: textBackgroundPadding,
|
|
77
78
|
style: {
|
|
78
|
-
opacity: 0.95,
|
|
79
|
+
opacity: textBackgroundOpacity ?? 0.95,
|
|
79
80
|
cornerRadius: textBackgroundBorderRadius ?? 4,
|
|
80
81
|
fill: textBackgroundColor,
|
|
81
82
|
stroke: textBackgroundBorderColor,
|
|
@@ -86,7 +87,6 @@ const generateAnnotationPointPipe = (options)=>{
|
|
|
86
87
|
}
|
|
87
88
|
},
|
|
88
89
|
style: {
|
|
89
|
-
opacity: 0.95,
|
|
90
90
|
visible: true,
|
|
91
91
|
textAlign: textAlign,
|
|
92
92
|
textBaseline: textBaseline,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationPointCommon.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/annotationPointCommon.ts"],"sourcesContent":["import type { ISpec, IMarkPointSpec } from '@visactor/vchart'\nimport { selector, selectorWithDynamicFilter } from '../../../../../dataSelector'\nimport { MeasureId } from 'src/dataReshape/constant'\nimport type {\n ChartDynamicFilter,\n Datum,\n Selector,\n Selectors,\n SpecPipelineContext,\n VChartSpecPipe,\n VSeed,\n} from 'src/types'\nimport { isSubset } from './utils'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport { isBarLikeChart } from 'src/pipeline/utils/chatType'\nexport const generateAnnotationPointPipe = (options: {\n findSelectedDatas?: (options: {\n dataset: Datum[]\n selector: Selector | Selectors | undefined | null\n measureId?: string | null\n dynamicFilter?: ChartDynamicFilter\n spec: ISpec\n context: SpecPipelineContext\n }) => Datum[]\n generateMarkPoint?: (datum: Datum, spec: ISpec, context: SpecPipelineContext) => IMarkPointSpec[] | undefined\n}) => {\n const findSelectedDatas =\n options.findSelectedDatas ??\n ((opts) => {\n const { dataset, selector: s, measureId, dynamicFilter } = opts\n return dataset.filter((datum) => {\n const isSelected = dynamicFilter ? selectorWithDynamicFilter(datum, dynamicFilter, s) : selector(datum, s)\n return isSelected && (!measureId || datum[MeasureId] === measureId)\n })\n })\n const generateMarkPoint =\n options.generateMarkPoint ??\n ((datum: Datum) => {\n return [\n {\n coordinate: (data: Datum[], context) => {\n const targetDatum = data.find((item) => isSubset(datum, item))\n if (context.getStack() === true) {\n const stackedDatum = { ...datum, ...targetDatum }\n return {\n ...stackedDatum,\n [context.getStackValueField()]: stackedDatum['__VCHART_STACK_END'],\n }\n }\n\n return targetDatum\n },\n },\n ]\n })\n\n return ((spec: ISpec, context: SpecPipelineContext) => {\n const { advancedVSeed, vseed } = context\n const { annotation, config } = advancedVSeed\n\n if (!annotation || !annotation.annotationPoint) {\n return spec\n }\n\n const theme = config?.[vseed.chartType as 'column']?.annotation?.annotationPoint\n const { annotationPoint } = annotation\n const annotationPointList = Array.isArray(annotationPoint) ? annotationPoint : [annotationPoint]\n const isHorizontalBar = isBarLikeChart(advancedVSeed as VSeed)\n const defaultStyle = isHorizontalBar\n ? {\n textAlign: 'right',\n textBaseline: 'middle',\n }\n : {\n textAlign: 'center',\n textBaseline: 'top',\n }\n\n const markPoint = annotationPointList.flatMap((annotationPoint) => {\n const {\n selector: selectorPoint,\n measureId,\n dynamicFilter,\n text = '',\n textColor = theme?.textColor ?? '#ffffff',\n textFontSize = theme?.textFontSize ?? 12,\n textFontWeight = theme?.textFontWeight ?? 400,\n textAlign = defaultStyle.textAlign,\n textBaseline = defaultStyle.textBaseline,\n textBackgroundBorderColor = theme?.textBackgroundBorderColor,\n textBackgroundBorderRadius = theme?.textBackgroundBorderRadius ?? 4,\n textBackgroundBorderWidth = theme?.textBackgroundBorderWidth ?? 1,\n textBackgroundColor = theme?.textBackgroundColor ?? '#212121',\n textBackgroundPadding = theme?.textBackgroundPadding ?? 2,\n textBackgroundVisible = theme?.textBackgroundVisible ?? true,\n offsetX = theme?.offsetX ?? 0,\n offsetY = theme?.offsetY ?? 0,\n } = annotationPoint\n\n const dataset = advancedVSeed.dataset.flat()\n const selectedData =\n selectorPoint || dynamicFilter\n ? findSelectedDatas({\n dataset,\n selector: selectorPoint,\n measureId,\n dynamicFilter,\n spec,\n context,\n })\n : []\n const dx = -10 - (isHorizontalBar ? (textFontSize as number) : 0) // 由于vchart tag实现问题,需要设置这个强制偏移量\n const dy = isHorizontalBar ? 0 : (textFontSize as number)\n const markPointStyle = {\n zIndex: ANNOTATION_Z_INDEX,\n regionRelative: true,\n itemLine: {\n visible: false,\n },\n itemContent: {\n offsetY,\n offsetX,\n confine: true,\n text: {\n text: text,\n labelBackground: {\n visible: textBackgroundVisible,\n padding: textBackgroundPadding,\n style: {\n opacity: 0.95,\n cornerRadius: textBackgroundBorderRadius ?? 4,\n fill: textBackgroundColor,\n stroke: textBackgroundBorderColor,\n lineWidth: textBackgroundBorderWidth,\n dx,\n dy,\n },\n },\n },\n style: {\n
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationPointCommon.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/annotationPointCommon.ts"],"sourcesContent":["import type { ISpec, IMarkPointSpec } from '@visactor/vchart'\nimport { selector, selectorWithDynamicFilter } from '../../../../../dataSelector'\nimport { MeasureId } from 'src/dataReshape/constant'\nimport type {\n ChartDynamicFilter,\n Datum,\n Selector,\n Selectors,\n SpecPipelineContext,\n VChartSpecPipe,\n VSeed,\n} from 'src/types'\nimport { isSubset } from './utils'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport { isBarLikeChart } from 'src/pipeline/utils/chatType'\nexport const generateAnnotationPointPipe = (options: {\n findSelectedDatas?: (options: {\n dataset: Datum[]\n selector: Selector | Selectors | undefined | null\n measureId?: string | null\n dynamicFilter?: ChartDynamicFilter\n spec: ISpec\n context: SpecPipelineContext\n }) => Datum[]\n generateMarkPoint?: (datum: Datum, spec: ISpec, context: SpecPipelineContext) => IMarkPointSpec[] | undefined\n}) => {\n const findSelectedDatas =\n options.findSelectedDatas ??\n ((opts) => {\n const { dataset, selector: s, measureId, dynamicFilter } = opts\n return dataset.filter((datum) => {\n const isSelected = dynamicFilter ? selectorWithDynamicFilter(datum, dynamicFilter, s) : selector(datum, s)\n return isSelected && (!measureId || datum[MeasureId] === measureId)\n })\n })\n const generateMarkPoint =\n options.generateMarkPoint ??\n ((datum: Datum) => {\n return [\n {\n coordinate: (data: Datum[], context) => {\n const targetDatum = data.find((item) => isSubset(datum, item))\n if (context.getStack() === true) {\n const stackedDatum = { ...datum, ...targetDatum }\n return {\n ...stackedDatum,\n [context.getStackValueField()]: stackedDatum['__VCHART_STACK_END'],\n }\n }\n\n return targetDatum\n },\n },\n ]\n })\n\n return ((spec: ISpec, context: SpecPipelineContext) => {\n const { advancedVSeed, vseed } = context\n const { annotation, config } = advancedVSeed\n\n if (!annotation || !annotation.annotationPoint) {\n return spec\n }\n\n const theme = config?.[vseed.chartType as 'column']?.annotation?.annotationPoint\n const { annotationPoint } = annotation\n const annotationPointList = Array.isArray(annotationPoint) ? annotationPoint : [annotationPoint]\n const isHorizontalBar = isBarLikeChart(advancedVSeed as VSeed)\n const defaultStyle = isHorizontalBar\n ? {\n textAlign: 'right',\n textBaseline: 'middle',\n }\n : {\n textAlign: 'center',\n textBaseline: 'top',\n }\n\n const markPoint = annotationPointList.flatMap((annotationPoint) => {\n const {\n selector: selectorPoint,\n measureId,\n dynamicFilter,\n text = '',\n textColor = theme?.textColor ?? '#ffffff',\n textFontSize = theme?.textFontSize ?? 12,\n textFontWeight = theme?.textFontWeight ?? 400,\n textAlign = defaultStyle.textAlign,\n textBaseline = defaultStyle.textBaseline,\n textBackgroundBorderColor = theme?.textBackgroundBorderColor,\n textBackgroundBorderRadius = theme?.textBackgroundBorderRadius ?? 4,\n textBackgroundBorderWidth = theme?.textBackgroundBorderWidth ?? 1,\n textBackgroundColor = theme?.textBackgroundColor ?? '#212121',\n textBackgroundPadding = theme?.textBackgroundPadding ?? 2,\n textBackgroundVisible = theme?.textBackgroundVisible ?? true,\n offsetX = theme?.offsetX ?? 0,\n offsetY = theme?.offsetY ?? 0,\n } = annotationPoint\n const textBackgroundOpacity = theme?.textBackgroundOpacity\n\n const dataset = advancedVSeed.dataset.flat()\n const selectedData =\n selectorPoint || dynamicFilter\n ? findSelectedDatas({\n dataset,\n selector: selectorPoint,\n measureId,\n dynamicFilter,\n spec,\n context,\n })\n : []\n const dx = -10 - (isHorizontalBar ? (textFontSize as number) : 0) // 由于vchart tag实现问题,需要设置这个强制偏移量\n const dy = isHorizontalBar ? 0 : (textFontSize as number)\n const markPointStyle = {\n zIndex: ANNOTATION_Z_INDEX,\n regionRelative: true,\n itemLine: {\n visible: false,\n },\n itemContent: {\n offsetY,\n offsetX,\n confine: true,\n text: {\n text: text,\n labelBackground: {\n visible: textBackgroundVisible,\n padding: textBackgroundPadding,\n style: {\n opacity: textBackgroundOpacity ?? 0.95,\n cornerRadius: textBackgroundBorderRadius ?? 4,\n fill: textBackgroundColor,\n stroke: textBackgroundBorderColor,\n lineWidth: textBackgroundBorderWidth,\n dx,\n dy,\n },\n },\n },\n style: {\n visible: true,\n textAlign: textAlign,\n textBaseline: textBaseline,\n fill: textColor,\n stroke: textBackgroundColor,\n lineWidth: 1,\n fontSize: textFontSize,\n fontWeight: textFontWeight,\n dx,\n dy,\n },\n },\n } as Partial<IMarkPointSpec>\n\n return selectedData.reduce((res: IMarkPointSpec[], datum) => {\n const marks = generateMarkPoint(datum, spec, context)\n\n if (marks && marks.length) {\n marks.forEach((mark) => {\n res.push({\n ...markPointStyle,\n ...mark,\n } as IMarkPointSpec)\n })\n }\n\n return res\n }, [])\n }) as unknown as IMarkPointSpec[]\n\n return {\n ...spec,\n markPoint,\n } as ISpec\n }) as VChartSpecPipe\n}\n"],"names":["generateAnnotationPointPipe","options","findSelectedDatas","opts","dataset","s","measureId","dynamicFilter","datum","isSelected","selectorWithDynamicFilter","selector","MeasureId","generateMarkPoint","data","context","targetDatum","item","isSubset","stackedDatum","spec","advancedVSeed","vseed","annotation","config","theme","annotationPoint","annotationPointList","Array","isHorizontalBar","isBarLikeChart","defaultStyle","markPoint","selectorPoint","text","textColor","textFontSize","textFontWeight","textAlign","textBaseline","textBackgroundBorderColor","textBackgroundBorderRadius","textBackgroundBorderWidth","textBackgroundColor","textBackgroundPadding","textBackgroundVisible","offsetX","offsetY","textBackgroundOpacity","selectedData","dx","dy","markPointStyle","ANNOTATION_Z_INDEX","res","marks","mark"],"mappings":";;;;;AAeO,MAAMA,8BAA8B,CAACC;IAW1C,MAAMC,oBACJD,QAAQ,iBAAiB,IACvB,EAAAE;QACA,MAAM,EAAEC,OAAO,EAAE,UAAUC,CAAC,EAAEC,SAAS,EAAEC,aAAa,EAAE,GAAGJ;QAC3D,OAAOC,QAAQ,MAAM,CAAC,CAACI;YACrB,MAAMC,aAAaF,gBAAgBG,0BAA0BF,OAAOD,eAAeF,KAAKM,SAASH,OAAOH;YACxG,OAAOI,cAAe,EAACH,aAAaE,KAAK,CAACI,UAAU,KAAKN,SAAQ;QACnE;IACF;IACF,MAAMO,oBACJZ,QAAQ,iBAAiB,IACvB,EAAAO,QACO;YACL;gBACE,YAAY,C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A,OAAO;YACL,GAAGlC,IAAI;YACPY;QACF;IACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isArray, isNumber, isString } from "remeda";
|
|
2
2
|
import { ANNOTATION_Z_INDEX } from "../../../../utils/constant.js";
|
|
3
|
-
import { resolveAnnotationValue } from "./utils.js";
|
|
3
|
+
import { getAnnotationLineDash, resolveAnnotationValue } from "./utils.js";
|
|
4
4
|
const annotationVerticalLine_annotationVerticalLine = (spec, context)=>{
|
|
5
5
|
const { advancedVSeed, vseed } = context;
|
|
6
6
|
const { annotation, config } = advancedVSeed;
|
|
@@ -19,7 +19,10 @@ const annotationVerticalLine_annotationVerticalLine = (spec, context)=>{
|
|
|
19
19
|
insideEnd: 'insideEndTop'
|
|
20
20
|
};
|
|
21
21
|
const markLine = annotationVerticalLineList.flatMap((annotationVerticalLine)=>{
|
|
22
|
-
const { xValue, dynamicFilter, text = '', textPosition = 'insideEnd', textColor = theme?.textColor ?? '#ffffff', textFontSize = theme?.textFontSize ?? 12, textFontWeight = theme?.textFontWeight ?? 400, textAlign = 'center', textBaseline = 'top', lineColor = theme?.lineColor ?? '#212121',
|
|
22
|
+
const { xValue, dynamicFilter, text = '', textPosition = 'insideEnd', textColor = theme?.textColor ?? '#ffffff', textFontSize = theme?.textFontSize ?? 12, textFontWeight = theme?.textFontWeight ?? 400, textAlign = 'center', textBaseline = 'top', lineColor = theme?.lineColor ?? '#212121', lineVisible = theme?.lineStyle ?? true, lineWidth = theme?.lineWidth ?? 1, textBackgroundVisible = theme?.textBackgroundVisible ?? true, textBackgroundColor = theme?.textBackgroundColor ?? '#212121', textBackgroundBorderColor = theme?.textBackgroundBorderColor ?? '#212121', textBackgroundBorderRadius = theme?.textBackgroundBorderRadius ?? 4, textBackgroundBorderWidth = theme?.textBackgroundBorderWidth ?? 1, textBackgroundPadding = theme?.textBackgroundPadding ?? 2 } = annotationVerticalLine;
|
|
23
|
+
const lineStyle = annotationVerticalLine.lineStyle ?? theme?.lineStyle ?? 'dashed';
|
|
24
|
+
const lineDash = getAnnotationLineDash(lineStyle, annotationVerticalLine.lineStyle ? void 0 : theme?.lineDash);
|
|
25
|
+
const textBackgroundOpacity = theme?.textBackgroundOpacity;
|
|
23
26
|
const generateOneMarkLine = (x)=>({
|
|
24
27
|
x,
|
|
25
28
|
autoRange: true,
|
|
@@ -30,15 +33,7 @@ const annotationVerticalLine_annotationVerticalLine = (spec, context)=>{
|
|
|
30
33
|
stroke: lineColor,
|
|
31
34
|
lineStyle: lineStyle,
|
|
32
35
|
lineWidth: lineWidth,
|
|
33
|
-
lineDash
|
|
34
|
-
5,
|
|
35
|
-
2
|
|
36
|
-
] : 'dotted' === lineStyle ? [
|
|
37
|
-
2,
|
|
38
|
-
5
|
|
39
|
-
] : [
|
|
40
|
-
0
|
|
41
|
-
]
|
|
36
|
+
lineDash
|
|
42
37
|
}
|
|
43
38
|
},
|
|
44
39
|
label: {
|
|
@@ -46,7 +41,6 @@ const annotationVerticalLine_annotationVerticalLine = (spec, context)=>{
|
|
|
46
41
|
text: text,
|
|
47
42
|
position: positionMap[textPosition || 'insideEnd'],
|
|
48
43
|
style: {
|
|
49
|
-
opacity: 0.95,
|
|
50
44
|
dx: 5,
|
|
51
45
|
visible: true,
|
|
52
46
|
stroke: textBackgroundColor,
|
|
@@ -61,13 +55,13 @@ const annotationVerticalLine_annotationVerticalLine = (spec, context)=>{
|
|
|
61
55
|
visible: textBackgroundVisible,
|
|
62
56
|
padding: textBackgroundPadding,
|
|
63
57
|
style: {
|
|
64
|
-
opacity: 0.95,
|
|
58
|
+
opacity: textBackgroundOpacity ?? 0.95,
|
|
65
59
|
dx: 5,
|
|
66
60
|
cornerRadius: textBackgroundBorderRadius,
|
|
67
61
|
fill: textBackgroundColor,
|
|
68
|
-
fillOpacity: 1,
|
|
69
62
|
stroke: textBackgroundBorderColor,
|
|
70
|
-
lineWidth: textBackgroundBorderWidth
|
|
63
|
+
lineWidth: textBackgroundBorderWidth,
|
|
64
|
+
fillOpacity: 1
|
|
71
65
|
}
|
|
72
66
|
}
|
|
73
67
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationVerticalLine.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/annotationVerticalLine.ts"],"sourcesContent":["import type { ILineChartSpec, IMarkLineSpec } from '@visactor/vchart'\nimport type { VChartSpecPipe } from 'src/types'\nimport { isArray, isNumber, isString } from 'remeda'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport { resolveAnnotationValue } from './utils'\n\nexport const annotationVerticalLine: VChartSpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const { annotation, config } = advancedVSeed\n\n if (!annotation || !annotation.annotationVerticalLine) {\n return spec\n }\n\n const theme = config?.[vseed.chartType as 'column']?.annotation?.annotationVerticalLine\n const { annotationVerticalLine } = annotation\n const annotationVerticalLineList = Array.isArray(annotationVerticalLine)\n ? annotationVerticalLine\n : [annotationVerticalLine]\n\n const positionMap = {\n outsideStart: 'start',\n outsideEnd: 'end',\n outsideMiddle: 'middle',\n insideStart: 'insideStartTop',\n insideMiddle: 'insideMiddleTop',\n insideEnd: 'insideEndTop',\n }\n const markLine = annotationVerticalLineList.flatMap((annotationVerticalLine) => {\n const {\n xValue,\n dynamicFilter,\n text = '',\n textPosition = 'insideEnd',\n textColor = theme?.textColor ?? '#ffffff',\n textFontSize = theme?.textFontSize ?? 12,\n textFontWeight = theme?.textFontWeight ?? 400,\n textAlign = 'center',\n textBaseline = 'top',\n\n lineColor = theme?.lineColor ?? '#212121',\n
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationVerticalLine.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/annotationVerticalLine.ts"],"sourcesContent":["import type { ILineChartSpec, IMarkLineSpec } from '@visactor/vchart'\nimport type { VChartSpecPipe } from 'src/types'\nimport { isArray, isNumber, isString } from 'remeda'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport { getAnnotationLineDash, resolveAnnotationValue } from './utils'\n\nexport const annotationVerticalLine: VChartSpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const { annotation, config } = advancedVSeed\n\n if (!annotation || !annotation.annotationVerticalLine) {\n return spec\n }\n\n const theme = config?.[vseed.chartType as 'column']?.annotation?.annotationVerticalLine\n const { annotationVerticalLine } = annotation\n const annotationVerticalLineList = Array.isArray(annotationVerticalLine)\n ? annotationVerticalLine\n : [annotationVerticalLine]\n\n const positionMap = {\n outsideStart: 'start',\n outsideEnd: 'end',\n outsideMiddle: 'middle',\n insideStart: 'insideStartTop',\n insideMiddle: 'insideMiddleTop',\n insideEnd: 'insideEndTop',\n }\n const markLine = annotationVerticalLineList.flatMap((annotationVerticalLine) => {\n const {\n xValue,\n dynamicFilter,\n text = '',\n textPosition = 'insideEnd',\n textColor = theme?.textColor ?? '#ffffff',\n textFontSize = theme?.textFontSize ?? 12,\n textFontWeight = theme?.textFontWeight ?? 400,\n textAlign = 'center',\n textBaseline = 'top',\n\n lineColor = theme?.lineColor ?? '#212121',\n lineVisible = theme?.lineStyle ?? true,\n lineWidth = theme?.lineWidth ?? 1,\n\n textBackgroundVisible = theme?.textBackgroundVisible ?? true,\n textBackgroundColor = theme?.textBackgroundColor ?? '#212121',\n textBackgroundBorderColor = theme?.textBackgroundBorderColor ?? '#212121',\n textBackgroundBorderRadius = theme?.textBackgroundBorderRadius ?? 4,\n textBackgroundBorderWidth = theme?.textBackgroundBorderWidth ?? 1,\n textBackgroundPadding = theme?.textBackgroundPadding ?? 2,\n } = annotationVerticalLine\n const lineStyle = annotationVerticalLine.lineStyle ?? theme?.lineStyle ?? 'dashed'\n const lineDash = getAnnotationLineDash(lineStyle, annotationVerticalLine.lineStyle ? undefined : theme?.lineDash)\n const textBackgroundOpacity = theme?.textBackgroundOpacity\n\n const generateOneMarkLine = (x: number | string) => ({\n x,\n autoRange: true,\n zIndex: ANNOTATION_Z_INDEX,\n line: {\n style: {\n visible: lineVisible,\n stroke: lineColor,\n lineStyle: lineStyle,\n lineWidth: lineWidth,\n lineDash,\n },\n },\n label: {\n confine: true,\n text: text,\n position: (positionMap as any)[textPosition || 'insideEnd'],\n style: {\n dx: 5,\n visible: true,\n stroke: textBackgroundColor,\n lineWidth: 1,\n textAlign: textAlign,\n textBaseline: textBaseline,\n fill: textColor,\n fontSize: textFontSize,\n fontWeight: textFontWeight,\n },\n labelBackground: {\n visible: textBackgroundVisible,\n padding: textBackgroundPadding,\n style: {\n opacity: textBackgroundOpacity ?? 0.95,\n dx: 5,\n cornerRadius: textBackgroundBorderRadius,\n fill: textBackgroundColor,\n stroke: textBackgroundBorderColor,\n lineWidth: textBackgroundBorderWidth,\n fillOpacity: 1,\n },\n },\n },\n startSymbol: {\n visible: theme?.startSymbolVisible ?? true,\n symbolType: theme?.startSymbolType ?? 'triangleDown',\n size: 5 + (lineWidth || 1),\n style: {\n dy: -3,\n fill: lineColor,\n },\n },\n endSymbol: {\n visible: theme?.endSymbolVisible ?? false,\n symbolType: theme?.endSymbolType ?? 'arrow',\n size: 10 + (lineWidth || 1),\n style: {\n dy: 4,\n fill: lineColor,\n },\n },\n })\n\n const finalXValue = resolveAnnotationValue({\n dynamicFilter,\n fallback: dynamicFilter?.fallback as string | number | undefined,\n defaultValue: xValue,\n })\n\n if (isArray(finalXValue) || isString(finalXValue) || isNumber(finalXValue)) {\n const xValueArr = Array.isArray(finalXValue) ? finalXValue : [finalXValue]\n return xValueArr.map(generateOneMarkLine)\n }\n\n return []\n }) as IMarkLineSpec[]\n\n const specMarkLine = ((spec as ILineChartSpec).markLine as IMarkLineSpec[]) || []\n const newMarkLine = [...specMarkLine, ...(markLine || [])]\n\n return {\n ...spec,\n markLine: newMarkLine,\n }\n}\n"],"names":["annotationVerticalLine","spec","context","advancedVSeed","vseed","annotation","config","theme","annotationVerticalLineList","Array","positionMap","markLine","xValue","dynamicFilter","text","textPosition","textColor","textFontSize","textFontWeight","textAlign","textBaseline","lineColor","lineVisible","lineWidth","textBackgroundVisible","textBackgroundColor","textBackgroundBorderColor","textBackgroundBorderRadius","textBackgroundBorderWidth","textBackgroundPadding","lineStyle","lineDash","getAnnotationLineDash","undefined","textBackgroundOpacity","generateOneMarkLine","x","ANNOTATION_Z_INDEX","finalXValue","resolveAnnotationValue","isArray","isString","isNumber","xValueArr","specMarkLine","newMarkLine"],"mappings":";;;AAMO,MAAMA,gDAAyC,CAACC,MAAMC;IAC3D,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IACjC,MAAM,EAAEG,UAAU,EAAEC,MAAM,EAAE,GAAGH;IAE/B,IAAI,CAACE,cAAc,CAACA,WAAW,sBAAsB,EACnD,OAAOJ;IAGT,MAAMM,QAAQD,QAAQ,CAACF,MAAM,SAAS,CAAa,EAAE,YAAY;IACjE,MAAM,EAAEJ,sBAAsB,EAAE,GAAGK;IACnC,MAAMG,6BAA6BC,MAAM,OAAO,CAACT,0BAC7CA,yBACA;QAACA;KAAuB;IAE5B,MAAMU,cAAc;QAClB,cAAc;QACd,YAAY;QACZ,eAAe;QACf,aAAa;QACb,cAAc;QACd,WAAW;IACb;IACA,MAAMC,WAAWH,2BAA2B,OAAO,CAAC,CAACR;QACnD,MAAM,EACJY,MAAM,EACNC,aAAa,EACbC,OAAO,EAAE,EACTC,eAAe,WAAW,EAC1BC,YAAYT,OAAO,aAAa,SAAS,EACzCU,eAAeV,OAAO,gBAAgB,EAAE,EACxCW,iBAAiBX,OAAO,kBAAkB,GAAG,EAC7CY,YAAY,QAAQ,EACpBC,eAAe,KAAK,EAEpBC,YAAYd,OAAO,aAAa,SAAS,EACzCe,cAAcf,OAAO,aAAa,IAAI,EACtCgB,YAAYhB,OAAO,aAAa,CAAC,EAEjCiB,wBAAwBjB,OAAO,yBAAyB,IAAI,EAC5DkB,sBAAsBlB,OAAO,uBAAuB,SAAS,EAC7DmB,4BAA4BnB,OAAO,6BAA6B,SAAS,EACz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D;QAChB;QAEA,IAAI4B,QAAQF,gBAAgBG,SAASH,gBAAgBI,SAASJ,cAAc;YAC1E,MAAMK,YAAYlC,MAAM,OAAO,CAAC6B,eAAeA,cAAc;gBAACA;aAAY;YAC1E,OAAOK,UAAU,GAAG,CAACR;QACvB;QAEA,OAAO,EAAE;IACX;IAEA,MAAMS,eAAiB3C,KAAwB,QAAQ,IAAwB,EAAE;IACjF,MAAM4C,cAAc;WAAID;WAAkBjC,YAAY,EAAE;KAAE;IAE1D,OAAO;QACL,GAAGV,IAAI;QACP,UAAU4C;IACZ;AACF"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Datum, ValueDynamicFilter } from '../../../../../types';
|
|
2
|
+
export type AnnotationLineStyle = 'solid' | 'dashed' | 'dotted';
|
|
3
|
+
export declare const getAnnotationLineDash: (lineStyle?: AnnotationLineStyle | null, lineDash?: number[] | null) => number[];
|
|
2
4
|
export declare const isSubset: (sub: Datum, obj: Datum, excludeMeasuresIds?: string[]) => boolean;
|
|
3
5
|
export declare const ANNOTATION_AREA_TEXT_STYLE_BY_POSITION: {
|
|
4
6
|
top: {
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
const getAnnotationLineDash = (lineStyle, lineDash)=>{
|
|
2
|
+
if (Array.isArray(lineDash)) return lineDash;
|
|
3
|
+
if ('dashed' === lineStyle) return [
|
|
4
|
+
2,
|
|
5
|
+
2
|
|
6
|
+
];
|
|
7
|
+
if ('dotted' === lineStyle) return [
|
|
8
|
+
2,
|
|
9
|
+
5
|
|
10
|
+
];
|
|
11
|
+
return [
|
|
12
|
+
0
|
|
13
|
+
];
|
|
14
|
+
};
|
|
1
15
|
const isSubset = (sub, obj, excludeMeasuresIds)=>Object.entries(sub).every(([key, value])=>{
|
|
2
16
|
if (excludeMeasuresIds && excludeMeasuresIds.includes(key)) return false;
|
|
3
17
|
if ('string' == typeof value) return obj[key] === value;
|
|
@@ -44,6 +58,6 @@ const resolveAnnotationValue = (options)=>{
|
|
|
44
58
|
if (void 0 !== fallback) return fallback;
|
|
45
59
|
return defaultValue;
|
|
46
60
|
};
|
|
47
|
-
export { ANNOTATION_AREA_TEXT_STYLE_BY_POSITION, isSubset, resolveAnnotationValue };
|
|
61
|
+
export { ANNOTATION_AREA_TEXT_STYLE_BY_POSITION, getAnnotationLineDash, isSubset, resolveAnnotationValue };
|
|
48
62
|
|
|
49
63
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/utils.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/utils.ts"],"sourcesContent":["import type { Datum, ValueDynamicFilter } from 'src/types'\n\nexport const isSubset = (sub: Datum, obj: Datum, excludeMeasuresIds?: string[]) => {\n return Object.entries(sub).every(([key, value]) => {\n if (excludeMeasuresIds && excludeMeasuresIds.includes(key)) {\n return false\n }\n\n if (typeof value === 'string') {\n return obj[key] === value\n }\n if (typeof value === 'number') {\n return obj[key] === value\n }\n return true\n })\n}\n\nexport const ANNOTATION_AREA_TEXT_STYLE_BY_POSITION = {\n top: {\n textAlign: 'center',\n textBaseline: 'top',\n },\n topRight: {\n textAlign: 'right',\n textBaseline: 'top',\n },\n topLeft: {\n textAlign: 'left',\n textBaseline: 'top',\n },\n bottom: {\n textAlign: 'center',\n textBaseline: 'bottom',\n },\n bottomLeft: {\n textAlign: 'left',\n textBaseline: 'bottom',\n },\n bottomRight: {\n textAlign: 'right',\n textBaseline: 'bottom',\n },\n left: {\n textAlign: 'left',\n textBaseline: 'middle',\n },\n right: {\n textAlign: 'right',\n textBaseline: 'middle',\n },\n}\n\n/**\n * 解析标注线的值,优先级:dynamicFilter (success=true) > fallback > defaultValue\n */\nexport const resolveAnnotationValue = (options: {\n dynamicFilter?: ValueDynamicFilter\n fallback?: string | number\n defaultValue?: any\n}): (string | number) | (string | number)[] | undefined => {\n const { dynamicFilter, fallback, defaultValue } = options\n\n // 优先使用 dynamicFilter\n if (dynamicFilter?.result?.success && dynamicFilter.result.data !== undefined) {\n return dynamicFilter.result.data\n }\n\n // 其次使用 fallback\n if (fallback !== undefined) {\n return fallback\n }\n\n // 最后使用原始的 defaultValue\n return defaultValue\n}\n"],"names":["isSubset","sub","obj","excludeMeasuresIds","Object","key","value","ANNOTATION_AREA_TEXT_STYLE_BY_POSITION","resolveAnnotationValue","options","dynamicFilter","fallback","defaultValue","undefined"],"mappings":"
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/utils.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/utils.ts"],"sourcesContent":["import type { Datum, ValueDynamicFilter } from 'src/types'\n\nexport type AnnotationLineStyle = 'solid' | 'dashed' | 'dotted'\n\nexport const getAnnotationLineDash = (lineStyle?: AnnotationLineStyle | null, lineDash?: number[] | null) => {\n if (Array.isArray(lineDash)) {\n return lineDash\n }\n\n if (lineStyle === 'dashed') {\n return [2, 2]\n }\n\n if (lineStyle === 'dotted') {\n return [2, 5]\n }\n\n return [0]\n}\n\nexport const isSubset = (sub: Datum, obj: Datum, excludeMeasuresIds?: string[]) => {\n return Object.entries(sub).every(([key, value]) => {\n if (excludeMeasuresIds && excludeMeasuresIds.includes(key)) {\n return false\n }\n\n if (typeof value === 'string') {\n return obj[key] === value\n }\n if (typeof value === 'number') {\n return obj[key] === value\n }\n return true\n })\n}\n\nexport const ANNOTATION_AREA_TEXT_STYLE_BY_POSITION = {\n top: {\n textAlign: 'center',\n textBaseline: 'top',\n },\n topRight: {\n textAlign: 'right',\n textBaseline: 'top',\n },\n topLeft: {\n textAlign: 'left',\n textBaseline: 'top',\n },\n bottom: {\n textAlign: 'center',\n textBaseline: 'bottom',\n },\n bottomLeft: {\n textAlign: 'left',\n textBaseline: 'bottom',\n },\n bottomRight: {\n textAlign: 'right',\n textBaseline: 'bottom',\n },\n left: {\n textAlign: 'left',\n textBaseline: 'middle',\n },\n right: {\n textAlign: 'right',\n textBaseline: 'middle',\n },\n}\n\n/**\n * 解析标注线的值,优先级:dynamicFilter (success=true) > fallback > defaultValue\n */\nexport const resolveAnnotationValue = (options: {\n dynamicFilter?: ValueDynamicFilter\n fallback?: string | number\n defaultValue?: any\n}): (string | number) | (string | number)[] | undefined => {\n const { dynamicFilter, fallback, defaultValue } = options\n\n // 优先使用 dynamicFilter\n if (dynamicFilter?.result?.success && dynamicFilter.result.data !== undefined) {\n return dynamicFilter.result.data\n }\n\n // 其次使用 fallback\n if (fallback !== undefined) {\n return fallback\n }\n\n // 最后使用原始的 defaultValue\n return defaultValue\n}\n"],"names":["getAnnotationLineDash","lineStyle","lineDash","Array","isSubset","sub","obj","excludeMeasuresIds","Object","key","value","ANNOTATION_AREA_TEXT_STYLE_BY_POSITION","resolveAnnotationValue","options","dynamicFilter","fallback","defaultValue","undefined"],"mappings":"AAIO,MAAMA,wBAAwB,CAACC,WAAwCC;IAC5E,IAAIC,MAAM,OAAO,CAACD,WAChB,OAAOA;IAGT,IAAID,AAAc,aAAdA,WACF,OAAO;QAAC;QAAG;KAAE;IAGf,IAAIA,AAAc,aAAdA,WACF,OAAO;QAAC;QAAG;KAAE;IAGf,OAAO;QAAC;KAAE;AACZ;AAEO,MAAMG,WAAW,CAACC,KAAYC,KAAYC,qBACxCC,OAAO,OAAO,CAACH,KAAK,KAAK,CAAC,CAAC,CAACI,KAAKC,MAAM;QAC5C,IAAIH,sBAAsBA,mBAAmB,QAAQ,CAACE,MACpD,OAAO;QAGT,IAAI,AAAiB,YAAjB,OAAOC,OACT,OAAOJ,GAAG,CAACG,IAAI,KAAKC;QAEtB,IAAI,AAAiB,YAAjB,OAAOA,OACT,OAAOJ,GAAG,CAACG,IAAI,KAAKC;QAEtB,OAAO;IACT;AAGK,MAAMC,yCAAyC;IACpD,KAAK;QACH,WAAW;QACX,cAAc;IAChB;IACA,UAAU;QACR,WAAW;QACX,cAAc;IAChB;IACA,SAAS;QACP,WAAW;QACX,cAAc;IAChB;IACA,QAAQ;QACN,WAAW;QACX,cAAc;IAChB;IACA,YAAY;QACV,WAAW;QACX,cAAc;IAChB;IACA,aAAa;QACX,WAAW;QACX,cAAc;IAChB;IACA,MAAM;QACJ,WAAW;QACX,cAAc;IAChB;IACA,OAAO;QACL,WAAW;QACX,cAAc;IAChB;AACF;AAKO,MAAMC,yBAAyB,CAACC;IAKrC,MAAM,EAAEC,aAAa,EAAEC,QAAQ,EAAEC,YAAY,EAAE,GAAGH;IAGlD,IAAIC,eAAe,QAAQ,WAAWA,AAA8BG,WAA9BH,cAAc,MAAM,CAAC,IAAI,EAC7D,OAAOA,cAAc,MAAM,CAAC,IAAI;IAIlC,IAAIC,AAAaE,WAAbF,UACF,OAAOA;IAIT,OAAOC;AACT"}
|
|
@@ -1,49 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
topLeft,
|
|
9
|
-
topRight
|
|
10
|
-
];
|
|
11
|
-
};
|
|
12
|
-
const mergeStackCornerRadius = (cornerRadius)=>{
|
|
13
|
-
if (!Array.isArray(cornerRadius)) return cornerRadius;
|
|
14
|
-
const [topLeft = 0, topRight = 0, bottomRight = 0, bottomLeft = 0] = cornerRadius;
|
|
15
|
-
return [
|
|
16
|
-
Math.max(topLeft, bottomRight),
|
|
17
|
-
Math.max(topRight, bottomLeft),
|
|
18
|
-
Math.max(bottomRight, topLeft),
|
|
19
|
-
Math.max(bottomLeft, topRight)
|
|
20
|
-
];
|
|
21
|
-
};
|
|
22
|
-
const getStackRangeCornerRadius = (cornerRadius, datum)=>{
|
|
23
|
-
const stackStart = datum?.['__VCHART_STACK_START'];
|
|
24
|
-
const stackEnd = datum?.['__VCHART_STACK_END'];
|
|
25
|
-
if ('number' != typeof stackStart || 'number' != typeof stackEnd) return;
|
|
26
|
-
const hasPositivePart = stackStart > 0 || stackEnd > 0;
|
|
27
|
-
const hasNegativePart = stackStart < 0 || stackEnd < 0;
|
|
28
|
-
if (hasPositivePart && hasNegativePart) return mergeStackCornerRadius(cornerRadius);
|
|
29
|
-
if (hasPositivePart) return cornerRadius;
|
|
30
|
-
if (hasNegativePart) return reverseStackCornerRadius(cornerRadius);
|
|
31
|
-
return 0;
|
|
32
|
-
};
|
|
1
|
+
import { createStackCornerRadius, hasMoveInAnimation } from "./stackCornerRadiusUtils.js";
|
|
2
|
+
const hasBarMoveInAnimation = (spec)=>[
|
|
3
|
+
spec.animationAppear,
|
|
4
|
+
spec.animationNormal,
|
|
5
|
+
spec.animationEnter,
|
|
6
|
+
spec.animationUpdate
|
|
7
|
+
].some(hasMoveInAnimation);
|
|
33
8
|
const stackCornerRadius_stackCornerRadius = (spec, context)=>{
|
|
34
9
|
const { advancedVSeed, vseed } = context;
|
|
35
10
|
const { chartType } = vseed;
|
|
36
11
|
const stackCornerRadius = advancedVSeed.config?.[chartType]?.stackCornerRadius;
|
|
37
12
|
if ('dualAxis' === chartType && 'bar' !== spec.type) return spec;
|
|
13
|
+
const stackCornerRadiusCallback = createStackCornerRadius(stackCornerRadius);
|
|
14
|
+
if (!hasBarMoveInAnimation(spec)) return {
|
|
15
|
+
...spec,
|
|
16
|
+
stackCornerRadius: stackCornerRadiusCallback
|
|
17
|
+
};
|
|
38
18
|
return {
|
|
39
19
|
...spec,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return 0;
|
|
20
|
+
bar: {
|
|
21
|
+
...spec.bar,
|
|
22
|
+
style: {
|
|
23
|
+
...spec.bar?.style,
|
|
24
|
+
cornerRadius: stackCornerRadiusCallback
|
|
25
|
+
}
|
|
47
26
|
}
|
|
48
27
|
};
|
|
49
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/stack/stackCornerRadius.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/stack/stackCornerRadius.ts"],"sourcesContent":["import type { IBarChartSpec } from '@visactor/vchart'\nimport
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/stack/stackCornerRadius.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/stack/stackCornerRadius.ts"],"sourcesContent":["import type { IBarChartSpec } from '@visactor/vchart'\nimport type { VChartSpecPipe, StackCornerRadius } from 'src/types'\nimport { createStackCornerRadius, hasMoveInAnimation } from './stackCornerRadiusUtils'\n\nconst hasBarMoveInAnimation = (spec: IBarChartSpec): boolean => {\n return [spec.animationAppear, spec.animationNormal, spec.animationEnter, spec.animationUpdate].some(\n hasMoveInAnimation,\n )\n}\n\nexport const stackCornerRadius: VChartSpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n const stackCornerRadius = advancedVSeed.config?.[chartType as 'column']?.stackCornerRadius as StackCornerRadius\n\n if (chartType === 'dualAxis' && (spec as any).type !== 'bar') {\n return spec\n }\n\n const stackCornerRadiusCallback = createStackCornerRadius(stackCornerRadius)\n\n if (!hasBarMoveInAnimation(spec as IBarChartSpec)) {\n return { ...spec, stackCornerRadius: stackCornerRadiusCallback } as IBarChartSpec\n }\n\n // VChart implements stackCornerRadius with a final-position clipPath, which clips moveIn.\n return {\n ...spec,\n bar: {\n ...(spec as IBarChartSpec).bar,\n style: {\n ...(spec as IBarChartSpec).bar?.style,\n cornerRadius: stackCornerRadiusCallback,\n },\n },\n } as IBarChartSpec\n}\n"],"names":["hasBarMoveInAnimation","spec","hasMoveInAnimation","stackCornerRadius","context","advancedVSeed","vseed","chartType","stackCornerRadiusCallback","createStackCornerRadius"],"mappings":";AAIA,MAAMA,wBAAwB,CAACC,OACtB;QAACA,KAAK,eAAe;QAAEA,KAAK,eAAe;QAAEA,KAAK,cAAc;QAAEA,KAAK,eAAe;KAAC,CAAC,IAAI,CACjGC;AAIG,MAAMC,sCAAoC,CAACF,MAAMG;IACtD,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IACjC,MAAM,EAAEG,SAAS,EAAE,GAAGD;IACtB,MAAMH,oBAAoBE,cAAc,MAAM,EAAE,CAACE,UAAsB,EAAE;IAEzE,IAAIA,AAAc,eAAdA,aAA6BN,AAAsB,UAAtBA,KAAa,IAAI,EAChD,OAAOA;IAGT,MAAMO,4BAA4BC,wBAAwBN;IAE1D,IAAI,CAACH,sBAAsBC,OACzB,OAAO;QAAE,GAAGA,IAAI;QAAE,mBAAmBO;IAA0B;IAIjE,OAAO;QACL,GAAGP,IAAI;QACP,KAAK;YACH,GAAIA,KAAuB,GAAG;YAC9B,OAAO;gBACL,GAAIA,KAAuB,GAAG,EAAE,KAAK;gBACrC,cAAcO;YAChB;QACF;IACF;AACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Datum, StackCornerRadius } from '../../../../../types';
|
|
2
|
+
export type StackCornerRadiusCallback = (_: unknown, datum: Datum) => StackCornerRadius | 0;
|
|
3
|
+
export declare const createStackCornerRadius: (cornerRadius: StackCornerRadius) => StackCornerRadiusCallback;
|
|
4
|
+
export declare const hasMoveInAnimation: (animation: unknown) => boolean;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { FoldMeasureId } from "../../../../../dataReshape/constant.js";
|
|
2
|
+
const reverseStackCornerRadius = (cornerRadius)=>{
|
|
3
|
+
if (!Array.isArray(cornerRadius)) return cornerRadius;
|
|
4
|
+
const [topLeft = 0, topRight = 0, bottomRight = 0, bottomLeft = 0] = cornerRadius;
|
|
5
|
+
return [
|
|
6
|
+
bottomRight,
|
|
7
|
+
bottomLeft,
|
|
8
|
+
topLeft,
|
|
9
|
+
topRight
|
|
10
|
+
];
|
|
11
|
+
};
|
|
12
|
+
const mergeStackCornerRadius = (cornerRadius)=>{
|
|
13
|
+
if (!Array.isArray(cornerRadius)) return cornerRadius;
|
|
14
|
+
const [topLeft = 0, topRight = 0, bottomRight = 0, bottomLeft = 0] = cornerRadius;
|
|
15
|
+
return [
|
|
16
|
+
Math.max(topLeft, bottomRight),
|
|
17
|
+
Math.max(topRight, bottomLeft),
|
|
18
|
+
Math.max(bottomRight, topLeft),
|
|
19
|
+
Math.max(bottomLeft, topRight)
|
|
20
|
+
];
|
|
21
|
+
};
|
|
22
|
+
const getStackRangeCornerRadius = (cornerRadius, datum)=>{
|
|
23
|
+
const stackStart = datum?.['__VCHART_STACK_START'];
|
|
24
|
+
const stackEnd = datum?.['__VCHART_STACK_END'];
|
|
25
|
+
if ('number' != typeof stackStart || 'number' != typeof stackEnd) return;
|
|
26
|
+
const hasPositivePart = stackStart > 0 || stackEnd > 0;
|
|
27
|
+
const hasNegativePart = stackStart < 0 || stackEnd < 0;
|
|
28
|
+
if (hasPositivePart && hasNegativePart) return mergeStackCornerRadius(cornerRadius);
|
|
29
|
+
if (hasPositivePart) return cornerRadius;
|
|
30
|
+
if (hasNegativePart) return reverseStackCornerRadius(cornerRadius);
|
|
31
|
+
return 0;
|
|
32
|
+
};
|
|
33
|
+
const createStackCornerRadius = (cornerRadius)=>(_, datum)=>{
|
|
34
|
+
const stackRangeCornerRadius = getStackRangeCornerRadius(cornerRadius, datum);
|
|
35
|
+
if (void 0 !== stackRangeCornerRadius) return stackRangeCornerRadius;
|
|
36
|
+
const value = datum?.[datum?.[FoldMeasureId]];
|
|
37
|
+
if (value > 0) return cornerRadius;
|
|
38
|
+
if (value < 0) return reverseStackCornerRadius(cornerRadius);
|
|
39
|
+
return 0;
|
|
40
|
+
};
|
|
41
|
+
const hasMoveInAnimation = (animation)=>{
|
|
42
|
+
if (!animation) return false;
|
|
43
|
+
if (Array.isArray(animation)) return animation.some(hasMoveInAnimation);
|
|
44
|
+
if ('object' != typeof animation) return false;
|
|
45
|
+
const animationRecord = animation;
|
|
46
|
+
return 'moveIn' === animationRecord.type || Object.values(animationRecord).some(hasMoveInAnimation);
|
|
47
|
+
};
|
|
48
|
+
export { createStackCornerRadius, hasMoveInAnimation };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=stackCornerRadiusUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/stack/stackCornerRadiusUtils.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/stack/stackCornerRadiusUtils.ts"],"sourcesContent":["import { FoldMeasureId } from 'src/dataReshape/constant'\nimport type { Datum, StackCornerRadius } from 'src/types'\n\nexport type StackCornerRadiusCallback = (_: unknown, datum: Datum) => StackCornerRadius | 0\n\nconst reverseStackCornerRadius = (cornerRadius: StackCornerRadius): StackCornerRadius => {\n if (!Array.isArray(cornerRadius)) {\n return cornerRadius\n }\n\n const [topLeft = 0, topRight = 0, bottomRight = 0, bottomLeft = 0] = cornerRadius\n\n return [bottomRight, bottomLeft, topLeft, topRight]\n}\n\nconst mergeStackCornerRadius = (cornerRadius: StackCornerRadius): StackCornerRadius => {\n if (!Array.isArray(cornerRadius)) {\n return cornerRadius\n }\n\n const [topLeft = 0, topRight = 0, bottomRight = 0, bottomLeft = 0] = cornerRadius\n\n return [\n Math.max(topLeft, bottomRight),\n Math.max(topRight, bottomLeft),\n Math.max(bottomRight, topLeft),\n Math.max(bottomLeft, topRight),\n ]\n}\n\nconst getStackRangeCornerRadius = (\n cornerRadius: StackCornerRadius,\n datum: Datum,\n): StackCornerRadius | 0 | undefined => {\n const stackStart = datum?.['__VCHART_STACK_START']\n const stackEnd = datum?.['__VCHART_STACK_END']\n\n if (typeof stackStart !== 'number' || typeof stackEnd !== 'number') {\n return undefined\n }\n\n const hasPositivePart = stackStart > 0 || stackEnd > 0\n const hasNegativePart = stackStart < 0 || stackEnd < 0\n\n if (hasPositivePart && hasNegativePart) {\n return mergeStackCornerRadius(cornerRadius)\n }\n\n if (hasPositivePart) {\n return cornerRadius\n }\n\n if (hasNegativePart) {\n return reverseStackCornerRadius(cornerRadius)\n }\n\n return 0\n}\n\nexport const createStackCornerRadius = (cornerRadius: StackCornerRadius): StackCornerRadiusCallback => {\n return (_: unknown, datum: Datum) => {\n const stackRangeCornerRadius = getStackRangeCornerRadius(cornerRadius, datum)\n\n if (stackRangeCornerRadius !== undefined) {\n return stackRangeCornerRadius\n }\n\n const value = datum?.[datum?.[FoldMeasureId]]\n\n if (value > 0) {\n return cornerRadius\n }\n\n if (value < 0) {\n return reverseStackCornerRadius(cornerRadius)\n }\n\n return 0\n }\n}\n\nexport const hasMoveInAnimation = (animation: unknown): boolean => {\n if (!animation) {\n return false\n }\n\n if (Array.isArray(animation)) {\n return animation.some(hasMoveInAnimation)\n }\n\n if (typeof animation !== 'object') {\n return false\n }\n\n const animationRecord = animation as Record<string, unknown>\n\n return animationRecord.type === 'moveIn' || Object.values(animationRecord).some(hasMoveInAnimation)\n}\n"],"names":["reverseStackCornerRadius","cornerRadius","Array","topLeft","topRight","bottomRight","bottomLeft","mergeStackCornerRadius","Math","getStackRangeCornerRadius","datum","stackStart","stackEnd","hasPositivePart","hasNegativePart","createStackCornerRadius","_","stackRangeCornerRadius","undefined","value","FoldMeasureId","hasMoveInAnimation","animation","animationRecord","Object"],"mappings":";AAKA,MAAMA,2BAA2B,CAACC;IAChC,IAAI,CAACC,MAAM,OAAO,CAACD,eACjB,OAAOA;IAGT,MAAM,CAACE,UAAU,CAAC,EAAEC,WAAW,CAAC,EAAEC,cAAc,CAAC,EAAEC,aAAa,CAAC,CAAC,GAAGL;IAErE,OAAO;QAACI;QAAaC;QAAYH;QAASC;KAAS;AACrD;AAEA,MAAMG,yBAAyB,CAACN;IAC9B,IAAI,CAACC,MAAM,OAAO,CAACD,eACjB,OAAOA;IAGT,MAAM,CAACE,UAAU,CAAC,EAAEC,WAAW,CAAC,EAAEC,cAAc,CAAC,EAAEC,aAAa,CAAC,CAAC,GAAGL;IAErE,OAAO;QACLO,KAAK,GAAG,CAACL,SAASE;QAClBG,KAAK,GAAG,CAACJ,UAAUE;QACnBE,KAAK,GAAG,CAACH,aAAaF;QACtBK,KAAK,GAAG,CAACF,YAAYF;KACtB;AACH;AAEA,MAAMK,4BAA4B,CAChCR,cACAS;IAEA,MAAMC,aAAaD,OAAO,CA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