@hitachivantara/uikit-react-viz 5.15.17 → 5.15.19
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/ConfusionMatrix/utils.cjs +7 -1
- package/dist/esm/ConfusionMatrix/ConfusionMatrix.js.map +1 -1
- package/dist/esm/ConfusionMatrix/utils.js +7 -1
- package/dist/esm/ConfusionMatrix/utils.js.map +1 -1
- package/dist/esm/hooks/useLegend.js.map +1 -1
- package/dist/esm/hooks/useSeries.js.map +1 -1
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +4 -4
|
@@ -30,8 +30,14 @@ const useColorScale = ({
|
|
|
30
30
|
}, []);
|
|
31
31
|
const max = Math.max(...flatData);
|
|
32
32
|
const min = Math.min(...flatData);
|
|
33
|
+
const parsedColors = custom?.map(
|
|
34
|
+
(c) => typeof c === "string" ? colors?.[c] || c : c.color
|
|
35
|
+
);
|
|
33
36
|
return {
|
|
34
|
-
colorScale:
|
|
37
|
+
colorScale: parsedColors || [
|
|
38
|
+
colors?.base_light || "",
|
|
39
|
+
colors?.cat3 || ""
|
|
40
|
+
],
|
|
35
41
|
max,
|
|
36
42
|
min
|
|
37
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfusionMatrix.js","sources":["../../../src/ConfusionMatrix/ConfusionMatrix.tsx"],"sourcesContent":["import { forwardRef, useMemo } from \"react\";\nimport ReactECharts from \"echarts-for-react/lib/core\";\nimport { HeatmapChart } from \"echarts/charts\";\nimport {\n GridComponent,\n TooltipComponent,\n VisualMapComponent,\n} from \"echarts/components\";\nimport * as echarts from \"echarts/core\";\nimport { type ExtractNames } from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseChart } from \"../BaseChart\";\nimport {\n HvVisualMapHookProps,\n useData,\n useGrid,\n useOption,\n useTooltip,\n useVisualMap,\n useXAxis,\n useYAxis,\n} from \"../hooks\";\nimport {\n Arrayable,\n HvChartCommonProps,\n HvChartXAxis,\n HvChartYAxis,\n} from \"../types/common\";\nimport { HvConfusionMatrixMeasure } from \"../types/measures\";\nimport { HvChartTooltip } from \"../types/tooltip\";\nimport { getGroupKey } from \"../utils\";\nimport { useClasses } from \"./ConfusionMatrix.styles\";\nimport {\n HvConfusionMatrixColorScale,\n HvConfusionMatrixFormat,\n HvConfusionMatrixValuesProps,\n} from \"./types\";\nimport { useColorScale, useGridLayout, useSeries } from \"./utils\";\n\n// Register chart components\necharts.use([\n HeatmapChart,\n VisualMapComponent,\n GridComponent,\n TooltipComponent,\n]);\n\nexport type HvConfusionMatrixClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvConfusionMatrixProps\n extends Omit<HvChartCommonProps, \"tooltip\"> {\n /** Column to measure. */\n measure: HvConfusionMatrixMeasure;\n /** Columns to use to split the measure. */\n splitBy?: Arrayable<string>;\n /**\n * Column to use for the delta confusion matrix.\n *\n * It can be set to `true` in case the `measure` already has the calculations for the delta confusion matrix.\n */\n delta?: boolean | string;\n /** Options for the xAxis, i.e. the horizontal axis. */\n xAxis?: HvChartXAxis;\n /** Options for the yAxis, i.e. the vertical axis. */\n yAxis?: HvChartYAxis;\n /** Tooltip options. */\n tooltip?: Omit<HvChartTooltip, \"type\">;\n /** Format of the confusion matrix. Defaults to `square`. */\n format?: HvConfusionMatrixFormat;\n /** Properties to customize the prediction values. */\n valuesProps?: HvConfusionMatrixValuesProps;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvConfusionMatrixClasses;\n /**\n * Color scale of the confusion matrix.\n *\n * If an array of two strings is provided, the first and second values are the lower and upper ends of the scale, respectively.\n * An array of objects can also be used to create a custom scale.\n * If `delta` is not provided, a default color scale is used when `colorScale` is not defined: `[base-light, cat3]`.\n */\n colorScale?: [string, string] | HvConfusionMatrixColorScale[];\n}\n\n/**\n * Confusion Matrix is a table displaying the performance of a predictive model.\n * Typically the columns show the predicted class and the rows the expected class.\n * The main diagonal counts the positive matches while the cells outside it count the mismatches between predicted and expected.\n */\nexport const HvConfusionMatrix = forwardRef<\n ReactECharts,\n HvConfusionMatrixProps\n>(function HvConfusionMatrix(props, ref) {\n const {\n legend,\n groupBy,\n measure,\n sortBy,\n splitBy,\n filters,\n grid,\n data: dataProp,\n tooltip,\n xAxis,\n yAxis,\n colorScale: colorScaleProp,\n delta,\n valuesProps,\n width,\n height,\n format = \"square\",\n classes: classesProp,\n onOptionChange,\n ...others\n } = props;\n\n const { classes } = useClasses(classesProp);\n\n const groupByKey = getGroupKey(groupBy);\n\n const { data: chartData } = useData({\n data: dataProp,\n groupBy,\n measures: [measure],\n sortBy: sortBy ?? groupBy, // automatically orders x axis to create the confusion matrix\n splitBy,\n filters,\n delta: typeof delta === \"string\" ? delta : undefined,\n });\n\n const colorScale = useColorScale({\n delta: !!delta,\n data: chartData,\n custom: colorScaleProp,\n filterKey: groupByKey,\n });\n\n const chartVisualMap = useVisualMap({\n show: colorScale?.pieces != null,\n type: colorScale?.pieces != null ? \"piecewise\" : \"continuous\",\n ...(colorScale as Pick<\n HvVisualMapHookProps,\n \"max\" | \"min\" | \"colorScale\" | \"pieces\"\n >),\n ...legend,\n });\n\n const chartTooltip = useTooltip({\n component: (params) => {\n const value = params?.series?.[0].value;\n const fmtValue =\n typeof measure !== \"string\" && measure.valueFormatter\n ? measure.valueFormatter(value)\n : tooltip?.valueFormatter\n ? tooltip?.valueFormatter(value)\n : value;\n const ftmTitle = tooltip?.titleFormatter\n ? tooltip.titleFormatter(params?.title)\n : params?.title;\n\n const content = `${ftmTitle} - ${params?.series?.[0].name}: ${fmtValue}`;\n\n return `\n <div class=\"${classes.tooltipRoot}\">\n <div class=\"${classes.tooltipContainer}\">\n <div>\n <p class=\"${classes.tooltipText}\">${content}</p>\n </div>\n </div>\n </div>`;\n },\n ...tooltip,\n });\n\n const chartYAxis = useYAxis({\n axes: [\n {\n type: \"categorical\",\n name: \"True Label\",\n position: \"left\",\n ...yAxis,\n nameProps: {\n location: \"center\",\n padding:\n yAxis?.nameProps?.location == null ||\n yAxis?.nameProps?.location === \"center\"\n ? yAxis?.position === \"right\"\n ? [50, 0, 0, 0]\n : [0, 0, 50, 0]\n : undefined,\n ...yAxis?.nameProps,\n },\n data: chartData\n .columnNames()\n .filter((p) => p !== groupByKey)\n .reverse(),\n },\n ],\n });\n\n const chartXAxis = useXAxis({\n name: \"Predicted Value\",\n position: \"top\",\n ...xAxis,\n nameProps: {\n location: \"center\",\n padding:\n xAxis?.nameProps?.location == null ||\n xAxis?.nameProps?.location === \"center\"\n ? xAxis?.position === \"bottom\"\n ? [30, 0, 0, 0]\n : [0, 0, 30, 0]\n : undefined,\n ...xAxis?.nameProps,\n },\n data: chartData.array(groupByKey) as any,\n });\n\n const chartSeries = useSeries({\n data: chartData,\n filterKey: groupByKey,\n valuesProps,\n delta: !!(delta && colorScale == null),\n });\n\n const chartGridLayout = useGridLayout({\n data: chartData,\n format,\n filterKey: groupByKey,\n visualMapVisible: chartVisualMap.visualMap.show,\n visualMapYPosition: chartVisualMap.visualMap.top,\n xAxisPosition: chartXAxis.xAxis.position,\n });\n\n const chartGrid = useGrid({\n // If sizes are provided, the grid size should automatically adapt to the values provided\n width: width != null ? undefined : chartGridLayout.size.width,\n height: height != null ? undefined : chartGridLayout.size.height,\n ...chartGridLayout.padding,\n ...grid,\n });\n\n const size = useMemo(() => {\n return {\n width,\n // Echarts has a problem were the height is always set to 300px\n // Thus, we need to update the height to make sure the chart is not cut out\n height:\n height ??\n chartGridLayout.size.height +\n chartGridLayout.padding.bottom +\n chartGridLayout.padding.top,\n };\n }, [\n chartGridLayout.padding.bottom,\n chartGridLayout.padding.top,\n chartGridLayout.size.height,\n height,\n width,\n ]);\n\n const option = useOption({\n option: {\n ...chartVisualMap,\n ...chartTooltip,\n ...chartGrid,\n ...chartXAxis,\n ...chartYAxis,\n ...chartSeries,\n },\n onOptionChange,\n });\n\n return <HvBaseChart ref={ref} option={option} {...size} {...others} />;\n});\n"],"names":["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,SAAS,cAAc;AAAA,EAAA,CAClC;AAED,QAAM,kBAAkB,cAAc;AAAA,IACpC,MAAM;AAAA,IACN;AAAA,IACA,WAAW;AAAA,IACX,kBAAkB,eAAe,UAAU;AAAA,IAC3C,oBAAoB,eAAe,UAAU;AAAA,IAC7C,eAAe,WAAW,MAAM;AAAA,EAAA,CACjC;AAED,QAAM,YAAY,QAAQ;AAAA;AAAA,IAExB,OAAO,SAAS,OAAO,SAAY,gBAAgB,KAAK;AAAA,IACxD,QAAQ,UAAU,OAAO,SAAY,gBAAgB,KAAK;AAAA,IAC1D,GAAG,gBAAgB;AAAA,IACnB,GAAG;AAAA,EAAA,CACJ;AAEK,QAAA,OAAO,QAAQ,MAAM;AAClB,WAAA;AAAA,MACL;AAAA;AAAA;AAAA,MAGA,QACE,UACA,gBAAgB,KAAK,SACnB,gBAAgB,QAAQ,SACxB,gBAAgB,QAAQ;AAAA,IAC9B;AAAA,EAAA,GACC;AAAA,IACD,gBAAgB,QAAQ;AAAA,IACxB,gBAAgB,QAAQ;AAAA,IACxB,gBAAgB,KAAK;AAAA,IACrB;AAAA,IACA;AAAA,EAAA,CACD;AAED,QAAM,SAAS,UAAU;AAAA,IACvB,QAAQ;AAAA,MACN,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAAA,IACA;AAAA,EAAA,CACD;AAED,6BAAQ,aAAY,EAAA,KAAU,QAAiB,GAAG,MAAO,GAAG,QAAQ;AACtE,CAAC;"}
|
|
1
|
+
{"version":3,"file":"ConfusionMatrix.js","sources":["../../../src/ConfusionMatrix/ConfusionMatrix.tsx"],"sourcesContent":["import { forwardRef, useMemo } from \"react\";\nimport ReactECharts from \"echarts-for-react/lib/core\";\nimport { HeatmapChart } from \"echarts/charts\";\nimport {\n GridComponent,\n TooltipComponent,\n VisualMapComponent,\n} from \"echarts/components\";\nimport * as echarts from \"echarts/core\";\nimport { type ExtractNames } from \"@hitachivantara/uikit-react-utils\";\nimport { HvColorAny } from \"@hitachivantara/uikit-styles\";\n\nimport { HvBaseChart } from \"../BaseChart\";\nimport {\n HvVisualMapHookProps,\n useData,\n useGrid,\n useOption,\n useTooltip,\n useVisualMap,\n useXAxis,\n useYAxis,\n} from \"../hooks\";\nimport {\n Arrayable,\n HvChartCommonProps,\n HvChartXAxis,\n HvChartYAxis,\n} from \"../types/common\";\nimport { HvConfusionMatrixMeasure } from \"../types/measures\";\nimport { HvChartTooltip } from \"../types/tooltip\";\nimport { getGroupKey } from \"../utils\";\nimport { useClasses } from \"./ConfusionMatrix.styles\";\nimport {\n HvConfusionMatrixColorScale,\n HvConfusionMatrixFormat,\n HvConfusionMatrixValuesProps,\n} from \"./types\";\nimport { useColorScale, useGridLayout, useSeries } from \"./utils\";\n\n// Register chart components\necharts.use([\n HeatmapChart,\n VisualMapComponent,\n GridComponent,\n TooltipComponent,\n]);\n\nexport type HvConfusionMatrixClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvConfusionMatrixProps\n extends Omit<HvChartCommonProps, \"tooltip\"> {\n /** Column to measure. */\n measure: HvConfusionMatrixMeasure;\n /** Columns to use to split the measure. */\n splitBy?: Arrayable<string>;\n /**\n * Column to use for the delta confusion matrix.\n *\n * It can be set to `true` in case the `measure` already has the calculations for the delta confusion matrix.\n */\n delta?: boolean | string;\n /** Options for the xAxis, i.e. the horizontal axis. */\n xAxis?: HvChartXAxis;\n /** Options for the yAxis, i.e. the vertical axis. */\n yAxis?: HvChartYAxis;\n /** Tooltip options. */\n tooltip?: Omit<HvChartTooltip, \"type\">;\n /** Format of the confusion matrix. Defaults to `square`. */\n format?: HvConfusionMatrixFormat;\n /** Properties to customize the prediction values. */\n valuesProps?: HvConfusionMatrixValuesProps;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvConfusionMatrixClasses;\n /**\n * Color scale of the confusion matrix.\n *\n * If an array of two strings is provided, the first and second values are the lower and upper ends of the scale, respectively.\n * An array of objects can also be used to create a custom scale.\n * If `delta` is not provided, a default color scale is used when `colorScale` is not defined: `[base-light, cat3]`.\n */\n colorScale?: [HvColorAny, HvColorAny] | HvConfusionMatrixColorScale[];\n}\n\n/**\n * Confusion Matrix is a table displaying the performance of a predictive model.\n * Typically the columns show the predicted class and the rows the expected class.\n * The main diagonal counts the positive matches while the cells outside it count the mismatches between predicted and expected.\n */\nexport const HvConfusionMatrix = forwardRef<\n ReactECharts,\n HvConfusionMatrixProps\n>(function HvConfusionMatrix(props, ref) {\n const {\n legend,\n groupBy,\n measure,\n sortBy,\n splitBy,\n filters,\n grid,\n data: dataProp,\n tooltip,\n xAxis,\n yAxis,\n colorScale: colorScaleProp,\n delta,\n valuesProps,\n width,\n height,\n format = \"square\",\n classes: classesProp,\n onOptionChange,\n ...others\n } = props;\n\n const { classes } = useClasses(classesProp);\n\n const groupByKey = getGroupKey(groupBy);\n\n const { data: chartData } = useData({\n data: dataProp,\n groupBy,\n measures: [measure],\n sortBy: sortBy ?? groupBy, // automatically orders x axis to create the confusion matrix\n splitBy,\n filters,\n delta: typeof delta === \"string\" ? delta : undefined,\n });\n\n const colorScale = useColorScale({\n delta: !!delta,\n data: chartData,\n custom: colorScaleProp,\n filterKey: groupByKey,\n });\n\n const chartVisualMap = useVisualMap({\n show: colorScale?.pieces != null,\n type: colorScale?.pieces != null ? \"piecewise\" : \"continuous\",\n ...(colorScale as Pick<\n HvVisualMapHookProps,\n \"max\" | \"min\" | \"colorScale\" | \"pieces\"\n >),\n ...legend,\n });\n\n const chartTooltip = useTooltip({\n component: (params) => {\n const value = params?.series?.[0].value;\n const fmtValue =\n typeof measure !== \"string\" && measure.valueFormatter\n ? measure.valueFormatter(value)\n : tooltip?.valueFormatter\n ? tooltip?.valueFormatter(value)\n : value;\n const ftmTitle = tooltip?.titleFormatter\n ? tooltip.titleFormatter(params?.title)\n : params?.title;\n\n const content = `${ftmTitle} - ${params?.series?.[0].name}: ${fmtValue}`;\n\n return `\n <div class=\"${classes.tooltipRoot}\">\n <div class=\"${classes.tooltipContainer}\">\n <div>\n <p class=\"${classes.tooltipText}\">${content}</p>\n </div>\n </div>\n </div>`;\n },\n ...tooltip,\n });\n\n const chartYAxis = useYAxis({\n axes: [\n {\n type: \"categorical\",\n name: \"True Label\",\n position: \"left\",\n ...yAxis,\n nameProps: {\n location: \"center\",\n padding:\n yAxis?.nameProps?.location == null ||\n yAxis?.nameProps?.location === \"center\"\n ? yAxis?.position === \"right\"\n ? [50, 0, 0, 0]\n : [0, 0, 50, 0]\n : undefined,\n ...yAxis?.nameProps,\n },\n data: chartData\n .columnNames()\n .filter((p) => p !== groupByKey)\n .reverse(),\n },\n ],\n });\n\n const chartXAxis = useXAxis({\n name: \"Predicted Value\",\n position: \"top\",\n ...xAxis,\n nameProps: {\n location: \"center\",\n padding:\n xAxis?.nameProps?.location == null ||\n xAxis?.nameProps?.location === \"center\"\n ? xAxis?.position === \"bottom\"\n ? [30, 0, 0, 0]\n : [0, 0, 30, 0]\n : undefined,\n ...xAxis?.nameProps,\n },\n data: chartData.array(groupByKey) as any,\n });\n\n const chartSeries = useSeries({\n data: chartData,\n filterKey: groupByKey,\n valuesProps,\n delta: !!(delta && colorScale == null),\n });\n\n const chartGridLayout = useGridLayout({\n data: chartData,\n format,\n filterKey: groupByKey,\n visualMapVisible: chartVisualMap.visualMap.show,\n visualMapYPosition: chartVisualMap.visualMap.top,\n xAxisPosition: chartXAxis.xAxis.position,\n });\n\n const chartGrid = useGrid({\n // If sizes are provided, the grid size should automatically adapt to the values provided\n width: width != null ? undefined : chartGridLayout.size.width,\n height: height != null ? undefined : chartGridLayout.size.height,\n ...chartGridLayout.padding,\n ...grid,\n });\n\n const size = useMemo(() => {\n return {\n width,\n // Echarts has a problem were the height is always set to 300px\n // Thus, we need to update the height to make sure the chart is not cut out\n height:\n height ??\n chartGridLayout.size.height +\n chartGridLayout.padding.bottom +\n chartGridLayout.padding.top,\n };\n }, [\n chartGridLayout.padding.bottom,\n chartGridLayout.padding.top,\n chartGridLayout.size.height,\n height,\n width,\n ]);\n\n const option = useOption({\n option: {\n ...chartVisualMap,\n ...chartTooltip,\n ...chartGrid,\n ...chartXAxis,\n ...chartYAxis,\n ...chartSeries,\n },\n onOptionChange,\n });\n\n return <HvBaseChart ref={ref} option={option} {...size} {...others} />;\n});\n"],"names":["HvConfusionMatrix"],"mappings":";;;;;;;;;;;;;;;;AAyCA,QAAQ,IAAI;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AA2CM,MAAM,oBAAoB,WAG/B,SAASA,mBAAkB,OAAO,KAAK;AACjC,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,SAAS;AAAA,IACT;AAAA,IACA,GAAG;AAAA,EAAA,IACD;AAEJ,QAAM,EAAE,QAAA,IAAY,WAAW,WAAW;AAEpC,QAAA,aAAa,YAAY,OAAO;AAEtC,QAAM,EAAE,MAAM,UAAU,IAAI,QAAQ;AAAA,IAClC,MAAM;AAAA,IACN;AAAA,IACA,UAAU,CAAC,OAAO;AAAA,IAClB,QAAQ,UAAU;AAAA;AAAA,IAClB;AAAA,IACA;AAAA,IACA,OAAO,OAAO,UAAU,WAAW,QAAQ;AAAA,EAAA,CAC5C;AAED,QAAM,aAAa,cAAc;AAAA,IAC/B,OAAO,CAAC,CAAC;AAAA,IACT,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,EAAA,CACZ;AAED,QAAM,iBAAiB,aAAa;AAAA,IAClC,MAAM,YAAY,UAAU;AAAA,IAC5B,MAAM,YAAY,UAAU,OAAO,cAAc;AAAA,IACjD,GAAI;AAAA,IAIJ,GAAG;AAAA,EAAA,CACJ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
|
}, []);
|
|
29
29
|
const max = Math.max(...flatData);
|
|
30
30
|
const min = Math.min(...flatData);
|
|
31
|
+
const parsedColors = custom?.map(
|
|
32
|
+
(c) => typeof c === "string" ? colors?.[c] || c : c.color
|
|
33
|
+
);
|
|
31
34
|
return {
|
|
32
|
-
colorScale:
|
|
35
|
+
colorScale: parsedColors || [
|
|
36
|
+
colors?.base_light || "",
|
|
37
|
+
colors?.cat3 || ""
|
|
38
|
+
],
|
|
33
39
|
max,
|
|
34
40
|
min
|
|
35
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../src/ConfusionMatrix/utils.ts"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport type ColumnTable from \"arquero/dist/types/table/column-table\";\nimport { useTheme } from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvChartXAxis } from \"../types/common\";\nimport {\n HvConfusionMatrixColorScale,\n HvConfusionMatrixFormat,\n HvConfusionMatrixValuesProps,\n} from \"./types\";\n\nexport const useColorScale = ({\n data,\n delta,\n custom,\n filterKey,\n}: {\n data: ColumnTable;\n delta: boolean;\n filterKey: string;\n custom?: [string, string] | HvConfusionMatrixColorScale[];\n}) => {\n const { colors } = useTheme();\n\n const colorScale = useMemo(() => {\n if (custom == null && delta) {\n return;\n }\n\n if (custom && typeof custom[0] === \"object\") {\n return {\n pieces: (custom as HvConfusionMatrixColorScale[]).reduce<\n HvConfusionMatrixColorScale[]\n >((acc, curr) => {\n acc.push({\n ...curr,\n color: colors?.[curr.color] || curr.color,\n });\n return acc;\n }, []),\n };\n }\n\n const flatData = data\n .columnNames()\n .filter((p) => p !== filterKey)\n .reduce<number[]>((acc, c) => {\n acc.push(...data.array(c));\n return acc;\n }, []);\n const max = Math.max(...flatData);\n const min = Math.min(...flatData);\n\n return {\n colorScale:
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/ConfusionMatrix/utils.ts"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport type ColumnTable from \"arquero/dist/types/table/column-table\";\nimport { useTheme } from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvChartXAxis } from \"../types/common\";\nimport {\n HvConfusionMatrixColorScale,\n HvConfusionMatrixFormat,\n HvConfusionMatrixValuesProps,\n} from \"./types\";\n\nexport const useColorScale = ({\n data,\n delta,\n custom,\n filterKey,\n}: {\n data: ColumnTable;\n delta: boolean;\n filterKey: string;\n custom?: [string, string] | HvConfusionMatrixColorScale[];\n}) => {\n const { colors } = useTheme();\n\n const colorScale = useMemo(() => {\n if (custom == null && delta) {\n return;\n }\n\n if (custom && typeof custom[0] === \"object\") {\n return {\n pieces: (custom as HvConfusionMatrixColorScale[]).reduce<\n HvConfusionMatrixColorScale[]\n >((acc, curr) => {\n acc.push({\n ...curr,\n color: colors?.[curr.color] || curr.color,\n });\n return acc;\n }, []),\n };\n }\n\n const flatData = data\n .columnNames()\n .filter((p) => p !== filterKey)\n .reduce<number[]>((acc, c) => {\n acc.push(...data.array(c));\n return acc;\n }, []);\n const max = Math.max(...flatData);\n const min = Math.min(...flatData);\n\n const parsedColors = custom?.map((c) =>\n typeof c === \"string\" ? colors?.[c] || c : c.color,\n );\n\n return {\n colorScale: parsedColors || [\n colors?.base_light || \"\",\n colors?.cat3 || \"\",\n ],\n max,\n min,\n };\n }, [colors, custom, data, filterKey, delta]);\n\n return colorScale;\n};\n\nexport const useSeries = ({\n data,\n filterKey,\n delta,\n valuesProps,\n}: {\n data: ColumnTable;\n filterKey: string;\n delta: boolean;\n valuesProps?: HvConfusionMatrixValuesProps;\n}) => {\n const { colors } = useTheme();\n\n const getDeltaColor = useCallback(\n (value: number, diagonal: boolean) => {\n if ((diagonal && value > 0) || (!diagonal && value < 0)) {\n return colors?.positive;\n }\n if ((diagonal && value < 0) || (!diagonal && value > 0)) {\n return colors?.negative;\n }\n\n return colors?.base_light;\n },\n [colors],\n );\n\n const chartSeries = useMemo(() => {\n return {\n series: {\n id: `series~${filterKey}`,\n type: \"heatmap\",\n label: {\n show: true,\n ...valuesProps,\n ...(valuesProps?.color && {\n color: colors?.[valuesProps.color] || valuesProps.color,\n }),\n },\n emphasis: {\n disabled: true,\n },\n data: data\n .columnNames()\n .filter((p) => p !== filterKey)\n .reduce<(string | number)[][]>((acc, c, j) => {\n const row: any = (data.array(c) as any[]).reduce<\n {\n value: any[];\n visualMap?: boolean;\n itemStyle?: object;\n }[]\n >((racc, rv, i) => {\n racc.push({\n value: [data.array(filterKey)[i], c, rv != null ? rv : \"-\"],\n ...(delta && {\n visualMap: false,\n itemStyle: {\n color: getDeltaColor(rv, i === j),\n },\n }),\n });\n return racc;\n }, []);\n\n acc.push(...row);\n return acc;\n }, []),\n },\n };\n }, [colors, data, delta, filterKey, getDeltaColor, valuesProps]);\n\n return chartSeries;\n};\n\nconst SQUARE_SIZE = 52;\n\nexport const useGridLayout = ({\n data,\n filterKey,\n format,\n xAxisPosition,\n visualMapVisible,\n visualMapYPosition,\n}: {\n xAxisPosition: HvChartXAxis[\"position\"];\n data: ColumnTable;\n filterKey: string;\n format: HvConfusionMatrixFormat;\n visualMapVisible: boolean;\n visualMapYPosition: \"top\" | \"center\" | \"bottom\";\n}) => {\n const size = useMemo(() => {\n const nCols = data.array(filterKey).length;\n const nRows = data.columnNames().filter((p) => p !== filterKey).length;\n const itemHeight = format === \"square\" ? SQUARE_SIZE : SQUARE_SIZE / 2;\n\n return {\n padding: {\n bottom:\n xAxisPosition === \"bottom\" ||\n (visualMapVisible && visualMapYPosition === \"bottom\")\n ? 60\n : 20,\n top:\n xAxisPosition === \"top\" ||\n (visualMapVisible && visualMapYPosition === \"top\")\n ? 60\n : 20,\n ...(visualMapVisible &&\n visualMapYPosition === \"bottom\" &&\n xAxisPosition === \"bottom\" && {\n bottom: 100,\n }),\n ...(visualMapVisible &&\n visualMapYPosition === \"top\" &&\n xAxisPosition === \"top\" && {\n top: 100,\n }),\n left: 80,\n right: 80,\n },\n size: {\n height: Math.max(itemHeight * nRows, itemHeight * 8),\n width: Math.max(SQUARE_SIZE * nCols, SQUARE_SIZE * 8),\n },\n };\n }, [\n data,\n filterKey,\n format,\n visualMapVisible,\n visualMapYPosition,\n xAxisPosition,\n ]);\n\n return size;\n};\n"],"names":[],"mappings":";;AAWO,MAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAKM;AACE,QAAA,EAAE,OAAO,IAAI,SAAS;AAEtB,QAAA,aAAa,QAAQ,MAAM;AAC3B,QAAA,UAAU,QAAQ,OAAO;AAC3B;AAAA,IAAA;AAGF,QAAI,UAAU,OAAO,OAAO,CAAC,MAAM,UAAU;AACpC,aAAA;AAAA,QACL,QAAS,OAAyC,OAEhD,CAAC,KAAK,SAAS;AACf,cAAI,KAAK;AAAA,YACP,GAAG;AAAA,YACH,OAAO,SAAS,KAAK,KAAK,KAAK,KAAK;AAAA,UAAA,CACrC;AACM,iBAAA;AAAA,QAAA,GACN,CAAE,CAAA;AAAA,MACP;AAAA,IAAA;AAGF,UAAM,WAAW,KACd,YAAY,EACZ,OAAO,CAAC,MAAM,MAAM,SAAS,EAC7B,OAAiB,CAAC,KAAK,MAAM;AAC5B,UAAI,KAAK,GAAG,KAAK,MAAM,CAAC,CAAC;AAClB,aAAA;AAAA,IACT,GAAG,EAAE;AACP,UAAM,MAAM,KAAK,IAAI,GAAG,QAAQ;AAChC,UAAM,MAAM,KAAK,IAAI,GAAG,QAAQ;AAEhC,UAAM,eAAe,QAAQ;AAAA,MAAI,CAAC,MAChC,OAAO,MAAM,WAAW,SAAS,CAAC,KAAK,IAAI,EAAE;AAAA,IAC/C;AAEO,WAAA;AAAA,MACL,YAAY,gBAAgB;AAAA,QAC1B,QAAQ,cAAc;AAAA,QACtB,QAAQ,QAAQ;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EAAA,GACC,CAAC,QAAQ,QAAQ,MAAM,WAAW,KAAK,CAAC;AAEpC,SAAA;AACT;AAEO,MAAM,Y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AAA,MAAA;AAAA,IAEX;AAAA,EAAA,GACC,CAAC,QAAQ,MAAM,OAAO,WAAW,eAAe,WAAW,CAAC;AAExD,SAAA;AACT;AAEA,MAAM,cAAc;AAEb,MAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAOM;AACE,QAAA,OAAO,QAAQ,MAAM;AACzB,UAAM,QAAQ,KAAK,MAAM,SAAS,EAAE;AAC9B,UAAA,QAAQ,KAAK,cAAc,OAAO,CAAC,MAAM,MAAM,SAAS,EAAE;AAChE,UAAM,aAAa,WAAW,WAAW,cAAc,cAAc;AAE9D,WAAA;AAAA,MACL,SAAS;AAAA,QACP,QACE,kBAAkB,YACjB,oBAAoB,uBAAuB,WACxC,KACA;AAAA,QACN,KACE,kBAAkB,SACjB,oBAAoB,uBAAuB,QACxC,KACA;AAAA,QACN,GAAI,oBACF,uBAAuB,YACvB,kBAAkB,YAAY;AAAA,UAC5B,QAAQ;AAAA,QACV;AAAA,QACF,GAAI,oBACF,uBAAuB,SACvB,kBAAkB,SAAS;AAAA,UACzB,KAAK;AAAA,QACP;AAAA,QACF,MAAM;AAAA,QACN,OAAO;AAAA,MACT;AAAA,MACA,MAAM;AAAA,QACJ,QAAQ,KAAK,IAAI,aAAa,OAAO,aAAa,CAAC;AAAA,QACnD,OAAO,KAAK,IAAI,cAAc,OAAO,cAAc,CAAC;AAAA,MAAA;AAAA,IAExD;AAAA,EAAA,GACC;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AAEM,SAAA;AACT;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLegend.js","sources":["../../../src/hooks/useLegend.tsx"],"sourcesContent":["import { useMemo } from \"react\";\n\nimport { HvEChartsOption } from \"../types/common\";\nimport { HvChartLegend, HvChartLegendIcon } from \"../types/legend\";\nimport { getLegendIcon } from \"../utils\";\n\ninterface HvLegendHookProps {\n show?: HvChartLegend[\"show\"];\n direction?: HvChartLegend[\"direction\"];\n position?: HvChartLegend[\"position\"];\n series?: Pick<HvEChartsOption, \"series.series\">;\n icon?: HvChartLegendIcon;\n formatter?: string | ((value?: string) => string);\n}\n\nexport const useLegend = ({\n series,\n show,\n icon,\n formatter,\n position: positionProp,\n direction = \"horizontal\",\n}: HvLegendHookProps) => {\n const option = useMemo<Pick<HvEChartsOption, \"legend\">>(() => {\n const position: Record<string, string> = {\n y: positionProp?.y ?? \"top\",\n x: positionProp?.x ?? \"center\",\n };\n\n return {\n legend: {\n show: show ?? (Array.isArray(series) && series.length > 1),\n itemGap: 20,\n formatter,\n orient: direction,\n ...position,\n ...(icon && { icon: getLegendIcon(icon) }),\n ...(!icon && {\n data:\n show !== false && Array.isArray(series)\n ? series.map((s) => {\n let iconType: HvChartLegendIcon = \"line\";\n if (s.areaStyle != null) {\n iconType = \"square\";\n }\n if (s.type === \"scatter\") {\n iconType = \"circle\";\n }\n return {\n name: s.name as string,\n icon: getLegendIcon(iconType),\n };\n })\n : undefined,\n }),\n },\n };\n }, [series, show, icon, formatter, positionProp, direction]);\n\n return option;\n};\n"],"names":[],"mappings":";;AAeO,MAAM,YAAY,CAAC;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,YAAY;AACd,MAAyB;AACjB,QAAA,SAAS,QAAyC,MAAM;AAC5D,UAAM,WAAmC;AAAA,MACvC,GAAG,cAAc,KAAK;AAAA,MACtB,GAAG,cAAc,KAAK;AAAA,IACxB;AAEO,WAAA;AAAA,MACL,QAAQ;AAAA,QACN,MAAM,SAAS,MAAM,QAAQ,MAAM,KAAK,OAAO,SAAS;AAAA,QACxD,SAAS;AAAA,QACT;AAAA,QACA,QAAQ;AAAA,QACR,GAAG;AAAA,QACH,GAAI,QAAQ,EAAE,MAAM,cAAc,IAAI,EAAE;AAAA,QACxC,GAAI,CAAC,QAAQ;AAAA,UACX,MACE,SAAS,SAAS,MAAM,QAAQ,MAAM,IAClC,OAAO,IAAI,CAAC,MAAM;AAChB,gBAAI,WAA8B;AAC9B,gBAAA,EAAE,aAAa,MAAM;AACZ,yBAAA;AAAA,YAAA;AAET,gBAAA,EAAE,SAAS,WAAW;AACb,yBAAA;AAAA,YAAA;AAEN,mBAAA;AAAA,cACL,MAAM,EAAE;AAAA,cACR,MAAM,cAAc,QAAQ;AAAA,YAC9B;AAAA,
|
|
1
|
+
{"version":3,"file":"useLegend.js","sources":["../../../src/hooks/useLegend.tsx"],"sourcesContent":["import { useMemo } from \"react\";\n\nimport { HvEChartsOption } from \"../types/common\";\nimport { HvChartLegend, HvChartLegendIcon } from \"../types/legend\";\nimport { getLegendIcon } from \"../utils\";\n\ninterface HvLegendHookProps {\n show?: HvChartLegend[\"show\"];\n direction?: HvChartLegend[\"direction\"];\n position?: HvChartLegend[\"position\"];\n series?: Pick<HvEChartsOption, \"series.series\">;\n icon?: HvChartLegendIcon;\n formatter?: string | ((value?: string) => string);\n}\n\nexport const useLegend = ({\n series,\n show,\n icon,\n formatter,\n position: positionProp,\n direction = \"horizontal\",\n}: HvLegendHookProps) => {\n const option = useMemo<Pick<HvEChartsOption, \"legend\">>(() => {\n const position: Record<string, string> = {\n y: positionProp?.y ?? \"top\",\n x: positionProp?.x ?? \"center\",\n };\n\n return {\n legend: {\n show: show ?? (Array.isArray(series) && series.length > 1),\n itemGap: 20,\n formatter,\n orient: direction,\n ...position,\n ...(icon && { icon: getLegendIcon(icon) }),\n ...(!icon && {\n data:\n show !== false && Array.isArray(series)\n ? series.map((s) => {\n let iconType: HvChartLegendIcon = \"line\";\n if (s.areaStyle != null) {\n iconType = \"square\";\n }\n if (s.type === \"scatter\") {\n iconType = \"circle\";\n }\n return {\n name: s.name as string,\n icon: getLegendIcon(iconType),\n };\n })\n : undefined,\n }),\n },\n };\n }, [series, show, icon, formatter, positionProp, direction]);\n\n return option;\n};\n"],"names":[],"mappings":";;AAeO,MAAM,YAAY,CAAC;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,YAAY;AACd,MAAyB;AACjB,QAAA,SAAS,QAAyC,MAAM;AAC5D,UAAM,WAAmC;AAAA,MACvC,GAAG,cAAc,KAAK;AAAA,MACtB,GAAG,cAAc,KAAK;AAAA,IACxB;AAEO,WAAA;AAAA,MACL,QAAQ;AAAA,QACN,MAAM,SAAS,MAAM,QAAQ,MAAM,KAAK,OAAO,SAAS;AAAA,QACxD,SAAS;AAAA,QACT;AAAA,QACA,QAAQ;AAAA,QACR,GAAG;AAAA,QACH,GAAI,QAAQ,EAAE,MAAM,cAAc,IAAI,EAAE;AAAA,QACxC,GAAI,CAAC,QAAQ;AAAA,UACX,MACE,SAAS,SAAS,MAAM,QAAQ,MAAM,IAClC,OAAO,IAAI,CAAC,MAAM;AAChB,gBAAI,WAA8B;AAC9B,gBAAA,EAAE,aAAa,MAAM;AACZ,yBAAA;AAAA,YAAA;AAET,gBAAA,EAAE,SAAS,WAAW;AACb,yBAAA;AAAA,YAAA;AAEN,mBAAA;AAAA,cACL,MAAM,EAAE;AAAA,cACR,MAAM,cAAc,QAAQ;AAAA,YAC9B;AAAA,UAAA,CACD,IACD;AAAA,QAAA;AAAA,MACR;AAAA,IAEJ;AAAA,EAAA,GACC,CAAC,QAAQ,MAAM,MAAM,WAAW,cAAc,SAAS,CAAC;AAEpD,SAAA;AACT;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSeries.js","sources":["../../../src/hooks/useSeries.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { internal } from \"arquero\";\nimport {\n BarSeriesOption,\n LineSeriesOption,\n PieSeriesOption,\n ScatterSeriesOption,\n} from \"echarts/charts\";\n\nimport { HvChartEmptyCellMode } from \"../types\";\nimport {\n HvAxisChartCommonProps,\n HvChartCommonProps,\n HvEChartsOption,\n} from \"../types/common\";\nimport {\n BarFullMeasure,\n LineFullMeasure,\n ScatterPlotMeasure,\n} from \"../types/measures\";\nimport { getGroupKey, getMeasure, SingleMeasure } from \"../utils\";\n\ninterface HvSeriesHookProps {\n type: \"line\" | \"bar\" | \"pie\" | \"scatter\" | \"treemap\";\n data: internal.ColumnTable;\n groupBy: HvChartCommonProps[\"groupBy\"];\n measuresMapping: Record<string, SingleMeasure>;\n area?: boolean;\n areaOpacity?: number;\n emptyCellMode?: HvChartEmptyCellMode;\n stack?: HvAxisChartCommonProps[\"stack\"];\n nameFormatter?: HvAxisChartCommonProps[\"seriesNameFormatter\"];\n horizontal?: boolean;\n radius?: number | string | (number | string)[];\n}\n\nexport const useSeries = ({\n groupBy,\n type,\n data,\n measuresMapping,\n nameFormatter,\n stack,\n emptyCellMode,\n radius,\n horizontal = false,\n area = false,\n areaOpacity = 0.5,\n}: HvSeriesHookProps) => {\n const groupByKey = getGroupKey(groupBy);\n\n const option: Pick<HvEChartsOption, \"series\"> = useMemo<\n Pick<HvEChartsOption, \"series\">\n >(() => {\n return {\n series: data\n .columnNames()\n .filter((c) => c !== groupByKey)\n .map((c) => {\n const measure = getMeasure(c, measuresMapping);\n\n let pieOps: PieSeriesOption = {};\n let lineOps: LineSeriesOption = {};\n let barOps: BarSeriesOption = {};\n let scatterOps: ScatterSeriesOption = {};\n\n // scatter\n if (type === \"scatter\") {\n const yAxisId =\n typeof measure !== \"string\"\n ? (measure as ScatterPlotMeasure).yAxis\n : undefined;\n scatterOps = {\n yAxisId,\n encode: {\n x: groupByKey,\n y: c,\n },\n };\n }\n\n // pie\n if (type === \"pie\") {\n pieOps = {\n encode: {\n value: c,\n itemName: groupByKey,\n },\n labelLine: {\n show: false,\n },\n label: {\n show: false,\n },\n emphasis: {\n label: {\n show: false,\n },\n },\n radius,\n };\n }\n\n // line or bar\n if (type === \"line\" || type === \"bar\") {\n const sampling =\n typeof measure !== \"string\"\n ? (measure as LineFullMeasure | BarFullMeasure).sampling\n : undefined;\n const yAxisId =\n typeof measure !== \"string\"\n ? (measure as LineFullMeasure | BarFullMeasure).yAxis\n : undefined;\n const stackName =\n typeof measure !== \"string\"\n ? ((measure as LineFullMeasure | BarFullMeasure).stack ??\n stack ??\n undefined)\n : (stack ?? undefined);\n\n const axisOps = {\n sampling,\n yAxisId,\n stack: stackName,\n encode: horizontal\n ? {\n x: c,\n y: groupByKey,\n }\n : {\n x: groupByKey,\n y: c,\n },\n };\n\n // bar\n if (type === \"bar\") {\n barOps = {\n ...axisOps,\n barMaxWidth: 90,\n barMinWidth: 3,\n };\n }\n\n // line\n if (type === \"line\") {\n const showSymbol =\n typeof measure !== \"string\"\n ? !(measure as LineFullMeasure).hideSymbol\n : true;\n const connectNulls =\n typeof measure !== \"string\" &&\n (measure as LineFullMeasure).emptyCellMode\n ? (measure as LineFullMeasure).emptyCellMode === \"connect\"\n : emptyCellMode === \"connect\";\n const isArea =\n typeof measure !== \"string\"\n ? ((measure as LineFullMeasure).area ?? area)\n : area;\n const aOpacity =\n typeof measure !== \"string\"\n ? ((measure as LineFullMeasure).areaOpacity ?? areaOpacity)\n : areaOpacity;\n\n lineOps = {\n ...axisOps,\n connectNulls,\n showSymbol,\n areaStyle: isArea ? { opacity: aOpacity } : undefined,\n };\n }\n }\n\n return {\n id: `series~${groupByKey}~${c}`,\n type,\n name: nameFormatter ? nameFormatter(c) : c,\n ...pieOps,\n ...barOps,\n ...lineOps,\n ...scatterOps,\n };\n }),\n };\n }, [\n data,\n groupByKey,\n measuresMapping,\n type,\n nameFormatter,\n radius,\n stack,\n horizontal,\n emptyCellMode,\n area,\n areaOpacity,\n ]);\n\n return option;\n};\n"],"names":[],"mappings":";;AAoCO,MAAM,YAAY,CAAC;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,OAAO;AAAA,EACP,cAAc;AAChB,MAAyB;AACjB,QAAA,aAAa,YAAY,OAAO;AAEhC,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AAAA,YACf;AAAA,UAAA;AAIF,cAAI,SAAS,QAAQ;AACnB,kBAAM,aACJ,OAAO,YAAY,WACf,CAAE,QAA4B,aAC9B;AACA,kBAAA,eACJ,OAAO,YAAY,YAClB,QAA4B,gBACxB,QAA4B,kBAAkB,YAC/C,kBAAkB;AACxB,kBAAM,SACJ,OAAO,YAAY,WACb,QAA4B,QAAQ,OACtC;AACN,kBAAM,WACJ,OAAO,YAAY,WACb,QAA4B,eAAe,cAC7C;AAEI,sBAAA;AAAA,cACR,GAAG;AAAA,cACH;AAAA,cACA;AAAA,cACA,WAAW,SAAS,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"useSeries.js","sources":["../../../src/hooks/useSeries.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { internal } from \"arquero\";\nimport {\n BarSeriesOption,\n LineSeriesOption,\n PieSeriesOption,\n ScatterSeriesOption,\n} from \"echarts/charts\";\n\nimport { HvChartEmptyCellMode } from \"../types\";\nimport {\n HvAxisChartCommonProps,\n HvChartCommonProps,\n HvEChartsOption,\n} from \"../types/common\";\nimport {\n BarFullMeasure,\n LineFullMeasure,\n ScatterPlotMeasure,\n} from \"../types/measures\";\nimport { getGroupKey, getMeasure, SingleMeasure } from \"../utils\";\n\ninterface HvSeriesHookProps {\n type: \"line\" | \"bar\" | \"pie\" | \"scatter\" | \"treemap\";\n data: internal.ColumnTable;\n groupBy: HvChartCommonProps[\"groupBy\"];\n measuresMapping: Record<string, SingleMeasure>;\n area?: boolean;\n areaOpacity?: number;\n emptyCellMode?: HvChartEmptyCellMode;\n stack?: HvAxisChartCommonProps[\"stack\"];\n nameFormatter?: HvAxisChartCommonProps[\"seriesNameFormatter\"];\n horizontal?: boolean;\n radius?: number | string | (number | string)[];\n}\n\nexport const useSeries = ({\n groupBy,\n type,\n data,\n measuresMapping,\n nameFormatter,\n stack,\n emptyCellMode,\n radius,\n horizontal = false,\n area = false,\n areaOpacity = 0.5,\n}: HvSeriesHookProps) => {\n const groupByKey = getGroupKey(groupBy);\n\n const option: Pick<HvEChartsOption, \"series\"> = useMemo<\n Pick<HvEChartsOption, \"series\">\n >(() => {\n return {\n series: data\n .columnNames()\n .filter((c) => c !== groupByKey)\n .map((c) => {\n const measure = getMeasure(c, measuresMapping);\n\n let pieOps: PieSeriesOption = {};\n let lineOps: LineSeriesOption = {};\n let barOps: BarSeriesOption = {};\n let scatterOps: ScatterSeriesOption = {};\n\n // scatter\n if (type === \"scatter\") {\n const yAxisId =\n typeof measure !== \"string\"\n ? (measure as ScatterPlotMeasure).yAxis\n : undefined;\n scatterOps = {\n yAxisId,\n encode: {\n x: groupByKey,\n y: c,\n },\n };\n }\n\n // pie\n if (type === \"pie\") {\n pieOps = {\n encode: {\n value: c,\n itemName: groupByKey,\n },\n labelLine: {\n show: false,\n },\n label: {\n show: false,\n },\n emphasis: {\n label: {\n show: false,\n },\n },\n radius,\n };\n }\n\n // line or bar\n if (type === \"line\" || type === \"bar\") {\n const sampling =\n typeof measure !== \"string\"\n ? (measure as LineFullMeasure | BarFullMeasure).sampling\n : undefined;\n const yAxisId =\n typeof measure !== \"string\"\n ? (measure as LineFullMeasure | BarFullMeasure).yAxis\n : undefined;\n const stackName =\n typeof measure !== \"string\"\n ? ((measure as LineFullMeasure | BarFullMeasure).stack ??\n stack ??\n undefined)\n : (stack ?? undefined);\n\n const axisOps = {\n sampling,\n yAxisId,\n stack: stackName,\n encode: horizontal\n ? {\n x: c,\n y: groupByKey,\n }\n : {\n x: groupByKey,\n y: c,\n },\n };\n\n // bar\n if (type === \"bar\") {\n barOps = {\n ...axisOps,\n barMaxWidth: 90,\n barMinWidth: 3,\n };\n }\n\n // line\n if (type === \"line\") {\n const showSymbol =\n typeof measure !== \"string\"\n ? !(measure as LineFullMeasure).hideSymbol\n : true;\n const connectNulls =\n typeof measure !== \"string\" &&\n (measure as LineFullMeasure).emptyCellMode\n ? (measure as LineFullMeasure).emptyCellMode === \"connect\"\n : emptyCellMode === \"connect\";\n const isArea =\n typeof measure !== \"string\"\n ? ((measure as LineFullMeasure).area ?? area)\n : area;\n const aOpacity =\n typeof measure !== \"string\"\n ? ((measure as LineFullMeasure).areaOpacity ?? areaOpacity)\n : areaOpacity;\n\n lineOps = {\n ...axisOps,\n connectNulls,\n showSymbol,\n areaStyle: isArea ? { opacity: aOpacity } : undefined,\n };\n }\n }\n\n return {\n id: `series~${groupByKey}~${c}`,\n type,\n name: nameFormatter ? nameFormatter(c) : c,\n ...pieOps,\n ...barOps,\n ...lineOps,\n ...scatterOps,\n };\n }),\n };\n }, [\n data,\n groupByKey,\n measuresMapping,\n type,\n nameFormatter,\n radius,\n stack,\n horizontal,\n emptyCellMode,\n area,\n areaOpacity,\n ]);\n\n return option;\n};\n"],"names":[],"mappings":";;AAoCO,MAAM,YAAY,CAAC;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,OAAO;AAAA,EACP,cAAc;AAChB,MAAyB;AACjB,QAAA,aAAa,YAAY,OAAO;AAEhC,QAAA,SAA0C,QAE9C,MAAM;AACC,WAAA;AAAA,MACL,QAAQ,KACL,YAAY,EACZ,OAAO,CAAC,MAAM,MAAM,UAAU,EAC9B,IAAI,CAAC,MAAM;AACJ,cAAA,UAAU,WAAW,GAAG,eAAe;AAE7C,YAAI,SAA0B,CAAC;AAC/B,YAAI,UAA4B,CAAC;AACjC,YAAI,SAA0B,CAAC;AAC/B,YAAI,aAAkC,CAAC;AAGvC,YAAI,SAAS,WAAW;AACtB,gBAAM,UACJ,OAAO,YAAY,WACd,QAA+B,QAChC;AACO,uBAAA;AAAA,YACX;AAAA,YACA,QAAQ;AAAA,cACN,GAAG;AAAA,cACH,GAAG;AAAA,YAAA;AAAA,UAEP;AAAA,QAAA;AAIF,YAAI,SAAS,OAAO;AACT,mBAAA;AAAA,YACP,QAAQ;AAAA,cACN,OAAO;AAAA,cACP,UAAU;AAAA,YAC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AAG;AAAA,UACH,GAAG;AAAA,UACH,GAAG;AAAA,UACH,GAAG;AAAA,QACL;AAAA,MACD,CAAA;AAAA,IACL;AAAA,EAAA,GACC;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AAEM,SAAA;AACT;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utils/index.ts"],"sourcesContent":["import { from, internal, table } from \"arquero\";\nimport type ColumnTable from \"arquero/dist/types/table/column-table\";\n\nimport type {\n HvBarChartMeasures,\n HvChartAxisType,\n HvChartData,\n HvChartFilter,\n HvChartFilterOperation,\n HvConfusionMatrixMeasure,\n HvDonutChartMeasure,\n HvLineChartMeasures,\n} from \"../types\";\nimport { HvChartCommonProps } from \"../types/common\";\nimport { HvChartLegendIcon } from \"../types/legend\";\nimport { HvScatterPlotMeasure } from \"../types/measures\";\n\nexport const getAxisType = (type?: HvChartAxisType) => {\n switch (type) {\n case \"categorical\":\n return \"category\";\n case \"time\":\n return \"time\";\n case \"continuous\":\n return \"value\";\n default:\n return undefined;\n }\n};\n\nexport const getGroupKey = (groupBy: HvChartCommonProps[\"groupBy\"]) =>\n Array.isArray(groupBy) ? groupBy.join(\"_\") : groupBy;\n\nexport const getLegendIcon = (icon: HvChartLegendIcon) => {\n switch (icon) {\n case \"circle\":\n return \"circle\";\n case \"square\":\n return \"path://M0,0L16,0L16,16L0,16L0,0Z\";\n case \"line\":\n default:\n return \"path://M0,0L16,0L16,2L0,2Z\";\n }\n};\n\nexport type SingleMeasure =\n | HvLineChartMeasures\n | HvBarChartMeasures\n | HvScatterPlotMeasure\n | HvDonutChartMeasure\n | HvConfusionMatrixMeasure;\n\nexport const getMeasure = (\n name: string,\n mapping: Record<string, SingleMeasure>,\n) => {\n // find the key that matches the most number of characters\n // we are not doing the first match because columns can be repeated if they use different agg functions\n let measure: SingleMeasure | undefined;\n let count = 0;\n for (const key of Object.keys(mapping)) {\n if (name.includes(key) && key.length >= count) {\n count = key.length;\n measure = mapping[key];\n }\n }\n // return the found measure in measures array or return the first one\n return measure ?? Object.values(mapping)[0];\n};\n\nexport const getFilterFunction = (\n operation: HvChartFilterOperation,\n field: HvChartFilter[\"field\"],\n value: HvChartFilter[\"value\"],\n): Function => {\n const valueArray = Array.isArray(value) ? value : [value];\n if (valueArray.length === 0) return () => true;\n\n switch (operation) {\n case \"is\": {\n return (row: any) => valueArray.includes(row[field]);\n }\n case \"isNot\": {\n return (row: any) => !valueArray.includes(row[field]);\n }\n case \"contains\":\n return (row: any) => {\n let include = false;\n for (const val of valueArray) {\n if (String(row[field]).includes(String(val))) {\n include = true;\n }\n }\n return include;\n };\n case \"notContains\":\n return (row: any) => {\n let include = true;\n for (const val of valueArray) {\n if (String(row[field]).includes(String(val))) {\n include = false;\n }\n }\n return include;\n };\n case \"greaterThan\":\n return (row: any) => {\n let include = false;\n for (const val of valueArray) {\n if (row[field] > val) {\n include = true;\n }\n }\n return include;\n };\n case \"greaterThanOrEqual\":\n return (row: any) => {\n let include = false;\n for (const val of valueArray) {\n if (row[field] >= val) {\n include = true;\n }\n }\n return include;\n };\n case \"lessThan\":\n return (row: any) => {\n let include = false;\n for (const val of valueArray) {\n if (row[field] < val) {\n include = true;\n }\n }\n return include;\n };\n case \"lessThanOrEqual\":\n return (row: any) => {\n let include = false;\n for (const val of valueArray) {\n if (row[field] <= val) {\n include = true;\n }\n }\n return include;\n };\n case \"between\":\n return (row: any) =>\n row[field] >= valueArray[0] && row[field] <= valueArray[1];\n case \"ends\":\n return (row: any) => {\n let include = false;\n for (const val of valueArray) {\n if (String(row[field]).endsWith(String(val))) {\n include = true;\n }\n }\n return include;\n };\n case \"notEnds\":\n return (row: any) => {\n let include = true;\n for (const val of valueArray) {\n if (String(row[field]).endsWith(String(val))) {\n include = false;\n }\n }\n return include;\n };\n case \"starts\":\n return (row: any) => {\n let include = false;\n for (const val of valueArray) {\n if (String(row[field]).startsWith(String(val))) {\n include = true;\n }\n }\n return include;\n };\n case \"notStarts\":\n return (row: any) => {\n let include = true;\n for (const val of valueArray) {\n if (String(row[field]).startsWith(String(val))) {\n include = false;\n }\n }\n return include;\n };\n\n default:\n throw new Error(\"Unsupported operation\");\n }\n};\n\n// Note: Exported to the users\n/**\n * Combine filter functions into a single function. Only rows that pass all filters will be included.\n * Should be used inside the `escape` function provided by Arquero.\n * */\nexport const getHvArqueroCombinedFilters = (\n row: any,\n filters: HvChartFilter[],\n) => {\n return filters.every((filter) => {\n const { field, operation, value } = filter;\n const filterFunction = Object.hasOwn(row, field)\n ? getFilterFunction(operation, field, value)\n : () => true;\n return filterFunction(row);\n });\n};\n\n/**\n * Normalizes a column name by replacing all characters that are not letters or numbers by \"__\"\n */\nexport const normalizeColumnName = (string: string) => {\n return string.replace(/[^a-zA-Z0-9]/g, \"__\");\n};\n\n/**\n * Converts data to a arquero data table and normalizes the column names for data processing.\n * @param data Chart data\n * @returns Processed data and reversed columns mapping to switch the columns to their original name\n */\nexport const processTableData = (data: HvChartData) => {\n let tableData: ColumnTable;\n if (data instanceof internal.ColumnTable) {\n tableData = data;\n } else if (Array.isArray(data)) {\n tableData = from(data);\n } else {\n tableData = table(data);\n }\n\n // Normalize the column names to remove any special character and spaces since it can lead to errors during processing\n const nameMapping: Record<string, string> = {};\n const reversedNameMapping: Record<string, string> = {};\n for (const column of tableData.columnNames()) {\n const normalizedName = normalizeColumnName(column);\n nameMapping[column] = normalizedName;\n reversedNameMapping[normalizedName] = column;\n }\n\n return {\n data: tableData.select(nameMapping),\n mapping: reversedNameMapping,\n };\n};\n"],"names":[],"mappings":";AAiBa,MAAA,cAAc,CAAC,SAA2B;AACrD,UAAQ,MAAM;AAAA,IACZ,KAAK;AACI,aAAA;AAAA,IACT,KAAK;AACI,aAAA;AAAA,IACT,KAAK;AACI,aAAA;AAAA,IACT;AACS,aAAA;AAAA,E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;AACtC,UAAA,iBAAiB,oBAAoB,MAAM;AACjD,gBAAY,MAAM,IAAI;AACtB,wBAAoB,cAAc,IAAI;AAAA,EAAA;AAGjC,SAAA;AAAA,IACL,MAAM,UAAU,OAAO,WAAW;AAAA,IAClC,SAAS;AAAA,EACX;AACF;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utils/index.ts"],"sourcesContent":["import { from, internal, table } from \"arquero\";\nimport type ColumnTable from \"arquero/dist/types/table/column-table\";\n\nimport type {\n HvBarChartMeasures,\n HvChartAxisType,\n HvChartData,\n HvChartFilter,\n HvChartFilterOperation,\n HvConfusionMatrixMeasure,\n HvDonutChartMeasure,\n HvLineChartMeasures,\n} from \"../types\";\nimport { HvChartCommonProps } from \"../types/common\";\nimport { HvChartLegendIcon } from \"../types/legend\";\nimport { HvScatterPlotMeasure } from \"../types/measures\";\n\nexport const getAxisType = (type?: HvChartAxisType) => {\n switch (type) {\n case \"categorical\":\n return \"category\";\n case \"time\":\n return \"time\";\n case \"continuous\":\n return \"value\";\n default:\n return undefined;\n }\n};\n\nexport const getGroupKey = (groupBy: HvChartCommonProps[\"groupBy\"]) =>\n Array.isArray(groupBy) ? groupBy.join(\"_\") : groupBy;\n\nexport const getLegendIcon = (icon: HvChartLegendIcon) => {\n switch (icon) {\n case \"circle\":\n return \"circle\";\n case \"square\":\n return \"path://M0,0L16,0L16,16L0,16L0,0Z\";\n case \"line\":\n default:\n return \"path://M0,0L16,0L16,2L0,2Z\";\n }\n};\n\nexport type SingleMeasure =\n | HvLineChartMeasures\n | HvBarChartMeasures\n | HvScatterPlotMeasure\n | HvDonutChartMeasure\n | HvConfusionMatrixMeasure;\n\nexport const getMeasure = (\n name: string,\n mapping: Record<string, SingleMeasure>,\n) => {\n // find the key that matches the most number of characters\n // we are not doing the first match because columns can be repeated if they use different agg functions\n let measure: SingleMeasure | undefined;\n let count = 0;\n for (const key of Object.keys(mapping)) {\n if (name.includes(key) && key.length >= count) {\n count = key.length;\n measure = mapping[key];\n }\n }\n // return the found measure in measures array or return the first one\n return measure ?? Object.values(mapping)[0];\n};\n\nexport const getFilterFunction = (\n operation: HvChartFilterOperation,\n field: HvChartFilter[\"field\"],\n value: HvChartFilter[\"value\"],\n) => {\n const valueArray = Array.isArray(value) ? value : [value];\n if (valueArray.length === 0) return () => true;\n\n switch (operation) {\n case \"is\": {\n return (row: any) => valueArray.includes(row[field]);\n }\n case \"isNot\": {\n return (row: any) => !valueArray.includes(row[field]);\n }\n case \"contains\":\n return (row: any) => {\n let include = false;\n for (const val of valueArray) {\n if (String(row[field]).includes(String(val))) {\n include = true;\n }\n }\n return include;\n };\n case \"notContains\":\n return (row: any) => {\n let include = true;\n for (const val of valueArray) {\n if (String(row[field]).includes(String(val))) {\n include = false;\n }\n }\n return include;\n };\n case \"greaterThan\":\n return (row: any) => {\n let include = false;\n for (const val of valueArray) {\n if (row[field] > val) {\n include = true;\n }\n }\n return include;\n };\n case \"greaterThanOrEqual\":\n return (row: any) => {\n let include = false;\n for (const val of valueArray) {\n if (row[field] >= val) {\n include = true;\n }\n }\n return include;\n };\n case \"lessThan\":\n return (row: any) => {\n let include = false;\n for (const val of valueArray) {\n if (row[field] < val) {\n include = true;\n }\n }\n return include;\n };\n case \"lessThanOrEqual\":\n return (row: any) => {\n let include = false;\n for (const val of valueArray) {\n if (row[field] <= val) {\n include = true;\n }\n }\n return include;\n };\n case \"between\":\n return (row: any) =>\n row[field] >= valueArray[0] && row[field] <= valueArray[1];\n case \"ends\":\n return (row: any) => {\n let include = false;\n for (const val of valueArray) {\n if (String(row[field]).endsWith(String(val))) {\n include = true;\n }\n }\n return include;\n };\n case \"notEnds\":\n return (row: any) => {\n let include = true;\n for (const val of valueArray) {\n if (String(row[field]).endsWith(String(val))) {\n include = false;\n }\n }\n return include;\n };\n case \"starts\":\n return (row: any) => {\n let include = false;\n for (const val of valueArray) {\n if (String(row[field]).startsWith(String(val))) {\n include = true;\n }\n }\n return include;\n };\n case \"notStarts\":\n return (row: any) => {\n let include = true;\n for (const val of valueArray) {\n if (String(row[field]).startsWith(String(val))) {\n include = false;\n }\n }\n return include;\n };\n\n default:\n throw new Error(\"Unsupported operation\");\n }\n};\n\n// Note: Exported to the users\n/**\n * Combine filter functions into a single function. Only rows that pass all filters will be included.\n * Should be used inside the `escape` function provided by Arquero.\n * */\nexport const getHvArqueroCombinedFilters = (\n row: any,\n filters: HvChartFilter[],\n) => {\n return filters.every((filter) => {\n const { field, operation, value } = filter;\n const filterFunction = Object.hasOwn(row, field)\n ? getFilterFunction(operation, field, value)\n : () => true;\n return filterFunction(row);\n });\n};\n\n/**\n * Normalizes a column name by replacing all characters that are not letters or numbers by \"__\"\n */\nexport const normalizeColumnName = (string: string) => {\n return string.replace(/[^a-zA-Z0-9]/g, \"__\");\n};\n\n/**\n * Converts data to a arquero data table and normalizes the column names for data processing.\n * @param data Chart data\n * @returns Processed data and reversed columns mapping to switch the columns to their original name\n */\nexport const processTableData = (data: HvChartData) => {\n let tableData: ColumnTable;\n if (data instanceof internal.ColumnTable) {\n tableData = data;\n } else if (Array.isArray(data)) {\n tableData = from(data);\n } else {\n tableData = table(data);\n }\n\n // Normalize the column names to remove any special character and spaces since it can lead to errors during processing\n const nameMapping: Record<string, string> = {};\n const reversedNameMapping: Record<string, string> = {};\n for (const column of tableData.columnNames()) {\n const normalizedName = normalizeColumnName(column);\n nameMapping[column] = normalizedName;\n reversedNameMapping[normalizedName] = column;\n }\n\n return {\n data: tableData.select(nameMapping),\n mapping: reversedNameMapping,\n };\n};\n"],"names":[],"mappings":";AAiBa,MAAA,cAAc,CAAC,SAA2B;AACrD,UAAQ,MAAM;AAAA,IACZ,KAAK;AACI,aAAA;AAAA,IACT,KAAK;AACI,aAAA;AAAA,IACT,KAAK;AACI,aAAA;AAAA,IACT;AACS,aAAA;AAAA,EAAA;AAEb;AAEa,MAAA,cAAc,CAAC,YAC1B,MAAM,QAAQ,OAAO,IAAI,QAAQ,KAAK,GAAG,IAAI;AAElC,MAAA,g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,SAAA;AAAA,IACL,MAAM,UAAU,OAAO,WAAW;AAAA,IAClC,SAAS;AAAA,EACX;AACF;"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -348,7 +348,7 @@ export declare interface HvConfusionMatrixProps extends Omit<HvChartCommonProps,
|
|
|
348
348
|
* An array of objects can also be used to create a custom scale.
|
|
349
349
|
* If `delta` is not provided, a default color scale is used when `colorScale` is not defined: `[base-light, cat3]`.
|
|
350
350
|
*/
|
|
351
|
-
colorScale?: [
|
|
351
|
+
colorScale?: [HvColorAny, HvColorAny] | HvConfusionMatrixColorScale[];
|
|
352
352
|
}
|
|
353
353
|
|
|
354
354
|
export declare interface HvConfusionMatrixValuesProps {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/uikit-react-viz",
|
|
3
|
-
"version": "5.15.
|
|
3
|
+
"version": "5.15.19",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Hitachi Vantara UI Kit Team",
|
|
6
6
|
"description": "Contributed React visualization components for the NEXT UI Kit.",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@hitachivantara/uikit-react-utils": "^0.2.
|
|
37
|
-
"@hitachivantara/uikit-styles": "^5.
|
|
36
|
+
"@hitachivantara/uikit-react-utils": "^0.2.26",
|
|
37
|
+
"@hitachivantara/uikit-styles": "^5.42.0"
|
|
38
38
|
},
|
|
39
39
|
"files": [
|
|
40
40
|
"dist"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"access": "public",
|
|
44
44
|
"directory": "package"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "aa4abe1847a1621258a0ed5dd721c7fd39f6c276",
|
|
47
47
|
"exports": {
|
|
48
48
|
".": {
|
|
49
49
|
"types": "./dist/types/index.d.ts",
|