@visactor/vseed 0.1.43 → 0.1.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +3 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/builder/builder/builder.d.ts +4380 -0
- package/dist/esm/dataSelector/selector.d.ts +1 -1
- package/dist/esm/dataSelector/selector.js +1 -2
- package/dist/esm/dataSelector/selector.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipeline/histogram.js +2 -0
- package/dist/esm/pipeline/advanced/chart/pipeline/histogram.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/config/histogram.d.ts +1 -0
- package/dist/esm/pipeline/advanced/chart/pipes/config/histogram.js +35 -2
- package/dist/esm/pipeline/advanced/chart/pipes/config/histogram.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/regressionLine/regressionLine.js +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/regressionLine/regressionLine.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithHistogramEncoding.js +22 -2
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithHistogramEncoding.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithHistogramEncoding.js +22 -3
- package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithHistogramEncoding.js.map +1 -1
- package/dist/esm/pipeline/advanced/table/pipeline/pivotTable.js +3 -2
- package/dist/esm/pipeline/advanced/table/pipeline/pivotTable.js.map +1 -1
- package/dist/esm/pipeline/advanced/table/pipeline/table.js +2 -1
- package/dist/esm/pipeline/advanced/table/pipeline/table.js.map +1 -1
- package/dist/esm/pipeline/advanced/table/pipes/{default/defaultMeasureName.d.ts → cellStyle/cellStyle.d.ts} +1 -1
- package/dist/esm/pipeline/advanced/table/pipes/cellStyle/cellStyle.js +16 -0
- package/dist/esm/pipeline/advanced/table/pipes/cellStyle/cellStyle.js.map +1 -0
- package/dist/esm/pipeline/advanced/table/pipes/cellStyle/index.d.ts +1 -0
- package/dist/esm/pipeline/advanced/table/pipes/cellStyle/index.js +2 -0
- package/dist/esm/pipeline/advanced/table/pipes/default/defaultMeasureId.d.ts +2 -0
- package/dist/esm/pipeline/advanced/table/pipes/default/{defaultMeasureName.js → defaultMeasureId.js} +5 -5
- package/dist/esm/pipeline/advanced/table/pipes/default/defaultMeasureId.js.map +1 -0
- package/dist/esm/pipeline/advanced/table/pipes/default/index.d.ts +1 -1
- package/dist/esm/pipeline/advanced/table/pipes/default/index.js +2 -2
- package/dist/esm/pipeline/advanced/table/pipes/index.d.ts +1 -0
- package/dist/esm/pipeline/advanced/table/pipes/index.js +1 -0
- package/dist/esm/pipeline/spec/chart/pipeline/histogram.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationArea.js +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationArea.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationAreaBand.js +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationAreaBand.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationHorizontalLine.js +22 -3
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationHorizontalLine.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPoint.js +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPoint.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationVerticalLine.js +20 -1
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationVerticalLine.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/annotation/splitLine.js +23 -7
- package/dist/esm/pipeline/spec/chart/pipes/annotation/splitLine.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/xBand.js +2 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/xBand.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/xLinear.js +2 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/xLinear.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yBand.js +2 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yBand.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinear.js +2 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinear.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinearPrimary.js +2 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinearPrimary.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinearSecondary.js +2 -1
- package/dist/esm/pipeline/spec/chart/pipes/axes/yLinearSecondary.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/init/histogram.js +4 -0
- package/dist/esm/pipeline/spec/chart/pipes/init/histogram.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/label/label.js +2 -1
- package/dist/esm/pipeline/spec/chart/pipes/label/label.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/legend/discreteLegend.js +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/legend/discreteLegend.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/legend/pivotDiscreteLegend.js +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/legend/pivotDiscreteLegend.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/markStyle/barStyle.js +5 -7
- package/dist/esm/pipeline/spec/chart/pipes/markStyle/barStyle.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotAxisStyle.js +23 -6
- package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotAxisStyle.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotGridStyle.js +39 -34
- package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotGridStyle.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotIndicators.js +10 -3
- package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotIndicators.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/ecdfRegressionLine.js +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/ecdfRegressionLine.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/kdeRegressionLine.js +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/regressionLine/kdeRegressionLine.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltip.js +4 -2
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltip.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipBoxplot.js +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipBoxplot.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipDualAxis.js +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipDualAxis.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipHeatmap.js +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipHeatmap.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipHistogram.js +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipHistogram.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipScatter.js +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipScatter.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipStyle.d.ts +3 -0
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipStyle.js +31 -0
- package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipStyle.js.map +1 -0
- package/dist/esm/pipeline/spec/table/pipeline/pivotTable.js +3 -2
- package/dist/esm/pipeline/spec/table/pipeline/pivotTable.js.map +1 -1
- package/dist/esm/pipeline/spec/table/pipeline/table.js +3 -2
- package/dist/esm/pipeline/spec/table/pipeline/table.js.map +1 -1
- package/dist/esm/pipeline/spec/table/pipes/cellStyle/common.d.ts +2 -0
- package/dist/esm/pipeline/spec/table/pipes/cellStyle/common.js +14 -0
- package/dist/esm/pipeline/spec/table/pipes/cellStyle/common.js.map +1 -0
- package/dist/esm/pipeline/spec/table/pipes/cellStyle/index.d.ts +2 -0
- package/dist/esm/pipeline/spec/table/pipes/cellStyle/index.js +2 -0
- package/dist/esm/pipeline/spec/table/pipes/cellStyle/pivot.d.ts +2 -0
- package/dist/esm/pipeline/spec/table/pipes/cellStyle/pivot.js +49 -0
- package/dist/esm/pipeline/spec/table/pipes/cellStyle/pivot.js.map +1 -0
- package/dist/esm/pipeline/spec/table/pipes/cellStyle/table.d.ts +2 -0
- package/dist/esm/pipeline/spec/table/pipes/cellStyle/table.js +41 -0
- package/dist/esm/pipeline/spec/table/pipes/cellStyle/table.js.map +1 -0
- package/dist/esm/pipeline/spec/table/pipes/index.d.ts +1 -0
- package/dist/esm/pipeline/spec/table/pipes/index.js +1 -0
- package/dist/esm/pipeline/spec/table/pipes/rows/pivotRows.js +13 -3
- package/dist/esm/pipeline/spec/table/pipes/rows/pivotRows.js.map +1 -1
- package/dist/esm/pipeline/utils/constant.d.ts +3 -1
- package/dist/esm/pipeline/utils/constant.js +4 -2
- package/dist/esm/pipeline/utils/constant.js.map +1 -1
- package/dist/esm/pipeline/utils/measures/depth.js.map +1 -1
- package/dist/esm/pipeline/utils/measures/find.js.map +1 -1
- package/dist/esm/pipeline/utils/tree/traverse.d.ts +1 -11
- package/dist/esm/pipeline/utils/tree/traverse.js +3 -4
- package/dist/esm/pipeline/utils/tree/traverse.js.map +1 -1
- package/dist/esm/theme/common/axes.js +2 -2
- package/dist/esm/theme/common/axes.js.map +1 -1
- package/dist/esm/theme/common/table.d.ts +30 -22
- package/dist/esm/theme/common/table.js +12 -2
- package/dist/esm/theme/common/table.js.map +1 -1
- package/dist/esm/theme/common/tooltip.d.ts +3 -2
- package/dist/esm/theme/common/tooltip.js +24 -2
- package/dist/esm/theme/common/tooltip.js.map +1 -1
- package/dist/esm/theme/dark/dark.js +2 -2
- package/dist/esm/theme/dark/dark.js.map +1 -1
- package/dist/esm/theme/light/light.js +2 -2
- package/dist/esm/theme/light/light.js.map +1 -1
- package/dist/esm/types/advancedVSeed.d.ts +3442 -0
- package/dist/esm/types/advancedVSeed.js +2 -0
- package/dist/esm/types/advancedVSeed.js.map +1 -1
- package/dist/esm/types/chartType/area/zArea.d.ts +80 -0
- package/dist/esm/types/chartType/areaPercent/zAreaPercent.d.ts +80 -0
- package/dist/esm/types/chartType/bar/zBar.d.ts +80 -0
- package/dist/esm/types/chartType/barParallel/zBarParallel.d.ts +80 -0
- package/dist/esm/types/chartType/barPercent/zBarPercent.d.ts +80 -0
- package/dist/esm/types/chartType/boxplot/zBoxplot.d.ts +80 -0
- package/dist/esm/types/chartType/column/zColumn.d.ts +82 -0
- package/dist/esm/types/chartType/columnParallel/zColumnParallel.d.ts +80 -0
- package/dist/esm/types/chartType/columnPercent/zColumnPercent.d.ts +80 -0
- package/dist/esm/types/chartType/donut/zDonut.d.ts +80 -0
- package/dist/esm/types/chartType/dualAxis/zDualAxis.d.ts +80 -0
- package/dist/esm/types/chartType/funnel/zFunnel.d.ts +80 -0
- package/dist/esm/types/chartType/heatmap/zHeatmap.d.ts +80 -0
- package/dist/esm/types/chartType/histogram/histogram.d.ts +2 -2
- package/dist/esm/types/chartType/histogram/zHistogram.d.ts +88 -4
- package/dist/esm/types/chartType/histogram/zHistogram.js +2 -2
- package/dist/esm/types/chartType/histogram/zHistogram.js.map +1 -1
- package/dist/esm/types/chartType/line/zLine.d.ts +80 -0
- package/dist/esm/types/chartType/pie/zPie.d.ts +80 -0
- package/dist/esm/types/chartType/pivotTable/pivotTable.d.ts +5 -1
- package/dist/esm/types/chartType/pivotTable/zPivotTable.d.ts +76 -0
- package/dist/esm/types/chartType/pivotTable/zPivotTable.js +2 -1
- package/dist/esm/types/chartType/pivotTable/zPivotTable.js.map +1 -1
- package/dist/esm/types/chartType/radar/zRadar.d.ts +80 -0
- package/dist/esm/types/chartType/rose/zRose.d.ts +80 -0
- package/dist/esm/types/chartType/roseParallel/zRoseParallel.d.ts +80 -0
- package/dist/esm/types/chartType/scatter/zScatter.d.ts +88 -0
- package/dist/esm/types/chartType/table/table.d.ts +5 -1
- package/dist/esm/types/chartType/table/zTable.d.ts +76 -0
- package/dist/esm/types/chartType/table/zTable.js +2 -1
- package/dist/esm/types/chartType/table/zTable.js.map +1 -1
- package/dist/esm/types/properties/cellStyle/bodyCellStyle.d.ts +138 -0
- package/dist/esm/types/properties/cellStyle/bodyCellStyle.js +16 -0
- package/dist/esm/types/properties/cellStyle/bodyCellStyle.js.map +1 -0
- package/dist/esm/types/properties/cellStyle/cellStyle.d.ts +80 -0
- package/dist/esm/types/properties/cellStyle/cellStyle.js +8 -0
- package/dist/esm/types/properties/cellStyle/cellStyle.js.map +1 -0
- package/dist/esm/types/properties/cellStyle/index.d.ts +1 -0
- package/dist/esm/types/properties/cellStyle/index.js +1 -0
- package/dist/esm/types/properties/config/area.d.ts +164 -0
- package/dist/esm/types/properties/config/bar.d.ts +246 -0
- package/dist/esm/types/properties/config/boxplot.d.ts +82 -0
- package/dist/esm/types/properties/config/column.d.ts +258 -0
- package/dist/esm/types/properties/config/config.d.ts +1676 -0
- package/dist/esm/types/properties/config/dualAxis.d.ts +82 -0
- package/dist/esm/types/properties/config/funnel.d.ts +82 -0
- package/dist/esm/types/properties/config/heatmap.d.ts +82 -0
- package/dist/esm/types/properties/config/histogram.d.ts +94 -0
- package/dist/esm/types/properties/config/label/label.d.ts +5 -0
- package/dist/esm/types/properties/config/label/zLabel.d.ts +69 -0
- package/dist/esm/types/properties/config/label/zLabel.js +6 -1
- package/dist/esm/types/properties/config/label/zLabel.js.map +1 -1
- package/dist/esm/types/properties/config/label/zPieLabel.d.ts +69 -0
- package/dist/esm/types/properties/config/line.d.ts +82 -0
- package/dist/esm/types/properties/config/pie.d.ts +246 -0
- package/dist/esm/types/properties/config/pivotGrid/pivotGrid.d.ts +2 -0
- package/dist/esm/types/properties/config/pivotGrid/pivotGrid.js +3 -1
- package/dist/esm/types/properties/config/pivotGrid/pivotGrid.js.map +1 -1
- package/dist/esm/types/properties/config/rose.d.ts +164 -0
- package/dist/esm/types/properties/config/scatter.d.ts +94 -0
- package/dist/esm/types/properties/config/tooltip/tooltip.d.ts +12 -0
- package/dist/esm/types/properties/config/tooltip/tooltip.js +12 -1
- package/dist/esm/types/properties/config/tooltip/tooltip.js.map +1 -1
- package/dist/esm/types/properties/index.d.ts +1 -0
- package/dist/esm/types/properties/index.js +1 -0
- package/dist/esm/types/properties/markStyle/barStyle.d.ts +5 -0
- package/dist/esm/types/properties/markStyle/barStyle.js.map +1 -1
- package/dist/esm/types/properties/regressionLine/ecdfRegressionLine.d.ts +4 -0
- package/dist/esm/types/properties/regressionLine/kdeRegressionLine.d.ts +4 -0
- package/dist/esm/types/properties/regressionLine/zRegressionLine.d.ts +18 -0
- package/dist/esm/types/properties/regressionLine/zRegressionLine.js +1 -0
- package/dist/esm/types/properties/regressionLine/zRegressionLine.js.map +1 -1
- package/dist/esm/types/properties/theme/customTheme.d.ts +3352 -0
- package/dist/esm/types/zVseed.d.ts +1890 -124
- package/dist/umd/index.js +726 -349
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/esm/pipeline/advanced/table/pipes/default/defaultMeasureName.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationArea.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/annotation/annotationArea.ts"],"sourcesContent":["import type { ICartesianSeries, ILineChartSpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { Datum, SpecPipe } from 'src/types'\nimport { isSubset } from './utils'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\n\nexport const annotationArea: SpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const { annotation, config } = advancedVSeed\n\n if (!annotation || !annotation.annotationArea) {\n return spec\n }\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\n const markArea = annotationAreaList.flatMap((annotationArea) => {\n const {\n selector: selectorPoint,\n text = '',\n textPosition = 'top',\n textColor = theme?.textColor ?? '#ffffff',\n textFontSize = theme?.textFontSize ?? 12,\n textFontWeight = theme?.textFontWeight ?? 400,\n textAlign = 'center',\n textBaseline = 'top',\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\n const dataset = advancedVSeed.dataset.flat()\n const selectedData = selectorPoint ? dataset.filter((datum) => selector(datum, selectorPoint)) : []\n\n const labelPosition = positionMap[textPosition || 'top']\n const isBottom = labelPosition.toLocaleLowerCase().includes('bottom')\n\n return {\n zIndex: ANNOTATION_Z_INDEX,\n regionRelative: true,\n positions: (data: Datum[], context: ICartesianSeries) => {\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 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 yScale = yAxisHelper.getScale()\n\n const minX = Math.min(...xyList.map((item) => item.x)) - (outerPadding || 4)\n const maxX = Math.max(...xyList.map((item) => item.x)) + (outerPadding || 4)\n const minY = Math.min(...yScale.range())\n const maxY = Math.max(...yScale.range())\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 xScale = xAxisHelper.getScale()\n\n const minY = Math.min(...xyList.map((item) => item.y)) - (outerPadding || 4)\n const maxY = Math.max(...xyList.map((item) => item.y)) + (outerPadding || 4)\n const minX = Math.min(...xScale.range())\n const maxX = Math.max(...xScale.range())\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: labelPosition,\n visible: true,\n text: text,\n style: {\n dy: isBottom ? -(textFontSize || 12) * 2 : 0,\n textAlign: textAlign,\n textBaseline: textBaseline,\n fill: textColor,\n stroke: textBackgroundColor,\n lineWidth: 1,\n fontSize: textFontSize,\n fontWeight: textFontWeight,\n },\n\n labelBackground: {\n visible: textBackgroundVisible,\n padding: textBackgroundPadding,\n style: {\n dy: isBottom ? -(textFontSize || 12) * 2 : 0,\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":["annotationArea","spec","context","advancedVSeed","vseed","annotation","config","theme","annotationAreaList","Array","positionMap","markArea","selectorPoint","text","textPosition","textColor","textFontSize","textFontWeight","textAlign","textBaseline","textBackgroundVisible","textBackgroundColor","textBackgroundBorderColor","textBackgroundBorderWidth","textBackgroundBorderRadius","textBackgroundPadding","areaColor","areaColorOpacity","areaBorderColor","areaBorderRadius","areaBorderWidth","areaLineDash","outerPadding","dataset","selectedData","datum","selector","labelPosition","isBottom","ANNOTATION_Z_INDEX","data","positionData","item","isSubset","xyList","yAxisHelper","xAxisHelper","yScale","minX","Math","maxX","minY","maxY","xScale"],"mappings":";;;AAMO,MAAMA,gCAA2B,CAACC,MAAMC;IAC7C,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;IAGT,MAAMM,QAAQD,QAAQ,CAACF,MAAM,SAAS,CAAa,EAAE,YAAY;IACjE,MAAM,EAAEJ,cAAc,EAAE,GAAGK;IAC3B,MAAMG,qBAAqBC,MAAM,OAAO,CAACT,kBAAkBA,iBAAiB;QAACA;KAAe;IAE5F,MAAMU,cAAc;QAClB,KAAK;QACL,UAAU;QACV,S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GD;4BACH,GAAGC;wBACL;wBAEA;4BACE,GAAGD;4BACH,GAAGE;wBACL;wBAEA;4BACE,GAAGJ;4BACH,GAAGI;wBACL;qBACD;gBACH;gBAEA,OAAO,EAAE;YACX;YACA,OAAO;gBACL,UAAUf;gBACV,SAAS;gBACT,MAAMxB;gBACN,OAAO;oBACL,IAAIyB,WAAW,AAAwB,IAAxB,CAAEtB,CAAAA,gBAAgB,EAAC,IAAS;oBAC3C,WAAWE;oBACX,cAAcC;oBACd,MAAMJ;oBACN,QAAQM;oBACR,WAAW;oBACX,UAAUL;oBACV,YAAYC;gBACd;gBAEA,iBAAiB;oBACf,SAASG;oBACT,SAASK;oBACT,OAAO;wBACL,IAAIa,WAAW,AAAwB,IAAxB,CAAEtB,CAAAA,gBAAgB,EAAC,IAAS;wBAC3C,cAAcQ,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,UAAUU;IACZ;AACF"}
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationArea.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/annotation/annotationArea.ts"],"sourcesContent":["import type { ICartesianSeries, ILineChartSpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { Datum, SpecPipe } from 'src/types'\nimport { isSubset } from './utils'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\n\nexport const annotationArea: SpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const { annotation, config } = advancedVSeed\n\n if (!annotation || !annotation.annotationArea) {\n return spec\n }\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\n const markArea = annotationAreaList.flatMap((annotationArea) => {\n const {\n selector: selectorPoint,\n text = '',\n textPosition = 'top',\n textColor = theme?.textColor ?? '#ffffff',\n textFontSize = theme?.textFontSize ?? 12,\n textFontWeight = theme?.textFontWeight ?? 400,\n textAlign = 'center',\n textBaseline = 'top',\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\n const dataset = advancedVSeed.dataset.flat()\n const selectedData = selectorPoint ? dataset.filter((datum) => selector(datum, selectorPoint)) : []\n\n const labelPosition = positionMap[textPosition || 'top']\n const isBottom = labelPosition.toLocaleLowerCase().includes('bottom')\n\n return {\n zIndex: ANNOTATION_Z_INDEX,\n regionRelative: true,\n positions: (data: Datum[], context: ICartesianSeries) => {\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 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 yScale = yAxisHelper.getScale()\n\n const minX = Math.min(...xyList.map((item) => item.x)) - (outerPadding || 4)\n const maxX = Math.max(...xyList.map((item) => item.x)) + (outerPadding || 4)\n const minY = Math.min(...yScale.range())\n const maxY = Math.max(...yScale.range())\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 xScale = xAxisHelper.getScale()\n\n const minY = Math.min(...xyList.map((item) => item.y)) - (outerPadding || 4)\n const maxY = Math.max(...xyList.map((item) => item.y)) + (outerPadding || 4)\n const minX = Math.min(...xScale.range())\n const maxX = Math.max(...xScale.range())\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: labelPosition,\n visible: true,\n text: text,\n style: {\n opacity: 0.95,\n dy: isBottom ? -(textFontSize || 12) * 2 : 0,\n textAlign: textAlign,\n textBaseline: textBaseline,\n fill: textColor,\n stroke: textBackgroundColor,\n lineWidth: 1,\n fontSize: textFontSize,\n fontWeight: textFontWeight,\n },\n\n labelBackground: {\n visible: textBackgroundVisible,\n padding: textBackgroundPadding,\n style: {\n opacity: 0.95,\n dy: isBottom ? -(textFontSize || 12) * 2 : 0,\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":["annotationArea","spec","context","advancedVSeed","vseed","annotation","config","theme","annotationAreaList","Array","positionMap","markArea","selectorPoint","text","textPosition","textColor","textFontSize","textFontWeight","textAlign","textBaseline","textBackgroundVisible","textBackgroundColor","textBackgroundBorderColor","textBackgroundBorderWidth","textBackgroundBorderRadius","textBackgroundPadding","areaColor","areaColorOpacity","areaBorderColor","areaBorderRadius","areaBorderWidth","areaLineDash","outerPadding","dataset","selectedData","datum","selector","labelPosition","isBottom","ANNOTATION_Z_INDEX","data","positionData","item","isSubset","xyList","yAxisHelper","xAxisHelper","yScale","minX","Math","maxX","minY","maxY","xScale"],"mappings":";;;AAMO,MAAMA,gCAA2B,CAACC,MAAMC;IAC7C,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;IAGT,MAAMM,QAAQD,QAAQ,CAACF,MAAM,SAAS,CAAa,EAAE,YAAY;IACjE,MAAM,EAAEJ,cAAc,EAAE,GAAGK;IAC3B,MAAMG,qBAAqBC,MAAM,OAAO,CAACT,kBAAkBA,iBAAiB;QAACA;KAAe;IAE5F,MAAMU,cAAc;QAClB,KAAK;QACL,UAAU;QACV,SAAS;QACT,QAAQ;QACR,YAAY;QACZ,aAAa;QACb,MAAM;QACN,OAAO;IACT;IAEA,MAAMC,WAAWH,mBAAmB,OAAO,CAAC,CAACR;QAC3C,MAAM,EACJ,UAAUY,aAAa,EACvBC,OAAO,EAAE,EACTC,eAAe,KAAK,E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AMxB;gBACN,OAAO;oBACL,SAAS;oBACT,IAAIyB,WAAW,AAAwB,IAAxB,CAAEtB,CAAAA,gBAAgB,EAAC,IAAS;oBAC3C,WAAWE;oBACX,cAAcC;oBACd,MAAMJ;oBACN,QAAQM;oBACR,WAAW;oBACX,UAAUL;oBACV,YAAYC;gBACd;gBAEA,iBAAiB;oBACf,SAASG;oBACT,SAASK;oBACT,OAAO;wBACL,SAAS;wBACT,IAAIa,WAAW,AAAwB,IAAxB,CAAEtB,CAAAA,gBAAgB,EAAC,IAAS;wBAC3C,cAAcQ,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,UAAUU;IACZ;AACF"}
|
|
@@ -112,6 +112,7 @@ const annotationAreaBand = (spec, context)=>{
|
|
|
112
112
|
visible: true,
|
|
113
113
|
text: text,
|
|
114
114
|
style: {
|
|
115
|
+
opacity: 0.95,
|
|
115
116
|
dy: dy,
|
|
116
117
|
textAlign: textAlign,
|
|
117
118
|
textBaseline: textBaseline,
|
|
@@ -125,6 +126,7 @@ const annotationAreaBand = (spec, context)=>{
|
|
|
125
126
|
visible: textBackgroundVisible,
|
|
126
127
|
padding: textBackgroundPadding,
|
|
127
128
|
style: {
|
|
129
|
+
opacity: 0.95,
|
|
128
130
|
dy: dy,
|
|
129
131
|
cornerRadius: textBackgroundBorderRadius ?? 4,
|
|
130
132
|
fill: textBackgroundColor,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationAreaBand.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/annotation/annotationAreaBand.ts"],"sourcesContent":["import { type ICartesianSeries, type ILineChartSpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { Datum, SpecPipe, VSeed } from 'src/types'\nimport { isSubset } from './utils'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport { isBarLikeChart } from 'src/pipeline/utils/chatType'\n\nexport const annotationAreaBand: SpecPipe = (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 defaultOptions = isBarLikeChart(advancedVSeed as VSeed)\n ? {\n textPosition: 'right',\n textAlign: 'right',\n }\n : {\n textPosition: 'top',\n textAlign: 'center',\n }\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 textAlign = defaultOptions.textAlign,\n textBaseline = 'middle',\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 ?? defaultOptions.textPosition\n\n const dy = textPosition.includes('bottom') ? -1 * textFontSize! : 0\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 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 yScale = yAxisHelper.getScale()\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 = Math.min(...yScale.range())\n const maxY = Math.max(...yScale.range())\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 xScale = xAxisHelper.getScale()\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\n const minX = Math.min(...xScale.range())\n const maxX = Math.max(...xScale.range())\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 dy: dy,\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 dy: dy,\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","defaultOptions","isBarLikeChart","markArea","selectorPoint","text","textColor","textFontSize","textFontWeight","textAlign","textBaseline","textBackgroundVisible","textBackgroundColor","textBackgroundBorderColor","textBackgroundBorderWidth","textBackgroundBorderRadius","textBackgroundPadding","areaColor","areaColorOpacity","areaBorderColor","areaBorderRadius","areaBorderWidth","areaLineDash","outerPadding","textPosition","dy","dataset","selectedData","datum","selector","ANNOTATION_Z_INDEX","data","positionData","item","isSubset","xyList","bandPosition","yAxisHelper","xAxisHelper","depth","xBandWidth","yScale","startX","Math","endX","width","middleX","minX","maxX","minY","maxY","yBandWidth","xScale","startY","endY","middleY"],"mappings":";;;;AAOO,MAAMA,qBAA+B,CAACC,MAAMC;IACjD,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,iBAAiBC,eAAeV,iBAClC;QACE,cAAc;QACd,WAAW;IACb,IACA;QACE,cAAc;QACd,WAAW;IACb;IAEJ,MAAMW,WAAWL,mBAAmB,OAAO,CAAC,CAACD;QAC3C,MAAM,EACJ,UAAUO,aAAa,EACvBC,OAAO,EAAE,EACTC,YAAYV,OAAO,aAAa,SAAS,EACzCW,eAAeX,OAAO,gBAAgB,EAAE,EACxCY,iBAAiBZ,OAAO,kBAAkB,GAAG,EAC7Ca,YAAYR,eAAe,SAAS,EACpCS,eAAe,QAAQ,EAEvBC,wBAAwBf,OAAO,yBAAyB,IAAI,EAC5DgB,sBAAsBhB,OAAO,uBAAuB,SAAS,EAC7DiB,4BAA4BjB,OAAO,6BAA6B,S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K,UAAUV,QAAQ;oBAE/B,MAAME,OAAOJ,KAAK,GAAG,IAAIS,OAAO,KAAK;oBACrC,MAAMJ,OAAOL,KAAK,GAAG,IAAIS,OAAO,KAAK;oBAErC,OAAO;wBAEL;4BACE,GAAGL;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,UAAUlD,WAAW,CAACwB,aAAyB;gBAC/C,SAAS;gBACT,MAAMnB;gBACN,OAAO;oBACL,IAAIoB;oBACJ,WAAWhB;oBACX,cAAcC;oBACd,QAAQE;oBACR,WAAW;oBACX,MAAMN;oBACN,UAAUC;oBACV,YAAYC;gBACd;gBAEA,iBAAiB;oBACf,SAASG;oBACT,SAASK;oBACT,OAAO;wBACL,IAAIS;wBACJ,cAAcV,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,GAAGhC,IAAI;QACP,UAAUa;IACZ;AACF"}
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationAreaBand.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/annotation/annotationAreaBand.ts"],"sourcesContent":["import { type ICartesianSeries, type ILineChartSpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { Datum, SpecPipe, VSeed } from 'src/types'\nimport { isSubset } from './utils'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport { isBarLikeChart } from 'src/pipeline/utils/chatType'\n\nexport const annotationAreaBand: SpecPipe = (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 defaultOptions = isBarLikeChart(advancedVSeed as VSeed)\n ? {\n textPosition: 'right',\n textAlign: 'right',\n }\n : {\n textPosition: 'top',\n textAlign: 'center',\n }\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 textAlign = defaultOptions.textAlign,\n textBaseline = 'middle',\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 ?? defaultOptions.textPosition\n\n const dy = textPosition.includes('bottom') ? -1 * textFontSize! : 0\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 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 yScale = yAxisHelper.getScale()\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 = Math.min(...yScale.range())\n const maxY = Math.max(...yScale.range())\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 xScale = xAxisHelper.getScale()\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\n const minX = Math.min(...xScale.range())\n const maxX = Math.max(...xScale.range())\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 dy: dy,\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 dy: dy,\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","defaultOptions","isBarLikeChart","markArea","selectorPoint","text","textColor","textFontSize","textFontWeight","textAlign","textBaseline","textBackgroundVisible","textBackgroundColor","textBackgroundBorderColor","textBackgroundBorderWidth","textBackgroundBorderRadius","textBackgroundPadding","areaColor","areaColorOpacity","areaBorderColor","areaBorderRadius","areaBorderWidth","areaLineDash","outerPadding","textPosition","dy","dataset","selectedData","datum","selector","ANNOTATION_Z_INDEX","data","positionData","item","isSubset","xyList","bandPosition","yAxisHelper","xAxisHelper","depth","xBandWidth","yScale","startX","Math","endX","width","middleX","minX","maxX","minY","maxY","yBandWidth","xScale","startY","endY","middleY"],"mappings":";;;;AAOO,MAAMA,qBAA+B,CAACC,MAAMC;IACjD,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,iBAAiBC,eAAeV,iBAClC;QACE,cAAc;QACd,WAAW;IACb,IACA;QACE,cAAc;QACd,WAAW;IACb;IAEJ,MAAMW,WAAWL,mBAAmB,OAAO,CAAC,CAACD;QAC3C,MAAM,EACJ,UAAUO,aAAa,EACvBC,OAAO,EAAE,EACTC,YAAYV,OAAO,aAAa,SAAS,EACzCW,eAAeX,OAAO,gBAAgB,EAAE,EACxCY,iBAAiBZ,OAAO,kBAAkB,GAAG,EAC7Ca,YAAYR,eAAe,SAAS,EACpCS,eAAe,QAAQ,EAEvBC,wBAAwBf,OAAO,yBAAyB,IAAI,EAC5DgB,sBAAsBhB,OAAO,uBAAuB,SAAS,EAC7DiB,4BAA4BjB,OAAO,6BAA6B,SAAS,EACzEkB,4BAA4BlB,OAAO,6BAA6B,CAAC,EACjEmB,6BAA6BnB,OAAO,8BAA8B,CAAC,EACnEoB,wBAAwBpB,OAAO,yBAAyB,CAAC,EAEzDqB,YAAYrB,OAAO,aAAa,SAAS,EACzCsB,mBAAmBt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;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,UAAUlD,WAAW,CAACwB,aAAyB;gBAC/C,SAAS;gBACT,MAAMnB;gBACN,OAAO;oBACL,SAAS;oBACT,IAAIoB;oBACJ,WAAWhB;oBACX,cAAcC;oBACd,QAAQE;oBACR,WAAW;oBACX,MAAMN;oBACN,UAAUC;oBACV,YAAYC;gBACd;gBAEA,iBAAiB;oBACf,SAASG;oBACT,SAASK;oBACT,OAAO;wBACL,SAAS;wBACT,IAAIS;wBACJ,cAAcV,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,GAAGhC,IAAI;QACP,UAAUa;IACZ;AACF"}
|
|
@@ -23,7 +23,23 @@ const annotationHorizontalLine_annotationHorizontalLine = (spec, context)=>{
|
|
|
23
23
|
const { selector: selectorPoint, yValue, text = '', textPosition = 'insideEnd', textColor = theme?.textColor ?? '#ffffff', textFontSize = theme?.textFontSize ?? 12, textFontWeight = theme?.textFontWeight ?? 400, textAlign = 'right', textBaseline = 'bottom', lineColor = theme?.lineColor ?? '#212121', lineStyle = theme?.lineStyle ?? 'dashed', 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;
|
|
24
24
|
const dataset = advancedVSeed.dataset.flat();
|
|
25
25
|
const generateOneMarkLine = (y)=>({
|
|
26
|
-
|
|
26
|
+
positions: (datum, series)=>{
|
|
27
|
+
const regionStart = series.getRegion()?.getLayoutStartPoint();
|
|
28
|
+
const xAxisHelper = series.getXAxisHelper();
|
|
29
|
+
const yAxisHelper = series.getYAxisHelper();
|
|
30
|
+
const yPos = yAxisHelper.getScale(0).scale(y) + regionStart.y;
|
|
31
|
+
const xRange = xAxisHelper.getScale(0).range();
|
|
32
|
+
return [
|
|
33
|
+
{
|
|
34
|
+
x: xRange ? xRange[0] + regionStart.x : 0,
|
|
35
|
+
y: yPos
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
x: xRange ? xRange[1] + regionStart.x : 0,
|
|
39
|
+
y: yPos
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
},
|
|
27
43
|
zIndex: ANNOTATION_Z_INDEX,
|
|
28
44
|
line: {
|
|
29
45
|
style: {
|
|
@@ -42,9 +58,11 @@ const annotationHorizontalLine_annotationHorizontalLine = (spec, context)=>{
|
|
|
42
58
|
}
|
|
43
59
|
},
|
|
44
60
|
label: {
|
|
61
|
+
confine: true,
|
|
45
62
|
text: text,
|
|
46
63
|
position: positionMap[textPosition || 'insideEnd'],
|
|
47
64
|
style: {
|
|
65
|
+
opacity: 0.95,
|
|
48
66
|
visible: true,
|
|
49
67
|
dy: 4,
|
|
50
68
|
stroke: textBackgroundColor,
|
|
@@ -59,6 +77,7 @@ const annotationHorizontalLine_annotationHorizontalLine = (spec, context)=>{
|
|
|
59
77
|
visible: textBackgroundVisible,
|
|
60
78
|
padding: textBackgroundPadding,
|
|
61
79
|
style: {
|
|
80
|
+
opacity: 0.95,
|
|
62
81
|
dy: 4,
|
|
63
82
|
cornerRadius: textBackgroundBorderRadius,
|
|
64
83
|
fill: textBackgroundColor,
|
|
@@ -71,9 +90,9 @@ const annotationHorizontalLine_annotationHorizontalLine = (spec, context)=>{
|
|
|
71
90
|
startSymbol: {
|
|
72
91
|
visible: theme?.startSymbolVisible ?? true,
|
|
73
92
|
symbolType: theme?.startSymbolType ?? 'triangleDown',
|
|
74
|
-
size: 5,
|
|
93
|
+
size: 5 + (lineWidth || 1),
|
|
75
94
|
style: {
|
|
76
|
-
dx:
|
|
95
|
+
dx: 3,
|
|
77
96
|
fill: lineColor
|
|
78
97
|
}
|
|
79
98
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationHorizontalLine.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/annotation/annotationHorizontalLine.ts"],"sourcesContent":["import type { ILineChartSpec, IMarkLineSpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { SpecPipe } from 'src/types'\nimport { isArray, isNumber, isString } from 'remeda'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\n\nexport const annotationHorizontalLine: SpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const { annotation, datasetReshapeInfo, config } = advancedVSeed\n const { foldInfo, unfoldInfo } = datasetReshapeInfo[0]\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 selector: selectorPoint,\n yValue,\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 lineStyle = theme?.lineStyle ?? 'dashed',\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\n const dataset = advancedVSeed.dataset.flat()\n\n const generateOneMarkLine = (y: string | number) => {\n return {\n y,\n zIndex: ANNOTATION_Z_INDEX,\n line: {\n style: {\n visible: lineVisible,\n stroke: lineColor,\n lineWidth: lineWidth,\n lineDash: lineStyle === 'dashed' ? [5, 2] : lineStyle === 'dotted' ? [2, 5] : [0],\n },\n },\n label: {\n text: text,\n position: positionMap[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 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,\n style: {\n dx:
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationHorizontalLine.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/annotation/annotationHorizontalLine.ts"],"sourcesContent":["import type { Datum, ICartesianSeries, ILineChartSpec, IMarkLineSpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { SpecPipe } from 'src/types'\nimport { isArray, isNumber, isString } from 'remeda'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\n\nexport const annotationHorizontalLine: SpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const { annotation, datasetReshapeInfo, config } = advancedVSeed\n const { foldInfo, unfoldInfo } = datasetReshapeInfo[0]\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 selector: selectorPoint,\n yValue,\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 lineStyle = theme?.lineStyle ?? 'dashed',\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\n const dataset = advancedVSeed.dataset.flat()\n\n const generateOneMarkLine = (y: string | number) => {\n return {\n positions: (datum: Datum[], series: ICartesianSeries) => {\n const regionStart = series.getRegion()?.getLayoutStartPoint()\n const xAxisHelper = series.getXAxisHelper()\n const yAxisHelper = series.getYAxisHelper()\n const yPos = yAxisHelper.getScale!(0).scale(y) + regionStart.y\n const xRange = xAxisHelper.getScale!(0).range()\n\n return [\n { x: xRange ? xRange[0] + regionStart.x : 0, y: yPos },\n {\n x: xRange ? xRange[1] + regionStart.x : 0,\n y: yPos,\n },\n ]\n },\n zIndex: ANNOTATION_Z_INDEX,\n line: {\n style: {\n visible: lineVisible,\n stroke: lineColor,\n lineWidth: lineWidth,\n lineDash: lineStyle === 'dashed' ? [5, 2] : lineStyle === 'dotted' ? [2, 5] : [0],\n },\n },\n label: {\n confine: true,\n text: text,\n position: positionMap[textPosition || 'insideEnd'],\n style: {\n opacity: 0.95,\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: 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 if ((!selectorPoint && isArray(yValue)) || isString(yValue) || isNumber(yValue)) {\n const yValueArr = Array.isArray(yValue) ? yValue : [yValue]\n return yValueArr.map(generateOneMarkLine)\n }\n\n const selectedData = selectorPoint ? dataset.filter((datum) => selector(datum, selectorPoint)) : []\n\n return selectedData.map((datum) => {\n if (datum[unfoldInfo.encodingY]) {\n return generateOneMarkLine(datum[unfoldInfo.encodingY] as string)\n }\n if (datum[foldInfo.measureValue]) {\n return generateOneMarkLine(datum[foldInfo.measureValue] as string)\n }\n return {}\n })\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","datasetReshapeInfo","config","foldInfo","unfoldInfo","theme","annotationHorizontalLineList","Array","positionMap","markLine","selectorPoint","yValue","text","textPosition","textColor","textFontSize","textFontWeight","textAlign","textBaseline","lineColor","lineStyle","lineVisible","lineWidth","textBackgroundVisible","textBackgroundColor","textBackgroundBorderColor","textBackgroundBorderRadius","textBackgroundBorderWidth","textBackgroundPadding","dataset","generateOneMarkLine","y","datum","series","regionStart","xAxisHelper","yAxisHelper","yPos","xRange","ANNOTATION_Z_INDEX","isArray","isString","isNumber","yValueArr","selectedData","selector","specMarkLine","newMarkLine"],"mappings":";;;AAMO,MAAMA,oDAAqC,CAACC,MAAMC;IACvD,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IACjC,MAAM,EAAEG,UAAU,EAAEC,kBAAkB,EAAEC,MAAM,EAAE,GAAGJ;IACnD,MAAM,EAAEK,QAAQ,EAAEC,UAAU,EAAE,GAAGH,kBAAkB,CAAC,EAAE;IAEtD,IAAI,CAACD,cAAc,CAACA,WAAW,wBAAwB,EACrD,OAAOJ;IAET,MAAMS,QAAQH,QAAQ,CAACH,MAAM,SAAS,CAAa,EAAE,YAAY;IACjE,MAAM,EAAEJ,wBAAwB,EAAE,GAAGK;IACrC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UAAU,GAAG,CAACb;QACvB;QAEA,MAAMc,eAAelC,gBAAgBmB,QAAQ,MAAM,CAAC,CAACG,QAAUa,SAASb,OAAOtB,kBAAkB,EAAE;QAEnG,OAAOkC,aAAa,GAAG,CAAC,CAACZ;YACvB,IAAIA,KAAK,CAAC5B,WAAW,SAAS,CAAC,EAC7B,OAAO0B,oBAAoBE,KAAK,CAAC5B,WAAW,SAAS,CAAC;YAExD,IAAI4B,KAAK,CAAC7B,SAAS,YAAY,CAAC,EAC9B,OAAO2B,oBAAoBE,KAAK,CAAC7B,SAAS,YAAY,CAAC;YAEzD,OAAO,CAAC;QACV;IACF;IACA,MAAM2C,eAAiBlD,KAAwB,QAAQ,IAAwB,EAAE;IACjF,MAAMmD,cAAc;WAAID;WAAkBrC,YAAY,EAAE;KAAE;IAC1D,OAAO;QACL,GAAGb,IAAI;QACP,UAAUmD;IACZ;AACF"}
|
|
@@ -39,6 +39,7 @@ const annotationPoint_annotationPoint = (spec, context)=>{
|
|
|
39
39
|
text: {
|
|
40
40
|
text: text,
|
|
41
41
|
style: {
|
|
42
|
+
opacity: 0.95,
|
|
42
43
|
visible: true,
|
|
43
44
|
textAlign: textAlign,
|
|
44
45
|
textBaseline: textBaseline,
|
|
@@ -54,6 +55,7 @@ const annotationPoint_annotationPoint = (spec, context)=>{
|
|
|
54
55
|
visible: textBackgroundVisible,
|
|
55
56
|
padding: textBackgroundPadding,
|
|
56
57
|
style: {
|
|
58
|
+
opacity: 0.95,
|
|
57
59
|
cornerRadius: textBackgroundBorderRadius ?? 4,
|
|
58
60
|
fill: textBackgroundColor,
|
|
59
61
|
stroke: textBackgroundBorderColor,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationPoint.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/annotation/annotationPoint.ts"],"sourcesContent":["import type { ILineChartSpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { Datum, SpecPipe, VSeed } from 'src/types'\nimport { isSubset } from './utils'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport { isBarLikeChart } from 'src/pipeline/utils/chatType'\n\nexport const annotationPoint: SpecPipe = (spec, context) => {\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 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 = selectorPoint ? dataset.filter((datum) => selector(datum, selectorPoint)) : []\n const dx = -10 - (isHorizontalBar ? (textFontSize as number) : 0) // 由于vchart tag实现问题,需要设置这个强制偏移量\n const dy = isHorizontalBar ? 0 : (textFontSize as number)\n\n return selectedData.map((datum) => {\n return {\n zIndex: ANNOTATION_Z_INDEX,\n regionRelative: true,\n coordinate: (data: Datum[]) => {\n return data.find((item) => isSubset(datum, item))\n },\n\n itemLine: {\n visible: false,\n },\n itemContent: {\n offsetY,\n offsetX,\n confine: true,\n text: {\n text: text,\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 labelBackground: {\n visible: textBackgroundVisible,\n padding: textBackgroundPadding,\n style: {\n cornerRadius: textBackgroundBorderRadius ?? 4,\n fill: textBackgroundColor,\n stroke: textBackgroundBorderColor,\n lineWidth: textBackgroundBorderWidth,\n dx,\n dy,\n },\n },\n },\n },\n }\n })\n }) as ILineChartSpec['markPoint']\n\n return {\n ...spec,\n markPoint,\n }\n}\n"],"names":["annotationPoint","spec","context","advancedVSeed","vseed","annotation","config","theme","annotationPointList","Array","isHorizontalBar","isBarLikeChart","defaultStyle","markPoint","selectorPoint","text","textColor","textFontSize","textFontWeight","textAlign","textBaseline","textBackgroundBorderColor","textBackgroundBorderRadius","textBackgroundBorderWidth","textBackgroundColor","textBackgroundPadding","textBackgroundVisible","offsetX","offsetY","dataset","selectedData","datum","selector","dx","dy","ANNOTATION_Z_INDEX","data","item","isSubset"],"mappings":";;;;AAOO,MAAMA,kCAA4B,CAACC,MAAMC;IAC9C,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IACjC,MAAM,EAAEG,UAAU,EAAEC,MAAM,EAAE,GAAGH;IAE/B,IAAI,CAACE,cAAc,CAACA,WAAW,eAAe,EAC5C,OAAOJ;IAGT,MAAMM,QAAQD,QAAQ,CAACF,MAAM,SAAS,CAAa,EAAE,YAAY;IACjE,MAAM,EAAEJ,eAAe,EAAE,GAAGK;IAC5B,MAAMG,sBAAsBC,MAAM,OAAO,CAACT,mBAAmBA,kBAAkB;QAACA;KAAgB;IAChG,MAAMU,kBAAkBC,eAAeR;IACvC,MAAMS,eAAeF,kBACj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ACZe;4BACAC;wBACF;wBACA,iBAAiB;4BACf,SAASR;4BACT,SAASD;4BACT,OAAO;gCACL,cAAcH,8BAA8B;gCAC5C,MAAME;gCACN,QAAQH;gCACR,WAAWE;gCACXU;gCACAC;4BACF;wBACF;oBACF;gBACF;YACF;IAEJ;IAEA,OAAO;QACL,GAAGjC,IAAI;QACPY;IACF;AACF"}
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationPoint.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/annotation/annotationPoint.ts"],"sourcesContent":["import type { ILineChartSpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { Datum, SpecPipe, VSeed } from 'src/types'\nimport { isSubset } from './utils'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport { isBarLikeChart } from 'src/pipeline/utils/chatType'\n\nexport const annotationPoint: SpecPipe = (spec, context) => {\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 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 = selectorPoint ? dataset.filter((datum) => selector(datum, selectorPoint)) : []\n const dx = -10 - (isHorizontalBar ? (textFontSize as number) : 0) // 由于vchart tag实现问题,需要设置这个强制偏移量\n const dy = isHorizontalBar ? 0 : (textFontSize as number)\n\n return selectedData.map((datum) => {\n return {\n zIndex: ANNOTATION_Z_INDEX,\n regionRelative: true,\n coordinate: (data: Datum[]) => {\n return data.find((item) => isSubset(datum, item))\n },\n\n itemLine: {\n visible: false,\n },\n itemContent: {\n offsetY,\n offsetX,\n confine: true,\n text: {\n text: text,\n style: {\n opacity: 0.95,\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 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 },\n }\n })\n }) as ILineChartSpec['markPoint']\n\n return {\n ...spec,\n markPoint,\n }\n}\n"],"names":["annotationPoint","spec","context","advancedVSeed","vseed","annotation","config","theme","annotationPointList","Array","isHorizontalBar","isBarLikeChart","defaultStyle","markPoint","selectorPoint","text","textColor","textFontSize","textFontWeight","textAlign","textBaseline","textBackgroundBorderColor","textBackgroundBorderRadius","textBackgroundBorderWidth","textBackgroundColor","textBackgroundPadding","textBackgroundVisible","offsetX","offsetY","dataset","selectedData","datum","selector","dx","dy","ANNOTATION_Z_INDEX","data","item","is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G,MAAMmB,KAAK,MAAOvB,CAAAA,kBAAmBO,eAA0B;QAC/D,MAAMiB,KAAKxB,kBAAkB,IAAKO;QAElC,OAAOa,aAAa,GAAG,CAAC,CAACC,QAChB;gBACL,QAAQI;gBACR,gBAAgB;gBAChB,YAAY,CAACC,OACJA,KAAK,IAAI,CAAC,CAACC,OAASC,SAASP,OAAOM;gBAG7C,UAAU;oBACR,SAAS;gBACX;gBACA,aAAa;oBACXT;oBACAD;oBACA,SAAS;oBACT,MAAM;wBACJ,MAAMZ;wBACN,OAAO;4BACL,SAAS;4BACT,SAAS;4BACT,WAAWI;4BACX,cAAcC;4BACd,MAAMJ;4BACN,QAAQQ;4BACR,WAAW;4BACX,UAAUP;4BACV,YAAYC;4BACZe;4BACAC;wBACF;wBACA,iBAAiB;4BACf,SAASR;4BACT,SAASD;4BACT,OAAO;gCACL,SAAS;gCACT,cAAcH,8BAA8B;gCAC5C,MAAME;gCACN,QAAQH;gCACR,WAAWE;gCACXU;gCACAC;4BACF;wBACF;oBACF;gBACF;YACF;IAEJ;IAEA,OAAO;QACL,GAAGjC,IAAI;QACPY;IACF;AACF"}
|
|
@@ -23,7 +23,23 @@ const annotationVerticalLine_annotationVerticalLine = (spec, context)=>{
|
|
|
23
23
|
const { selector: selectorPoint, xValue, text = '', textPosition = 'insideEnd', textColor = theme?.textColor ?? '#ffffff', textFontSize = theme?.textFontSize ?? 12, textFontWeight = theme?.textFontWeight ?? 400, textAlign = 'center', textBaseline = 'top', lineColor = theme?.lineColor ?? '#212121', lineStyle = theme?.lineStyle ?? 'dashed', lineVisible = theme?.lineStyle ?? true, lineWidth = theme?.lineWidth ?? 1, textBackgroundVisible = theme?.textBackgroundVisible ?? true, textBackgroundColor = theme?.textBackgroundColor ?? '#212121', textBackgroundBorderColor = theme?.textBackgroundBorderColor ?? '#212121', textBackgroundBorderRadius = theme?.textBackgroundBorderRadius ?? 4, textBackgroundBorderWidth = theme?.textBackgroundBorderWidth ?? 1, textBackgroundPadding = theme?.textBackgroundPadding ?? 2 } = annotationVerticalLine;
|
|
24
24
|
const dataset = advancedVSeed.dataset.flat();
|
|
25
25
|
const generateOneMarkLine = (x)=>({
|
|
26
|
-
|
|
26
|
+
positions: (datum, series)=>{
|
|
27
|
+
const regionStart = series.getRegion()?.getLayoutStartPoint();
|
|
28
|
+
const xAxisHelper = series.getXAxisHelper();
|
|
29
|
+
const yAxisHelper = series.getYAxisHelper();
|
|
30
|
+
const xPos = xAxisHelper.getScale(0).scale(x) + regionStart.x;
|
|
31
|
+
const yRange = yAxisHelper.getScale(0).range();
|
|
32
|
+
return [
|
|
33
|
+
{
|
|
34
|
+
x: xPos,
|
|
35
|
+
y: yRange ? yRange[0] + regionStart.y : 0
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
x: xPos,
|
|
39
|
+
y: yRange ? yRange[1] + regionStart.y : 0
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
},
|
|
27
43
|
zIndex: ANNOTATION_Z_INDEX,
|
|
28
44
|
line: {
|
|
29
45
|
style: {
|
|
@@ -43,9 +59,11 @@ const annotationVerticalLine_annotationVerticalLine = (spec, context)=>{
|
|
|
43
59
|
}
|
|
44
60
|
},
|
|
45
61
|
label: {
|
|
62
|
+
confine: true,
|
|
46
63
|
text: text,
|
|
47
64
|
position: positionMap[textPosition || 'insideEnd'],
|
|
48
65
|
style: {
|
|
66
|
+
opacity: 0.95,
|
|
49
67
|
dx: 5,
|
|
50
68
|
visible: true,
|
|
51
69
|
stroke: textBackgroundColor,
|
|
@@ -60,6 +78,7 @@ const annotationVerticalLine_annotationVerticalLine = (spec, context)=>{
|
|
|
60
78
|
visible: textBackgroundVisible,
|
|
61
79
|
padding: textBackgroundPadding,
|
|
62
80
|
style: {
|
|
81
|
+
opacity: 0.95,
|
|
63
82
|
dx: 5,
|
|
64
83
|
cornerRadius: textBackgroundBorderRadius,
|
|
65
84
|
fill: textBackgroundColor,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationVerticalLine.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/annotation/annotationVerticalLine.ts"],"sourcesContent":["import type { ILineChartSpec, IMarkLineSpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { SpecPipe } from 'src/types'\nimport { isArray, isNumber, isString } from 'remeda'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\n\nexport const annotationVerticalLine: SpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const { annotation, datasetReshapeInfo, config } = advancedVSeed\n\n const { unfoldInfo, foldInfo } = datasetReshapeInfo[0]\n\n if (!annotation || !annotation.annotationVerticalLine) {\n return spec\n }\n\n const theme = config?.[vseed.chartType as 'column']?.annotation?.annotationVerticalLine\n const { annotationVerticalLine } = annotation\n const annotationVerticalLineList = Array.isArray(annotationVerticalLine)\n ? annotationVerticalLine\n : [annotationVerticalLine]\n\n const positionMap = {\n outsideStart: 'start',\n outsideEnd: 'end',\n outsideMiddle: 'middle',\n insideStart: 'insideStartTop',\n insideMiddle: 'insideMiddleTop',\n insideEnd: 'insideEndTop',\n }\n const markLine = annotationVerticalLineList.flatMap((annotationVerticalLine) => {\n const {\n selector: selectorPoint,\n xValue,\n text = '',\n textPosition = 'insideEnd',\n textColor = theme?.textColor ?? '#ffffff',\n textFontSize = theme?.textFontSize ?? 12,\n textFontWeight = theme?.textFontWeight ?? 400,\n textAlign = 'center',\n textBaseline = 'top',\n\n lineColor = theme?.lineColor ?? '#212121',\n lineStyle = theme?.lineStyle ?? 'dashed',\n lineVisible = theme?.lineStyle ?? true,\n lineWidth = theme?.lineWidth ?? 1,\n\n textBackgroundVisible = theme?.textBackgroundVisible ?? true,\n textBackgroundColor = theme?.textBackgroundColor ?? '#212121',\n textBackgroundBorderColor = theme?.textBackgroundBorderColor ?? '#212121',\n textBackgroundBorderRadius = theme?.textBackgroundBorderRadius ?? 4,\n textBackgroundBorderWidth = theme?.textBackgroundBorderWidth ?? 1,\n textBackgroundPadding = theme?.textBackgroundPadding ?? 2,\n } = annotationVerticalLine\n\n const dataset = advancedVSeed.dataset.flat()\n\n const generateOneMarkLine = (x: number | string) => ({\n x: x
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationVerticalLine.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/annotation/annotationVerticalLine.ts"],"sourcesContent":["import type { Datum, ICartesianSeries, ILineChartSpec, IMarkLineSpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { SpecPipe } from 'src/types'\nimport { isArray, isNumber, isString } from 'remeda'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\n\nexport const annotationVerticalLine: SpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const { annotation, datasetReshapeInfo, config } = advancedVSeed\n\n const { unfoldInfo, foldInfo } = datasetReshapeInfo[0]\n\n if (!annotation || !annotation.annotationVerticalLine) {\n return spec\n }\n\n const theme = config?.[vseed.chartType as 'column']?.annotation?.annotationVerticalLine\n const { annotationVerticalLine } = annotation\n const annotationVerticalLineList = Array.isArray(annotationVerticalLine)\n ? annotationVerticalLine\n : [annotationVerticalLine]\n\n const positionMap = {\n outsideStart: 'start',\n outsideEnd: 'end',\n outsideMiddle: 'middle',\n insideStart: 'insideStartTop',\n insideMiddle: 'insideMiddleTop',\n insideEnd: 'insideEndTop',\n }\n const markLine = annotationVerticalLineList.flatMap((annotationVerticalLine) => {\n const {\n selector: selectorPoint,\n xValue,\n text = '',\n textPosition = 'insideEnd',\n textColor = theme?.textColor ?? '#ffffff',\n textFontSize = theme?.textFontSize ?? 12,\n textFontWeight = theme?.textFontWeight ?? 400,\n textAlign = 'center',\n textBaseline = 'top',\n\n lineColor = theme?.lineColor ?? '#212121',\n lineStyle = theme?.lineStyle ?? 'dashed',\n lineVisible = theme?.lineStyle ?? true,\n lineWidth = theme?.lineWidth ?? 1,\n\n textBackgroundVisible = theme?.textBackgroundVisible ?? true,\n textBackgroundColor = theme?.textBackgroundColor ?? '#212121',\n textBackgroundBorderColor = theme?.textBackgroundBorderColor ?? '#212121',\n textBackgroundBorderRadius = theme?.textBackgroundBorderRadius ?? 4,\n textBackgroundBorderWidth = theme?.textBackgroundBorderWidth ?? 1,\n textBackgroundPadding = theme?.textBackgroundPadding ?? 2,\n } = annotationVerticalLine\n\n const dataset = advancedVSeed.dataset.flat()\n\n const generateOneMarkLine = (x: number | string) => ({\n positions: (datum: Datum[], series: ICartesianSeries) => {\n const regionStart = series.getRegion()?.getLayoutStartPoint()\n const xAxisHelper = series.getXAxisHelper()\n const yAxisHelper = series.getYAxisHelper()\n const xPos = xAxisHelper.getScale!(0).scale(x) + regionStart.x\n const yRange = yAxisHelper.getScale!(0).range()\n\n return [\n { x: xPos, y: yRange ? yRange[0] + regionStart.y : 0 },\n {\n x: xPos,\n y: yRange ? yRange[1] + regionStart.y : 0,\n },\n ]\n },\n zIndex: ANNOTATION_Z_INDEX,\n line: {\n style: {\n visible: lineVisible,\n stroke: lineColor,\n lineStyle: lineStyle,\n lineWidth: lineWidth,\n lineDash: lineStyle === 'dashed' ? [5, 2] : lineStyle === 'dotted' ? [2, 5] : [0],\n },\n },\n label: {\n confine: true,\n text: text,\n position: positionMap[textPosition || 'insideEnd'],\n style: {\n opacity: 0.95,\n dx: 5,\n visible: true,\n stroke: textBackgroundColor,\n lineWidth: 1,\n textAlign: textAlign,\n textBaseline: textBaseline,\n fill: textColor,\n fontSize: textFontSize,\n fontWeight: textFontWeight,\n },\n labelBackground: {\n visible: textBackgroundVisible,\n padding: textBackgroundPadding,\n style: {\n opacity: 0.95,\n dx: 5,\n cornerRadius: textBackgroundBorderRadius,\n fill: textBackgroundColor,\n fillOpacity: 1,\n stroke: textBackgroundBorderColor,\n lineWidth: textBackgroundBorderWidth,\n },\n },\n },\n startSymbol: {\n visible: theme?.startSymbolVisible ?? true,\n symbolType: theme?.startSymbolType ?? 'triangleDown',\n size: 5 + (lineWidth || 1),\n style: {\n dy: -3,\n fill: lineColor,\n },\n },\n endSymbol: {\n visible: theme?.endSymbolVisible ?? false,\n symbolType: theme?.endSymbolType ?? 'arrow',\n size: 10 + (lineWidth || 1),\n style: {\n dy: 4,\n fill: lineColor,\n },\n },\n })\n\n if ((!selectorPoint && isArray(xValue)) || isString(xValue) || isNumber(xValue)) {\n const xValueArr = Array.isArray(xValue) ? xValue : [xValue]\n return xValueArr.map(generateOneMarkLine)\n }\n\n const selectedData = selectorPoint ? dataset.filter((datum) => selector(datum, selectorPoint)) : []\n\n return selectedData.map((datum) => {\n if (datum[unfoldInfo.encodingX]) {\n return generateOneMarkLine(datum[unfoldInfo.encodingX] as string)\n }\n if (datum[foldInfo.measureValue]) {\n return generateOneMarkLine(datum[foldInfo.measureValue] as string)\n }\n return {}\n })\n }) as IMarkLineSpec[]\n\n const specMarkLine = ((spec as ILineChartSpec).markLine as IMarkLineSpec[]) || []\n const newMarkLine = [...specMarkLine, ...(markLine || [])]\n\n return {\n ...spec,\n markLine: newMarkLine,\n }\n}\n"],"names":["annotationVerticalLine","spec","context","advancedVSeed","vseed","annotation","datasetReshapeInfo","config","unfoldInfo","foldInfo","theme","annotationVerticalLineList","Array","positionMap","markLine","selectorPoint","xValue","text","textPosition","textColor","textFontSize","textFontWeight","textAlign","textBaseline","lineColor","lineStyle","lineVisible","lineWidth","textBackgroundVisible","textBackgroundColor","textBackgroundBorderColor","textBackgroundBorderRadius","textBackgroundBorderWidth","textBackgroundPadding","dataset","generateOneMarkLine","x","datum","series","regionStart","xAxisHelper","yAxisHelper","xPos","yRange","ANNOTATION_Z_INDEX","isArray","isString","isNumber","xValueArr","selectedData","selector","specMarkLine","newMarkLine"],"mappings":";;;AAMO,MAAMA,gDAAmC,CAACC,MAAMC;IACrD,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IACjC,MAAM,EAAEG,UAAU,EAAEC,kBAAkB,EAAEC,MAAM,EAAE,GAA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AAO,iBAAiB;oBACpC,MAAM,KAAMiB,CAAAA,aAAa;oBACzB,OAAO;wBACL,IAAI;wBACJ,MAAMH;oBACR;gBACF;YACF;QAEA,IAAK,CAACT,iBAAiB8B,QAAQ7B,WAAY8B,SAAS9B,WAAW+B,SAAS/B,SAAS;YAC/E,MAAMgC,YAAYpC,MAAM,OAAO,CAACI,UAAUA,SAAS;gBAACA;aAAO;YAC3D,OAAOgC,UAAU,GAAG,CAACb;QACvB;QAEA,MAAMc,eAAelC,gBAAgBmB,QAAQ,MAAM,CAAC,CAACG,QAAUa,SAASb,OAAOtB,kBAAkB,EAAE;QAEnG,OAAOkC,aAAa,GAAG,CAAC,CAACZ;YACvB,IAAIA,KAAK,CAAC7B,WAAW,SAAS,CAAC,EAC7B,OAAO2B,oBAAoBE,KAAK,CAAC7B,WAAW,SAAS,CAAC;YAExD,IAAI6B,KAAK,CAAC5B,SAAS,YAAY,CAAC,EAC9B,OAAO0B,oBAAoBE,KAAK,CAAC5B,SAAS,YAAY,CAAC;YAEzD,OAAO,CAAC;QACV;IACF;IAEA,MAAM0C,eAAiBlD,KAAwB,QAAQ,IAAwB,EAAE;IACjF,MAAMmD,cAAc;WAAID;WAAkBrC,YAAY,EAAE;KAAE;IAE1D,OAAO;QACL,GAAGb,IAAI;QACP,UAAUmD;IACZ;AACF"}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
import { Color, array } from "@visactor/vutils";
|
|
1
|
+
import { Color, array, clamper } from "@visactor/vutils";
|
|
2
2
|
import { isNullish, isNumber, isPlainObject } from "remeda";
|
|
3
|
+
const formatGradientStops = (stops)=>{
|
|
4
|
+
const firstInvalidateIndex = stops.findIndex((stop)=>stop.offset < 0 || stop.offset > 1);
|
|
5
|
+
if (firstInvalidateIndex >= 0) {
|
|
6
|
+
if (stops[firstInvalidateIndex].offset > 1) {
|
|
7
|
+
const newStops = stops.slice(0, firstInvalidateIndex + 1);
|
|
8
|
+
newStops[newStops.length - 1].offset = 1;
|
|
9
|
+
return newStops;
|
|
10
|
+
}
|
|
11
|
+
const newStops = stops.slice(firstInvalidateIndex + 1);
|
|
12
|
+
newStops[0].offset = 0;
|
|
13
|
+
return newStops;
|
|
14
|
+
}
|
|
15
|
+
return stops;
|
|
16
|
+
};
|
|
3
17
|
const splitLine = (spec, context)=>{
|
|
4
18
|
const { advancedVSeed } = context;
|
|
5
19
|
const { annotation, chartType, datasetReshapeInfo } = advancedVSeed;
|
|
@@ -41,7 +55,8 @@ const splitLine = (spec, context)=>{
|
|
|
41
55
|
});
|
|
42
56
|
});
|
|
43
57
|
if (!points || !points.length) return;
|
|
44
|
-
const
|
|
58
|
+
const scale = lineSeries.getYAxisHelper().getScale(0);
|
|
59
|
+
const splitCoordinate = scale.scale(splitValue);
|
|
45
60
|
const minY = Math.min(...points.map((p)=>p.y));
|
|
46
61
|
const maxY = Math.max(...points.map((p)=>p.y));
|
|
47
62
|
const ratio = (splitCoordinate - minY) / (maxY - minY);
|
|
@@ -51,7 +66,7 @@ const splitLine = (spec, context)=>{
|
|
|
51
66
|
x1: 0,
|
|
52
67
|
y0: 0,
|
|
53
68
|
y1: 1,
|
|
54
|
-
stops: [
|
|
69
|
+
stops: formatGradientStops([
|
|
55
70
|
{
|
|
56
71
|
color: colorConfig.positiveColor,
|
|
57
72
|
offset: 0
|
|
@@ -68,7 +83,7 @@ const splitLine = (spec, context)=>{
|
|
|
68
83
|
color: colorConfig.negativeColor,
|
|
69
84
|
offset: 1
|
|
70
85
|
}
|
|
71
|
-
]
|
|
86
|
+
])
|
|
72
87
|
};
|
|
73
88
|
const areaFill = {
|
|
74
89
|
gradient: 'linear',
|
|
@@ -76,7 +91,7 @@ const splitLine = (spec, context)=>{
|
|
|
76
91
|
x1: 0,
|
|
77
92
|
y0: 0,
|
|
78
93
|
y1: 1,
|
|
79
|
-
stops: [
|
|
94
|
+
stops: formatGradientStops([
|
|
80
95
|
{
|
|
81
96
|
color: colorConfig.positiveColor,
|
|
82
97
|
offset: 0
|
|
@@ -93,7 +108,7 @@ const splitLine = (spec, context)=>{
|
|
|
93
108
|
color: colorConfig.negativeColor,
|
|
94
109
|
offset: 1
|
|
95
110
|
}
|
|
96
|
-
]
|
|
111
|
+
])
|
|
97
112
|
};
|
|
98
113
|
const attrs = {
|
|
99
114
|
segments: null,
|
|
@@ -106,12 +121,13 @@ const splitLine = (spec, context)=>{
|
|
|
106
121
|
lineGraphics[0].setAttributes(attrs);
|
|
107
122
|
lineGraphics[0].setFinalAttributes?.(attrs);
|
|
108
123
|
const start = lineSeries.getRegion().getLayoutStartPoint();
|
|
124
|
+
const range = scale.range();
|
|
109
125
|
return {
|
|
110
126
|
points: points.map((entry)=>({
|
|
111
127
|
x: entry.x + start.x,
|
|
112
128
|
y: entry.y + start.y
|
|
113
129
|
})),
|
|
114
|
-
splitCoordinate,
|
|
130
|
+
splitCoordinate: clamper(range[0], range[range.length - 1])(splitCoordinate) + start.y,
|
|
115
131
|
areaFill,
|
|
116
132
|
lineStroke
|
|
117
133
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/splitLine.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/annotation/splitLine.ts"],"sourcesContent":["import type { ICartesianSeries, IChart, ILineChartSpec, IVChart } from '@visactor/vchart'\nimport { array, Color as VUtilColor } from '@visactor/vutils'\nimport { isNullish, isNumber, isPlainObject } from 'remeda'\nimport type { AnnotationHorizontalLine, SpecPipe, Color } from 'src/types'\n\ninterface SplitConfig {\n points: { x: number; y: number }[]\n splitCoordinate: number\n lineStroke: {\n gradient: string\n x0: number\n x1: number\n y0: number\n y1: number\n stops: {\n color: string\n offset: number\n }[]\n }\n areaFill: {\n gradient: string\n x0: number\n x1: number\n y0: number\n y1: number\n stops: {\n color: string\n offset: number\n }[]\n }\n}\n\nexport const splitLine: SpecPipe = (spec, context) => {\n const { advancedVSeed } = context\n const { annotation, chartType, datasetReshapeInfo } = advancedVSeed\n\n if (!annotation || !annotation.annotationHorizontalLine) {\n return spec\n }\n const baseConfig = advancedVSeed.config[chartType] as { color: Color }\n\n const splitLineConfig = array(annotation.annotationHorizontalLine).find(\n (item) => !!(item as AnnotationHorizontalLine).splitLine,\n ) as AnnotationHorizontalLine | undefined\n\n const splitValue = +(splitLineConfig?.yValue as number | string)\n\n if (Number.isNaN(splitValue) || !isNumber(splitValue)) {\n return spec\n }\n const result = { ...spec } as Partial<ILineChartSpec>\n const colorTheme = baseConfig?.color ?? {}\n const colorConfig = {\n positiveColor: colorTheme.positiveColor || 'red',\n negativeColor: colorTheme.negativeColor || 'green',\n ...(isPlainObject(splitLineConfig?.splitLine) ? splitLineConfig?.splitLine : {}),\n }\n\n const groupMark = {\n type: 'group',\n name: 'annotationHorizontalLine-splitLine',\n zIndex: 300,\n style: {\n splitConfig: (datum: any, ctx: any) => {\n const vchart = ctx.vchart as IVChart\n const chart = vchart.getChart() as IChart\n const lineSeries = chart.getAllSeries().find((s) => s.type === 'line' || s.type === 'area') as ICartesianSeries\n\n if (!lineSeries) {\n return\n }\n const lineMark = lineSeries.getMarkInName('line') ?? lineSeries.getMarkInName('area')\n\n if (!lineMark) {\n return\n }\n const lineGraphics = lineMark.getGraphics()\n\n if (!lineGraphics || lineGraphics.length !== 1 || !lineGraphics[0]) {\n return\n }\n const points = ((lineGraphics[0].attribute as any).points ?? []) as { x: number; y: number }[]\n\n if ((lineGraphics[0].attribute as any).segments?.length) {\n ;((lineGraphics[0].attribute as any).segments as any[]).forEach(\n (seg: { points: { x: number; y: number }[] }) => {\n seg.points.forEach((pt: { x: number; y: number }) => {\n points.push({ x: pt.x, y: pt.y })\n })\n },\n )\n }\n\n if (!points || !points.length) {\n return\n }\n const splitCoordinate = lineSeries.getYAxisHelper().getScale!(0).scale(splitValue)\n const minY = Math.min(...points.map((p) => p.y))\n const maxY = Math.max(...points.map((p) => p.y))\n const ratio = (splitCoordinate - minY) / (maxY - minY)\n const lineStroke = {\n gradient: 'linear',\n x0: 0,\n x1: 0,\n y0: 0,\n y1: 1,\n stops: [\n {\n color: colorConfig.positiveColor,\n offset: 0,\n },\n {\n color: colorConfig.positiveColor,\n offset: ratio,\n },\n {\n color: colorConfig.negativeColor,\n offset: ratio + 0.0000001,\n },\n {\n color: colorConfig.negativeColor,\n offset: 1,\n },\n ],\n }\n const areaFill = {\n gradient: 'linear',\n x0: 0,\n x1: 0,\n y0: 0,\n y1: 1,\n stops: [\n {\n color: colorConfig.positiveColor,\n offset: 0,\n },\n {\n color: new VUtilColor(colorConfig.positiveColor).setOpacity(0).toRGBA(),\n offset: ratio,\n },\n {\n offset: ratio + 0.0000001,\n color: new VUtilColor(colorConfig.negativeColor).setOpacity(0).toRGBA(),\n },\n {\n color: colorConfig.negativeColor,\n offset: 1,\n },\n ],\n }\n const attrs: any = {\n segments: null,\n points,\n }\n\n if (lineGraphics[0].type === 'area') {\n attrs.stroke = lineStroke\n attrs.fill = areaFill\n } else {\n attrs.stroke = lineStroke\n }\n\n lineGraphics[0].setAttributes(attrs as unknown as Record<string, any>)\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n lineGraphics[0].setFinalAttributes?.(attrs)\n const start = lineSeries.getRegion().getLayoutStartPoint()\n\n return {\n points: points.map((entry) => ({ x: entry.x + start.x, y: entry.y + start.y })),\n splitCoordinate,\n areaFill,\n lineStroke,\n } as SplitConfig\n },\n },\n children: [\n {\n type: 'area',\n interactive: false,\n zIndex: 500,\n style: {\n fillOpacity: 0.5,\n points: (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.splitConfig) {\n const { points, splitCoordinate } = parentNode.attribute.splitConfig as SplitConfig\n\n return points.map((entry: { x: number; y: number }) => {\n return {\n ...entry,\n y1: splitCoordinate,\n }\n })\n }\n\n return []\n },\n fill: (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.splitConfig) {\n const { areaFill } = parentNode.attribute.splitConfig as SplitConfig\n\n return areaFill\n }\n\n return\n },\n },\n },\n ],\n }\n\n if (!result.customMark) {\n result.customMark = []\n }\n\n ;(result.customMark as any[]).push(groupMark)\n\n const seriesSpec =\n result.type === 'line' || result.type === 'area'\n ? result\n : result.series?.find((s) => s.type === 'line' || s.type === 'area')\n\n if (seriesSpec) {\n if (!seriesSpec.point) {\n seriesSpec.point = {}\n }\n if (!seriesSpec.line) {\n seriesSpec.line = {}\n }\n\n if (!seriesSpec.point.style) {\n seriesSpec.point.style = {}\n }\n if (!seriesSpec.line.style) {\n seriesSpec.line.style = {}\n }\n\n const measureValueKey = datasetReshapeInfo[0].foldInfo.measureValue\n\n seriesSpec.point.style.fill = (datum) => {\n return datum?.[measureValueKey] >= splitValue ? colorConfig.positiveColor : colorConfig.negativeColor\n }\n seriesSpec.line.style.stroke = (datum) => {\n return datum?.[measureValueKey] >= splitValue ? colorConfig.positiveColor : colorConfig.negativeColor\n }\n if (seriesSpec.label && (seriesSpec.label as any).visible && isNullish((seriesSpec.label as any).style?.fill)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n ;(seriesSpec.label as any).style = {\n ...(seriesSpec.label as any).style,\n fill: (datum: any) => {\n return datum?.[measureValueKey] >= splitValue ? colorConfig.positiveColor : colorConfig.negativeColor\n },\n }\n }\n }\n\n return result\n}\n"],"names":["splitLine","spec","context","advancedVSeed","annotation","chartType","datasetReshapeInfo","baseConfig","splitLineConfig","array","item","splitValue","Number","isNumber","result","colorTheme","colorConfig","isPlainObject","groupMark","datum","ctx","vchart","chart","lineSeries","s","lineMark","lineGraphics","points","seg","pt","splitCoordinate","minY","Math","p","maxY","ratio","lineStroke","areaFill","VUtilColor","attrs","start","entry","opt","parentNode","seriesSpec","measureValueKey","isNullish"],"mappings":";;AAgCO,MAAMA,YAAsB,CAACC,MAAMC;IACxC,MAAM,EAAEC,aAAa,EAAE,GAAGD;IAC1B,MAAM,EAAEE,UAAU,EAAEC,SAAS,EAAEC,kBAAkB,EAAE,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,aAAa;QAEzG;IAEJ;IAEA,OAAOF;AACT"}
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/splitLine.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/annotation/splitLine.ts"],"sourcesContent":["import type { ICartesianSeries, IChart, ILineChartSpec, IVChart } from '@visactor/vchart'\nimport { array, clamper, Color as VUtilColor } from '@visactor/vutils'\nimport { isNullish, isNumber, isPlainObject } from 'remeda'\nimport type { AnnotationHorizontalLine, SpecPipe, Color } from 'src/types'\n\ninterface SplitConfig {\n points: { x: number; y: number }[]\n splitCoordinate: number\n lineStroke: {\n gradient: string\n x0: number\n x1: number\n y0: number\n y1: number\n stops: {\n color: string\n offset: number\n }[]\n }\n areaFill: {\n gradient: string\n x0: number\n x1: number\n y0: number\n y1: number\n stops: {\n color: string\n offset: number\n }[]\n }\n}\n\nconst formatGradientStops = (stops: { color: string; offset: number }[]) => {\n const firstInvalidateIndex = stops.findIndex((stop) => stop.offset < 0 || stop.offset > 1)\n\n if (firstInvalidateIndex >= 0) {\n if (stops[firstInvalidateIndex].offset > 1) {\n const newStops = stops.slice(0, firstInvalidateIndex + 1)\n newStops[newStops.length - 1].offset = 1\n\n return newStops\n }\n const newStops = stops.slice(firstInvalidateIndex + 1)\n\n newStops[0].offset = 0\n return newStops\n }\n\n return stops\n}\n\nexport const splitLine: SpecPipe = (spec, context) => {\n const { advancedVSeed } = context\n const { annotation, chartType, datasetReshapeInfo } = advancedVSeed\n\n if (!annotation || !annotation.annotationHorizontalLine) {\n return spec\n }\n const baseConfig = advancedVSeed.config[chartType] as { color: Color }\n\n const splitLineConfig = array(annotation.annotationHorizontalLine).find(\n (item) => !!(item as AnnotationHorizontalLine).splitLine,\n ) as AnnotationHorizontalLine | undefined\n\n const splitValue = +(splitLineConfig?.yValue as number | string)\n\n if (Number.isNaN(splitValue) || !isNumber(splitValue)) {\n return spec\n }\n const result = { ...spec } as Partial<ILineChartSpec>\n const colorTheme = baseConfig?.color ?? {}\n const colorConfig = {\n positiveColor: colorTheme.positiveColor || 'red',\n negativeColor: colorTheme.negativeColor || 'green',\n ...(isPlainObject(splitLineConfig?.splitLine) ? splitLineConfig?.splitLine : {}),\n }\n\n const groupMark = {\n type: 'group',\n name: 'annotationHorizontalLine-splitLine',\n zIndex: 300,\n style: {\n splitConfig: (datum: any, ctx: any) => {\n const vchart = ctx.vchart as IVChart\n const chart = vchart.getChart() as IChart\n const lineSeries = chart.getAllSeries().find((s) => s.type === 'line' || s.type === 'area') as ICartesianSeries\n\n if (!lineSeries) {\n return\n }\n const lineMark = lineSeries.getMarkInName('line') ?? lineSeries.getMarkInName('area')\n\n if (!lineMark) {\n return\n }\n const lineGraphics = lineMark.getGraphics()\n\n if (!lineGraphics || lineGraphics.length !== 1 || !lineGraphics[0]) {\n return\n }\n const points = ((lineGraphics[0].attribute as any).points ?? []) as { x: number; y: number }[]\n\n if ((lineGraphics[0].attribute as any).segments?.length) {\n ;((lineGraphics[0].attribute as any).segments as any[]).forEach(\n (seg: { points: { x: number; y: number }[] }) => {\n seg.points.forEach((pt: { x: number; y: number }) => {\n points.push({ x: pt.x, y: pt.y })\n })\n },\n )\n }\n\n if (!points || !points.length) {\n return\n }\n const scale = lineSeries.getYAxisHelper().getScale!(0)\n const splitCoordinate = scale.scale(splitValue)\n const minY = Math.min(...points.map((p) => p.y))\n const maxY = Math.max(...points.map((p) => p.y))\n const ratio = (splitCoordinate - minY) / (maxY - minY)\n\n const lineStroke = {\n gradient: 'linear',\n x0: 0,\n x1: 0,\n y0: 0,\n y1: 1,\n stops: formatGradientStops([\n {\n color: colorConfig.positiveColor,\n offset: 0,\n },\n {\n color: colorConfig.positiveColor,\n offset: ratio,\n },\n {\n color: colorConfig.negativeColor,\n offset: ratio + 0.0000001,\n },\n {\n color: colorConfig.negativeColor,\n offset: 1,\n },\n ]),\n }\n const areaFill = {\n gradient: 'linear',\n x0: 0,\n x1: 0,\n y0: 0,\n y1: 1,\n stops: formatGradientStops([\n {\n color: colorConfig.positiveColor,\n offset: 0,\n },\n {\n color: new VUtilColor(colorConfig.positiveColor).setOpacity(0).toRGBA(),\n offset: ratio,\n },\n {\n offset: ratio + 0.0000001,\n color: new VUtilColor(colorConfig.negativeColor).setOpacity(0).toRGBA(),\n },\n {\n color: colorConfig.negativeColor,\n offset: 1,\n },\n ]),\n }\n const attrs: any = {\n segments: null,\n points,\n }\n\n if (lineGraphics[0].type === 'area') {\n attrs.stroke = lineStroke\n attrs.fill = areaFill\n } else {\n attrs.stroke = lineStroke\n }\n\n lineGraphics[0].setAttributes(attrs as unknown as Record<string, any>)\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n lineGraphics[0].setFinalAttributes?.(attrs)\n const start = lineSeries.getRegion().getLayoutStartPoint()\n const range = scale.range() as number[]\n\n return {\n points: points.map((entry) => ({ x: entry.x + start.x, y: entry.y + start.y })),\n splitCoordinate: clamper(range[0], range[range.length - 1])(splitCoordinate as number) + start.y,\n areaFill,\n lineStroke,\n } as SplitConfig\n },\n },\n children: [\n {\n type: 'area',\n interactive: false,\n zIndex: 500,\n style: {\n fillOpacity: 0.5,\n points: (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.splitConfig) {\n const { points, splitCoordinate } = parentNode.attribute.splitConfig as SplitConfig\n\n return points.map((entry: { x: number; y: number }) => {\n return {\n ...entry,\n y1: splitCoordinate,\n }\n })\n }\n\n return []\n },\n fill: (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.splitConfig) {\n const { areaFill } = parentNode.attribute.splitConfig as SplitConfig\n\n return areaFill\n }\n\n return\n },\n },\n },\n ],\n }\n\n if (!result.customMark) {\n result.customMark = []\n }\n\n ;(result.customMark as any[]).push(groupMark)\n\n const seriesSpec =\n result.type === 'line' || result.type === 'area'\n ? result\n : result.series?.find((s) => s.type === 'line' || s.type === 'area')\n\n if (seriesSpec) {\n if (!seriesSpec.point) {\n seriesSpec.point = {}\n }\n if (!seriesSpec.line) {\n seriesSpec.line = {}\n }\n\n if (!seriesSpec.point.style) {\n seriesSpec.point.style = {}\n }\n if (!seriesSpec.line.style) {\n seriesSpec.line.style = {}\n }\n\n const measureValueKey = datasetReshapeInfo[0].foldInfo.measureValue\n\n seriesSpec.point.style.fill = (datum) => {\n return datum?.[measureValueKey] >= splitValue ? colorConfig.positiveColor : colorConfig.negativeColor\n }\n seriesSpec.line.style.stroke = (datum) => {\n return datum?.[measureValueKey] >= splitValue ? colorConfig.positiveColor : colorConfig.negativeColor\n }\n if (seriesSpec.label && (seriesSpec.label as any).visible && isNullish((seriesSpec.label as any).style?.fill)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n ;(seriesSpec.label as any).style = {\n ...(seriesSpec.label as any).style,\n fill: (datum: any) => {\n return datum?.[measureValueKey] >= splitValue ? colorConfig.positiveColor : colorConfig.negativeColor\n },\n }\n }\n }\n\n return result\n}\n"],"names":["formatGradientStops","stops","firstInvalidateIndex","stop","newStops","splitLine","spec","context","advancedVSeed","annotation","chartType","datasetReshapeInfo","baseConfig","splitLineConfig","array","item","splitValue","Number","isNumber","result","colorTheme","colorConfig","isPlainObject","groupMark","datum","ctx","vchart","chart","lineSeries","s","lineMark","lineGraphics","points","seg","pt","scale","splitCoordinate","minY","Math","p","maxY","ratio","lineStroke","areaFill","VUtilColor","attrs","start","range","entry","clamper","opt","parentNode","seriesSpec","measureValueKey","isNullish"],"mappings":";;AAgCA,MAAMA,sBAAsB,CAACC;IAC3B,MAAMC,uBAAuBD,MAAM,SAAS,CAAC,CAACE,OAASA,KAAK,MAAM,GAAG,KAAKA,KAAK,MAAM,GAAG;IAExF,IAAID,wBAAwB,GAAG;QAC7B,IAAID,KAAK,CAACC,qBAAqB,CAAC,MAAM,GAAG,GAAG;YAC1C,MAAME,WAAWH,MAAM,KAAK,CAAC,GAAGC,uBAAuB;YACvDE,QAAQ,CAACA,SAAS,MAAM,GAAG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C,IAAI,GAAG,CAAC5B,QACtBA,OAAO,CAAC6B,gBAAgB,IAAIrC,aAAaK,YAAY,aAAa,GAAGA,YAAY,aAAa;QAEvG+B,WAAW,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC5B,QACvBA,OAAO,CAAC6B,gBAAgB,IAAIrC,aAAaK,YAAY,aAAa,GAAGA,YAAY,aAAa;QAEvG,IAAI+B,WAAW,KAAK,IAAKA,WAAW,KAAK,CAAS,OAAO,IAAIE,UAAWF,WAAW,KAAK,CAAS,KAAK,EAAE,OAEpGA,WAAW,KAAK,CAAS,KAAK,GAAG;YACjC,GAAIA,WAAW,KAAK,CAAS,KAAK;YAClC,MAAM,CAAC5B,QACEA,OAAO,CAAC6B,gBAAgB,IAAIrC,aAAaK,YAAY,aAAa,GAAGA,YAAY,aAAa;QAEzG;IAEJ;IAEA,OAAOF;AACT"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defaultTitleText } from "./title/defaultTitleText.js";
|
|
2
|
+
import { AXIS_LABEL_SPACE } from "../../../../utils/index.js";
|
|
2
3
|
const xBand = (spec, context)=>{
|
|
3
4
|
const result = {
|
|
4
5
|
...spec
|
|
@@ -20,7 +21,7 @@ const xBand = (spec, context)=>{
|
|
|
20
21
|
label: {
|
|
21
22
|
visible: label?.visible,
|
|
22
23
|
flush: true,
|
|
23
|
-
space:
|
|
24
|
+
space: AXIS_LABEL_SPACE,
|
|
24
25
|
style: {
|
|
25
26
|
maxLineWidth: labelAutoLimitLength,
|
|
26
27
|
fill: label?.labelColor,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/axes/xBand.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/axes/xBand.ts"],"sourcesContent":["import type { ICartesianBandAxisSpec, ISpec } from '@visactor/vchart'\nimport type { SpecPipe, XBandAxis } from 'src/types'\nimport { defaultTitleText } from './title/defaultTitleText'\n\nexport const xBand: SpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n const { measures, dimensions, encoding } = advancedVSeed\n const config = advancedVSeed.config?.[chartType as 'column']?.xAxis as XBandAxis\n\n if (!result.axes) {\n result.axes = []\n }\n\n const {\n visible = true,\n label,\n tick,\n title,\n grid,\n line,\n labelAutoHide,\n labelAutoHideGap,\n labelAutoLimit,\n labelAutoLimitLength = 80,\n labelAutoRotate,\n labelAutoRotateAngleRange,\n } = config\n\n const sampling = !(labelAutoHide || labelAutoRotate || labelAutoLimit)\n\n const bandAxis = {\n visible,\n type: 'band',\n orient: 'bottom',\n maxHeight: labelAutoLimitLength + 60,\n sampling,\n hover: true,\n label: {\n visible: label?.visible,\n flush: true,\n space:
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/axes/xBand.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/axes/xBand.ts"],"sourcesContent":["import type { ICartesianBandAxisSpec, ISpec } from '@visactor/vchart'\nimport type { SpecPipe, XBandAxis } from 'src/types'\nimport { defaultTitleText } from './title/defaultTitleText'\nimport { AXIS_LABEL_SPACE } from 'src/pipeline/utils'\n\nexport const xBand: SpecPipe = (spec, context) => {\n const result = { ...spec } as ISpec\n const { advancedVSeed, vseed } = context\n const { chartType } = vseed\n const { measures, dimensions, encoding } = advancedVSeed\n const config = advancedVSeed.config?.[chartType as 'column']?.xAxis as XBandAxis\n\n if (!result.axes) {\n result.axes = []\n }\n\n const {\n visible = true,\n label,\n tick,\n title,\n grid,\n line,\n labelAutoHide,\n labelAutoHideGap,\n labelAutoLimit,\n labelAutoLimitLength = 80,\n labelAutoRotate,\n labelAutoRotateAngleRange,\n } = config\n\n const sampling = !(labelAutoHide || labelAutoRotate || labelAutoLimit)\n\n const bandAxis = {\n visible,\n type: 'band',\n orient: 'bottom',\n maxHeight: labelAutoLimitLength + 60,\n sampling,\n hover: true,\n label: {\n visible: label?.visible,\n flush: true,\n space: AXIS_LABEL_SPACE,\n style: {\n maxLineWidth: labelAutoLimitLength,\n fill: label?.labelColor,\n angle: label?.labelAngle,\n fontSize: label?.labelFontSize,\n fontWeight: label?.labelFontWeight,\n },\n\n // 防重叠相关\n minGap: labelAutoHideGap,\n autoHide: labelAutoHide,\n autoHideMethod: 'greedy',\n autoHideSeparation: labelAutoHideGap,\n autoLimit: labelAutoLimit,\n autoRotate: labelAutoRotate,\n autoRotateAngle: labelAutoRotateAngleRange,\n lastVisible: true,\n },\n title: {\n visible: title?.visible,\n text: title?.titleText || defaultTitleText(measures, dimensions, encoding.x as string[]),\n style: {\n fill: title?.titleColor,\n fontSize: title?.titleFontSize,\n fontWeight: title?.titleFontWeight,\n },\n },\n tick: {\n visible: tick?.visible,\n tickSize: tick?.tickSize,\n inside: tick?.tickInside,\n style: {\n stroke: tick?.tickColor,\n },\n },\n grid: {\n visible: grid?.visible,\n style: {\n lineWidth: grid?.gridWidth,\n stroke: grid?.gridColor,\n lineDash: grid?.gridLineDash,\n },\n },\n domainLine: {\n visible: line?.visible,\n style: {\n lineWidth: line?.lineWidth,\n stroke: line?.lineColor,\n },\n },\n paddingInner: [0.15, 0.1],\n paddingOuter: [0.075, 0.1],\n } as ICartesianBandAxisSpec\n\n result.axes = [...result.axes, bandAxis] as ISpec['axes']\n return result\n}\n"],"names":["xBand","spec","context","result","advancedVSeed","vseed","chartType","measures","dimensions","encoding","config","visible","label","tick","title","grid","line","labelAutoHide","labelAutoHideGap","labelAutoLimit","labelAutoLimitLength","labelAutoRotate","labelAutoRotateAngleRange","sampling","bandAxis","AXIS_LABEL_SPACE","defaultTitleText"],"mappings":";;AAKO,MAAMA,QAAkB,CAACC,MAAMC;IACpC,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAEC,KAAK,EAAE,GAAGH;IACjC,MAAM,EAAEI,SAAS,EAAE,GAAGD;IACtB,MAAM,EAAEE,QAAQ,EAAEC,UAAU,EAAEC,QAAQ,EA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AAc;YAAC;YAAM;SAAI;QACzB,cAAc;YAAC;YAAO;SAAI;IAC5B;IAEAb,OAAO,IAAI,GAAG;WAAIA,OAAO,IAAI;QAAEqB;KAAS;IACxC,OAAOrB;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LINEAR_AXIS_INNER_OFFSET_TOP, createNumFormatter, isAreaPercent, isBarPercent, isColumnPercent } from "../../../../utils/index.js";
|
|
1
|
+
import { AXIS_LABEL_SPACE, LINEAR_AXIS_INNER_OFFSET_TOP, createNumFormatter, isAreaPercent, isBarPercent, isColumnPercent } from "../../../../utils/index.js";
|
|
2
2
|
import { createLinearFormat, createLinearPercentFormat } from "./format/linearFormat.js";
|
|
3
3
|
import { defaultTitleText } from "./title/defaultTitleText.js";
|
|
4
4
|
const xLinear = (spec, context)=>{
|
|
@@ -26,6 +26,7 @@ const xLinear = (spec, context)=>{
|
|
|
26
26
|
max,
|
|
27
27
|
min,
|
|
28
28
|
label: {
|
|
29
|
+
space: AXIS_LABEL_SPACE,
|
|
29
30
|
visible: label?.visible,
|
|
30
31
|
formatMethod: (value)=>{
|
|
31
32
|
if (isBarPercent(vseed) || isColumnPercent(vseed) || isAreaPercent(vseed)) return createLinearPercentFormat(value, autoFormat, numFormat, formatter, percentFormatter);
|