@visactor/vseed 0.1.24 → 0.1.26

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.
@@ -1,3 +1,6 @@
1
1
  import type { Builder } from '../builder';
2
- export declare const getColorItems: (builder: Builder) => string[];
2
+ export declare const getColorItems: (builder: Builder) => {
3
+ id: string;
4
+ alias: string;
5
+ }[];
3
6
  export declare const getColorIdMap: (builder: Builder) => Record<string, string>;
@@ -9,7 +9,10 @@ const getColorItems = (builder)=>{
9
9
  ...prev,
10
10
  ...cur.unfoldInfo.colorIdMap
11
11
  }), {});
12
- return colorItems.map((d)=>colorIdMap[d]);
12
+ return colorItems.map((d)=>({
13
+ id: d,
14
+ alias: colorIdMap[d]
15
+ }));
13
16
  };
14
17
  const getColorIdMap = (builder)=>{
15
18
  const advancedVSeed = builder.advancedVSeed;
@@ -1 +1 @@
1
- {"version":3,"file":"builder/builder/advanced/colorItems.js","sources":["webpack://@visactor/vseed/./src/builder/builder/advanced/colorItems.ts"],"sourcesContent":["import { unique } from 'remeda'\nimport type { Builder } from '../builder'\nimport { isPivotTable, isTable } from 'src/pipeline'\n\nexport const getColorItems = (builder: Builder): string[] => {\n const advancedVSeed = builder.advancedVSeed\n\n if (!advancedVSeed || isTable(builder.vseed) || isPivotTable(builder.vseed)) {\n return []\n }\n\n const { datasetReshapeInfo } = advancedVSeed\n const colorItems = unique(datasetReshapeInfo.flatMap((d) => d.unfoldInfo.colorItems))\n const colorIdMap = datasetReshapeInfo.reduce<Record<string, string>>((prev, cur) => {\n return { ...prev, ...cur.unfoldInfo.colorIdMap }\n }, {})\n\n return colorItems.map((d) => colorIdMap[d])\n}\n\nexport const getColorIdMap = (builder: Builder): Record<string, string> => {\n const advancedVSeed = builder.advancedVSeed\n\n if (!advancedVSeed || isTable(builder.vseed) || isPivotTable(builder.vseed)) {\n return {}\n }\n\n const { datasetReshapeInfo } = advancedVSeed\n const colorIdMap = datasetReshapeInfo.reduce<Record<string, string>>((prev, cur) => {\n return { ...prev, ...cur.unfoldInfo.colorIdMap }\n }, {})\n\n return colorIdMap\n}\n"],"names":["getColorItems","builder","advancedVSeed","isTable","isPivotTable","datasetReshapeInfo","colorItems","unique","d","colorIdMap","prev","cur","getColorIdMap"],"mappings":";;AAIO,MAAMA,gBAAgB,CAACC;IAC5B,MAAMC,gBAAgBD,QAAQ,aAAa;IAE3C,IAAI,CAACC,iBAAiBC,QAAQF,QAAQ,KAAK,KAAKG,aAAaH,QAAQ,KAAK,GACxE,OAAO,EAAE;IAGX,MAAM,EAAEI,kBAAkB,EAAE,GAAGH;IAC/B,MAAMI,aAAaC,OAAOF,mBAAmB,OAAO,CAAC,CAACG,IAAMA,EAAE,UAAU,CAAC,UAAU;IACnF,MAAMC,aAAaJ,mBAAmB,MAAM,CAAyB,CAACK,MAAMC,MACnE;YAAE,GAAGD,IAAI;YAAE,GAAGC,IAAI,UAAU,CAAC,UAAU;QAAC,IAC9C,CAAC;IAEJ,OAAOL,WAAW,GAAG,CAAC,CAACE,IAAMC,UAAU,CAACD,EAAE;AAC5C;AAEO,MAAMI,gBAAgB,CAACX;IAC5B,MAAMC,gBAAgBD,QAAQ,aAAa;IAE3C,IAAI,CAACC,iBAAiBC,QAAQF,QAAQ,KAAK,KAAKG,aAAaH,QAAQ,KAAK,GACxE,OAAO,CAAC;IAGV,MAAM,EAAEI,kBAAkB,EAAE,GAAGH;IAC/B,MAAMO,aAAaJ,mBAAmB,MAAM,CAAyB,CAACK,MAAMC,MACnE;YAAE,GAAGD,IAAI;YAAE,GAAGC,IAAI,UAAU,CAAC,UAAU;QAAC,IAC9C,CAAC;IAEJ,OAAOF;AACT"}
1
+ {"version":3,"file":"builder/builder/advanced/colorItems.js","sources":["webpack://@visactor/vseed/./src/builder/builder/advanced/colorItems.ts"],"sourcesContent":["import { unique } from 'remeda'\nimport type { Builder } from '../builder'\nimport { isPivotTable, isTable } from 'src/pipeline'\n\nexport const getColorItems = (builder: Builder): { id: string; alias: string }[] => {\n const advancedVSeed = builder.advancedVSeed\n\n if (!advancedVSeed || isTable(builder.vseed) || isPivotTable(builder.vseed)) {\n return []\n }\n\n const { datasetReshapeInfo } = advancedVSeed\n const colorItems = unique(datasetReshapeInfo.flatMap((d) => d.unfoldInfo.colorItems))\n const colorIdMap = datasetReshapeInfo.reduce<Record<string, string>>((prev, cur) => {\n return { ...prev, ...cur.unfoldInfo.colorIdMap }\n }, {})\n\n return colorItems.map((d) => ({\n id: d,\n alias: colorIdMap[d],\n }))\n}\n\nexport const getColorIdMap = (builder: Builder): Record<string, string> => {\n const advancedVSeed = builder.advancedVSeed\n\n if (!advancedVSeed || isTable(builder.vseed) || isPivotTable(builder.vseed)) {\n return {}\n }\n\n const { datasetReshapeInfo } = advancedVSeed\n const colorIdMap = datasetReshapeInfo.reduce<Record<string, string>>((prev, cur) => {\n return { ...prev, ...cur.unfoldInfo.colorIdMap }\n }, {})\n\n return colorIdMap\n}\n"],"names":["getColorItems","builder","advancedVSeed","isTable","isPivotTable","datasetReshapeInfo","colorItems","unique","d","colorIdMap","prev","cur","getColorIdMap"],"mappings":";;AAIO,MAAMA,gBAAgB,CAACC;IAC5B,MAAMC,gBAAgBD,QAAQ,aAAa;IAE3C,IAAI,CAACC,iBAAiBC,QAAQF,QAAQ,KAAK,KAAKG,aAAaH,QAAQ,KAAK,GACxE,OAAO,EAAE;IAGX,MAAM,EAAEI,kBAAkB,EAAE,GAAGH;IAC/B,MAAMI,aAAaC,OAAOF,mBAAmB,OAAO,CAAC,CAACG,IAAMA,EAAE,UAAU,CAAC,UAAU;IACnF,MAAMC,aAAaJ,mBAAmB,MAAM,CAAyB,CAACK,MAAMC,MACnE;YAAE,GAAGD,IAAI;YAAE,GAAGC,IAAI,UAAU,CAAC,UAAU;QAAC,IAC9C,CAAC;IAEJ,OAAOL,WAAW,GAAG,CAAC,CAACE,IAAO;YAC5B,IAAIA;YACJ,OAAOC,UAAU,CAACD,EAAE;QACtB;AACF;AAEO,MAAMI,gBAAgB,CAACX;IAC5B,MAAMC,gBAAgBD,QAAQ,aAAa;IAE3C,IAAI,CAACC,iBAAiBC,QAAQF,QAAQ,KAAK,KAAKG,aAAaH,QAAQ,KAAK,GACxE,OAAO,CAAC;IAGV,MAAM,EAAEI,kBAAkB,EAAE,GAAGH;IAC/B,MAAMO,aAAaJ,mBAAmB,MAAM,CAAyB,CAACK,MAAMC,MACnE;YAAE,GAAGD,IAAI;YAAE,GAAGC,IAAI,UAAU,CAAC,UAAU;QAAC,IAC9C,CAAC;IAEJ,OAAOF;AACT"}
@@ -25,7 +25,10 @@ export declare class Builder implements VSeedBuilder {
25
25
  * @description 获取颜色项, 颜色项可以重复,
26
26
  * @returns 颜色项
27
27
  */
28
- getColorItems: () => string[];
28
+ getColorItems: () => {
29
+ id: string;
30
+ alias: string;
31
+ }[];
29
32
  /**
30
33
  * @description 获取颜色id映射
31
34
  * @returns 颜色id映射
@@ -1,10 +1,9 @@
1
1
  import { selector } from "../../../../../dataSelector/index.js";
2
- import { groupBy, isEmpty, isNullish } from "remeda";
2
+ import { isEmpty, isNullish } from "remeda";
3
3
  import { getCurveTension, getCurveType } from "./curve/index.js";
4
4
  const lineStyle_lineStyle = (spec, context)=>{
5
5
  const { advancedVSeed } = context;
6
- const { markStyle, datasetReshapeInfo, dataset } = advancedVSeed;
7
- const { unfoldInfo } = datasetReshapeInfo[0];
6
+ const { markStyle } = advancedVSeed;
8
7
  const { lineStyle } = markStyle;
9
8
  const result = {
10
9
  ...spec,
@@ -16,8 +15,6 @@ const lineStyle_lineStyle = (spec, context)=>{
16
15
  const lineStyles = Array.isArray(lineStyle) ? lineStyle : [
17
16
  lineStyle
18
17
  ];
19
- const colorId = unfoldInfo.encodingColorId;
20
- const lineGroups = groupBy(dataset, (d)=>d[colorId ?? '']);
21
18
  const customMap = lineStyles.reduce((result, style, index)=>{
22
19
  const { lineColor, lineColorOpacity, lineSmooth, lineStyle, lineWidth = 2, lineVisible = true } = style;
23
20
  const dashSegment = 2 * lineWidth;
@@ -38,8 +35,8 @@ const lineStyle_lineStyle = (spec, context)=>{
38
35
  ...result,
39
36
  [`custom${index + 1}`]: {
40
37
  level: index + 1,
41
- filter: (datum)=>{
42
- const lineData = lineGroups[datum[colorId ?? '']];
38
+ filter: (_, node)=>{
39
+ const lineData = node.renderNode.context.data;
43
40
  for (const d of lineData)if (selector(d, style.selector)) return true;
44
41
  return false;
45
42
  },
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline/spec/chart/pipes/markStyle/lineStyle.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/markStyle/lineStyle.ts"],"sourcesContent":["import type { IAreaChartSpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { Datum, LineStyle, SpecPipe } from 'src/types'\nimport { groupBy, isEmpty, isNullish } from 'remeda'\nimport { getCurveTension, getCurveType } from './curve'\n\nexport const lineStyle: SpecPipe = (spec, context) => {\n const { advancedVSeed } = context\n const { markStyle, datasetReshapeInfo, dataset } = advancedVSeed\n const { unfoldInfo } = datasetReshapeInfo[0]\n const { lineStyle } = markStyle\n const result = {\n ...spec,\n line: {\n style: {},\n },\n } as IAreaChartSpec\n\n if (isNullish(lineStyle) || isEmpty(lineStyle)) {\n return result\n }\n\n const lineStyles = (Array.isArray(lineStyle) ? lineStyle : [lineStyle]) as LineStyle[]\n\n const colorId = unfoldInfo.encodingColorId\n const lineGroups = groupBy(dataset, (d) => d[colorId ?? ''] as string)\n\n const customMap = lineStyles.reduce<object>((result, style, index) => {\n const { lineColor, lineColorOpacity, lineSmooth, lineStyle, lineWidth = 2, lineVisible = true } = style\n\n const dashSegment = lineWidth * 2\n const dashGap = lineWidth\n\n const lineDash =\n lineStyle === 'dashed' ? [dashSegment, dashSegment] : lineStyle === 'dotted' ? [dashGap / 2, dashGap * 2] : [0, 0]\n\n const curveType = getCurveType(context.vseed, lineSmooth)\n const curveTension = getCurveTension(context.vseed, lineSmooth)\n\n return {\n ...result,\n [`custom${index + 1}`]: {\n // 优先级: 后者覆盖前者\n level: index + 1,\n filter: (datum: Datum) => {\n const lineData = lineGroups[datum[colorId ?? ''] as string]\n for (const d of lineData) {\n if (selector(d, style.selector)) {\n return true\n }\n }\n return false\n },\n style: {\n visible: lineVisible,\n curveType: curveType,\n curveTension: curveTension,\n strokeOpacity: lineColorOpacity,\n stroke: lineColor,\n lineWidth: lineWidth,\n lineDash: lineDash,\n },\n },\n }\n }, {})\n\n return {\n ...result,\n line: {\n ...result.line,\n state: {\n ...customMap,\n },\n },\n }\n}\n"],"names":["lineStyle","spec","context","advancedVSeed","markStyle","datasetReshapeInfo","dataset","unfoldInfo","result","isNullish","isEmpty","lineStyles","Array","colorId","lineGroups","groupBy","d","customMap","style","index","lineColor","lineColorOpacity","lineSmooth","lineWidth","lineVisible","dashSegment","dashGap","lineDash","curveType","getCurveType","curveTension","getCurveTension","datum","lineData","selector"],"mappings":";;;AAMO,MAAMA,sBAAsB,CAACC,MAAMC;IACxC,MAAM,EAAEC,aAAa,EAAE,GAAGD;IAC1B,MAAM,EAAEE,SAAS,EAAEC,kBAAkB,EAAEC,OAAO,EAAE,GAAGH;IACnD,MAAM,EAAEI,UAAU,EAAE,GAAGF,kBAAkB,CAAC,EAAE;IAC5C,MAAM,EAAEL,SAAS,EAAE,GAAGI;IACtB,MAAMI,SAAS;QACb,GAAGP,IAAI;QACP,MAAM;YACJ,OAAO,CAAC;QACV;IACF;IAEA,IAAIQ,UAAUT,cAAcU,QAAQV,YAClC,OAAOQ;IAGT,MAAMG,aAAcC,MAAM,OAAO,CAACZ,aAAaA,YAAY;QAACA;KAAU;IAEtE,MAAMa,UAAUN,WAAW,eAAe;IAC1C,MAAMO,aAAaC,QAAQT,SAAS,CAACU,IAAMA,CAAC,CAACH,WAAW,GAAG;IAE3D,MAAMI,YAAYN,WAAW,MAAM,CAAS,CAACH,QAAQU,OAAOC;QAC1D,MAAM,EAAEC,SAAS,EAAEC,gBAAgB,EAAEC,UAAU,EAAEtB,SAAS,EAAEuB,YAAY,CAAC,EAAEC,cAAc,IAAI,EAAE,GAAGN;QAElG,MAAMO,cAAcF,AAAY,IAAZA;QACpB,MAAMG,UAAUH;QAEhB,MAAMI,WACJ3B,AAAc,aAAdA,YAAyB;YAACyB;YAAaA;SAAY,GAAGzB,AAAc,aAAdA,YAAyB;YAAC0B,UAAU;YAAa,IAAVA;SAAY,GAAG;YAAC;YAAG;SAAE;QAEpH,MAAME,YAAYC,aAAa3B,QAAQ,KAAK,EAAEoB;QAC9C,MAAMQ,eAAeC,gBAAgB7B,QAAQ,KAAK,EAAEoB;QAEpD,OAAO;YACL,GAAGd,MAAM;YACT,CAAC,CAAC,MAAM,EAAEW,QAAQ,GAAG,CAAC,EAAE;gBAEtB,OAAOA,QAAQ;gBACf,QAAQ,CAACa;oBACP,MAAMC,WAAWnB,UAAU,CAACkB,KAAK,CAACnB,WAAW,GAAG,CAAW;oBAC3D,KAAK,MAAMG,KAAKiB,SACd,IAAIC,SAASlB,GAAGE,MAAM,QAAQ,GAC5B,OAAO;oBAGX,OAAO;gBACT;gBACA,OAAO;oBACL,SAASM;oBACT,WAAWI;oBACX,cAAcE;oBACd,eAAeT;oBACf,QAAQD;oBACR,WAAWG;oBACX,UAAUI;gBACZ;YACF;QACF;IACF,GAAG,CAAC;IAEJ,OAAO;QACL,GAAGnB,MAAM;QACT,MAAM;YACJ,GAAGA,OAAO,IAAI;YACd,OAAO;gBACL,GAAGS,SAAS;YACd;QACF;IACF;AACF"}
1
+ {"version":3,"file":"pipeline/spec/chart/pipes/markStyle/lineStyle.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/markStyle/lineStyle.ts"],"sourcesContent":["import type { IAreaChartSpec } from '@visactor/vchart'\nimport { selector } from '../../../../../dataSelector'\nimport type { Datum, LineStyle, SpecPipe } from 'src/types'\nimport { isEmpty, isNullish } from 'remeda'\nimport { getCurveTension, getCurveType } from './curve'\n\nexport const lineStyle: SpecPipe = (spec, context) => {\n const { advancedVSeed } = context\n const { markStyle } = advancedVSeed\n const { lineStyle } = markStyle\n const result = {\n ...spec,\n line: {\n style: {},\n },\n } as IAreaChartSpec\n\n if (isNullish(lineStyle) || isEmpty(lineStyle)) {\n return result\n }\n\n const lineStyles = (Array.isArray(lineStyle) ? lineStyle : [lineStyle]) as LineStyle[]\n\n const customMap = lineStyles.reduce<object>((result, style, index) => {\n const { lineColor, lineColorOpacity, lineSmooth, lineStyle, lineWidth = 2, lineVisible = true } = style\n\n const dashSegment = lineWidth * 2\n const dashGap = lineWidth\n\n const lineDash =\n lineStyle === 'dashed' ? [dashSegment, dashSegment] : lineStyle === 'dotted' ? [dashGap / 2, dashGap * 2] : [0, 0]\n\n const curveType = getCurveType(context.vseed, lineSmooth)\n const curveTension = getCurveTension(context.vseed, lineSmooth)\n\n return {\n ...result,\n [`custom${index + 1}`]: {\n // 优先级: 后者覆盖前者\n level: index + 1,\n filter: (\n _: Datum,\n node: {\n renderNode: {\n context: {\n data: Datum[]\n }\n }\n },\n ) => {\n const lineData = node.renderNode.context.data\n for (const d of lineData) {\n if (selector(d, style.selector)) {\n return true\n }\n }\n return false\n },\n style: {\n visible: lineVisible,\n curveType: curveType,\n curveTension: curveTension,\n strokeOpacity: lineColorOpacity,\n stroke: lineColor,\n lineWidth: lineWidth,\n lineDash: lineDash,\n },\n },\n }\n }, {})\n\n return {\n ...result,\n line: {\n ...result.line,\n state: {\n ...customMap,\n },\n },\n }\n}\n"],"names":["lineStyle","spec","context","advancedVSeed","markStyle","result","isNullish","isEmpty","lineStyles","Array","customMap","style","index","lineColor","lineColorOpacity","lineSmooth","lineWidth","lineVisible","dashSegment","dashGap","lineDash","curveType","getCurveType","curveTension","getCurveTension","_","node","lineData","d","selector"],"mappings":";;;AAMO,MAAMA,sBAAsB,CAACC,MAAMC;IACxC,MAAM,EAAEC,aAAa,EAAE,GAAGD;IAC1B,MAAM,EAAEE,SAAS,EAAE,GAAGD;IACtB,MAAM,EAAEH,SAAS,EAAE,GAAGI;IACtB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7 @@
1
1
  import { isNumber } from "remeda";
2
2
  import { intl } from "../../../i18n/index.js";
3
3
  const createNumFormatter = (format, locale = intl.getLocale())=>{
4
- const { type = 'number', ratio = 1, symbol = '', thousandSeparator = true, prefix = '', suffix = '', fractionDigits = 2, significantDigits, roundingMode = 'halfExpand', roundingPriority = 'auto' } = format || {};
4
+ const { type = 'number', ratio = 1, thousandSeparator = true, prefix = '', suffix = '', symbol = '', fractionDigits = 2, significantDigits, roundingMode = 'halfExpand', roundingPriority = 'auto' } = format || {};
5
5
  const numFormatterOptions = {
6
6
  style: 'decimal',
7
7
  notation: 'scientific' === type ? 'scientific' : 'standard',
@@ -41,7 +41,8 @@ const createNumFormatter = (format, locale = intl.getLocale())=>{
41
41
  parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
42
42
  numStr = parts.join('.');
43
43
  }
44
- return `${prefix}${numStr}${typeSymbol}${symbol}${suffix}`;
44
+ const validSymbol = symbol ?? '';
45
+ return `${prefix}${numStr}${typeSymbol}${validSymbol}${suffix}`;
45
46
  };
46
47
  };
47
48
  const autoNumFormatter = (value, locale = intl.getLocale())=>{
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline/utils/format/createNumFormatter.js","sources":["webpack://@visactor/vseed/./src/pipeline/utils/format/createNumFormatter.ts"],"sourcesContent":["import { isNumber } from 'remeda'\nimport { intl } from '../../../i18n'\nimport type { Formatter, Locale, NumFormat } from 'src/types'\n\nexport const createNumFormatter = (format?: Partial<NumFormat>, locale: Locale = intl.getLocale()): Formatter => {\n const {\n type = 'number',\n ratio = 1,\n symbol = '',\n thousandSeparator = true,\n prefix = '',\n suffix = '',\n\n fractionDigits = 2,\n significantDigits,\n roundingMode = 'halfExpand',\n roundingPriority = 'auto',\n } = format || {}\n\n const numFormatterOptions: Intl.NumberFormatOptions = {\n style: 'decimal',\n notation: type === 'scientific' ? 'scientific' : 'standard',\n // @ts-expect-error roundingMode is not in NumberFormatOptions\n roundingMode,\n roundingPriority,\n }\n\n if (isNumber(fractionDigits)) {\n if (fractionDigits >= 0) {\n numFormatterOptions.minimumFractionDigits = fractionDigits\n numFormatterOptions.maximumFractionDigits = fractionDigits\n }\n }\n if (isNumber(significantDigits) && significantDigits > 0) {\n if (significantDigits > 0) {\n numFormatterOptions.minimumSignificantDigits = significantDigits\n numFormatterOptions.maximumSignificantDigits = significantDigits\n }\n }\n\n const numFormatter = new Intl.NumberFormat(locale, { ...numFormatterOptions, useGrouping: thousandSeparator })\n\n return (value?: number | string) => {\n let num = Number(value)\n let typeSymbol = ''\n if (Number.isNaN(num)) {\n return String(value)\n }\n\n // apply ratio for percent/permille\n if (type === 'percent') {\n num *= 100\n typeSymbol = '%'\n } else if (type === 'permille') {\n num *= 1000\n typeSymbol = '‰'\n } else if (type === 'number') {\n num = num / (ratio || 1)\n }\n\n // format value\n let numStr = numFormatter.format(num)\n\n // add thousand separator\n if (thousandSeparator) {\n const parts = numStr.split('.')\n parts[0] = parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',')\n numStr = parts.join('.')\n }\n\n // add symbol, typeSymbol, prefix and suffix\n return `${prefix}${numStr}${typeSymbol}${symbol}${suffix}`\n }\n}\n\nexport const autoNumFormatter = (value?: number | string, locale: Locale = intl.getLocale()): string => {\n if (value === undefined || value === null) return String(value)\n const num = Number(value)\n if (Number.isNaN(num)) return String(value)\n\n const numFormatterOptions: Intl.NumberFormatOptions = {\n style: 'decimal',\n notation: 'compact',\n useGrouping: true,\n }\n numFormatterOptions.minimumFractionDigits = 0\n numFormatterOptions.maximumFractionDigits = 2\n\n const numFormatter = new Intl.NumberFormat(locale, { ...numFormatterOptions })\n\n return numFormatter.format(Number(value))\n}\n"],"names":["createNumFormatter","format","locale","intl","type","ratio","symbol","thousandSeparator","prefix","suffix","fractionDigits","significantDigits","roundingMode","roundingPriority","numFormatterOptions","isNumber","numFormatter","Intl","value","num","Number","typeSymbol","String","numStr","parts","autoNumFormatter"],"mappings":";;AAIO,MAAMA,qBAAq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,IAAI,CAAC;QACtB;QAGA,OAAO,GAAGhB,SAASe,SAASF,aAAaf,SAASG,QAAQ;IAC5D;AACF;AAEO,MAAMgB,mBAAmB,CAACP,OAAyBhB,SAAiBC,KAAK,SAAS,EAAE;IACzF,IAAIe,QAAAA,OAAuC,OAAOI,OAAOJ;IACzD,MAAMC,MAAMC,OAAOF;IACnB,IAAIE,OAAO,KAAK,CAACD,MAAM,OAAOG,OAAOJ;IAErC,MAAMJ,sBAAgD;QACpD,OAAO;QACP,UAAU;QACV,aAAa;IACf;IACAA,oBAAoB,qBAAqB,GAAG;IAC5CA,oBAAoB,qBAAqB,GAAG;IAE5C,MAAME,eAAe,IAAIC,KAAK,YAAY,CAACf,QAAQ;QAAE,GAAGY,mBAAmB;IAAC;IAE5E,OAAOE,aAAa,MAAM,CAACI,OAAOF;AACpC"}
1
+ {"version":3,"file":"pipeline/utils/format/createNumFormatter.js","sources":["webpack://@visactor/vseed/./src/pipeline/utils/format/createNumFormatter.ts"],"sourcesContent":["import { isNumber } from 'remeda'\nimport { intl } from '../../../i18n'\nimport type { Formatter, Locale, NumFormat } from 'src/types'\n\nexport const createNumFormatter = (format?: Partial<NumFormat>, locale: Locale = intl.getLocale()): Formatter => {\n const {\n type = 'number',\n ratio = 1,\n thousandSeparator = true,\n prefix = '',\n suffix = '',\n symbol = '',\n fractionDigits = 2,\n significantDigits,\n roundingMode = 'halfExpand',\n roundingPriority = 'auto',\n } = format || {}\n\n const numFormatterOptions: Intl.NumberFormatOptions = {\n style: 'decimal',\n notation: type === 'scientific' ? 'scientific' : 'standard',\n // @ts-expect-error roundingMode is not in NumberFormatOptions\n roundingMode,\n roundingPriority,\n }\n\n if (isNumber(fractionDigits)) {\n if (fractionDigits >= 0) {\n numFormatterOptions.minimumFractionDigits = fractionDigits\n numFormatterOptions.maximumFractionDigits = fractionDigits\n }\n }\n if (isNumber(significantDigits) && significantDigits > 0) {\n if (significantDigits > 0) {\n numFormatterOptions.minimumSignificantDigits = significantDigits\n numFormatterOptions.maximumSignificantDigits = significantDigits\n }\n }\n\n const numFormatter = new Intl.NumberFormat(locale, { ...numFormatterOptions, useGrouping: thousandSeparator })\n\n return (value?: number | string) => {\n let num = Number(value)\n let typeSymbol = ''\n if (Number.isNaN(num)) {\n return String(value)\n }\n\n // apply ratio for percent/permille\n if (type === 'percent') {\n num *= 100\n typeSymbol = '%'\n } else if (type === 'permille') {\n num *= 1000\n typeSymbol = '‰'\n } else if (type === 'number') {\n num = num / (ratio || 1)\n }\n\n // format value\n let numStr = numFormatter.format(num)\n\n // add thousand separator\n if (thousandSeparator) {\n const parts = numStr.split('.')\n parts[0] = parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',')\n numStr = parts.join('.')\n }\n\n const validSymbol = symbol ?? ''\n\n // add symbol, typeSymbol, prefix and suffix\n return `${prefix}${numStr}${typeSymbol}${validSymbol}${suffix}`\n }\n}\n\nexport const autoNumFormatter = (value?: number | string, locale: Locale = intl.getLocale()): string => {\n if (value === undefined || value === null) return String(value)\n const num = Number(value)\n if (Number.isNaN(num)) return String(value)\n\n const numFormatterOptions: Intl.NumberFormatOptions = {\n style: 'decimal',\n notation: 'compact',\n useGrouping: true,\n }\n numFormatterOptions.minimumFractionDigits = 0\n numFormatterOptions.maximumFractionDigits = 2\n\n const numFormatter = new Intl.NumberFormat(locale, { ...numFormatterOptions })\n\n return numFormatter.format(Number(value))\n}\n"],"names":["createNumFormatter","format","locale","intl","type","ratio","thousandSeparator","prefix","suffix","symbol","fractionDigits","significantDigits","roundingMode","roundingPriority","numFormatterOptions","isNumber","numFormatter","Intl","value","num","Number","typeSymbol","String","numStr","parts","validSymbol","autoNumFormatter"],"mappings":";;AAIO,MAAMA,qBAAqB,CAACC,QAA6BC,SAAiBC,KAAK,SAAS,EAAE;IAC/F,MAAM,EACJC,OAAO,QAAQ,EACfC,QAAQ,CAAC,EACTC,oBAAoB,IAAI,EACxBC,SAAS,EAAE,EACXC,SAAS,EAAE,EACXC,SAAS,EA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S,EAAE;IACzF,IAAIe,QAAAA,OAAuC,OAAOI,OAAOJ;IACzD,MAAMC,MAAMC,OAAOF;IACnB,IAAIE,OAAO,KAAK,CAACD,MAAM,OAAOG,OAAOJ;IAErC,MAAMJ,sBAAgD;QACpD,OAAO;QACP,UAAU;QACV,aAAa;IACf;IACAA,oBAAoB,qBAAqB,GAAG;IAC5CA,oBAAoB,qBAAqB,GAAG;IAE5C,MAAME,eAAe,IAAIC,KAAK,YAAY,CAACf,QAAQ;QAAE,GAAGY,mBAAmB;IAAC;IAE5E,OAAOE,aAAa,MAAM,CAACI,OAAOF;AACpC"}
@@ -11,7 +11,10 @@ export declare abstract class VSeedBuilder {
11
11
  static getSpecPipeline: (chartType: ChartType) => SpecPipeline;
12
12
  static getTheme: (themeKey: string) => CustomThemeConfig;
13
13
  static getThemeMap: () => Record<string, CustomThemeConfig>;
14
- abstract getColorItems: () => string[];
14
+ abstract getColorItems: () => {
15
+ id: string;
16
+ alias: string;
17
+ }[];
15
18
  abstract getColorIdMap: () => Record<string, string>;
16
19
  abstract get spec(): Spec | null;
17
20
  abstract set spec(value: Spec | null);
@@ -1 +1 @@
1
- {"version":3,"file":"types/builder/builder.js","sources":["webpack://@visactor/vseed/./src/types/builder/builder.ts"],"sourcesContent":["import type { Spec } from 'src/types'\nimport type { ChartType, CustomThemeConfig } from '../properties'\nimport type { VSeed } from '../vseed'\nimport type { AdvancedPipeline, SpecPipeline } from '../pipeline'\nimport type { AdvancedVSeed } from '../advancedVSeed'\n\nexport abstract class VSeedBuilder {\n abstract build: () => Spec\n abstract buildAdvanced: () => AdvancedVSeed | null\n abstract buildSpec: (advancedVSeed: AdvancedVSeed) => Spec\n\n static getAdvancedPipeline: (chartType: ChartType) => AdvancedPipeline\n static getSpecPipeline: (chartType: ChartType) => SpecPipeline\n static getTheme: (themeKey: string) => CustomThemeConfig\n static getThemeMap: () => Record<string, CustomThemeConfig>\n\n abstract getColorItems: () => string[]\n abstract getColorIdMap: () => Record<string, string>\n\n abstract get spec(): Spec | null\n abstract set spec(value: Spec | null)\n abstract get vseed(): VSeed\n abstract set vseed(value: VSeed)\n abstract get advancedVSeed(): AdvancedVSeed | null\n abstract set advancedVSeed(value: AdvancedVSeed | null)\n}\n"],"names":["VSeedBuilder"],"mappings":"AAMO,MAAeA;IAKpB,OAAO,oBAA+D;IACtE,OAAO,gBAAuD;IAC9D,OAAO,SAAiD;IACxD,OAAO,YAAoD;AAW7D"}
1
+ {"version":3,"file":"types/builder/builder.js","sources":["webpack://@visactor/vseed/./src/types/builder/builder.ts"],"sourcesContent":["import type { Spec } from 'src/types'\nimport type { ChartType, CustomThemeConfig } from '../properties'\nimport type { VSeed } from '../vseed'\nimport type { AdvancedPipeline, SpecPipeline } from '../pipeline'\nimport type { AdvancedVSeed } from '../advancedVSeed'\n\nexport abstract class VSeedBuilder {\n abstract build: () => Spec\n abstract buildAdvanced: () => AdvancedVSeed | null\n abstract buildSpec: (advancedVSeed: AdvancedVSeed) => Spec\n\n static getAdvancedPipeline: (chartType: ChartType) => AdvancedPipeline\n static getSpecPipeline: (chartType: ChartType) => SpecPipeline\n static getTheme: (themeKey: string) => CustomThemeConfig\n static getThemeMap: () => Record<string, CustomThemeConfig>\n\n abstract getColorItems: () => { id: string; alias: string }[]\n abstract getColorIdMap: () => Record<string, string>\n\n abstract get spec(): Spec | null\n abstract set spec(value: Spec | null)\n abstract get vseed(): VSeed\n abstract set vseed(value: VSeed)\n abstract get advancedVSeed(): AdvancedVSeed | null\n abstract set advancedVSeed(value: AdvancedVSeed | null)\n}\n"],"names":["VSeedBuilder"],"mappings":"AAMO,MAAeA;IAKpB,OAAO,oBAA+D;IACtE,OAAO,gBAAuD;IAC9D,OAAO,SAAiD;IACxD,OAAO,YAAoD;AAW7D"}
package/dist/umd/index.js CHANGED
@@ -611,7 +611,10 @@
611
611
  ...prev,
612
612
  ...cur.unfoldInfo.colorIdMap
613
613
  }), {});
614
- return colorItems.map((d)=>colorIdMap[d]);
614
+ return colorItems.map((d)=>({
615
+ id: d,
616
+ alias: colorIdMap[d]
617
+ }));
615
618
  };
616
619
  const getColorIdMap = (builder)=>{
617
620
  const advancedVSeed = builder.advancedVSeed;
@@ -1048,7 +1051,7 @@
1048
1051
  return result || [];
1049
1052
  };
1050
1053
  const createNumFormatter = (format, locale = intl.getLocale())=>{
1051
- const { type = 'number', ratio = 1, symbol = '', thousandSeparator = true, prefix = '', suffix = '', fractionDigits = 2, significantDigits, roundingMode = 'halfExpand', roundingPriority = 'auto' } = format || {};
1054
+ const { type = 'number', ratio = 1, thousandSeparator = true, prefix = '', suffix = '', symbol = '', fractionDigits = 2, significantDigits, roundingMode = 'halfExpand', roundingPriority = 'auto' } = format || {};
1052
1055
  const numFormatterOptions = {
1053
1056
  style: 'decimal',
1054
1057
  notation: 'scientific' === type ? 'scientific' : 'standard',
@@ -1088,7 +1091,8 @@
1088
1091
  parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
1089
1092
  numStr = parts.join('.');
1090
1093
  }
1091
- return `${prefix}${numStr}${typeSymbol}${symbol}${suffix}`;
1094
+ const validSymbol = symbol ?? '';
1095
+ return `${prefix}${numStr}${typeSymbol}${validSymbol}${suffix}`;
1092
1096
  };
1093
1097
  };
1094
1098
  const autoNumFormatter = (value, locale = intl.getLocale())=>{
@@ -3271,22 +3275,6 @@
3271
3275
  }
3272
3276
  return result;
3273
3277
  };
3274
- function chunk_HVPVHFDT_i(...e) {
3275
- return chunk_WIMGWYZL_u(chunk_HVPVHFDT_p, e);
3276
- }
3277
- var chunk_HVPVHFDT_p = (e, d)=>{
3278
- let r = Object.create(null);
3279
- for(let n = 0; n < e.length; n++){
3280
- let t = e[n], y = d(t, n, e);
3281
- if (void 0 !== y) {
3282
- let o = r[y];
3283
- void 0 === o ? r[y] = [
3284
- t
3285
- ] : o.push(t);
3286
- }
3287
- }
3288
- return Object.setPrototypeOf(r, Object.prototype), r;
3289
- };
3290
3278
  const getCurveType = (vseed, lineSmooth = false)=>{
3291
3279
  if (!lineSmooth) return 'linear';
3292
3280
  return isRadar(vseed) ? 'catmullRomClosed' : 'monotone';
@@ -3297,8 +3285,7 @@
3297
3285
  };
3298
3286
  const lineStyle_lineStyle = (spec, context)=>{
3299
3287
  const { advancedVSeed } = context;
3300
- const { markStyle, datasetReshapeInfo, dataset } = advancedVSeed;
3301
- const { unfoldInfo } = datasetReshapeInfo[0];
3288
+ const { markStyle } = advancedVSeed;
3302
3289
  const { lineStyle } = markStyle;
3303
3290
  const result = {
3304
3291
  ...spec,
@@ -3310,8 +3297,6 @@
3310
3297
  const lineStyles = Array.isArray(lineStyle) ? lineStyle : [
3311
3298
  lineStyle
3312
3299
  ];
3313
- const colorId = unfoldInfo.encodingColorId;
3314
- const lineGroups = chunk_HVPVHFDT_i(dataset, (d)=>d[colorId ?? '']);
3315
3300
  const customMap = lineStyles.reduce((result, style, index)=>{
3316
3301
  const { lineColor, lineColorOpacity, lineSmooth, lineStyle, lineWidth = 2, lineVisible = true } = style;
3317
3302
  const dashSegment = 2 * lineWidth;
@@ -3332,8 +3317,8 @@
3332
3317
  ...result,
3333
3318
  [`custom${index + 1}`]: {
3334
3319
  level: index + 1,
3335
- filter: (datum)=>{
3336
- const lineData = lineGroups[datum[colorId ?? '']];
3320
+ filter: (_, node)=>{
3321
+ const lineData = node.renderNode.context.data;
3337
3322
  for (const d of lineData)if (selector_selector(d, style.selector)) return true;
3338
3323
  return false;
3339
3324
  },
@@ -5905,6 +5890,22 @@
5905
5890
  }
5906
5891
  return result;
5907
5892
  };
5893
+ function chunk_HVPVHFDT_i(...e) {
5894
+ return chunk_WIMGWYZL_u(chunk_HVPVHFDT_p, e);
5895
+ }
5896
+ var chunk_HVPVHFDT_p = (e, d)=>{
5897
+ let r = Object.create(null);
5898
+ for(let n = 0; n < e.length; n++){
5899
+ let t = e[n], y = d(t, n, e);
5900
+ if (void 0 !== y) {
5901
+ let o = r[y];
5902
+ void 0 === o ? r[y] = [
5903
+ t
5904
+ ] : o.push(t);
5905
+ }
5906
+ }
5907
+ return Object.setPrototypeOf(r, Object.prototype), r;
5908
+ };
5908
5909
  const areaStyle_areaStyle = (spec, context)=>{
5909
5910
  const { advancedVSeed } = context;
5910
5911
  const { markStyle, datasetReshapeInfo, dataset } = advancedVSeed;