@visactor/vseed 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPointCommon.js +14 -1
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPointCommon.js.map +1 -1
- package/dist/umd/index.js +14 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,20 @@ const generateAnnotationPointPipe = (options)=>{
|
|
|
6
6
|
const findSelectedDatas = options.findSelectedDatas ?? ((dataset, s)=>dataset.filter((datum)=>selector(datum, s)));
|
|
7
7
|
const generateMarkPoint = options.generateMarkPoint ?? ((datum)=>[
|
|
8
8
|
{
|
|
9
|
-
coordinate: (data
|
|
9
|
+
coordinate: (data, context)=>{
|
|
10
|
+
const targetDatum = data.find((item)=>isSubset(datum, item));
|
|
11
|
+
if (true === context.getStack()) {
|
|
12
|
+
const stackedDatum = {
|
|
13
|
+
...datum,
|
|
14
|
+
...targetDatum
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
...stackedDatum,
|
|
18
|
+
[context.getStackValueField()]: stackedDatum['__VCHART_STACK_END']
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return targetDatum;
|
|
22
|
+
}
|
|
10
23
|
}
|
|
11
24
|
]);
|
|
12
25
|
return (spec, context)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationPointCommon.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/annotation/annotationPointCommon.ts"],"sourcesContent":["import type { ISpec, IMarkPointSpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { Datum, Selector, Selectors, SpecPipelineContext, VChartSpecPipe, VSeed } from 'src/types'\nimport { isSubset } from './utils'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport { isBarLikeChart } from 'src/pipeline/utils/chatType'\
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationPointCommon.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/annotation/annotationPointCommon.ts"],"sourcesContent":["import type { ISpec, IMarkPointSpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { Datum, Selector, Selectors, SpecPipelineContext, VChartSpecPipe, VSeed } from 'src/types'\nimport { isSubset } from './utils'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport { isBarLikeChart } from 'src/pipeline/utils/chatType'\nexport const generateAnnotationPointPipe = (options: {\n findSelectedDatas?: (\n dataset: Datum[],\n selector: Selector | Selectors | undefined | null,\n spec: ISpec,\n context: SpecPipelineContext,\n ) => Datum[]\n generateMarkPoint?: (datum: Datum, spec: ISpec, context: SpecPipelineContext) => IMarkPointSpec[] | undefined\n}) => {\n const findSelectedDatas = options.findSelectedDatas ?? ((dataset, s) => dataset.filter((datum) => selector(datum, s)))\n const generateMarkPoint =\n options.generateMarkPoint ??\n ((datum: Datum) => {\n return [\n {\n coordinate: (data: Datum[], context) => {\n const targetDatum = data.find((item) => isSubset(datum, item))\n if (context.getStack() === true) {\n const stackedDatum = { ...datum, ...targetDatum }\n return {\n ...stackedDatum,\n [context.getStackValueField()]: stackedDatum['__VCHART_STACK_END'],\n }\n }\n\n return targetDatum\n },\n },\n ]\n })\n\n return ((spec: ISpec, context: SpecPipelineContext) => {\n const { advancedVSeed, vseed } = context\n const { annotation, config } = advancedVSeed\n\n if (!annotation || !annotation.annotationPoint) {\n return spec\n }\n\n const theme = config?.[vseed.chartType as 'column']?.annotation?.annotationPoint\n const { annotationPoint } = annotation\n const annotationPointList = Array.isArray(annotationPoint) ? annotationPoint : [annotationPoint]\n const isHorizontalBar = isBarLikeChart(advancedVSeed as VSeed)\n const defaultStyle = isHorizontalBar\n ? {\n textAlign: 'right',\n textBaseline: 'middle',\n }\n : {\n textAlign: 'center',\n textBaseline: 'top',\n }\n\n const markPoint = annotationPointList.flatMap((annotationPoint) => {\n const {\n selector: selectorPoint,\n 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 ? findSelectedDatas(dataset, selectorPoint, spec, context) : []\n const dx = -10 - (isHorizontalBar ? (textFontSize as number) : 0) // 由于vchart tag实现问题,需要设置这个强制偏移量\n const dy = isHorizontalBar ? 0 : (textFontSize as number)\n const markPointStyle = {\n zIndex: ANNOTATION_Z_INDEX,\n regionRelative: true,\n itemLine: {\n visible: false,\n },\n itemContent: {\n offsetY,\n offsetX,\n confine: true,\n text: {\n text: text,\n labelBackground: {\n visible: textBackgroundVisible,\n padding: textBackgroundPadding,\n style: {\n opacity: 0.95,\n cornerRadius: textBackgroundBorderRadius ?? 4,\n fill: textBackgroundColor,\n stroke: textBackgroundBorderColor,\n lineWidth: textBackgroundBorderWidth,\n dx,\n dy,\n },\n },\n },\n style: {\n 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 },\n } as Partial<IMarkPointSpec>\n\n return selectedData.reduce((res: IMarkPointSpec[], datum) => {\n const marks = generateMarkPoint(datum, spec, context)\n\n if (marks && marks.length) {\n marks.forEach((mark) => {\n res.push({\n ...markPointStyle,\n ...mark,\n } as IMarkPointSpec)\n })\n }\n\n return res\n }, [])\n }) as unknown as IMarkPointSpec[]\n\n return {\n ...spec,\n markPoint,\n } as ISpec\n }) as VChartSpecPipe\n}\n"],"names":["generateAnnotationPointPipe","options","findSelectedDatas","dataset","s","datum","selector","generateMarkPoint","data","context","targetDatum","item","isSubset","stackedDatum","spec","advancedVSeed","vseed","annotation","config","theme","annotationPoint","annotationPointList","Array","isHorizontalBar","isBarLikeChart","defaultStyle","markPoint","selectorPoint","text","textColor","textFontSize","textFontWeight","textAlign","textBaseline","textBackgroundBorderColor","textBackgroundBorderRadius","textBackgroundBorderWidth","textBackgroundColor","textBackgroundPadding","textBackgroundVisible","offsetX","offsetY","selectedData","dx","dy","markPointStyle","ANNOTATION_Z_INDEX","res","marks","mark"],"mappings":";;;;AAMO,MAAMA,8BAA8B,CAACC;IAS1C,MAAMC,oBAAoBD,QAAQ,iBAAiB,IAAM,EAAAE,SAASC,IAAMD,QAAQ,MAAM,CAAC,CAACE,QAAUC,SAASD,OAAOD,GAAE;IACpH,MAAMG,oBACJN,QAAQ,iBAAiB,IACvB,EAAAI,QACO;YACL;gBACE,YAAY,CAACG,MAAeC;oBAC1B,MAAMC,cAAcF,KAAK,IAAI,CAAC,CAACG,OAASC,SAASP,OAAOM;oBACxD,IAAIF,AAAuB,SAAvBA,QAAQ,QAAQ,IAAa;wBAC/B,MAAMI,eAAe;4BAAE,GAAGR,KAAK;4BAAE,GAAGK,WAAW;wBAAC;wBAChD,OAAO;4BACL,GAAGG,YAAY;4BACf,CAACJ,QAAQ,kBAAkB,GAAG,EAAEI,YAAY,CAAC,qBAAqB;wBACpE;oBACF;oBAEA,OAAOH;gBACT;YACF;SACD,AACH;IAEF,OAAQ,CAACI,MAAaL;QACpB,MAAM,EAAEM,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AClC,MAAMe,iBAAiB;gBACrB,QAAQC;gBACR,gBAAgB;gBAChB,UAAU;oBACR,SAAS;gBACX;gBACA,aAAa;oBACXL;oBACAD;oBACA,SAAS;oBACT,MAAM;wBACJ,MAAMZ;wBACN,iBAAiB;4BACf,SAASW;4BACT,SAASD;4BACT,OAAO;gCACL,SAAS;gCACT,cAAcH,8BAA8B;gCAC5C,MAAME;gCACN,QAAQH;gCACR,WAAWE;gCACXO;gCACAC;4BACF;wBACF;oBACF;oBACA,OAAO;wBACL,SAAS;wBACT,SAAS;wBACT,WAAWZ;wBACX,cAAcC;wBACd,MAAMJ;wBACN,QAAQQ;wBACR,WAAW;wBACX,UAAUP;wBACV,YAAYC;wBACZY;wBACAC;oBACF;gBACF;YACF;YAEA,OAAOF,aAAa,MAAM,CAAC,CAACK,KAAuB1C;gBACjD,MAAM2C,QAAQzC,kBAAkBF,OAAOS,MAAML;gBAE7C,IAAIuC,SAASA,MAAM,MAAM,EACvBA,MAAM,OAAO,CAAC,CAACC;oBACbF,IAAI,IAAI,CAAC;wBACP,GAAGF,cAAc;wBACjB,GAAGI,IAAI;oBACT;gBACF;gBAGF,OAAOF;YACT,GAAG,EAAE;QACP;QAEA,OAAO;YACL,GAAGjC,IAAI;YACPY;QACF;IACF;AACF"}
|
package/dist/umd/index.js
CHANGED
|
@@ -4070,7 +4070,20 @@
|
|
|
4070
4070
|
const findSelectedDatas = options.findSelectedDatas ?? ((dataset, s)=>dataset.filter((datum)=>selector_selector(datum, s)));
|
|
4071
4071
|
const generateMarkPoint = options.generateMarkPoint ?? ((datum)=>[
|
|
4072
4072
|
{
|
|
4073
|
-
coordinate: (data
|
|
4073
|
+
coordinate: (data, context)=>{
|
|
4074
|
+
const targetDatum = data.find((item)=>isSubset(datum, item));
|
|
4075
|
+
if (true === context.getStack()) {
|
|
4076
|
+
const stackedDatum = {
|
|
4077
|
+
...datum,
|
|
4078
|
+
...targetDatum
|
|
4079
|
+
};
|
|
4080
|
+
return {
|
|
4081
|
+
...stackedDatum,
|
|
4082
|
+
[context.getStackValueField()]: stackedDatum['__VCHART_STACK_END']
|
|
4083
|
+
};
|
|
4084
|
+
}
|
|
4085
|
+
return targetDatum;
|
|
4086
|
+
}
|
|
4074
4087
|
}
|
|
4075
4088
|
]);
|
|
4076
4089
|
return (spec, context)=>{
|