@visactor/vseed 0.4.28 → 0.5.1
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/advanced/chart/pipes/config/column.js +2 -1
- package/dist/esm/pipeline/advanced/chart/pipes/config/column.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/config/line.js +2 -1
- package/dist/esm/pipeline/advanced/chart/pipes/config/line.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/config/pie.js +2 -1
- package/dist/esm/pipeline/advanced/chart/pipes/config/pie.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/config/scatter.js +2 -1
- package/dist/esm/pipeline/advanced/chart/pipes/config/scatter.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/area.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/area.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/areaPercent.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/areaPercent.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/bar.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/bar.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/barParallel.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/barParallel.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/barPercent.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/barPercent.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/column.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/column.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/columnParallel.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/columnParallel.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/columnPercent.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/columnPercent.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/donut.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/donut.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/line.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/line.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/pie.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/pie.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/radar.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/radar.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/rose.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/rose.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/roseParallel.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/roseParallel.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/scatter.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/scatter.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/animation/animation.d.ts +15 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/animation.js +94 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/animation.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/bar.d.ts +77 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/bar.js +88 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/bar.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/index.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/index.js +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/lineOrArea.d.ts +254 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/lineOrArea.js +138 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/lineOrArea.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/pie.d.ts +71 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/pie.js +176 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/pie.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/radar.d.ts +131 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/radar.js +46 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/radar.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/scatter.d.ts +102 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/scatter.js +57 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/scatter.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/types.d.ts +130 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/types.js +19 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/types.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/bar.d.ts +11 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/bar.js +13 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/bar.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/barColor.d.ts +52 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/barColor.js +51 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/barColor.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/barGroup.d.ts +102 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/barGroup.js +84 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/barGroup.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/barMotion.d.ts +66 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/barMotion.js +72 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/barMotion.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/index.d.ts +86 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/index.js +60 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/index.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/lineOrArea.d.ts +29 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/lineOrArea.js +20 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/lineOrArea.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/pie.d.ts +14 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/pie.js +9 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/pie.js.map +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/scatter.d.ts +69 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/scatter.js +59 -0
- package/dist/esm/pipeline/spec/chart/pipes/animation/utils/scatter.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/index.d.ts +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/index.js +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/area.d.ts +6 -1
- package/dist/esm/types/chartType/area/zArea.d.ts +50 -0
- package/dist/esm/types/chartType/area/zArea.js +2 -1
- package/dist/esm/types/chartType/area/zArea.js.map +1 -1
- package/dist/esm/types/chartType/areaPercent/areaPercent.d.ts +6 -1
- package/dist/esm/types/chartType/areaPercent/zAreaPercent.d.ts +40 -0
- package/dist/esm/types/chartType/areaPercent/zAreaPercent.js +2 -1
- package/dist/esm/types/chartType/areaPercent/zAreaPercent.js.map +1 -1
- package/dist/esm/types/chartType/bar/bar.d.ts +6 -1
- package/dist/esm/types/chartType/bar/zBar.d.ts +50 -0
- package/dist/esm/types/chartType/bar/zBar.js +2 -1
- package/dist/esm/types/chartType/bar/zBar.js.map +1 -1
- package/dist/esm/types/chartType/barParallel/barParallel.d.ts +6 -1
- package/dist/esm/types/chartType/barParallel/zBarParallel.d.ts +50 -0
- package/dist/esm/types/chartType/barParallel/zBarParallel.js +2 -1
- package/dist/esm/types/chartType/barParallel/zBarParallel.js.map +1 -1
- package/dist/esm/types/chartType/barPercent/barPercent.d.ts +6 -1
- package/dist/esm/types/chartType/barPercent/zBarPercent.d.ts +40 -0
- package/dist/esm/types/chartType/barPercent/zBarPercent.js +2 -1
- package/dist/esm/types/chartType/barPercent/zBarPercent.js.map +1 -1
- package/dist/esm/types/chartType/column/column.d.ts +6 -1
- package/dist/esm/types/chartType/column/zColumn.d.ts +50 -0
- package/dist/esm/types/chartType/column/zColumn.js +2 -1
- package/dist/esm/types/chartType/column/zColumn.js.map +1 -1
- package/dist/esm/types/chartType/columnParallel/columnParallel.d.ts +6 -1
- package/dist/esm/types/chartType/columnParallel/zColumnParallel.d.ts +50 -0
- package/dist/esm/types/chartType/columnParallel/zColumnParallel.js +2 -1
- package/dist/esm/types/chartType/columnParallel/zColumnParallel.js.map +1 -1
- package/dist/esm/types/chartType/columnPercent/columnPercent.d.ts +6 -1
- package/dist/esm/types/chartType/columnPercent/zColumnPercent.d.ts +40 -0
- package/dist/esm/types/chartType/columnPercent/zColumnPercent.js +2 -1
- package/dist/esm/types/chartType/columnPercent/zColumnPercent.js.map +1 -1
- package/dist/esm/types/chartType/donut/donut.d.ts +6 -1
- package/dist/esm/types/chartType/donut/zDonut.d.ts +40 -0
- package/dist/esm/types/chartType/donut/zDonut.js +2 -1
- package/dist/esm/types/chartType/donut/zDonut.js.map +1 -1
- package/dist/esm/types/chartType/line/line.d.ts +6 -1
- package/dist/esm/types/chartType/line/zLine.d.ts +50 -0
- package/dist/esm/types/chartType/line/zLine.js +2 -1
- package/dist/esm/types/chartType/line/zLine.js.map +1 -1
- package/dist/esm/types/chartType/pie/pie.d.ts +6 -1
- package/dist/esm/types/chartType/pie/zPie.d.ts +40 -0
- package/dist/esm/types/chartType/pie/zPie.js +2 -1
- package/dist/esm/types/chartType/pie/zPie.js.map +1 -1
- package/dist/esm/types/chartType/radar/radar.d.ts +6 -1
- package/dist/esm/types/chartType/radar/zRadar.d.ts +40 -0
- package/dist/esm/types/chartType/radar/zRadar.js +2 -1
- package/dist/esm/types/chartType/radar/zRadar.js.map +1 -1
- package/dist/esm/types/chartType/rose/rose.d.ts +6 -1
- package/dist/esm/types/chartType/rose/zRose.d.ts +40 -0
- package/dist/esm/types/chartType/rose/zRose.js +2 -1
- package/dist/esm/types/chartType/rose/zRose.js.map +1 -1
- package/dist/esm/types/chartType/roseParallel/roseParallel.d.ts +6 -1
- package/dist/esm/types/chartType/roseParallel/zRoseParallel.d.ts +40 -0
- package/dist/esm/types/chartType/roseParallel/zRoseParallel.js +2 -1
- package/dist/esm/types/chartType/roseParallel/zRoseParallel.js.map +1 -1
- package/dist/esm/types/chartType/scatter/scatter.d.ts +6 -1
- package/dist/esm/types/chartType/scatter/zScatter.d.ts +40 -0
- package/dist/esm/types/chartType/scatter/zScatter.js +2 -1
- package/dist/esm/types/chartType/scatter/zScatter.js.map +1 -1
- 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/animation/animation.d.ts +72 -0
- package/dist/esm/types/properties/config/animation/animation.js +0 -0
- package/dist/esm/types/properties/config/animation/animationAtmosphere.d.ts +15 -0
- package/dist/esm/types/properties/config/animation/animationAtmosphere.js +0 -0
- package/dist/esm/types/properties/config/animation/animationConfig.d.ts +2 -0
- package/dist/esm/types/properties/config/animation/animationConfig.js +0 -0
- package/dist/esm/types/properties/config/animation/animationEffect.d.ts +72 -0
- package/dist/esm/types/properties/config/animation/animationEffect.js +0 -0
- package/dist/esm/types/properties/config/animation/animationLoop.d.ts +49 -0
- package/dist/esm/types/properties/config/animation/animationLoop.js +0 -0
- package/dist/esm/types/properties/config/animation/index.d.ts +6 -0
- package/dist/esm/types/properties/config/animation/index.js +1 -0
- package/dist/esm/types/properties/config/animation/zAnimation.d.ts +201 -0
- package/dist/esm/types/properties/config/animation/zAnimation.js +114 -0
- package/dist/esm/types/properties/config/animation/zAnimation.js.map +1 -0
- 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 +110 -4
- package/dist/esm/types/properties/config/area.js +3 -1
- package/dist/esm/types/properties/config/area.js.map +1 -1
- package/dist/esm/types/properties/config/bar.d.ts +165 -6
- package/dist/esm/types/properties/config/bar.js +3 -1
- package/dist/esm/types/properties/config/bar.js.map +1 -1
- package/dist/esm/types/properties/config/boxplot.d.ts +15 -2
- package/dist/esm/types/properties/config/column.d.ts +165 -6
- package/dist/esm/types/properties/config/column.js +3 -1
- package/dist/esm/types/properties/config/column.js.map +1 -1
- package/dist/esm/types/properties/config/config.d.ts +1125 -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/index.d.ts +1 -0
- package/dist/esm/types/properties/config/index.js +1 -0
- package/dist/esm/types/properties/config/line.d.ts +55 -2
- package/dist/esm/types/properties/config/line.js +3 -1
- package/dist/esm/types/properties/config/line.js.map +1 -1
- package/dist/esm/types/properties/config/pie.d.ts +120 -0
- package/dist/esm/types/properties/config/pie.js +6 -2
- package/dist/esm/types/properties/config/pie.js.map +1 -1
- package/dist/esm/types/properties/config/race.d.ts +330 -12
- package/dist/esm/types/properties/config/rose.d.ts +80 -0
- package/dist/esm/types/properties/config/rose.js +3 -1
- package/dist/esm/types/properties/config/rose.js.map +1 -1
- package/dist/esm/types/properties/config/scatter.d.ts +55 -2
- package/dist/esm/types/properties/config/scatter.js +3 -1
- package/dist/esm/types/properties/config/scatter.js.map +1 -1
- package/dist/esm/types/properties/theme/customTheme.d.ts +2250 -76
- package/dist/umd/index.js +5152 -689
- package/dist/umd/index.js.map +1 -1
- package/package.json +4 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationAreaBand.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/annotationAreaBand.ts"],"sourcesContent":["import { type ICartesianSeries, type ILineChartSpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { Datum, VChartSpecPipe, VSeed } from 'src/types'\nimport { ANNOTATION_AREA_TEXT_STYLE_BY_POSITION, isSubset } from './utils'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport { isBarLikeChart } from 'src/pipeline/utils/chatType'\n\nexport const annotationAreaBand: VChartSpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const { annotation, config } = advancedVSeed\n\n if (!annotation || !annotation.annotationArea) {\n return spec\n }\n const theme = config?.[vseed.chartType as 'column']?.annotation?.annotationArea\n const { annotationArea } = annotation\n const annotationAreaList = Array.isArray(annotationArea) ? annotationArea : [annotationArea]\n\n const positionMap = {\n top: 'insideTop',\n topRight: 'insideTopRight',\n topLeft: 'insideTopLeft',\n bottom: 'insideBottom',\n bottomLeft: 'insideBottomLeft',\n bottomRight: 'insideBottomRight',\n left: 'insideLeft',\n right: 'insideRight',\n }\n const defaultTextPosition = isBarLikeChart(advancedVSeed as VSeed) ? 'right' : 'top'\n\n const markArea = annotationAreaList.flatMap((annotationArea) => {\n const {\n selector: selectorPoint,\n text = '',\n textColor = theme?.textColor ?? '#ffffff',\n textFontSize = theme?.textFontSize ?? 12,\n textFontWeight = theme?.textFontWeight ?? 400,\n\n textBackgroundVisible = theme?.textBackgroundVisible ?? true,\n textBackgroundColor = theme?.textBackgroundColor ?? '#191d24',\n textBackgroundBorderColor = theme?.textBackgroundBorderColor ?? '#191d24',\n textBackgroundBorderWidth = theme?.textBackgroundBorderWidth ?? 1,\n textBackgroundBorderRadius = theme?.textBackgroundBorderRadius ?? 4,\n textBackgroundPadding = theme?.textBackgroundPadding ?? 4,\n\n areaColor = theme?.areaColor ?? '#888888',\n areaColorOpacity = theme?.areaColorOpacity ?? 0.15,\n areaBorderColor = theme?.areaBorderColor ?? '#888888',\n areaBorderRadius = theme?.areaBorderRadius ?? 4,\n areaBorderWidth = theme?.areaBorderWidth ?? 1,\n areaLineDash = theme?.areaLineDash,\n\n outerPadding = theme?.outerPadding ?? 4,\n } = annotationArea\n const textPosition: string = annotationArea.textPosition ?? defaultTextPosition\n const textAlign =\n annotationArea.textAlign ??\n ANNOTATION_AREA_TEXT_STYLE_BY_POSITION[textPosition as keyof typeof ANNOTATION_AREA_TEXT_STYLE_BY_POSITION]\n .textAlign\n const textBaseline =\n annotationArea.textBaseline ??\n ANNOTATION_AREA_TEXT_STYLE_BY_POSITION[textPosition as keyof typeof ANNOTATION_AREA_TEXT_STYLE_BY_POSITION]\n .textBaseline\n\n const dataset = advancedVSeed.dataset.flat()\n const selectedData = selectorPoint ? dataset.filter((datum) => selector(datum, selectorPoint)) : []\n\n return {\n zIndex: ANNOTATION_Z_INDEX,\n regionRelative: true,\n // coordinates: selectedData,\n positions: (data: Datum[], context: ICartesianSeries & { _scaleConfig?: { bandPosition?: number } }) => {\n const positionData = data.filter((item) => selectedData.some((datum) => isSubset(datum, item)))\n const xyList = positionData.map((datum) => context.dataToPosition(datum) as { x: number; y: number })\n\n const bandPosition = context?._scaleConfig?.bandPosition || 0\n\n const yAxisHelper = context.getYAxisHelper() as unknown as {\n getBandwidth: (depth?: number) => number\n getScale: () => {\n range: () => number[]\n }\n }\n const xAxisHelper = context.getXAxisHelper() as unknown as {\n getBandwidth: (depth?: number) => number\n getScale: () => {\n range: () => number[]\n }\n }\n\n if (typeof xAxisHelper?.getBandwidth === 'function') {\n const depth = context.fieldX.length ?? 0\n const xBandWidth = xAxisHelper?.getBandwidth?.(depth - 1)\n const regionRect = context.getRegion().getLayoutRect()\n const startX = Math.min(...xyList.map((item) => item.x)) - (outerPadding || 4)\n const endX = Math.max(...xyList.map((item) => item.x)) + (outerPadding || 4)\n\n const width = endX - startX + xBandWidth\n const middleX = (endX + startX) / 2 + xBandWidth * (0.5 - bandPosition)\n\n const minX = middleX - width / 2\n const maxX = middleX + width / 2\n\n const minY = 0\n const maxY = regionRect.height\n\n return [\n // 左上\n {\n x: minX,\n y: minY,\n },\n // 右上\n {\n x: maxX,\n y: minY,\n },\n // 右下\n {\n x: maxX,\n y: maxY,\n },\n // 左下\n {\n x: minX,\n y: maxY,\n },\n ]\n }\n\n if (typeof yAxisHelper?.getBandwidth === 'function') {\n const depth = context.fieldY.length ?? 0\n const yBandWidth = yAxisHelper?.getBandwidth?.(depth - 1)\n const regionRect = context.getRegion().getLayoutRect()\n\n const startY = Math.min(...xyList.map((item) => item.y)) - (outerPadding || 4)\n const endY = Math.max(...xyList.map((item) => item.y)) + (outerPadding || 4)\n const width = endY - startY + yBandWidth\n const middleY = (endY + startY) / 2 + yBandWidth * (0.5 - bandPosition)\n\n const minY = middleY - width / 2\n const maxY = middleY + width / 2\n const minX = 0\n const maxX = regionRect.width\n\n return [\n // 左上\n {\n x: minX,\n y: minY,\n },\n // 右上\n {\n x: maxX,\n y: minY,\n },\n // 右下\n {\n x: maxX,\n y: maxY,\n },\n // 左下\n {\n x: minX,\n y: maxY,\n },\n ]\n }\n\n return []\n },\n label: {\n position: positionMap[textPosition as 'bottom'],\n visible: true,\n text: text,\n style: {\n opacity: 0.95,\n textAlign: textAlign,\n textBaseline: textBaseline,\n stroke: textBackgroundColor,\n lineWidth: 1,\n fill: textColor,\n fontSize: textFontSize,\n fontWeight: textFontWeight,\n },\n\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 fillOpacity: 1,\n },\n },\n },\n area: {\n style: {\n visible: true,\n fill: areaColor,\n fillOpacity: areaColorOpacity,\n stroke: areaBorderColor,\n lineWidth: areaBorderWidth,\n cornerRadius: areaBorderRadius,\n lineDash: areaLineDash,\n },\n },\n }\n }) as ILineChartSpec['markArea']\n\n return {\n ...spec,\n markArea: markArea,\n }\n}\n"],"names":["annotationAreaBand","spec","context","advancedVSeed","vseed","annotation","config","theme","annotationArea","annotationAreaList","Array","positionMap","defaultTextPosition","isBarLikeChart","markArea","selectorPoint","text","textColor","textFontSize","textFontWeight","textBackgroundVisible","textBackgroundColor","textBackgroundBorderColor","textBackgroundBorderWidth","textBackgroundBorderRadius","textBackgroundPadding","areaColor","areaColorOpacity","areaBorderColor","areaBorderRadius","areaBorderWidth","areaLineDash","outerPadding","textPosition","textAlign","ANNOTATION_AREA_TEXT_STYLE_BY_POSITION","textBaseline","dataset","selectedData","datum","selector","ANNOTATION_Z_INDEX","data","positionData","item","isSubset","xyList","bandPosition","yAxisHelper","xAxisHelper","depth","xBandWidth","regionRect","startX","Math","endX","width","middleX","minX","maxX","minY","maxY","yBandWidth","startY","endY","middleY"],"mappings":";;;;AAOO,MAAMA,qBAAqC,CAACC,MAAMC;IACvD,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IACjC,MAAM,EAAEG,UAAU,EAAEC,MAAM,EAAE,GAAGH;IAE/B,IAAI,CAACE,cAAc,CAACA,WAAW,cAAc,EAC3C,OAAOJ;IAET,MAAMM,QAAQD,QAAQ,CAACF,MAAM,SAAS,CAAa,EAAE,YAAY;IACjE,MAAM,EAAEI,cAAc,EAAE,GAAGH;IAC3B,MAAMI,qBAAqBC,MAAM,OAAO,CAACF,kBAAkBA,iBAAiB;QAACA;KAAe;IAE5F,MAAMG,cAAc;QAClB,KAAK;QACL,UAAU;QACV,SAAS;QACT,QAAQ;QACR,YAAY;QACZ,aAAa;QACb,MAAM;QACN,OAAO;IACT;IACA,MAAMC,s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
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationAreaBand.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/annotationAreaBand.ts"],"sourcesContent":["import { type ICartesianSeries, type ILineChartSpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { Datum, VChartSpecPipe, VSeed } from 'src/types'\nimport { ANNOTATION_AREA_TEXT_STYLE_BY_POSITION, isSubset } from './utils'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport { isBarLikeChart } from 'src/pipeline/utils/chatType'\n\nexport const annotationAreaBand: VChartSpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const { annotation, config } = advancedVSeed\n\n if (!annotation || !annotation.annotationArea) {\n return spec\n }\n const theme = config?.[vseed.chartType as 'column']?.annotation?.annotationArea\n const { annotationArea } = annotation\n const annotationAreaList = Array.isArray(annotationArea) ? annotationArea : [annotationArea]\n\n const positionMap = {\n top: 'insideTop',\n topRight: 'insideTopRight',\n topLeft: 'insideTopLeft',\n bottom: 'insideBottom',\n bottomLeft: 'insideBottomLeft',\n bottomRight: 'insideBottomRight',\n left: 'insideLeft',\n right: 'insideRight',\n }\n const defaultTextPosition = isBarLikeChart(advancedVSeed as VSeed) ? 'right' : 'top'\n\n const markArea = annotationAreaList.flatMap((annotationArea) => {\n const {\n selector: selectorPoint,\n text = '',\n textColor = theme?.textColor ?? '#ffffff',\n textFontSize = theme?.textFontSize ?? 12,\n textFontWeight = theme?.textFontWeight ?? 400,\n\n textBackgroundVisible = theme?.textBackgroundVisible ?? true,\n textBackgroundColor = theme?.textBackgroundColor ?? '#191d24',\n textBackgroundBorderColor = theme?.textBackgroundBorderColor ?? '#191d24',\n textBackgroundBorderWidth = theme?.textBackgroundBorderWidth ?? 1,\n textBackgroundBorderRadius = theme?.textBackgroundBorderRadius ?? 4,\n textBackgroundPadding = theme?.textBackgroundPadding ?? 4,\n\n areaColor = theme?.areaColor ?? '#888888',\n areaColorOpacity = theme?.areaColorOpacity ?? 0.15,\n areaBorderColor = theme?.areaBorderColor ?? '#888888',\n areaBorderRadius = theme?.areaBorderRadius ?? 4,\n areaBorderWidth = theme?.areaBorderWidth ?? 1,\n areaLineDash = theme?.areaLineDash,\n\n outerPadding = theme?.outerPadding ?? 4,\n } = annotationArea\n const textBackgroundOpacity = theme?.textBackgroundOpacity\n const textPosition: string = annotationArea.textPosition ?? defaultTextPosition\n const textAlign =\n annotationArea.textAlign ??\n ANNOTATION_AREA_TEXT_STYLE_BY_POSITION[textPosition as keyof typeof ANNOTATION_AREA_TEXT_STYLE_BY_POSITION]\n .textAlign\n const textBaseline =\n annotationArea.textBaseline ??\n ANNOTATION_AREA_TEXT_STYLE_BY_POSITION[textPosition as keyof typeof ANNOTATION_AREA_TEXT_STYLE_BY_POSITION]\n .textBaseline\n\n const dataset = advancedVSeed.dataset.flat()\n const selectedData = selectorPoint ? dataset.filter((datum) => selector(datum, selectorPoint)) : []\n\n return {\n zIndex: ANNOTATION_Z_INDEX,\n regionRelative: true,\n // coordinates: selectedData,\n positions: (data: Datum[], context: ICartesianSeries & { _scaleConfig?: { bandPosition?: number } }) => {\n const positionData = data.filter((item) => selectedData.some((datum) => isSubset(datum, item)))\n const xyList = positionData.map((datum) => context.dataToPosition(datum) as { x: number; y: number })\n\n const bandPosition = context?._scaleConfig?.bandPosition || 0\n\n const yAxisHelper = context.getYAxisHelper() as unknown as {\n getBandwidth: (depth?: number) => number\n getScale: () => {\n range: () => number[]\n }\n }\n const xAxisHelper = context.getXAxisHelper() as unknown as {\n getBandwidth: (depth?: number) => number\n getScale: () => {\n range: () => number[]\n }\n }\n\n if (typeof xAxisHelper?.getBandwidth === 'function') {\n const depth = context.fieldX.length ?? 0\n const xBandWidth = xAxisHelper?.getBandwidth?.(depth - 1)\n const regionRect = context.getRegion().getLayoutRect()\n const startX = Math.min(...xyList.map((item) => item.x)) - (outerPadding || 4)\n const endX = Math.max(...xyList.map((item) => item.x)) + (outerPadding || 4)\n\n const width = endX - startX + xBandWidth\n const middleX = (endX + startX) / 2 + xBandWidth * (0.5 - bandPosition)\n\n const minX = middleX - width / 2\n const maxX = middleX + width / 2\n\n const minY = 0\n const maxY = regionRect.height\n\n return [\n // 左上\n {\n x: minX,\n y: minY,\n },\n // 右上\n {\n x: maxX,\n y: minY,\n },\n // 右下\n {\n x: maxX,\n y: maxY,\n },\n // 左下\n {\n x: minX,\n y: maxY,\n },\n ]\n }\n\n if (typeof yAxisHelper?.getBandwidth === 'function') {\n const depth = context.fieldY.length ?? 0\n const yBandWidth = yAxisHelper?.getBandwidth?.(depth - 1)\n const regionRect = context.getRegion().getLayoutRect()\n\n const startY = Math.min(...xyList.map((item) => item.y)) - (outerPadding || 4)\n const endY = Math.max(...xyList.map((item) => item.y)) + (outerPadding || 4)\n const width = endY - startY + yBandWidth\n const middleY = (endY + startY) / 2 + yBandWidth * (0.5 - bandPosition)\n\n const minY = middleY - width / 2\n const maxY = middleY + width / 2\n const minX = 0\n const maxX = regionRect.width\n\n return [\n // 左上\n {\n x: minX,\n y: minY,\n },\n // 右上\n {\n x: maxX,\n y: minY,\n },\n // 右下\n {\n x: maxX,\n y: maxY,\n },\n // 左下\n {\n x: minX,\n y: maxY,\n },\n ]\n }\n\n return []\n },\n label: {\n position: positionMap[textPosition as 'bottom'],\n visible: true,\n text: text,\n style: {\n textAlign: textAlign,\n textBaseline: textBaseline,\n stroke: textBackgroundColor,\n lineWidth: 1,\n fill: textColor,\n fontSize: textFontSize,\n fontWeight: textFontWeight,\n },\n\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 fillOpacity: 1,\n },\n },\n },\n area: {\n style: {\n visible: true,\n fill: areaColor,\n fillOpacity: areaColorOpacity,\n stroke: areaBorderColor,\n lineWidth: areaBorderWidth,\n cornerRadius: areaBorderRadius,\n lineDash: areaLineDash,\n },\n },\n }\n }) as ILineChartSpec['markArea']\n\n return {\n ...spec,\n markArea: markArea,\n }\n}\n"],"names":["annotationAreaBand","spec","context","advancedVSeed","vseed","annotation","config","theme","annotationArea","annotationAreaList","Array","positionMap","defaultTextPosition","isBarLikeChart","markArea","selectorPoint","text","textColor","textFontSize","textFontWeight","textBackgroundVisible","textBackgroundColor","textBackgroundBorderColor","textBackgroundBorderWidth","textBackgroundBorderRadius","textBackgroundPadding","areaColor","areaColorOpacity","areaBorderColor","areaBorderRadius","areaBorderWidth","areaLineDash","outerPadding","textBackgroundOpacity","textPosition","textAlign","ANNOTATION_AREA_TEXT_STYLE_BY_POSITION","textBaseline","dataset","selectedData","datum","selector","ANNOTATION_Z_INDEX","data","positionData","item","isSubset","xyList","bandPosition","yAxisHelper","xAxisHelper","depth","xBandWidth","regionRect","startX","Math","endX","width","middleX","minX","maxX","minY","maxY","yBandWidth","startY","endY","middleY"],"mappings":";;;;AAOO,MAAMA,qBAAqC,CAACC,MAAMC;IACvD,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IACjC,MAAM,EAAEG,UAAU,EAAEC,MAAM,EAAE,GAAGH;IAE/B,IAAI,CAACE,cAAc,CAACA,WAAW,cAAc,EAC3C,OAAOJ;IAET,MAAMM,QAAQD,QAAQ,CAACF,MAAM,SAAS,CAAa,EAAE,YAAY;IACjE,MAAM,EAAEI,cAAc,EAAE,GAAGH;IAC3B,MAAMI,qBAAqBC,MAAM,OAAO,CAACF,kBAAkBA,iBAAiB;QAACA;KAAe;IAE5F,MAAMG,cAAc;QAClB,KAAK;QACL,UAAU;QACV,SAAS;QACT,QAAQ;QACR,YAAY;QACZ,aAAa;QACb,MAAM;QACN,OAAO;IACT;IACA,MAAMC,sBAAsBC,eAAeV,iBAA0B,UAAU;IAE/E,MAAMW,WAAWL,mBAAmB,OAAO,CAAC,CAACD;QAC3C,MAAM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G,CAAC,CAACF,OAASA,KAAK,CAAC,KAAMb,CAAAA,gBAAgB;oBAC5E,MAAMiC,OAAOV,KAAK,GAAG,IAAIR,OAAO,GAAG,CAAC,CAACF,OAASA,KAAK,CAAC,KAAMb,CAAAA,gBAAgB;oBAC1E,MAAMyB,QAAQQ,OAAOD,SAASD;oBAC9B,MAAMG,UAAWD,AAAAA,CAAAA,OAAOD,MAAK,IAAK,IAAID,aAAc,OAAMf,YAAW;oBAErE,MAAMa,OAAOK,UAAUT,QAAQ;oBAC/B,MAAMK,OAAOI,UAAUT,QAAQ;oBAC/B,MAAME,OAAO;oBACb,MAAMC,OAAOP,WAAW,KAAK;oBAE7B,OAAO;wBAEL;4BACE,GAAGM;4BACH,GAAGE;wBACL;wBAEA;4BACE,GAAGD;4BACH,GAAGC;wBACL;wBAEA;4BACE,GAAGD;4BACH,GAAGE;wBACL;wBAEA;4BACE,GAAGH;4BACH,GAAGG;wBACL;qBACD;gBACH;gBAEA,OAAO,EAAE;YACX;YACA,OAAO;gBACL,UAAUnD,WAAW,CAACuB,aAAyB;gBAC/C,SAAS;gBACT,MAAMlB;gBACN,OAAO;oBACL,WAAWmB;oBACX,cAAcE;oBACd,QAAQhB;oBACR,WAAW;oBACX,MAAMJ;oBACN,UAAUC;oBACV,YAAYC;gBACd;gBAEA,iBAAiB;oBACf,SAASC;oBACT,SAASK;oBACT,OAAO;wBACL,SAASQ,yBAAyB;wBAClC,cAAcT,8BAA8B;wBAC5C,MAAMH;wBACN,QAAQC;wBACR,WAAWC;wBACX,aAAa;oBACf;gBACF;YACF;YACA,MAAM;gBACJ,OAAO;oBACL,SAAS;oBACT,MAAMG;oBACN,aAAaC;oBACb,QAAQC;oBACR,WAAWE;oBACX,cAAcD;oBACd,UAAUE;gBACZ;YACF;QACF;IACF;IAEA,OAAO;QACL,GAAG9B,IAAI;QACP,UAAUa;IACZ;AACF"}
|
|
@@ -2,15 +2,16 @@ import { autoFormatter, createFormatter, findAllMeasures } from "../../../../uti
|
|
|
2
2
|
import { isDimensionSelector, isFieldSelector, isMeasureSelector, isPartialDatumSelector } from "../../../../../dataSelector/index.js";
|
|
3
3
|
import { isEmpty } from "remeda";
|
|
4
4
|
import { ANNOTATION_Z_INDEX } from "../../../../utils/constant.js";
|
|
5
|
-
import {
|
|
5
|
+
import { getAnnotationLineDash } from "./utils.js";
|
|
6
|
+
import { buildDifferenceCoordinateDatum, buildDifferenceText, getDifferenceLineStackResolveMode, getRuntimeDifferenceValue, inferDifferenceConnectDirection, resolveDifferenceAnchor, usesDifferenceLineElementStackEnd } from "./annotationDifferenceLineCommon.js";
|
|
6
7
|
const DEFAULT_LINE_COLOR = '#BCC1CB';
|
|
7
8
|
const DEFAULT_TEXT_COLOR = '#ffffff';
|
|
8
9
|
const DEFAULT_TEXT_BACKGROUND_COLOR = '#BCC1CB';
|
|
9
10
|
const DEFAULT_TEXT_FONT_SIZE = 12;
|
|
10
|
-
const DEFAULT_LINE_WIDTH =
|
|
11
|
-
const DEFAULT_CORNER_RADIUS =
|
|
11
|
+
const DEFAULT_LINE_WIDTH = 1;
|
|
12
|
+
const DEFAULT_CORNER_RADIUS = 3;
|
|
12
13
|
const DEFAULT_LABEL_PADDING = 4;
|
|
13
|
-
const DEFAULT_END_SYMBOL_SIZE =
|
|
14
|
+
const DEFAULT_END_SYMBOL_SIZE = 6;
|
|
14
15
|
const DEFAULT_END_SYMBOL_REF_X = -4;
|
|
15
16
|
const DEFAULT_GUTTER_BASE_OFFSET = 20;
|
|
16
17
|
const DEFAULT_GUTTER_RIGHT_PADDING = 44;
|
|
@@ -23,6 +24,7 @@ const DEFAULT_PERCENT_DIFFERENCE_FORMAT = {
|
|
|
23
24
|
type: 'percent',
|
|
24
25
|
fractionDigits: 2
|
|
25
26
|
};
|
|
27
|
+
const shouldInferDifferenceConnectDirection = (chartType)=>'column' === chartType || 'bar' === chartType || 'columnParallel' === chartType || 'barParallel' === chartType;
|
|
26
28
|
const getDifferenceLinePath = (index, total)=>1 === total ? 'annotationDifferenceLine' : `annotationDifferenceLine[${index}]`;
|
|
27
29
|
const toArray = (value)=>{
|
|
28
30
|
if (Array.isArray(value)) return value;
|
|
@@ -63,21 +65,45 @@ const mergeDifferenceLineRegionPadding = (spec, paddingPatch)=>{
|
|
|
63
65
|
]
|
|
64
66
|
};
|
|
65
67
|
};
|
|
66
|
-
const buildFixedGutterExpandDistance = (
|
|
68
|
+
const buildFixedGutterExpandDistance = (connectDirection)=>(_markerData, context)=>{
|
|
67
69
|
const region = context?.region;
|
|
68
70
|
const coordinatePoints = Array.isArray(context?.coordinatePoints) ? context.coordinatePoints : [];
|
|
69
71
|
if (!region || 0 === coordinatePoints.length) return 0;
|
|
70
72
|
const { x: regionStartX, y: regionStartY } = region.getLayoutStartPoint();
|
|
71
|
-
const { width } = region.getLayoutRect();
|
|
72
|
-
if (
|
|
73
|
+
const { width, height } = region.getLayoutRect();
|
|
74
|
+
if ('top' === connectDirection) {
|
|
73
75
|
const targetY = regionStartY - DEFAULT_GUTTER_BASE_OFFSET;
|
|
74
76
|
const minY = Math.min(...coordinatePoints.map((point)=>point.y));
|
|
75
77
|
return Math.max(0, minY - targetY);
|
|
76
78
|
}
|
|
79
|
+
if ('bottom' === connectDirection) {
|
|
80
|
+
const targetY = regionStartY + height + DEFAULT_GUTTER_BASE_OFFSET;
|
|
81
|
+
const maxY = Math.max(...coordinatePoints.map((point)=>point.y));
|
|
82
|
+
return Math.max(0, targetY - maxY);
|
|
83
|
+
}
|
|
84
|
+
if ('left' === connectDirection) {
|
|
85
|
+
const targetX = regionStartX - DEFAULT_GUTTER_BASE_OFFSET;
|
|
86
|
+
const minX = Math.min(...coordinatePoints.map((point)=>point.x));
|
|
87
|
+
return Math.max(0, minX - targetX);
|
|
88
|
+
}
|
|
77
89
|
const targetX = regionStartX + width + DEFAULT_GUTTER_BASE_OFFSET;
|
|
78
90
|
const maxX = Math.max(...coordinatePoints.map((point)=>point.x));
|
|
79
91
|
return Math.max(0, targetX - maxX);
|
|
80
92
|
};
|
|
93
|
+
const getDifferenceLinePaddingPatch = (connectDirection)=>{
|
|
94
|
+
if ('top' === connectDirection) return {
|
|
95
|
+
top: DEFAULT_GUTTER_TOP_PADDING
|
|
96
|
+
};
|
|
97
|
+
if ('bottom' === connectDirection) return {
|
|
98
|
+
bottom: DEFAULT_GUTTER_TOP_PADDING
|
|
99
|
+
};
|
|
100
|
+
if ('left' === connectDirection) return {
|
|
101
|
+
left: DEFAULT_GUTTER_RIGHT_PADDING
|
|
102
|
+
};
|
|
103
|
+
return {
|
|
104
|
+
right: DEFAULT_GUTTER_RIGHT_PADDING
|
|
105
|
+
};
|
|
106
|
+
};
|
|
81
107
|
const getAxisFormatter = (spec)=>{
|
|
82
108
|
const valueAxisOrient = 'horizontal' === spec.direction ? 'bottom' : 'left';
|
|
83
109
|
const formatMethod = spec.axes?.find((axis)=>axis.orient === valueAxisOrient)?.label?.formatMethod;
|
|
@@ -146,6 +172,12 @@ const annotationDifferenceLine_annotationDifferenceLine = (spec, context)=>{
|
|
|
146
172
|
const axisFormatter = getAxisFormatter(chartSpec);
|
|
147
173
|
const percentFormatter = createFormatter(DEFAULT_PERCENT_DIFFERENCE_FORMAT);
|
|
148
174
|
const isHorizontalChart = 'horizontal' === chartSpec.direction;
|
|
175
|
+
const paddingPatch = {
|
|
176
|
+
top: 0,
|
|
177
|
+
right: 0,
|
|
178
|
+
bottom: 0,
|
|
179
|
+
left: 0
|
|
180
|
+
};
|
|
149
181
|
const markLine = annotationDifferenceLineList.flatMap((annotationDifferenceLine, index)=>{
|
|
150
182
|
try {
|
|
151
183
|
assertDifferenceLineConfig(annotationDifferenceLine, getDifferenceLinePath(index, annotationDifferenceLineList.length));
|
|
@@ -169,11 +201,23 @@ const annotationDifferenceLine_annotationDifferenceLine = (spec, context)=>{
|
|
|
169
201
|
if (start.mode !== end.mode) return [];
|
|
170
202
|
const usesRuntimeStackEnd = useElementStackEnd || ('column' === vseed.chartType || 'bar' === vseed.chartType) && 'element' === start.mode && 'auto' === stackResolveMode;
|
|
171
203
|
const useBracketStyle = isBracketChart || ('column' === vseed.chartType || 'bar' === vseed.chartType) && 'element' === start.mode && 'auto' === stackResolveMode;
|
|
172
|
-
const connectDirection =
|
|
173
|
-
|
|
204
|
+
const connectDirection = shouldInferDifferenceConnectDirection(vseed.chartType) ? inferDifferenceConnectDirection(vseed, [
|
|
205
|
+
start.value,
|
|
206
|
+
end.value
|
|
207
|
+
]) : isHorizontalChart ? 'top' : 'right';
|
|
208
|
+
const expandDistance = buildFixedGutterExpandDistance(connectDirection);
|
|
209
|
+
const currentPaddingPatch = getDifferenceLinePaddingPatch(connectDirection);
|
|
210
|
+
paddingPatch.top = Math.max(paddingPatch.top, currentPaddingPatch.top ?? 0);
|
|
211
|
+
paddingPatch.right = Math.max(paddingPatch.right, currentPaddingPatch.right ?? 0);
|
|
212
|
+
paddingPatch.bottom = Math.max(paddingPatch.bottom, currentPaddingPatch.bottom ?? 0);
|
|
213
|
+
paddingPatch.left = Math.max(paddingPatch.left, currentPaddingPatch.left ?? 0);
|
|
174
214
|
const lineColor = annotationDifferenceLine.lineColor ?? theme?.lineColor ?? DEFAULT_LINE_COLOR;
|
|
215
|
+
const lineStyle = annotationDifferenceLine.lineStyle;
|
|
216
|
+
const themeLineStyle = theme?.lineStyle;
|
|
217
|
+
const configuredLineDash = lineStyle ? getAnnotationLineDash(lineStyle) : theme?.lineDash ?? (themeLineStyle ? getAnnotationLineDash(themeLineStyle) : void 0);
|
|
175
218
|
const textColor = annotationDifferenceLine.textColor ?? theme?.textColor ?? DEFAULT_TEXT_COLOR;
|
|
176
219
|
const textBackgroundColor = annotationDifferenceLine.textBackgroundColor ?? theme?.textBackgroundColor ?? DEFAULT_TEXT_BACKGROUND_COLOR;
|
|
220
|
+
const textBackgroundOpacity = theme?.textBackgroundOpacity;
|
|
177
221
|
const textFontSize = annotationDifferenceLine.textFontSize ?? theme?.textFontSize ?? DEFAULT_TEXT_FONT_SIZE;
|
|
178
222
|
const differenceType = annotationDifferenceLine.differenceType ?? 'absolute';
|
|
179
223
|
const startMeasureId = resolveDifferenceMeasureId(start, annotationDifferenceLine.start.selector, measureIds);
|
|
@@ -208,6 +252,7 @@ const annotationDifferenceLine_annotationDifferenceLine = (spec, context)=>{
|
|
|
208
252
|
visible: true,
|
|
209
253
|
padding: DEFAULT_LABEL_PADDING,
|
|
210
254
|
style: {
|
|
255
|
+
opacity: textBackgroundOpacity ?? 0.95,
|
|
211
256
|
fill: textBackgroundColor,
|
|
212
257
|
fillOpacity: 1,
|
|
213
258
|
stroke: lineColor,
|
|
@@ -228,6 +273,7 @@ const annotationDifferenceLine_annotationDifferenceLine = (spec, context)=>{
|
|
|
228
273
|
visible: true,
|
|
229
274
|
padding: DEFAULT_LABEL_PADDING,
|
|
230
275
|
style: {
|
|
276
|
+
opacity: textBackgroundOpacity ?? 0.95,
|
|
231
277
|
fill: textBackgroundColor,
|
|
232
278
|
fillOpacity: 1,
|
|
233
279
|
stroke: lineColor,
|
|
@@ -271,18 +317,21 @@ const annotationDifferenceLine_annotationDifferenceLine = (spec, context)=>{
|
|
|
271
317
|
visible: true,
|
|
272
318
|
stroke: lineColor,
|
|
273
319
|
lineWidth: DEFAULT_LINE_WIDTH,
|
|
274
|
-
lineDash: DEFAULT_BRACKET_LINE_DASH
|
|
320
|
+
lineDash: configuredLineDash ?? DEFAULT_BRACKET_LINE_DASH
|
|
275
321
|
},
|
|
276
322
|
{
|
|
277
323
|
visible: true,
|
|
278
324
|
stroke: lineColor,
|
|
279
|
-
lineWidth: DEFAULT_LINE_WIDTH
|
|
325
|
+
lineWidth: DEFAULT_LINE_WIDTH,
|
|
326
|
+
...configuredLineDash ? {
|
|
327
|
+
lineDash: configuredLineDash
|
|
328
|
+
} : {}
|
|
280
329
|
},
|
|
281
330
|
{
|
|
282
331
|
visible: true,
|
|
283
332
|
stroke: lineColor,
|
|
284
333
|
lineWidth: DEFAULT_LINE_WIDTH,
|
|
285
|
-
lineDash: DEFAULT_BRACKET_LINE_DASH
|
|
334
|
+
lineDash: configuredLineDash ?? DEFAULT_BRACKET_LINE_DASH
|
|
286
335
|
}
|
|
287
336
|
]
|
|
288
337
|
} : {
|
|
@@ -290,7 +339,7 @@ const annotationDifferenceLine_annotationDifferenceLine = (spec, context)=>{
|
|
|
290
339
|
visible: true,
|
|
291
340
|
stroke: lineColor,
|
|
292
341
|
lineWidth: DEFAULT_LINE_WIDTH,
|
|
293
|
-
lineDash: [
|
|
342
|
+
lineDash: configuredLineDash ?? [
|
|
294
343
|
0
|
|
295
344
|
],
|
|
296
345
|
cornerRadius: DEFAULT_CORNER_RADIUS
|
|
@@ -323,11 +372,7 @@ const annotationDifferenceLine_annotationDifferenceLine = (spec, context)=>{
|
|
|
323
372
|
]
|
|
324
373
|
};
|
|
325
374
|
if (0 === markLine.length) return nextSpec;
|
|
326
|
-
return mergeDifferenceLineRegionPadding(nextSpec,
|
|
327
|
-
top: DEFAULT_GUTTER_TOP_PADDING
|
|
328
|
-
} : {
|
|
329
|
-
right: DEFAULT_GUTTER_RIGHT_PADDING
|
|
330
|
-
});
|
|
375
|
+
return mergeDifferenceLineRegionPadding(nextSpec, paddingPatch);
|
|
331
376
|
};
|
|
332
377
|
export { annotationDifferenceLine_annotationDifferenceLine as annotationDifferenceLine };
|
|
333
378
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationDifferenceLine.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/annotationDifferenceLine.ts"],"sourcesContent":["import type { IAreaChartSpec, IBarChartSpec, ICartesianSeries, ILineChartSpec, IMarkLineSpec } from '@visactor/vchart'\nimport type { AnnotationDifferenceLine, Measure, RegionPadding, VChartSpecPipe } from 'src/types'\nimport { createFormatter, findAllMeasures, autoFormatter } from '../../../../utils'\nimport {\n isDimensionSelector,\n isFieldSelector,\n isMeasureSelector,\n isPartialDatumSelector,\n} from '../../../../../dataSelector'\nimport { isEmpty } from 'remeda'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport {\n buildDifferenceCoordinateDatum,\n buildDifferenceText,\n getDifferenceLineStackResolveMode,\n getRuntimeDifferenceValue,\n type ResolvedDifferenceAnchor,\n usesDifferenceLineElementStackEnd,\n resolveDifferenceAnchor,\n} from './annotationDifferenceLineCommon'\n\nconst DEFAULT_LINE_COLOR = '#BCC1CB'\nconst DEFAULT_TEXT_COLOR = '#ffffff'\nconst DEFAULT_TEXT_BACKGROUND_COLOR = '#BCC1CB'\nconst DEFAULT_TEXT_FONT_SIZE = 12\nconst DEFAULT_LINE_WIDTH = 2\nconst DEFAULT_CORNER_RADIUS = 4\nconst DEFAULT_LABEL_PADDING = 4\nconst DEFAULT_END_SYMBOL_SIZE = 12\nconst DEFAULT_END_SYMBOL_REF_X = -4\nconst DEFAULT_GUTTER_BASE_OFFSET = 20\nconst DEFAULT_GUTTER_RIGHT_PADDING = 44\nconst DEFAULT_GUTTER_TOP_PADDING = 36\nconst DEFAULT_BRACKET_LINE_DASH: [number, number] = [2, 2]\nconst DEFAULT_PERCENT_DIFFERENCE_FORMAT = {\n type: 'percent' as const,\n fractionDigits: 2,\n}\n\ntype RegionPaddingObject = Required<Exclude<RegionPadding, number>>\n\nconst getDifferenceLinePath = (index: number, total: number) =>\n total === 1 ? 'annotationDifferenceLine' : `annotationDifferenceLine[${index}]`\n\nconst toArray = <T>(value: T | T[] | undefined | null): T[] => {\n if (Array.isArray(value)) {\n return value\n }\n\n return value === undefined || value === null ? [] : [value]\n}\n\nconst normalizeRegionPadding = (padding?: RegionPadding): RegionPaddingObject => {\n if (typeof padding === 'number') {\n return {\n top: padding,\n right: padding,\n bottom: padding,\n left: padding,\n }\n }\n\n return {\n top: padding?.top ?? 0,\n right: padding?.right ?? 0,\n bottom: padding?.bottom ?? 0,\n left: padding?.left ?? 0,\n }\n}\n\nconst mergeDifferenceLineRegionPadding = (\n spec: IBarChartSpec | ILineChartSpec | IAreaChartSpec,\n paddingPatch: Partial<RegionPaddingObject>,\n) => {\n const region = (spec as { region?: Array<Record<string, unknown>> }).region\n\n if (!Array.isArray(region) || region.length === 0) {\n return spec\n }\n\n const mergedPadding = normalizeRegionPadding(region[0].padding as RegionPadding | undefined)\n\n if (paddingPatch.top !== undefined) {\n mergedPadding.top = Math.max(mergedPadding.top, paddingPatch.top)\n }\n\n if (paddingPatch.right !== undefined) {\n mergedPadding.right = Math.max(mergedPadding.right, paddingPatch.right)\n }\n\n if (paddingPatch.bottom !== undefined) {\n mergedPadding.bottom = Math.max(mergedPadding.bottom, paddingPatch.bottom)\n }\n\n if (paddingPatch.left !== undefined) {\n mergedPadding.left = Math.max(mergedPadding.left, paddingPatch.left)\n }\n\n return {\n ...spec,\n region: [\n {\n ...region[0],\n padding: mergedPadding,\n },\n ...region.slice(1),\n ],\n }\n}\n\nconst buildFixedGutterExpandDistance = (isHorizontalChart: boolean) => {\n return (_markerData: unknown, context: any) => {\n const region = context?.region\n const coordinatePoints = Array.isArray(context?.coordinatePoints) ? context.coordinatePoints : []\n\n if (!region || coordinatePoints.length === 0) {\n return 0\n }\n\n const { x: regionStartX, y: regionStartY } = region.getLayoutStartPoint()\n const { width } = region.getLayoutRect()\n\n if (isHorizontalChart) {\n const targetY = regionStartY - DEFAULT_GUTTER_BASE_OFFSET\n const minY = Math.min(...coordinatePoints.map((point: { y: number }) => point.y))\n\n return Math.max(0, minY - targetY)\n }\n\n const targetX = regionStartX + width + DEFAULT_GUTTER_BASE_OFFSET\n const maxX = Math.max(...coordinatePoints.map((point: { x: number }) => point.x))\n\n return Math.max(0, targetX - maxX)\n }\n}\n\nconst getAxisFormatter = (spec: IBarChartSpec | ILineChartSpec | IAreaChartSpec) => {\n const valueAxisOrient = spec.direction === 'horizontal' ? 'bottom' : 'left'\n const formatMethod = spec.axes?.find((axis) => axis.orient === valueAxisOrient)?.label?.formatMethod\n\n return typeof formatMethod === 'function'\n ? (value: number) => String(formatMethod(value as never) ?? value)\n : undefined\n}\n\nconst getExplicitMeasureFormat = (measure?: Measure) => {\n if (measure?.numFormat && !isEmpty(measure.numFormat)) {\n return measure.numFormat\n }\n\n if (measure?.format && !isEmpty(measure.format)) {\n return measure.format\n }\n\n return undefined\n}\n\nconst inferMeasureIdFromDatum = (anchor: ResolvedDifferenceAnchor, measureIds: string[]) => {\n const candidateValues = [anchor.matchedDatum, anchor.coordinateDatum]\n\n for (const datum of candidateValues) {\n if (!datum) {\n continue\n }\n\n const candidates = measureIds.filter((measureId) => Number(datum[measureId]) === anchor.value)\n\n if (candidates.length === 1) {\n return candidates[0]\n }\n }\n\n return undefined\n}\n\nconst inferMeasureIdFromSelector = (\n selectorValue: AnnotationDifferenceLine['start']['selector'],\n measureIdSet: Set<string>,\n) => {\n const matchedMeasureIds = new Set<string>()\n\n for (const currentSelector of toArray(selectorValue)) {\n if (isMeasureSelector(currentSelector)) {\n if (measureIdSet.has(currentSelector.field)) {\n matchedMeasureIds.add(currentSelector.field)\n }\n continue\n }\n\n if (isFieldSelector(currentSelector) || isDimensionSelector(currentSelector)) {\n continue\n }\n\n if (isPartialDatumSelector(currentSelector)) {\n Object.keys(currentSelector).forEach((field) => {\n if (measureIdSet.has(field)) {\n matchedMeasureIds.add(field)\n }\n })\n }\n }\n\n return matchedMeasureIds.size === 1 ? Array.from(matchedMeasureIds)[0] : undefined\n}\n\nconst resolveDifferenceMeasureId = (\n anchor: ResolvedDifferenceAnchor,\n selectorValue: AnnotationDifferenceLine['start']['selector'],\n measureIds: string[],\n) => {\n if (anchor.mode !== 'element') {\n return undefined\n }\n\n if (measureIds.length === 1) {\n return measureIds[0]\n }\n\n const measureIdSet = new Set(measureIds)\n return inferMeasureIdFromSelector(selectorValue, measureIdSet) ?? inferMeasureIdFromDatum(anchor, measureIds)\n}\n\nconst assertDifferenceLineConfig: (value: unknown, path: string) => asserts value is AnnotationDifferenceLine = (\n value,\n path,\n) => {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new Error(`${path} must be an object`)\n }\n\n const start = (value as Record<string, unknown>).start\n if (typeof start !== 'object' || start === null || Array.isArray(start)) {\n throw new Error(`${path}.start is required`)\n }\n if ((start as Record<string, unknown>).selector == null) {\n throw new Error(`${path}.start.selector is required`)\n }\n\n const end = (value as Record<string, unknown>).end\n if (typeof end !== 'object' || end === null || Array.isArray(end)) {\n throw new Error(`${path}.end is required`)\n }\n if ((end as Record<string, unknown>).selector == null) {\n throw new Error(`${path}.end.selector is required`)\n }\n}\n\nexport const annotationDifferenceLine: VChartSpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const annotationDifferenceLine = advancedVSeed.annotation?.annotationDifferenceLine\n\n if (!annotationDifferenceLine) {\n return spec\n }\n\n const theme = advancedVSeed.config?.[vseed.chartType as 'column']?.annotation?.annotationDifferenceLine\n const annotationDifferenceLineList = Array.isArray(annotationDifferenceLine)\n ? annotationDifferenceLine\n : [annotationDifferenceLine]\n const dataset = advancedVSeed.dataset.flat()\n const chartSpec = spec as IBarChartSpec | ILineChartSpec | IAreaChartSpec\n const stackResolveMode = getDifferenceLineStackResolveMode(vseed, advancedVSeed)\n const useElementStackEnd = usesDifferenceLineElementStackEnd(vseed, advancedVSeed)\n const isBracketChart = vseed.chartType === 'line' || vseed.chartType === 'area'\n const measures = findAllMeasures(advancedVSeed.measures)\n const measureIds = measures.map((measure) => measure.id)\n const axisFormatter = getAxisFormatter(chartSpec)\n const percentFormatter = createFormatter(DEFAULT_PERCENT_DIFFERENCE_FORMAT)\n const isHorizontalChart = chartSpec.direction === 'horizontal'\n\n const markLine = annotationDifferenceLineList.flatMap((annotationDifferenceLine, index) => {\n try {\n assertDifferenceLineConfig(\n annotationDifferenceLine,\n getDifferenceLinePath(index, annotationDifferenceLineList.length),\n )\n\n const start = resolveDifferenceAnchor({\n dataset,\n selectorLabel: 'start',\n selectorValue: annotationDifferenceLine.start.selector,\n spec: chartSpec,\n stackResolveMode,\n allowSelectorFallback: !useElementStackEnd,\n })\n const end = resolveDifferenceAnchor({\n dataset,\n selectorLabel: 'end',\n selectorValue: annotationDifferenceLine.end.selector,\n spec: chartSpec,\n stackResolveMode,\n allowSelectorFallback: !useElementStackEnd,\n })\n\n if (!start || !end) {\n return []\n }\n\n if (start.mode !== end.mode) {\n return []\n }\n\n const usesRuntimeStackEnd =\n useElementStackEnd ||\n ((vseed.chartType === 'column' || vseed.chartType === 'bar') &&\n start.mode === 'element' &&\n stackResolveMode === 'auto')\n const useBracketStyle =\n isBracketChart ||\n ((vseed.chartType === 'column' || vseed.chartType === 'bar') &&\n start.mode === 'element' &&\n stackResolveMode === 'auto')\n const connectDirection = isHorizontalChart ? 'top' : 'right'\n const expandDistance = buildFixedGutterExpandDistance(isHorizontalChart)\n\n const lineColor = annotationDifferenceLine.lineColor ?? theme?.lineColor ?? DEFAULT_LINE_COLOR\n const textColor = annotationDifferenceLine.textColor ?? theme?.textColor ?? DEFAULT_TEXT_COLOR\n const textBackgroundColor =\n annotationDifferenceLine.textBackgroundColor ?? theme?.textBackgroundColor ?? DEFAULT_TEXT_BACKGROUND_COLOR\n const textFontSize = annotationDifferenceLine.textFontSize ?? theme?.textFontSize ?? DEFAULT_TEXT_FONT_SIZE\n const differenceType = annotationDifferenceLine.differenceType ?? 'absolute'\n const startMeasureId = resolveDifferenceMeasureId(start, annotationDifferenceLine.start.selector, measureIds)\n const endMeasureId = resolveDifferenceMeasureId(end, annotationDifferenceLine.end.selector, measureIds)\n const sameMeasure = startMeasureId !== undefined && startMeasureId === endMeasureId\n const explicitMeasureFormat = sameMeasure\n ? getExplicitMeasureFormat(measures.find((measure) => measure.id === startMeasureId))\n : undefined\n const differenceFormatter =\n differenceType === 'percent'\n ? percentFormatter\n : explicitMeasureFormat\n ? createFormatter(explicitMeasureFormat)\n : (axisFormatter ?? autoFormatter)\n\n const label = usesRuntimeStackEnd\n ? {\n visible: true,\n position: 'middle',\n refY: 0,\n formatMethod: (_markData: any[], seriesData: any[]) => {\n try {\n return buildDifferenceText(\n getRuntimeDifferenceValue({\n anchor: start,\n seriesData,\n useElementStackEnd: usesRuntimeStackEnd,\n }),\n getRuntimeDifferenceValue({\n anchor: end,\n seriesData,\n useElementStackEnd: usesRuntimeStackEnd,\n }),\n differenceType,\n differenceFormatter,\n )\n } catch {\n return ''\n }\n },\n style: {\n fill: textColor,\n fontSize: textFontSize,\n },\n labelBackground: {\n visible: true,\n padding: DEFAULT_LABEL_PADDING,\n style: {\n fill: textBackgroundColor,\n fillOpacity: 1,\n stroke: lineColor,\n lineWidth: 1,\n cornerRadius: DEFAULT_CORNER_RADIUS,\n },\n },\n }\n : {\n visible: true,\n position: 'middle',\n refY: 0,\n text: buildDifferenceText(start.value, end.value, differenceType, differenceFormatter),\n style: {\n fill: textColor,\n fontSize: textFontSize,\n },\n labelBackground: {\n visible: true,\n padding: DEFAULT_LABEL_PADDING,\n style: {\n fill: textBackgroundColor,\n fillOpacity: 1,\n stroke: lineColor,\n lineWidth: 1,\n cornerRadius: DEFAULT_CORNER_RADIUS,\n },\n },\n }\n\n return [\n {\n type: 'type-step',\n autoRange: true,\n zIndex: ANNOTATION_Z_INDEX,\n connectDirection,\n expandDistance,\n coordinates: (seriesData: any[], relativeSeries: ICartesianSeries) => {\n try {\n return [\n buildDifferenceCoordinateDatum({\n anchor: start,\n seriesData,\n relativeSeries,\n useElementStackEnd: usesRuntimeStackEnd,\n }),\n buildDifferenceCoordinateDatum({\n anchor: end,\n seriesData,\n relativeSeries,\n useElementStackEnd: usesRuntimeStackEnd,\n }),\n ]\n } catch {\n return []\n }\n },\n line: useBracketStyle\n ? {\n multiSegment: true,\n mainSegmentIndex: 1,\n style: [\n {\n visible: true,\n stroke: lineColor,\n lineWidth: DEFAULT_LINE_WIDTH,\n lineDash: DEFAULT_BRACKET_LINE_DASH,\n },\n {\n visible: true,\n stroke: lineColor,\n lineWidth: DEFAULT_LINE_WIDTH,\n },\n {\n visible: true,\n stroke: lineColor,\n lineWidth: DEFAULT_LINE_WIDTH,\n lineDash: DEFAULT_BRACKET_LINE_DASH,\n },\n ],\n }\n : {\n style: {\n visible: true,\n stroke: lineColor,\n lineWidth: DEFAULT_LINE_WIDTH,\n lineDash: [0],\n cornerRadius: DEFAULT_CORNER_RADIUS,\n },\n },\n label,\n startSymbol: {\n visible: false,\n },\n endSymbol: {\n visible: true,\n size: DEFAULT_END_SYMBOL_SIZE,\n refX: DEFAULT_END_SYMBOL_REF_X,\n style: {\n fill: lineColor,\n },\n },\n } as IMarkLineSpec,\n ]\n } catch {\n return []\n }\n })\n\n const specMarkLine = (chartSpec.markLine as IMarkLineSpec[]) || []\n const nextSpec = {\n ...spec,\n markLine: [...specMarkLine, ...markLine],\n }\n\n if (markLine.length === 0) {\n return nextSpec\n }\n\n return mergeDifferenceLineRegionPadding(\n nextSpec as IBarChartSpec | ILineChartSpec | IAreaChartSpec,\n isHorizontalChart ? { top: DEFAULT_GUTTER_TOP_PADDING } : { right: DEFAULT_GUTTER_RIGHT_PADDING },\n )\n}\n"],"names":["DEFAULT_LINE_COLOR","DEFAULT_TEXT_COLOR","DEFAULT_TEXT_BACKGROUND_COLOR","DEFAULT_TEXT_FONT_SIZE","DEFAULT_LINE_WIDTH","DEFAULT_CORNER_RADIUS","DEFAULT_LABEL_PADDING","DEFAULT_END_SYMBOL_SIZE","DEFAULT_END_SYMBOL_REF_X","DEFAULT_GUTTER_BASE_OFFSET","DEFAULT_GUTTER_RIGHT_PADDING","DEFAULT_GUTTER_TOP_PADDING","DEFAULT_BRACKET_LINE_DASH","DEFAULT_PERCENT_DIFFERENCE_FORMAT","getDifferenceLinePath","index","total","toArray","value","Array","normalizeRegionPadding","padding","mergeDifferenceLineRegionPadding","spec","paddingPatch","region","mergedPadding","undefined","Math","buildFixedGutterExpandDistance","isHorizontalChart","_markerData","context","coordinatePoints","regionStartX","regionStartY","width","targetY","minY","point","targetX","maxX","getAxisFormatter","valueAxisOrient","formatMethod","axis","String","getExplicitMeasureFormat","measure","isEmpty","inferMeasureIdFromDatum","anchor","measureIds","candidateValues","datum","candidates","measureId","Number","inferMeasureIdFromSelector","selectorValue","measureIdSet","matchedMeasureIds","Set","currentSelector","isMeasureSelector","isFieldSelector","isDimensionSelector","isPartialDatumSelector","Object","field","resolveDifferenceMeasureId","assertDifferenceLineConfig","path","Error","start","end","annotationDifferenceLine","advancedVSeed","vseed","theme","annotationDifferenceLineList","dataset","chartSpec","stackResolveMode","getDifferenceLineStackResolveMode","useElementStackEnd","usesDifferenceLineElementStackEnd","isBracketChart","measures","findAllMeasures","axisFormatter","percentFormatter","createFormatter","markLine","resolveDifferenceAnchor","usesRuntimeStackEnd","useBracketStyle","connectDirection","expandDistance","lineColor","textColor","textBackgroundColor","textFontSize","differenceType","startMeasureId","endMeasureId","sameMeasure","explicitMeasureFormat","differenceFormatter","autoFormatter","label","_markData","seriesData","buildDifferenceText","getRuntimeDifferenceValue","ANNOTATION_Z_INDEX","relativeSeries","buildDifferenceCoordinateDatum","specMarkLine","nextSpec"],"mappings":";;;;;AAqBA,MAAMA,qBAAqB;AAC3B,MAAMC,qBAAqB;AAC3B,MAAMC,gCAAgC;AACtC,MAAMC,yBAAyB;AAC/B,MAAMC,qBAAqB;AAC3B,MAAMC,wBAAwB;AAC9B,MAAMC,wBAAwB;AAC9B,MAAMC,0BAA0B;AAChC,MAAMC,2BAA2B;AACjC,MAAMC,6BAA6B;AACnC,MAAMC,+BAA+B;AACrC,MAAMC,6BAA6B;AACnC,MAAMC,4BAA8C;IAAC;IAAG;CAAE;AAC1D,MAAMC,oCAAoC;IACxC,MAAM;IACN,gBAAgB;AAClB;AAIA,MAAMC,wBAAwB,CAACC,OAAeC,QAC5CA,AAAU,MAAVA,QAAc,6BAA6B,CAAC,yBAAyB,EAAED,MAAM,CAAC,CAAC;AAEjF,MAAME,UAAU,CAAIC;IAClB,IAAIC,MAAM,OAAO,CAACD,QAChB,OAAOA;IAGT,OAAOA,QAAAA,QAAwC,EAAE,GAAG;QAACA;KAAM;AAC7D;AAEA,MAAME,yBAAyB,CAACC;IAC9B,IAAI,AAAmB,YA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;oBACAC;oBACA,aAAa,CAACc,YAAmBI;wBAC/B,IAAI;4BACF,OAAO;gCACLC,+BAA+B;oCAC7B,QAAQ3C;oCACRsC;oCACAI;oCACA,oBAAoBrB;gCACtB;gCACAsB,+BAA+B;oCAC7B,QAAQ1C;oCACRqC;oCACAI;oCACA,oBAAoBrB;gCACtB;6BACD;wBACH,EAAE,OAAM;4BACN,OAAO,EAAE;wBACX;oBACF;oBACA,MAAMC,kBACF;wBACE,cAAc;wBACd,kBAAkB;wBAClB,OAAO;4BACL;gCACE,SAAS;gCACT,QAAQG;gCACR,WAAW/F;gCACX,UAAUQ;4BACZ;4BACA;gCACE,SAAS;gCACT,QAAQuF;gCACR,WAAW/F;4BACb;4BACA;gCACE,SAAS;gCACT,QAAQ+F;gCACR,WAAW/F;gCACX,UAAUQ;4BACZ;yBACD;oBACH,IACA;wBACE,OAAO;4BACL,SAAS;4BACT,QAAQuF;4BACR,WAAW/F;4BACX,UAAU;gCAAC;6BAAE;4BACb,cAAcC;wBAChB;oBACF;oBACJyG;oBACA,aAAa;wBACX,SAAS;oBACX;oBACA,WAAW;wBACT,SAAS;wBACT,MAAMvG;wBACN,MAAMC;wBACN,OAAO;4BACL,MAAM2F;wBACR;oBACF;gBACF;aACD;QACH,EAAE,OAAM;YACN,OAAO,EAAE;QACX;IACF;IAEA,MAAMmB,eAAgBpC,UAAU,QAAQ,IAAwB,EAAE;IAClE,MAAMqC,WAAW;QACf,GAAGhG,IAAI;QACP,UAAU;eAAI+F;eAAiBzB;SAAS;IAC1C;IAEA,IAAIA,AAAoB,MAApBA,SAAS,MAAM,EACjB,OAAO0B;IAGT,OAAOjG,iCACLiG,UACAzF,oBAAoB;QAAE,KAAKnB;IAA2B,IAAI;QAAE,OAAOD;IAA6B;AAEpG"}
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationDifferenceLine.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/annotationDifferenceLine.ts"],"sourcesContent":["import type { IAreaChartSpec, IBarChartSpec, ICartesianSeries, ILineChartSpec, IMarkLineSpec } from '@visactor/vchart'\nimport type { AnnotationDifferenceLine, Measure, RegionPadding, VChartSpecPipe } from 'src/types'\nimport { createFormatter, findAllMeasures, autoFormatter } from '../../../../utils'\nimport {\n isDimensionSelector,\n isFieldSelector,\n isMeasureSelector,\n isPartialDatumSelector,\n} from '../../../../../dataSelector'\nimport { isEmpty } from 'remeda'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport { getAnnotationLineDash } from './utils'\nimport {\n buildDifferenceCoordinateDatum,\n buildDifferenceText,\n getDifferenceLineStackResolveMode,\n getRuntimeDifferenceValue,\n inferDifferenceConnectDirection,\n type ResolvedDifferenceAnchor,\n usesDifferenceLineElementStackEnd,\n resolveDifferenceAnchor,\n} from './annotationDifferenceLineCommon'\n\nconst DEFAULT_LINE_COLOR = '#BCC1CB'\nconst DEFAULT_TEXT_COLOR = '#ffffff'\nconst DEFAULT_TEXT_BACKGROUND_COLOR = '#BCC1CB'\nconst DEFAULT_TEXT_FONT_SIZE = 12\nconst DEFAULT_LINE_WIDTH = 1\nconst DEFAULT_CORNER_RADIUS = 3\nconst DEFAULT_LABEL_PADDING = 4\nconst DEFAULT_END_SYMBOL_SIZE = 6\nconst DEFAULT_END_SYMBOL_REF_X = -4\nconst DEFAULT_GUTTER_BASE_OFFSET = 20\nconst DEFAULT_GUTTER_RIGHT_PADDING = 44\nconst DEFAULT_GUTTER_TOP_PADDING = 36\nconst DEFAULT_BRACKET_LINE_DASH: [number, number] = [2, 2]\nconst DEFAULT_PERCENT_DIFFERENCE_FORMAT = {\n type: 'percent' as const,\n fractionDigits: 2,\n}\n\ntype RegionPaddingObject = Required<Exclude<RegionPadding, number>>\ntype DifferenceConnectDirection = 'top' | 'right' | 'bottom' | 'left'\n\nconst shouldInferDifferenceConnectDirection = (chartType: string) =>\n chartType === 'column' || chartType === 'bar' || chartType === 'columnParallel' || chartType === 'barParallel'\n\nconst getDifferenceLinePath = (index: number, total: number) =>\n total === 1 ? 'annotationDifferenceLine' : `annotationDifferenceLine[${index}]`\n\nconst toArray = <T>(value: T | T[] | undefined | null): T[] => {\n if (Array.isArray(value)) {\n return value\n }\n\n return value === undefined || value === null ? [] : [value]\n}\n\nconst normalizeRegionPadding = (padding?: RegionPadding): RegionPaddingObject => {\n if (typeof padding === 'number') {\n return {\n top: padding,\n right: padding,\n bottom: padding,\n left: padding,\n }\n }\n\n return {\n top: padding?.top ?? 0,\n right: padding?.right ?? 0,\n bottom: padding?.bottom ?? 0,\n left: padding?.left ?? 0,\n }\n}\n\nconst mergeDifferenceLineRegionPadding = (\n spec: IBarChartSpec | ILineChartSpec | IAreaChartSpec,\n paddingPatch: Partial<RegionPaddingObject>,\n) => {\n const region = (spec as { region?: Array<Record<string, unknown>> }).region\n\n if (!Array.isArray(region) || region.length === 0) {\n return spec\n }\n\n const mergedPadding = normalizeRegionPadding(region[0].padding as RegionPadding | undefined)\n\n if (paddingPatch.top !== undefined) {\n mergedPadding.top = Math.max(mergedPadding.top, paddingPatch.top)\n }\n\n if (paddingPatch.right !== undefined) {\n mergedPadding.right = Math.max(mergedPadding.right, paddingPatch.right)\n }\n\n if (paddingPatch.bottom !== undefined) {\n mergedPadding.bottom = Math.max(mergedPadding.bottom, paddingPatch.bottom)\n }\n\n if (paddingPatch.left !== undefined) {\n mergedPadding.left = Math.max(mergedPadding.left, paddingPatch.left)\n }\n\n return {\n ...spec,\n region: [\n {\n ...region[0],\n padding: mergedPadding,\n },\n ...region.slice(1),\n ],\n }\n}\n\nconst buildFixedGutterExpandDistance = (connectDirection: DifferenceConnectDirection) => {\n return (_markerData: unknown, context: any) => {\n const region = context?.region\n const coordinatePoints = Array.isArray(context?.coordinatePoints) ? context.coordinatePoints : []\n\n if (!region || coordinatePoints.length === 0) {\n return 0\n }\n\n const { x: regionStartX, y: regionStartY } = region.getLayoutStartPoint()\n const { width, height } = region.getLayoutRect()\n\n if (connectDirection === 'top') {\n const targetY = regionStartY - DEFAULT_GUTTER_BASE_OFFSET\n const minY = Math.min(...coordinatePoints.map((point: { y: number }) => point.y))\n\n return Math.max(0, minY - targetY)\n }\n\n if (connectDirection === 'bottom') {\n const targetY = regionStartY + height + DEFAULT_GUTTER_BASE_OFFSET\n const maxY = Math.max(...coordinatePoints.map((point: { y: number }) => point.y))\n\n return Math.max(0, targetY - maxY)\n }\n\n if (connectDirection === 'left') {\n const targetX = regionStartX - DEFAULT_GUTTER_BASE_OFFSET\n const minX = Math.min(...coordinatePoints.map((point: { x: number }) => point.x))\n\n return Math.max(0, minX - targetX)\n }\n\n const targetX = regionStartX + width + DEFAULT_GUTTER_BASE_OFFSET\n const maxX = Math.max(...coordinatePoints.map((point: { x: number }) => point.x))\n\n return Math.max(0, targetX - maxX)\n }\n}\n\nconst getDifferenceLinePaddingPatch = (connectDirection: DifferenceConnectDirection): Partial<RegionPaddingObject> => {\n if (connectDirection === 'top') {\n return { top: DEFAULT_GUTTER_TOP_PADDING }\n }\n\n if (connectDirection === 'bottom') {\n return { bottom: DEFAULT_GUTTER_TOP_PADDING }\n }\n\n if (connectDirection === 'left') {\n return { left: DEFAULT_GUTTER_RIGHT_PADDING }\n }\n\n return { right: DEFAULT_GUTTER_RIGHT_PADDING }\n}\n\nconst getAxisFormatter = (spec: IBarChartSpec | ILineChartSpec | IAreaChartSpec) => {\n const valueAxisOrient = spec.direction === 'horizontal' ? 'bottom' : 'left'\n const formatMethod = spec.axes?.find((axis) => axis.orient === valueAxisOrient)?.label?.formatMethod\n\n return typeof formatMethod === 'function'\n ? (value: number) => String(formatMethod(value as never) ?? value)\n : undefined\n}\n\nconst getExplicitMeasureFormat = (measure?: Measure) => {\n if (measure?.numFormat && !isEmpty(measure.numFormat)) {\n return measure.numFormat\n }\n\n if (measure?.format && !isEmpty(measure.format)) {\n return measure.format\n }\n\n return undefined\n}\n\nconst inferMeasureIdFromDatum = (anchor: ResolvedDifferenceAnchor, measureIds: string[]) => {\n const candidateValues = [anchor.matchedDatum, anchor.coordinateDatum]\n\n for (const datum of candidateValues) {\n if (!datum) {\n continue\n }\n\n const candidates = measureIds.filter((measureId) => Number(datum[measureId]) === anchor.value)\n\n if (candidates.length === 1) {\n return candidates[0]\n }\n }\n\n return undefined\n}\n\nconst inferMeasureIdFromSelector = (\n selectorValue: AnnotationDifferenceLine['start']['selector'],\n measureIdSet: Set<string>,\n) => {\n const matchedMeasureIds = new Set<string>()\n\n for (const currentSelector of toArray(selectorValue)) {\n if (isMeasureSelector(currentSelector)) {\n if (measureIdSet.has(currentSelector.field)) {\n matchedMeasureIds.add(currentSelector.field)\n }\n continue\n }\n\n if (isFieldSelector(currentSelector) || isDimensionSelector(currentSelector)) {\n continue\n }\n\n if (isPartialDatumSelector(currentSelector)) {\n Object.keys(currentSelector).forEach((field) => {\n if (measureIdSet.has(field)) {\n matchedMeasureIds.add(field)\n }\n })\n }\n }\n\n return matchedMeasureIds.size === 1 ? Array.from(matchedMeasureIds)[0] : undefined\n}\n\nconst resolveDifferenceMeasureId = (\n anchor: ResolvedDifferenceAnchor,\n selectorValue: AnnotationDifferenceLine['start']['selector'],\n measureIds: string[],\n) => {\n if (anchor.mode !== 'element') {\n return undefined\n }\n\n if (measureIds.length === 1) {\n return measureIds[0]\n }\n\n const measureIdSet = new Set(measureIds)\n return inferMeasureIdFromSelector(selectorValue, measureIdSet) ?? inferMeasureIdFromDatum(anchor, measureIds)\n}\n\nconst assertDifferenceLineConfig: (value: unknown, path: string) => asserts value is AnnotationDifferenceLine = (\n value,\n path,\n) => {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new Error(`${path} must be an object`)\n }\n\n const start = (value as Record<string, unknown>).start\n if (typeof start !== 'object' || start === null || Array.isArray(start)) {\n throw new Error(`${path}.start is required`)\n }\n if ((start as Record<string, unknown>).selector == null) {\n throw new Error(`${path}.start.selector is required`)\n }\n\n const end = (value as Record<string, unknown>).end\n if (typeof end !== 'object' || end === null || Array.isArray(end)) {\n throw new Error(`${path}.end is required`)\n }\n if ((end as Record<string, unknown>).selector == null) {\n throw new Error(`${path}.end.selector is required`)\n }\n}\n\nexport const annotationDifferenceLine: VChartSpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const annotationDifferenceLine = advancedVSeed.annotation?.annotationDifferenceLine\n\n if (!annotationDifferenceLine) {\n return spec\n }\n\n const theme = advancedVSeed.config?.[vseed.chartType as 'column']?.annotation?.annotationDifferenceLine\n const annotationDifferenceLineList = Array.isArray(annotationDifferenceLine)\n ? annotationDifferenceLine\n : [annotationDifferenceLine]\n const dataset = advancedVSeed.dataset.flat()\n const chartSpec = spec as IBarChartSpec | ILineChartSpec | IAreaChartSpec\n const stackResolveMode = getDifferenceLineStackResolveMode(vseed, advancedVSeed)\n const useElementStackEnd = usesDifferenceLineElementStackEnd(vseed, advancedVSeed)\n const isBracketChart = vseed.chartType === 'line' || vseed.chartType === 'area'\n const measures = findAllMeasures(advancedVSeed.measures)\n const measureIds = measures.map((measure) => measure.id)\n const axisFormatter = getAxisFormatter(chartSpec)\n const percentFormatter = createFormatter(DEFAULT_PERCENT_DIFFERENCE_FORMAT)\n const isHorizontalChart = chartSpec.direction === 'horizontal'\n\n const paddingPatch = {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n }\n\n const markLine = annotationDifferenceLineList.flatMap((annotationDifferenceLine, index) => {\n try {\n assertDifferenceLineConfig(\n annotationDifferenceLine,\n getDifferenceLinePath(index, annotationDifferenceLineList.length),\n )\n\n const start = resolveDifferenceAnchor({\n dataset,\n selectorLabel: 'start',\n selectorValue: annotationDifferenceLine.start.selector,\n spec: chartSpec,\n stackResolveMode,\n allowSelectorFallback: !useElementStackEnd,\n })\n const end = resolveDifferenceAnchor({\n dataset,\n selectorLabel: 'end',\n selectorValue: annotationDifferenceLine.end.selector,\n spec: chartSpec,\n stackResolveMode,\n allowSelectorFallback: !useElementStackEnd,\n })\n\n if (!start || !end) {\n return []\n }\n\n if (start.mode !== end.mode) {\n return []\n }\n\n const usesRuntimeStackEnd =\n useElementStackEnd ||\n ((vseed.chartType === 'column' || vseed.chartType === 'bar') &&\n start.mode === 'element' &&\n stackResolveMode === 'auto')\n const useBracketStyle =\n isBracketChart ||\n ((vseed.chartType === 'column' || vseed.chartType === 'bar') &&\n start.mode === 'element' &&\n stackResolveMode === 'auto')\n const connectDirection: DifferenceConnectDirection = shouldInferDifferenceConnectDirection(vseed.chartType)\n ? inferDifferenceConnectDirection(vseed, [start.value, end.value])\n : isHorizontalChart\n ? 'top'\n : 'right'\n const expandDistance = buildFixedGutterExpandDistance(connectDirection)\n const currentPaddingPatch = getDifferenceLinePaddingPatch(connectDirection)\n\n paddingPatch.top = Math.max(paddingPatch.top, currentPaddingPatch.top ?? 0)\n paddingPatch.right = Math.max(paddingPatch.right, currentPaddingPatch.right ?? 0)\n paddingPatch.bottom = Math.max(paddingPatch.bottom, currentPaddingPatch.bottom ?? 0)\n paddingPatch.left = Math.max(paddingPatch.left, currentPaddingPatch.left ?? 0)\n\n const lineColor = annotationDifferenceLine.lineColor ?? theme?.lineColor ?? DEFAULT_LINE_COLOR\n const lineStyle = annotationDifferenceLine.lineStyle\n const themeLineStyle = theme?.lineStyle\n const configuredLineDash = lineStyle\n ? getAnnotationLineDash(lineStyle)\n : (theme?.lineDash ?? (themeLineStyle ? getAnnotationLineDash(themeLineStyle) : undefined))\n const textColor = annotationDifferenceLine.textColor ?? theme?.textColor ?? DEFAULT_TEXT_COLOR\n const textBackgroundColor =\n annotationDifferenceLine.textBackgroundColor ?? theme?.textBackgroundColor ?? DEFAULT_TEXT_BACKGROUND_COLOR\n const textBackgroundOpacity = theme?.textBackgroundOpacity\n const textFontSize = annotationDifferenceLine.textFontSize ?? theme?.textFontSize ?? DEFAULT_TEXT_FONT_SIZE\n const differenceType = annotationDifferenceLine.differenceType ?? 'absolute'\n const startMeasureId = resolveDifferenceMeasureId(start, annotationDifferenceLine.start.selector, measureIds)\n const endMeasureId = resolveDifferenceMeasureId(end, annotationDifferenceLine.end.selector, measureIds)\n const sameMeasure = startMeasureId !== undefined && startMeasureId === endMeasureId\n const explicitMeasureFormat = sameMeasure\n ? getExplicitMeasureFormat(measures.find((measure) => measure.id === startMeasureId))\n : undefined\n const differenceFormatter =\n differenceType === 'percent'\n ? percentFormatter\n : explicitMeasureFormat\n ? createFormatter(explicitMeasureFormat)\n : (axisFormatter ?? autoFormatter)\n\n const label = usesRuntimeStackEnd\n ? {\n visible: true,\n position: 'middle',\n refY: 0,\n formatMethod: (_markData: any[], seriesData: any[]) => {\n try {\n return buildDifferenceText(\n getRuntimeDifferenceValue({\n anchor: start,\n seriesData,\n useElementStackEnd: usesRuntimeStackEnd,\n }),\n getRuntimeDifferenceValue({\n anchor: end,\n seriesData,\n useElementStackEnd: usesRuntimeStackEnd,\n }),\n differenceType,\n differenceFormatter,\n )\n } catch {\n return ''\n }\n },\n style: {\n fill: textColor,\n fontSize: textFontSize,\n },\n labelBackground: {\n visible: true,\n padding: DEFAULT_LABEL_PADDING,\n style: {\n opacity: textBackgroundOpacity ?? 0.95,\n fill: textBackgroundColor,\n fillOpacity: 1,\n stroke: lineColor,\n lineWidth: 1,\n cornerRadius: DEFAULT_CORNER_RADIUS,\n },\n },\n }\n : {\n visible: true,\n position: 'middle',\n refY: 0,\n text: buildDifferenceText(start.value, end.value, differenceType, differenceFormatter),\n style: {\n fill: textColor,\n fontSize: textFontSize,\n },\n labelBackground: {\n visible: true,\n padding: DEFAULT_LABEL_PADDING,\n style: {\n opacity: textBackgroundOpacity ?? 0.95,\n fill: textBackgroundColor,\n fillOpacity: 1,\n stroke: lineColor,\n lineWidth: 1,\n cornerRadius: DEFAULT_CORNER_RADIUS,\n },\n },\n }\n\n return [\n {\n type: 'type-step',\n autoRange: true,\n zIndex: ANNOTATION_Z_INDEX,\n connectDirection,\n expandDistance,\n coordinates: (seriesData: any[], relativeSeries: ICartesianSeries) => {\n try {\n return [\n buildDifferenceCoordinateDatum({\n anchor: start,\n seriesData,\n relativeSeries,\n useElementStackEnd: usesRuntimeStackEnd,\n }),\n buildDifferenceCoordinateDatum({\n anchor: end,\n seriesData,\n relativeSeries,\n useElementStackEnd: usesRuntimeStackEnd,\n }),\n ]\n } catch {\n return []\n }\n },\n line: useBracketStyle\n ? {\n multiSegment: true,\n mainSegmentIndex: 1,\n style: [\n {\n visible: true,\n stroke: lineColor,\n lineWidth: DEFAULT_LINE_WIDTH,\n lineDash: configuredLineDash ?? DEFAULT_BRACKET_LINE_DASH,\n },\n {\n visible: true,\n stroke: lineColor,\n lineWidth: DEFAULT_LINE_WIDTH,\n ...(configuredLineDash ? { lineDash: configuredLineDash } : {}),\n },\n {\n visible: true,\n stroke: lineColor,\n lineWidth: DEFAULT_LINE_WIDTH,\n lineDash: configuredLineDash ?? DEFAULT_BRACKET_LINE_DASH,\n },\n ],\n }\n : {\n style: {\n visible: true,\n stroke: lineColor,\n lineWidth: DEFAULT_LINE_WIDTH,\n lineDash: configuredLineDash ?? [0],\n cornerRadius: DEFAULT_CORNER_RADIUS,\n },\n },\n label,\n startSymbol: {\n visible: false,\n },\n endSymbol: {\n visible: true,\n size: DEFAULT_END_SYMBOL_SIZE,\n refX: DEFAULT_END_SYMBOL_REF_X,\n style: {\n fill: lineColor,\n },\n },\n } as IMarkLineSpec,\n ]\n } catch {\n return []\n }\n })\n\n const specMarkLine = (chartSpec.markLine as IMarkLineSpec[]) || []\n const nextSpec = {\n ...spec,\n markLine: [...specMarkLine, ...markLine],\n }\n\n if (markLine.length === 0) {\n return nextSpec\n }\n\n return mergeDifferenceLineRegionPadding(nextSpec as IBarChartSpec | ILineChartSpec | IAreaChartSpec, paddingPatch)\n}\n"],"names":["DEFAULT_LINE_COLOR","DEFAULT_TEXT_COLOR","DEFAULT_TEXT_BACKGROUND_COLOR","DEFAULT_TEXT_FONT_SIZE","DEFAULT_LINE_WIDTH","DEFAULT_CORNER_RADIUS","DEFAULT_LABEL_PADDING","DEFAULT_END_SYMBOL_SIZE","DEFAULT_END_SYMBOL_REF_X","DEFAULT_GUTTER_BASE_OFFSET","DEFAULT_GUTTER_RIGHT_PADDING","DEFAULT_GUTTER_TOP_PADDING","DEFAULT_BRACKET_LINE_DASH","DEFAULT_PERCENT_DIFFERENCE_FORMAT","shouldInferDifferenceConnectDirection","chartType","getDifferenceLinePath","index","total","toArray","value","Array","normalizeRegionPadding","padding","mergeDifferenceLineRegionPadding","spec","paddingPatch","region","mergedPadding","undefined","Math","buildFixedGutterExpandDistance","connectDirection","_markerData","context","coordinatePoints","regionStartX","regionStartY","width","height","targetY","minY","point","maxY","targetX","minX","maxX","getDifferenceLinePaddingPatch","getAxisFormatter","valueAxisOrient","formatMethod","axis","String","getExplicitMeasureFormat","measure","isEmpty","inferMeasureIdFromDatum","anchor","measureIds","candidateValues","datum","candidates","measureId","Number","inferMeasureIdFromSelector","selectorValue","measureIdSet","matchedMeasureIds","Set","currentSelector","isMeasureSelector","isFieldSelector","isDimensionSelector","isPartialDatumSelector","Object","field","resolveDifferenceMeasureId","assertDifferenceLineConfig","path","Error","start","end","annotationDifferenceLine","advancedVSeed","vseed","theme","annotationDifferenceLineList","dataset","chartSpec","stackResolveMode","getDifferenceLineStackResolveMode","useElementStackEnd","usesDifferenceLineElementStackEnd","isBracketChart","measures","findAllMeasures","axisFormatter","percentFormatter","createFormatter","isHorizontalChart","markLine","resolveDifferenceAnchor","usesRuntimeStackEnd","useBracketStyle","inferDifferenceConnectDirection","expandDistance","currentPaddingPatch","lineColor","lineStyle","themeLineStyle","configuredLineDash","getAnnotationLineDash","textColor","textBackgroundColor","textBackgroundOpacity","textFontSize","differenceType","startMeasureId","endMeasureId","sameMeasure","explicitMeasureFormat","differenceFormatter","autoFormatter","label","_markData","seriesData","buildDifferenceText","getRuntimeDifferenceValue","ANNOTATION_Z_INDEX","relativeSeries","buildDifferenceCoordinateDatum","specMarkLine","nextSpec"],"mappings":";;;;;;AAuBA,MAAMA,qBAAqB;AAC3B,MAAMC,qBAAqB;AAC3B,MAAMC,gCAAgC;AACtC,M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BACN,OAAO,EAAE;wBACX;oBACF;oBACA,MAAMC,kBACF;wBACE,cAAc;wBACd,kBAAkB;wBAClB,OAAO;4BACL;gCACE,SAAS;gCACT,QAAQI;gCACR,WAAWvG;gCACX,UAAU0G,sBAAsBlG;4BAClC;4BACA;gCACE,SAAS;gCACT,QAAQ+F;gCACR,WAAWvG;gCACX,GAAI0G,qBAAqB;oCAAE,UAAUA;gCAAmB,IAAI,CAAC,CAAC;4BAChE;4BACA;gCACE,SAAS;gCACT,QAAQH;gCACR,WAAWvG;gCACX,UAAU0G,sBAAsBlG;4BAClC;yBACD;oBACH,IACA;wBACE,OAAO;4BACL,SAAS;4BACT,QAAQ+F;4BACR,WAAWvG;4BACX,UAAU0G,sBAAsB;gCAAC;6BAAE;4BACnC,cAAczG;wBAChB;oBACF;oBACJsH;oBACA,aAAa;wBACX,SAAS;oBACX;oBACA,WAAW;wBACT,SAAS;wBACT,MAAMpH;wBACN,MAAMC;wBACN,OAAO;4BACL,MAAMmG;wBACR;oBACF;gBACF;aACD;QACH,EAAE,OAAM;YACN,OAAO,EAAE;QACX;IACF;IAEA,MAAMwB,eAAgB3C,UAAU,QAAQ,IAAwB,EAAE;IAClE,MAAM4C,WAAW;QACf,GAAG3G,IAAI;QACP,UAAU;eAAI0G;eAAiB/B;SAAS;IAC1C;IAEA,IAAIA,AAAoB,MAApBA,SAAS,MAAM,EACjB,OAAOgC;IAGT,OAAO5G,iCAAiC4G,UAA6D1G;AACvG"}
|
|
@@ -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,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,YAAY;oBAC3D,OAAO;wBACL,SAAS;wBACT,IAAI;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,iB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