@hitachivantara/uikit-react-viz 5.2.8 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/BarChart/BarChart.cjs +103 -4
- package/dist/cjs/components/BarChart/BarChart.cjs.map +1 -1
- package/dist/cjs/components/BaseChart/BaseChart.cjs +6 -349
- package/dist/cjs/components/BaseChart/BaseChart.cjs.map +1 -1
- package/dist/cjs/components/DonutChart/DonutChart.cjs +91 -0
- package/dist/cjs/components/DonutChart/DonutChart.cjs.map +1 -0
- package/dist/cjs/components/LineChart/LineChart.cjs +100 -4
- package/dist/cjs/components/LineChart/LineChart.cjs.map +1 -1
- package/dist/cjs/{components/BaseChart/BaseChart.styles.cjs → hooks/tooltip/styles.cjs} +2 -2
- package/dist/cjs/hooks/tooltip/styles.cjs.map +1 -0
- package/dist/cjs/hooks/tooltip/useTooltip.cjs +98 -0
- package/dist/cjs/hooks/tooltip/useTooltip.cjs.map +1 -0
- package/dist/cjs/hooks/useData.cjs +93 -0
- package/dist/cjs/hooks/useData.cjs.map +1 -0
- package/dist/cjs/hooks/useDataZoom.cjs +25 -0
- package/dist/cjs/hooks/useDataZoom.cjs.map +1 -0
- package/dist/cjs/hooks/useDataset.cjs +18 -0
- package/dist/cjs/hooks/useDataset.cjs.map +1 -0
- package/dist/cjs/hooks/useGrid.cjs +32 -0
- package/dist/cjs/hooks/useGrid.cjs.map +1 -0
- package/dist/cjs/hooks/useLegend.cjs +46 -0
- package/dist/cjs/hooks/useLegend.cjs.map +1 -0
- package/dist/cjs/hooks/useSeries.cjs +99 -0
- package/dist/cjs/hooks/useSeries.cjs.map +1 -0
- package/dist/cjs/hooks/useVizTheme.cjs.map +1 -1
- package/dist/cjs/hooks/useXAxis.cjs +29 -0
- package/dist/cjs/hooks/useXAxis.cjs.map +1 -0
- package/dist/cjs/hooks/useYAxis.cjs +42 -0
- package/dist/cjs/hooks/useYAxis.cjs.map +1 -0
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/providers/Provider.cjs +8 -10
- package/dist/cjs/providers/Provider.cjs.map +1 -1
- package/dist/cjs/utils/getGroupKey.cjs +5 -0
- package/dist/cjs/utils/getGroupKey.cjs.map +1 -0
- package/dist/cjs/utils/getLegendIcon.cjs +7 -4
- package/dist/cjs/utils/getLegendIcon.cjs.map +1 -1
- package/dist/cjs/utils/getMeasure.cjs +14 -0
- package/dist/cjs/utils/getMeasure.cjs.map +1 -0
- package/dist/cjs/utils/registerTheme.cjs +104 -0
- package/dist/cjs/utils/registerTheme.cjs.map +1 -0
- package/dist/esm/components/BarChart/BarChart.js +84 -4
- package/dist/esm/components/BarChart/BarChart.js.map +1 -1
- package/dist/esm/components/BaseChart/BaseChart.js +8 -351
- package/dist/esm/components/BaseChart/BaseChart.js.map +1 -1
- package/dist/esm/components/DonutChart/DonutChart.js +72 -0
- package/dist/esm/components/DonutChart/DonutChart.js.map +1 -0
- package/dist/esm/components/LineChart/LineChart.js +81 -4
- package/dist/esm/components/LineChart/LineChart.js.map +1 -1
- package/dist/esm/{components/BaseChart/BaseChart.styles.js → hooks/tooltip/styles.js} +2 -2
- package/dist/esm/hooks/tooltip/styles.js.map +1 -0
- package/dist/esm/hooks/tooltip/useTooltip.js +98 -0
- package/dist/esm/hooks/tooltip/useTooltip.js.map +1 -0
- package/dist/esm/hooks/useData.js +93 -0
- package/dist/esm/hooks/useData.js.map +1 -0
- package/dist/esm/hooks/useDataZoom.js +25 -0
- package/dist/esm/hooks/useDataZoom.js.map +1 -0
- package/dist/esm/hooks/useDataset.js +18 -0
- package/dist/esm/hooks/useDataset.js.map +1 -0
- package/dist/esm/hooks/useGrid.js +32 -0
- package/dist/esm/hooks/useGrid.js.map +1 -0
- package/dist/esm/hooks/useLegend.js +46 -0
- package/dist/esm/hooks/useLegend.js.map +1 -0
- package/dist/esm/hooks/useSeries.js +99 -0
- package/dist/esm/hooks/useSeries.js.map +1 -0
- package/dist/esm/hooks/useVizTheme.js.map +1 -1
- package/dist/esm/hooks/useXAxis.js +29 -0
- package/dist/esm/hooks/useXAxis.js.map +1 -0
- package/dist/esm/hooks/useYAxis.js +42 -0
- package/dist/esm/hooks/useYAxis.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/providers/Provider.js +8 -10
- package/dist/esm/providers/Provider.js.map +1 -1
- package/dist/esm/utils/getGroupKey.js +5 -0
- package/dist/esm/utils/getGroupKey.js.map +1 -0
- package/dist/esm/utils/getLegendIcon.js +7 -4
- package/dist/esm/utils/getLegendIcon.js.map +1 -1
- package/dist/esm/utils/getMeasure.js +14 -0
- package/dist/esm/utils/getMeasure.js.map +1 -0
- package/dist/esm/utils/registerTheme.js +85 -0
- package/dist/esm/utils/registerTheme.js.map +1 -0
- package/dist/types/index.d.ts +116 -79
- package/package.json +3 -3
- package/dist/cjs/components/BaseChart/BaseChart.styles.cjs.map +0 -1
- package/dist/cjs/utils/registerThemes.cjs +0 -106
- package/dist/cjs/utils/registerThemes.cjs.map +0 -1
- package/dist/esm/components/BaseChart/BaseChart.styles.js.map +0 -1
- package/dist/esm/utils/registerThemes.js +0 -87
- package/dist/esm/utils/registerThemes.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSeries.js","sources":["../../../src/hooks/useSeries.tsx"],"sourcesContent":["import { useMemo } from \"react\";\n\nimport { Arrayable } from \"@hitachivantara/uikit-react-core\";\n\nimport type { EChartsOption } from \"echarts-for-react/lib/types\";\nimport {\n BarSeriesOption,\n LineSeriesOption,\n PieSeriesOption,\n} from \"echarts/charts\";\n\nimport { internal } from \"arquero\";\n\nimport { getGroupKey, getMeasure } from \"@viz/utils\";\nimport {\n HvBarChartMeasures,\n HvChartEmptyCellMode,\n HvDonutChartMeasure,\n HvLineChartMeasures,\n} from \"@viz/types\";\nimport { HvAxisChartCommonProps, HvChartCommonProps } from \"@viz/types/common\";\nimport { BarFullMeasures, LineFullMeasures } from \"@viz/types/measures\";\n\ninterface HvSeriesHookProps {\n type: \"line\" | \"bar\" | \"pie\";\n data: internal.ColumnTable;\n groupBy: HvChartCommonProps[\"groupBy\"];\n measures:\n | Arrayable<HvLineChartMeasures | HvBarChartMeasures>\n | HvDonutChartMeasure;\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 measures,\n nameFormatter,\n stack,\n horizontal = false,\n area = false,\n areaOpacity = 0.5,\n emptyCellMode,\n radius,\n}: HvSeriesHookProps) => {\n const groupByKey = getGroupKey(groupBy);\n\n const option: Pick<EChartsOption, \"series\"> = useMemo<\n Pick<EChartsOption, \"series\">\n >(() => {\n return {\n series: data\n .columnNames()\n .filter((c) => c !== groupByKey)\n .map<LineSeriesOption | BarSeriesOption | PieSeriesOption>((c) => {\n const measure = getMeasure(c, measures);\n\n let pieOps: PieSeriesOption = {};\n let lineOps: LineSeriesOption = {};\n let barOps: BarSeriesOption = {};\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 LineFullMeasures | BarFullMeasures).sampling\n : undefined;\n const yAxisId =\n typeof measure !== \"string\"\n ? (measure as LineFullMeasures | BarFullMeasures).yAxis\n : undefined;\n const stackName =\n typeof measure !== \"string\"\n ? (measure as LineFullMeasures | BarFullMeasures).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 LineFullMeasures).hideSymbol\n : true;\n const connectNulls =\n typeof measure !== \"string\" &&\n (measure as LineFullMeasures).emptyCellMode\n ? (measure as LineFullMeasures).emptyCellMode === \"connect\"\n : emptyCellMode === \"connect\";\n const isArea =\n typeof measure !== \"string\"\n ? (measure as LineFullMeasures).area ?? area\n : area;\n const aOpacity =\n typeof measure !== \"string\"\n ? (measure as LineFullMeasures).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 } as LineSeriesOption | BarSeriesOption | PieSeriesOption;\n }),\n };\n }, [\n data,\n groupByKey,\n area,\n stack,\n nameFormatter,\n emptyCellMode,\n areaOpacity,\n measures,\n type,\n horizontal,\n radius,\n ]);\n\n return option;\n};\n"],"names":["useSeries","groupBy","type","data","measures","nameFormatter","stack","horizontal","area","areaOpacity","emptyCellMode","radius","groupByKey","getGroupKey","option","useMemo","series","columnNames","filter","c","map","measure","getMeasure","pieOps","lineOps","barOps","encode","value","itemName","labelLine","show","label","emphasis","sampling","undefined","yAxisId","yAxis","stackName","axisOps","x","y","barMaxWidth","barMinWidth","showSymbol","hideSymbol","connectNulls","isArea","aOpacity","areaStyle","opacity","id","name"],"mappings":";;;AAuCO,MAAMA,YAAYA,CAAC;AAAA,EACxBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,aAAa;AAAA,EACbC,OAAO;AAAA,EACPC,cAAc;AAAA,EACdC;AAAAA,EACAC;AACiB,MAAM;AACjBC,QAAAA,aAAaC,YAAYZ,OAAO;AAEhCa,QAAAA,SAAwCC,QAE5C,MAAM;AACC,WAAA;AAAA,MACLC,QAAQb,KACLc,YACAC,EAAAA,OAAQC,OAAMA,MAAMP,UAAU,EAC9BQ,IAA2DD,CAAM,MAAA;AAC1DE,cAAAA,UAAUC,WAAWH,GAAGf,QAAQ;AAEtC,YAAImB,SAA0B,CAAA;AAC9B,YAAIC,UAA4B,CAAA;AAChC,YAAIC,SAA0B,CAAA;AAG9B,YAAIvB,SAAS,OAAO;AACT,mBAAA;AAAA,YACPwB,QAAQ;AAAA,cACNC,OAAOR;AAAAA,cACPS,UAAUhB;AAAAA,YACZ;AAAA,YACAiB,WAAW;AAAA,cACTC,MAAM;AAAA,YACR;AAAA,YACAC,OAAO;AAAA,cACLD,MAAM;AAAA,YACR;AAAA,YACAE,UAAU;AAAA,cACRD,OAAO;AAAA,gBACLD,MAAM;AAAA,cACR;AAAA,YACF;AAAA,YACAnB;AAAAA,UAAAA;AAAAA,QAEJ;AAGIT,YAAAA,SAAS,UAAUA,SAAS,OAAO;AACrC,gBAAM+B,WACJ,OAAOZ,YAAY,WACdA,QAA+CY,WAChDC;AACN,gBAAMC,UACJ,OAAOd,YAAY,WACdA,QAA+Ce,QAChDF;AACAG,gBAAAA,YACJ,OAAOhB,YAAY,WACdA,QAA+Cf,SAChDA,SACA4B,SACA5B,SAAS4B;AAEf,gBAAMI,UAAU;AAAA,YACdL;AAAAA,YACAE;AAAAA,YACA7B,OAAO+B;AAAAA,YACPX,QAAQnB,aACJ;AAAA,cACEgC,GAAGpB;AAAAA,cACHqB,GAAG5B;AAAAA,YAAAA,IAEL;AAAA,cACE2B,GAAG3B;AAAAA,cACH4B,GAAGrB;AAAAA,YACL;AAAA,UAAA;AAIN,cAAIjB,SAAS,OAAO;AACT,qBAAA;AAAA,cACP,GAAGoC;AAAAA,cACHG,aAAa;AAAA,cACbC,aAAa;AAAA,YAAA;AAAA,UAEjB;AAGA,cAAIxC,SAAS,QAAQ;AACnB,kBAAMyC,aACJ,OAAOtB,YAAY,WACf,CAAEA,QAA6BuB,aAC/B;AACAC,kBAAAA,eACJ,OAAOxB,YAAY,YAClBA,QAA6BX,gBACzBW,QAA6BX,kBAAkB,YAChDA,kBAAkB;AACxB,kBAAMoC,SACJ,OAAOzB,YAAY,WACdA,QAA6Bb,QAAQA,OACtCA;AACN,kBAAMuC,WACJ,OAAO1B,YAAY,WACdA,QAA6BZ,eAAeA,cAC7CA;AAEI,sBAAA;AAAA,cACR,GAAG6B;AAAAA,cACHO;AAAAA,cACAF;AAAAA,cACAK,WAAWF,SAAS;AAAA,gBAAEG,SAASF;AAAAA,cAAab,IAAAA;AAAAA,YAAAA;AAAAA,UAEhD;AAAA,QACF;AAEO,eAAA;AAAA,UACLgB,IAAK,UAAStC,cAAcO;AAAAA,UAC5BjB;AAAAA,UACAiD,MAAM9C,gBAAgBA,cAAcc,CAAC,IAAIA;AAAAA,UACzC,GAAGI;AAAAA,UACH,GAAGE;AAAAA,UACH,GAAGD;AAAAA,QAAAA;AAAAA,MACL,CACD;AAAA,IAAA;AAAA,EAEJ,GAAA,CACDrB,MACAS,YACAJ,MACAF,OACAD,eACAK,eACAD,aACAL,UACAF,MACAK,YACAI,MAAM,CACP;AAEMG,SAAAA;AACT;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useVizTheme.js","sources":["../../../src/hooks/useVizTheme.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useVizTheme.js","sources":["../../../src/hooks/useVizTheme.ts"],"sourcesContent":["import { useContext } from \"react\";\n\nimport { HvVizContext, HvVizContextValue } from \"@viz/providers\";\n\nexport const useVizTheme = (): HvVizContextValue => {\n return useContext(HvVizContext);\n};\n"],"names":["useVizTheme","useContext","HvVizContext"],"mappings":";;AAIO,MAAMA,cAAcA,MAAyB;AAClD,SAAOC,WAAWC,YAAY;AAChC;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { getAxisType } from "../utils/getAxisType.js";
|
|
3
|
+
const useXAxis = ({
|
|
4
|
+
xAxis,
|
|
5
|
+
defaultType = "categorical",
|
|
6
|
+
scale = false
|
|
7
|
+
}) => {
|
|
8
|
+
const option = useMemo(() => {
|
|
9
|
+
return {
|
|
10
|
+
xAxis: {
|
|
11
|
+
id: xAxis == null ? void 0 : xAxis.id,
|
|
12
|
+
type: getAxisType(xAxis == null ? void 0 : xAxis.type) ?? getAxisType(defaultType),
|
|
13
|
+
name: xAxis == null ? void 0 : xAxis.name,
|
|
14
|
+
scale,
|
|
15
|
+
axisLabel: {
|
|
16
|
+
rotate: (xAxis == null ? void 0 : xAxis.labelRotation) ?? 0,
|
|
17
|
+
formatter: xAxis == null ? void 0 : xAxis.labelFormatter
|
|
18
|
+
},
|
|
19
|
+
max: (xAxis == null ? void 0 : xAxis.maxValue) === "max" ? "dataMax" : xAxis == null ? void 0 : xAxis.maxValue,
|
|
20
|
+
min: (xAxis == null ? void 0 : xAxis.minValue) === "min" ? "dataMin" : xAxis == null ? void 0 : xAxis.minValue
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}, [xAxis, scale, defaultType]);
|
|
24
|
+
return option;
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
useXAxis
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=useXAxis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useXAxis.js","sources":["../../../src/hooks/useXAxis.tsx"],"sourcesContent":["import { useMemo } from \"react\";\n\nimport type { EChartsOption } from \"echarts-for-react/lib/types\";\n\nimport { getAxisType } from \"@viz/utils\";\nimport { HvAxisChartCommonProps } from \"@viz/types/common\";\nimport { HvChartAxisType } from \"@viz/types\";\n\ninterface HvXAxisHookProps {\n xAxis: HvAxisChartCommonProps[\"xAxis\"];\n defaultType?: HvChartAxisType;\n scale?: boolean;\n}\n\nexport const useXAxis = ({\n xAxis,\n defaultType = \"categorical\",\n scale = false,\n}: HvXAxisHookProps) => {\n const option = useMemo<Pick<EChartsOption, \"xAxis\">>(() => {\n return {\n xAxis: {\n id: xAxis?.id,\n type: getAxisType(xAxis?.type) ?? getAxisType(defaultType),\n name: xAxis?.name,\n scale,\n axisLabel: {\n rotate: xAxis?.labelRotation ?? 0,\n formatter: xAxis?.labelFormatter,\n },\n max: xAxis?.maxValue === \"max\" ? \"dataMax\" : xAxis?.maxValue,\n min: xAxis?.minValue === \"min\" ? \"dataMin\" : xAxis?.minValue,\n },\n };\n }, [xAxis, scale, defaultType]);\n\n return option;\n};\n"],"names":["useXAxis","xAxis","defaultType","scale","option","useMemo","id","type","getAxisType","name","axisLabel","rotate","labelRotation","formatter","labelFormatter","max","maxValue","min","minValue"],"mappings":";;AAcO,MAAMA,WAAWA,CAAC;AAAA,EACvBC;AAAAA,EACAC,cAAc;AAAA,EACdC,QAAQ;AACQ,MAAM;AAChBC,QAAAA,SAASC,QAAsC,MAAM;AAClD,WAAA;AAAA,MACLJ,OAAO;AAAA,QACLK,IAAIL,+BAAOK;AAAAA,QACXC,MAAMC,YAAYP,+BAAOM,IAAI,KAAKC,YAAYN,WAAW;AAAA,QACzDO,MAAMR,+BAAOQ;AAAAA,QACbN;AAAAA,QACAO,WAAW;AAAA,UACTC,SAAQV,+BAAOW,kBAAiB;AAAA,UAChCC,WAAWZ,+BAAOa;AAAAA,QACpB;AAAA,QACAC,MAAKd,+BAAOe,cAAa,QAAQ,YAAYf,+BAAOe;AAAAA,QACpDC,MAAKhB,+BAAOiB,cAAa,QAAQ,YAAYjB,+BAAOiB;AAAAA,MACtD;AAAA,IAAA;AAAA,EAED,GAAA,CAACjB,OAAOE,OAAOD,WAAW,CAAC;AAEvBE,SAAAA;AACT;"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { getAxisType } from "../utils/getAxisType.js";
|
|
3
|
+
const useYAxis = ({
|
|
4
|
+
yAxis,
|
|
5
|
+
defaultType = "continuous"
|
|
6
|
+
}) => {
|
|
7
|
+
const option = useMemo(() => {
|
|
8
|
+
if (!yAxis || !Array.isArray(yAxis)) {
|
|
9
|
+
return {
|
|
10
|
+
yAxis: {
|
|
11
|
+
id: yAxis == null ? void 0 : yAxis.id,
|
|
12
|
+
type: getAxisType(yAxis == null ? void 0 : yAxis.type) ?? getAxisType(defaultType),
|
|
13
|
+
name: yAxis == null ? void 0 : yAxis.name,
|
|
14
|
+
axisLabel: {
|
|
15
|
+
rotate: (yAxis == null ? void 0 : yAxis.labelRotation) ?? 0,
|
|
16
|
+
formatter: yAxis == null ? void 0 : yAxis.labelFormatter
|
|
17
|
+
},
|
|
18
|
+
max: (yAxis == null ? void 0 : yAxis.maxValue) === "max" ? "dataMax" : yAxis == null ? void 0 : yAxis.maxValue,
|
|
19
|
+
min: (yAxis == null ? void 0 : yAxis.minValue) === "min" ? "dataMin" : yAxis == null ? void 0 : yAxis.minValue
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
yAxis: yAxis.map((axis) => ({
|
|
25
|
+
id: axis == null ? void 0 : axis.id,
|
|
26
|
+
type: getAxisType(axis == null ? void 0 : axis.type) ?? "value",
|
|
27
|
+
name: axis == null ? void 0 : axis.name,
|
|
28
|
+
axisLabel: {
|
|
29
|
+
rotate: (axis == null ? void 0 : axis.labelRotation) ?? 0,
|
|
30
|
+
formatter: axis == null ? void 0 : axis.labelFormatter
|
|
31
|
+
},
|
|
32
|
+
max: (axis == null ? void 0 : axis.maxValue) === "max" ? "dataMax" : axis == null ? void 0 : axis.maxValue,
|
|
33
|
+
min: (axis == null ? void 0 : axis.minValue) === "min" ? "dataMin" : axis == null ? void 0 : axis.minValue
|
|
34
|
+
}))
|
|
35
|
+
};
|
|
36
|
+
}, [yAxis, defaultType]);
|
|
37
|
+
return option;
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
useYAxis
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=useYAxis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useYAxis.js","sources":["../../../src/hooks/useYAxis.tsx"],"sourcesContent":["import { useMemo } from \"react\";\n\nimport type { EChartsOption } from \"echarts-for-react/lib/types\";\nimport type { YAXisComponentOption } from \"echarts/types/dist/echarts\";\n\nimport { getAxisType } from \"@viz/utils\";\nimport { HvAxisChartCommonProps } from \"@viz/types/common\";\nimport { HvChartAxisType } from \"@viz/types\";\n\ninterface HvYAxisHookProps {\n yAxis: HvAxisChartCommonProps[\"yAxis\"];\n defaultType?: HvChartAxisType;\n}\n\nexport const useYAxis = ({\n yAxis,\n defaultType = \"continuous\",\n}: HvYAxisHookProps) => {\n const option = useMemo<Pick<EChartsOption, \"yAxis\">>(() => {\n if (!yAxis || !Array.isArray(yAxis)) {\n return {\n yAxis: {\n id: yAxis?.id,\n type: getAxisType(yAxis?.type) ?? getAxisType(defaultType),\n name: yAxis?.name,\n axisLabel: {\n rotate: yAxis?.labelRotation ?? 0,\n formatter: yAxis?.labelFormatter,\n },\n max: yAxis?.maxValue === \"max\" ? \"dataMax\" : yAxis?.maxValue,\n min: yAxis?.minValue === \"min\" ? \"dataMin\" : yAxis?.minValue,\n },\n };\n }\n\n return {\n yAxis: yAxis.map<YAXisComponentOption>((axis) => ({\n id: axis?.id,\n type: getAxisType(axis?.type) ?? \"value\",\n name: axis?.name,\n axisLabel: {\n rotate: axis?.labelRotation ?? 0,\n formatter: axis?.labelFormatter,\n },\n max: axis?.maxValue === \"max\" ? \"dataMax\" : axis?.maxValue,\n min: axis?.minValue === \"min\" ? \"dataMin\" : axis?.minValue,\n })),\n };\n }, [yAxis, defaultType]);\n\n return option;\n};\n"],"names":["useYAxis","yAxis","defaultType","option","useMemo","Array","isArray","id","type","getAxisType","name","axisLabel","rotate","labelRotation","formatter","labelFormatter","max","maxValue","min","minValue","map","axis"],"mappings":";;AAcO,MAAMA,WAAWA,CAAC;AAAA,EACvBC;AAAAA,EACAC,cAAc;AACE,MAAM;AAChBC,QAAAA,SAASC,QAAsC,MAAM;AACzD,QAAI,CAACH,SAAS,CAACI,MAAMC,QAAQL,KAAK,GAAG;AAC5B,aAAA;AAAA,QACLA,OAAO;AAAA,UACLM,IAAIN,+BAAOM;AAAAA,UACXC,MAAMC,YAAYR,+BAAOO,IAAI,KAAKC,YAAYP,WAAW;AAAA,UACzDQ,MAAMT,+BAAOS;AAAAA,UACbC,WAAW;AAAA,YACTC,SAAQX,+BAAOY,kBAAiB;AAAA,YAChCC,WAAWb,+BAAOc;AAAAA,UACpB;AAAA,UACAC,MAAKf,+BAAOgB,cAAa,QAAQ,YAAYhB,+BAAOgB;AAAAA,UACpDC,MAAKjB,+BAAOkB,cAAa,QAAQ,YAAYlB,+BAAOkB;AAAAA,QACtD;AAAA,MAAA;AAAA,IAEJ;AAEO,WAAA;AAAA,MACLlB,OAAOA,MAAMmB,IAA2BC,CAAU,UAAA;AAAA,QAChDd,IAAIc,6BAAMd;AAAAA,QACVC,MAAMC,YAAYY,6BAAMb,IAAI,KAAK;AAAA,QACjCE,MAAMW,6BAAMX;AAAAA,QACZC,WAAW;AAAA,UACTC,SAAQS,6BAAMR,kBAAiB;AAAA,UAC/BC,WAAWO,6BAAMN;AAAAA,QACnB;AAAA,QACAC,MAAKK,6BAAMJ,cAAa,QAAQ,YAAYI,6BAAMJ;AAAAA,QAClDC,MAAKG,6BAAMF,cAAa,QAAQ,YAAYE,6BAAMF;AAAAA,MAAAA,EAClD;AAAA,IAAA;AAAA,EACJ,GACC,CAAClB,OAAOC,WAAW,CAAC;AAEhBC,SAAAA;AACT;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { HvLineChart } from "./components/LineChart/LineChart.js";
|
|
2
2
|
import { HvBarChart } from "./components/BarChart/BarChart.js";
|
|
3
|
+
import { HvDonutChart } from "./components/DonutChart/DonutChart.js";
|
|
3
4
|
import { HvVizContext, HvVizProvider } from "./providers/Provider.js";
|
|
4
5
|
export {
|
|
5
6
|
HvBarChart,
|
|
7
|
+
HvDonutChart,
|
|
6
8
|
HvLineChart,
|
|
7
9
|
HvVizContext,
|
|
8
10
|
HvVizProvider
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { createContext, useMemo } from "react";
|
|
1
2
|
import { useTheme } from "@hitachivantara/uikit-react-core";
|
|
2
|
-
import {
|
|
3
|
-
import { createContext, useEffect, useMemo } from "react";
|
|
3
|
+
import { registerTheme } from "../utils/registerTheme.js";
|
|
4
4
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
5
5
|
const HvVizContext = createContext({
|
|
6
6
|
theme: void 0
|
|
@@ -10,17 +10,15 @@ const HvVizProvider = ({
|
|
|
10
10
|
}) => {
|
|
11
11
|
const {
|
|
12
12
|
activeTheme,
|
|
13
|
-
colorModes,
|
|
14
13
|
selectedMode,
|
|
15
14
|
selectedTheme
|
|
16
15
|
} = useTheme();
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}), [theme]);
|
|
16
|
+
const value = useMemo(() => {
|
|
17
|
+
registerTheme(selectedTheme, selectedMode, activeTheme);
|
|
18
|
+
return {
|
|
19
|
+
theme: `${selectedTheme}-${selectedMode}`
|
|
20
|
+
};
|
|
21
|
+
}, [selectedTheme, selectedMode, activeTheme]);
|
|
24
22
|
return /* @__PURE__ */ jsx(HvVizContext.Provider, {
|
|
25
23
|
value,
|
|
26
24
|
children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.js","sources":["../../../src/providers/Provider.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"Provider.js","sources":["../../../src/providers/Provider.tsx"],"sourcesContent":["import { createContext, useMemo } from \"react\";\n\nimport { useTheme } from \"@hitachivantara/uikit-react-core\";\n\nimport { registerTheme } from \"@viz/utils\";\n\nexport interface HvVizContextValue {\n /**\n * Current theme\n */\n theme?: string;\n}\n\nexport const HvVizContext = createContext<HvVizContextValue>({\n theme: undefined,\n});\n\nexport interface HvVizProviderProps {\n /**\n * Component tree.\n */\n children?: React.ReactNode;\n}\n\n/**\n * Enables theming capabilities for visualizations.\n *\n * Without this provider the visualizations will not comply to the UI Kit themes.\n *\n * This provider should always be used in combination with the `HvProvider` from\n * the core package since the former uses the themes provided by the latter.\n *\n * `HvVizProvider` should always be used after `HvProvider` like so to work properly:\n *\n * ```\n * <HvProvider>\n * <HvVizProvider>\n * (...)\n * </HvVizProvider>\n * </HvProvider>\n * ```\n */\nexport const HvVizProvider = ({ children }: HvVizProviderProps) => {\n const { activeTheme, selectedMode, selectedTheme } = useTheme();\n\n const value = useMemo(() => {\n registerTheme(selectedTheme, selectedMode, activeTheme);\n\n return { theme: `${selectedTheme}-${selectedMode}` };\n }, [selectedTheme, selectedMode, activeTheme]);\n\n return (\n <HvVizContext.Provider value={value}>{children}</HvVizContext.Provider>\n );\n};\n"],"names":["HvVizContext","createContext","theme","undefined","HvVizProvider","children","activeTheme","selectedMode","selectedTheme","useTheme","value","useMemo","_jsx","Provider"],"mappings":";;;;AAaO,MAAMA,eAAeC,cAAiC;AAAA,EAC3DC,OAAOC;AACT,CAAC;AA2BM,MAAMC,gBAAgBA,CAAC;AAAA,EAAEC;AAA6B,MAAM;AAC3D,QAAA;AAAA,IAAEC;AAAAA,IAAaC;AAAAA,IAAcC;AAAAA,MAAkBC,SAAS;AAExDC,QAAAA,QAAQC,QAAQ,MAAM;AACZH,kBAAAA,eAAeD,cAAcD,WAAW;AAE/C,WAAA;AAAA,MAAEJ,OAAQ,GAAEM,iBAAiBD;AAAAA,IAAAA;AAAAA,EACnC,GAAA,CAACC,eAAeD,cAAcD,WAAW,CAAC;AAG3CM,SAAAA,oBAACZ,aAAaa,UAAQ;AAAA,IAACH;AAAAA,IAAaL;AAAAA,EAAAA,CAAkC;AAE1E;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getGroupKey.js","sources":["../../../src/utils/getGroupKey.ts"],"sourcesContent":["import { HvChartCommonProps } from \"@viz/types/common\";\n\nexport const getGroupKey = (groupBy: HvChartCommonProps[\"groupBy\"]) =>\n Array.isArray(groupBy) ? groupBy.join(\"_\") : groupBy;\n"],"names":["getGroupKey","groupBy","Array","isArray","join"],"mappings":"AAEaA,MAAAA,cAAcA,CAACC,YAC1BC,MAAMC,QAAQF,OAAO,IAAIA,QAAQG,KAAK,GAAG,IAAIH;"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
const getLegendIcon = (
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const getLegendIcon = (icon) => {
|
|
2
|
+
switch (icon) {
|
|
3
|
+
case "square":
|
|
4
|
+
return "path://M0,0L16,0L16,16L0,16L0,0Z";
|
|
5
|
+
case "line":
|
|
6
|
+
default:
|
|
7
|
+
return "path://M0,0L16,0L16,2L0,2Z";
|
|
4
8
|
}
|
|
5
|
-
return "path://M0,0L16,0L16,2L0,2Z";
|
|
6
9
|
};
|
|
7
10
|
export {
|
|
8
11
|
getLegendIcon
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLegendIcon.js","sources":["../../../src/utils/getLegendIcon.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"getLegendIcon.js","sources":["../../../src/utils/getLegendIcon.ts"],"sourcesContent":["import { HvChartLegendIcon } from \"@viz/types/legend\";\n\nexport const getLegendIcon = (icon: HvChartLegendIcon) => {\n switch (icon) {\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"],"names":["getLegendIcon","icon"],"mappings":"AAEaA,MAAAA,gBAAgBA,CAACC,SAA4B;AACxD,UAAQA,MAAI;AAAA,IACV,KAAK;AACI,aAAA;AAAA,IACT,KAAK;AAAA,IACL;AACS,aAAA;AAAA,EACX;AACF;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const getMeasure = (name, msr) => {
|
|
2
|
+
const measureName = name.split("_")[0];
|
|
3
|
+
const measuresArray = Array.isArray(msr) ? msr : [msr];
|
|
4
|
+
return measuresArray.find((m) => {
|
|
5
|
+
if (typeof m === "string") {
|
|
6
|
+
return m === measureName;
|
|
7
|
+
}
|
|
8
|
+
return m.field === measureName;
|
|
9
|
+
}) ?? measuresArray[0];
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
getMeasure
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=getMeasure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMeasure.js","sources":["../../../src/utils/getMeasure.ts"],"sourcesContent":["import { Arrayable } from \"@hitachivantara/uikit-react-core\";\n\nimport {\n HvBarChartMeasures,\n HvDonutChartMeasure,\n HvLineChartMeasures,\n} from \"@viz/types\";\n\nexport const getMeasure = (\n name: string,\n msr: Arrayable<HvLineChartMeasures | HvBarChartMeasures> | HvDonutChartMeasure\n): HvLineChartMeasures | HvBarChartMeasures | HvDonutChartMeasure => {\n const measureName = name.split(\"_\")[0];\n const measuresArray = Array.isArray(msr) ? msr : [msr];\n // find the measure in measures array or return the first one\n return (\n measuresArray.find((m) => {\n if (typeof m === \"string\") {\n return m === measureName;\n }\n return m.field === measureName;\n }) ?? measuresArray[0]\n );\n};\n"],"names":["getMeasure","name","msr","measureName","split","measuresArray","Array","isArray","find","m","field"],"mappings":"AAQaA,MAAAA,aAAaA,CACxBC,MACAC,QACmE;AACnE,QAAMC,cAAcF,KAAKG,MAAM,GAAG,EAAE,CAAC;AACrC,QAAMC,gBAAgBC,MAAMC,QAAQL,GAAG,IAAIA,MAAM,CAACA,GAAG;AAGnDG,SAAAA,cAAcG,KAAMC,CAAM,MAAA;AACpB,QAAA,OAAOA,MAAM,UAAU;AACzB,aAAOA,MAAMN;AAAAA,IACf;AACA,WAAOM,EAAEC,UAAUP;AAAAA,EAAAA,CACpB,KAAKE,cAAc,CAAC;AAEzB;"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as echarts from "echarts/core";
|
|
2
|
+
const registerTheme = (name, mode, themeStructure) => {
|
|
3
|
+
const baseText = {
|
|
4
|
+
color: themeStructure == null ? void 0 : themeStructure.colors.modes[mode].secondary,
|
|
5
|
+
fontWeight: themeStructure == null ? void 0 : themeStructure.fontWeights.normal,
|
|
6
|
+
fontSize: themeStructure == null ? void 0 : themeStructure.fontSizes.sm,
|
|
7
|
+
fontFamily: themeStructure == null ? void 0 : themeStructure.fontFamily.body
|
|
8
|
+
};
|
|
9
|
+
const customAxis = {
|
|
10
|
+
nameTextStyle: {
|
|
11
|
+
...baseText
|
|
12
|
+
},
|
|
13
|
+
axisLine: {
|
|
14
|
+
show: true,
|
|
15
|
+
lineStyle: {
|
|
16
|
+
color: themeStructure == null ? void 0 : themeStructure.colors.modes[mode].atmo3
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
axisTick: {
|
|
20
|
+
show: true,
|
|
21
|
+
lineStyle: {
|
|
22
|
+
color: themeStructure == null ? void 0 : themeStructure.colors.modes[mode].atmo3
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
axisLabel: {
|
|
26
|
+
color: themeStructure == null ? void 0 : themeStructure.colors.modes[mode].secondary_80,
|
|
27
|
+
fontWeight: themeStructure == null ? void 0 : themeStructure.fontWeights.normal,
|
|
28
|
+
fontSize: themeStructure == null ? void 0 : themeStructure.fontSizes.sm,
|
|
29
|
+
fontFamily: themeStructure == null ? void 0 : themeStructure.fontFamily.body
|
|
30
|
+
},
|
|
31
|
+
splitLine: {
|
|
32
|
+
show: true,
|
|
33
|
+
lineStyle: {
|
|
34
|
+
color: themeStructure == null ? void 0 : themeStructure.colors.modes[mode].atmo3
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
echarts.registerTheme(`${name}-${mode}`, {
|
|
39
|
+
color: [themeStructure == null ? void 0 : themeStructure.colors.modes[mode].cat1, themeStructure == null ? void 0 : themeStructure.colors.modes[mode].cat2, themeStructure == null ? void 0 : themeStructure.colors.modes[mode].cat3, themeStructure == null ? void 0 : themeStructure.colors.modes[mode].cat4, themeStructure == null ? void 0 : themeStructure.colors.modes[mode].cat5, themeStructure == null ? void 0 : themeStructure.colors.modes[mode].cat6, themeStructure == null ? void 0 : themeStructure.colors.modes[mode].cat7, themeStructure == null ? void 0 : themeStructure.colors.modes[mode].cat8, themeStructure == null ? void 0 : themeStructure.colors.modes[mode].cat9, themeStructure == null ? void 0 : themeStructure.colors.modes[mode].cat10, themeStructure == null ? void 0 : themeStructure.colors.modes[mode].cat11, themeStructure == null ? void 0 : themeStructure.colors.modes[mode].cat12],
|
|
40
|
+
legend: {
|
|
41
|
+
textStyle: {
|
|
42
|
+
...baseText
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
tooltip: {
|
|
46
|
+
borderWidth: 0,
|
|
47
|
+
padding: 0,
|
|
48
|
+
textStyle: {
|
|
49
|
+
...baseText
|
|
50
|
+
},
|
|
51
|
+
axisPointer: {
|
|
52
|
+
lineStyle: {
|
|
53
|
+
color: themeStructure == null ? void 0 : themeStructure.colors.modes[mode].secondary,
|
|
54
|
+
width: 1
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
dataZoom: {
|
|
59
|
+
textStyle: {
|
|
60
|
+
...baseText
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
categoryAxis: {
|
|
64
|
+
...customAxis
|
|
65
|
+
},
|
|
66
|
+
valueAxis: {
|
|
67
|
+
...customAxis
|
|
68
|
+
},
|
|
69
|
+
logAxis: {
|
|
70
|
+
...customAxis
|
|
71
|
+
},
|
|
72
|
+
timeAxis: {
|
|
73
|
+
...customAxis
|
|
74
|
+
},
|
|
75
|
+
line: {
|
|
76
|
+
lineStyle: {
|
|
77
|
+
width: 2
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
export {
|
|
83
|
+
registerTheme
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=registerTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerTheme.js","sources":["../../../src/utils/registerTheme.ts"],"sourcesContent":["import { HvTheme } from \"@hitachivantara/uikit-react-core\";\nimport * as echarts from \"echarts/core\";\n\nexport const registerTheme = (\n name: string,\n mode: string,\n themeStructure?: HvTheme\n) => {\n const baseText = {\n color: themeStructure?.colors.modes[mode].secondary,\n fontWeight: themeStructure?.fontWeights.normal,\n fontSize: themeStructure?.fontSizes.sm,\n fontFamily: themeStructure?.fontFamily.body,\n };\n\n const customAxis = {\n nameTextStyle: {\n ...baseText,\n },\n axisLine: {\n show: true,\n lineStyle: {\n color: themeStructure?.colors.modes[mode].atmo3,\n },\n },\n axisTick: {\n show: true,\n lineStyle: {\n color: themeStructure?.colors.modes[mode].atmo3,\n },\n },\n axisLabel: {\n color: themeStructure?.colors.modes[mode].secondary_80,\n fontWeight: themeStructure?.fontWeights.normal,\n fontSize: themeStructure?.fontSizes.sm,\n fontFamily: themeStructure?.fontFamily.body,\n },\n splitLine: {\n show: true,\n lineStyle: {\n color: themeStructure?.colors.modes[mode].atmo3,\n },\n },\n };\n\n echarts.registerTheme(`${name}-${mode}`, {\n color: [\n themeStructure?.colors.modes[mode].cat1,\n themeStructure?.colors.modes[mode].cat2,\n themeStructure?.colors.modes[mode].cat3,\n themeStructure?.colors.modes[mode].cat4,\n themeStructure?.colors.modes[mode].cat5,\n themeStructure?.colors.modes[mode].cat6,\n themeStructure?.colors.modes[mode].cat7,\n themeStructure?.colors.modes[mode].cat8,\n themeStructure?.colors.modes[mode].cat9,\n themeStructure?.colors.modes[mode].cat10,\n themeStructure?.colors.modes[mode].cat11,\n themeStructure?.colors.modes[mode].cat12,\n ],\n legend: {\n textStyle: {\n ...baseText,\n },\n },\n tooltip: {\n borderWidth: 0,\n padding: 0,\n textStyle: {\n ...baseText,\n },\n axisPointer: {\n lineStyle: {\n color: themeStructure?.colors.modes[mode].secondary,\n width: 1,\n },\n },\n },\n dataZoom: {\n textStyle: { ...baseText },\n },\n categoryAxis: {\n ...customAxis,\n },\n valueAxis: {\n ...customAxis,\n },\n logAxis: {\n ...customAxis,\n },\n timeAxis: {\n ...customAxis,\n },\n line: {\n lineStyle: {\n width: 2,\n },\n },\n });\n};\n"],"names":["registerTheme","name","mode","themeStructure","baseText","color","colors","modes","secondary","fontWeight","fontWeights","normal","fontSize","fontSizes","sm","fontFamily","body","customAxis","nameTextStyle","axisLine","show","lineStyle","atmo3","axisTick","axisLabel","secondary_80","splitLine","cat1","cat2","cat3","cat4","cat5","cat6","cat7","cat8","cat9","cat10","cat11","cat12","legend","textStyle","tooltip","borderWidth","padding","axisPointer","width","dataZoom","categoryAxis","valueAxis","logAxis","timeAxis","line"],"mappings":";AAGO,MAAMA,gBAAgBA,CAC3BC,MACAC,MACAC,mBACG;AACH,QAAMC,WAAW;AAAA,IACfC,OAAOF,iDAAgBG,OAAOC,MAAML,MAAMM;AAAAA,IAC1CC,YAAYN,iDAAgBO,YAAYC;AAAAA,IACxCC,UAAUT,iDAAgBU,UAAUC;AAAAA,IACpCC,YAAYZ,iDAAgBY,WAAWC;AAAAA,EAAAA;AAGzC,QAAMC,aAAa;AAAA,IACjBC,eAAe;AAAA,MACb,GAAGd;AAAAA,IACL;AAAA,IACAe,UAAU;AAAA,MACRC,MAAM;AAAA,MACNC,WAAW;AAAA,QACThB,OAAOF,iDAAgBG,OAAOC,MAAML,MAAMoB;AAAAA,MAC5C;AAAA,IACF;AAAA,IACAC,UAAU;AAAA,MACRH,MAAM;AAAA,MACNC,WAAW;AAAA,QACThB,OAAOF,iDAAgBG,OAAOC,MAAML,MAAMoB;AAAAA,MAC5C;AAAA,IACF;AAAA,IACAE,WAAW;AAAA,MACTnB,OAAOF,iDAAgBG,OAAOC,MAAML,MAAMuB;AAAAA,MAC1ChB,YAAYN,iDAAgBO,YAAYC;AAAAA,MACxCC,UAAUT,iDAAgBU,UAAUC;AAAAA,MACpCC,YAAYZ,iDAAgBY,WAAWC;AAAAA,IACzC;AAAA,IACAU,WAAW;AAAA,MACTN,MAAM;AAAA,MACNC,WAAW;AAAA,QACThB,OAAOF,iDAAgBG,OAAOC,MAAML,MAAMoB;AAAAA,MAC5C;AAAA,IACF;AAAA,EAAA;AAGMtB,UAAAA,cAAe,GAAEC,QAAQC,QAAQ;AAAA,IACvCG,OAAO,CACLF,iDAAgBG,OAAOC,MAAML,MAAMyB,MACnCxB,iDAAgBG,OAAOC,MAAML,MAAM0B,MACnCzB,iDAAgBG,OAAOC,MAAML,MAAM2B,MACnC1B,iDAAgBG,OAAOC,MAAML,MAAM4B,MACnC3B,iDAAgBG,OAAOC,MAAML,MAAM6B,MACnC5B,iDAAgBG,OAAOC,MAAML,MAAM8B,MACnC7B,iDAAgBG,OAAOC,MAAML,MAAM+B,MACnC9B,iDAAgBG,OAAOC,MAAML,MAAMgC,MACnC/B,iDAAgBG,OAAOC,MAAML,MAAMiC,MACnChC,iDAAgBG,OAAOC,MAAML,MAAMkC,OACnCjC,iDAAgBG,OAAOC,MAAML,MAAMmC,OACnClC,iDAAgBG,OAAOC,MAAML,MAAMoC,KAAK;AAAA,IAE1CC,QAAQ;AAAA,MACNC,WAAW;AAAA,QACT,GAAGpC;AAAAA,MACL;AAAA,IACF;AAAA,IACAqC,SAAS;AAAA,MACPC,aAAa;AAAA,MACbC,SAAS;AAAA,MACTH,WAAW;AAAA,QACT,GAAGpC;AAAAA,MACL;AAAA,MACAwC,aAAa;AAAA,QACXvB,WAAW;AAAA,UACThB,OAAOF,iDAAgBG,OAAOC,MAAML,MAAMM;AAAAA,UAC1CqC,OAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF;AAAA,IACAC,UAAU;AAAA,MACRN,WAAW;AAAA,QAAE,GAAGpC;AAAAA,MAAS;AAAA,IAC3B;AAAA,IACA2C,cAAc;AAAA,MACZ,GAAG9B;AAAAA,IACL;AAAA,IACA+B,WAAW;AAAA,MACT,GAAG/B;AAAAA,IACL;AAAA,IACAgC,SAAS;AAAA,MACP,GAAGhC;AAAAA,IACL;AAAA,IACAiC,UAAU;AAAA,MACR,GAAGjC;AAAAA,IACL;AAAA,IACAkC,MAAM;AAAA,MACJ9B,WAAW;AAAA,QACTwB,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EAAA,CACD;AACH;"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5,17 +5,9 @@ import type { CSSInterpolation } from '@emotion/serialize';
|
|
|
5
5
|
import { ExtractNames } from '@hitachivantara/uikit-react-core';
|
|
6
6
|
import type { JSX as JSX_2 } from '@emotion/react/jsx-runtime';
|
|
7
7
|
|
|
8
|
-
declare
|
|
9
|
-
|
|
10
|
-
declare interface BaseFullMeasuresField {
|
|
11
|
-
/** Column name. */
|
|
12
|
-
field: string;
|
|
13
|
-
/** Sampling function to use. */
|
|
14
|
-
sampling?: HvChartSampling;
|
|
8
|
+
declare interface AxisMeasures {
|
|
15
9
|
/** Id of the yAxis. */
|
|
16
10
|
yAxis?: string;
|
|
17
|
-
/** Aggregation function to use. If no `agg` is defined, it will default to `sum`. */
|
|
18
|
-
agg?: HvChartAggregation;
|
|
19
11
|
/**
|
|
20
12
|
* Stack name to use when the measure should be stacked.
|
|
21
13
|
*
|
|
@@ -24,89 +16,68 @@ declare interface BaseFullMeasuresField {
|
|
|
24
16
|
* If not specified, it defaults to the global `stacked` prop.
|
|
25
17
|
*/
|
|
26
18
|
stack?: string;
|
|
27
|
-
/**
|
|
19
|
+
/** Sampling function to use. */
|
|
20
|
+
sampling?: HvChartSampling;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare interface BarFullMeasures extends BaseMeasures, AxisMeasures {
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare interface BaseMeasures {
|
|
27
|
+
/** Column name. */
|
|
28
|
+
field: string;
|
|
29
|
+
/** Aggregation function to use. If no `agg` is defined, it will default to `sum`. */
|
|
30
|
+
agg?: HvChartAggregation;
|
|
31
|
+
/** Formatter for the value. This will be used in the tooltips and overrides the tooltip's value formatter. */
|
|
28
32
|
valueFormatter?: (value?: string | number) => string;
|
|
29
33
|
}
|
|
30
34
|
|
|
35
|
+
declare interface DonutFullMeasures extends BaseMeasures {
|
|
36
|
+
}
|
|
37
|
+
|
|
31
38
|
/** Empty cell mode */
|
|
32
39
|
declare const emptyCellMode: readonly ["connect", "void"];
|
|
33
40
|
|
|
34
|
-
declare type
|
|
41
|
+
declare type FullSortBy = {
|
|
35
42
|
/** Column name. */
|
|
36
43
|
field: string;
|
|
37
44
|
/** Order function to use. If no `order` is defined, it will default to `asc`. */
|
|
38
45
|
order?: HvChartOrder;
|
|
39
46
|
};
|
|
40
47
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* A bar chart is a chart or graph that presents categorical data with rectangular bars.
|
|
45
|
-
*/
|
|
46
|
-
export declare const HvBarChart: ({ horizontal, ...others }: HvBarChartProps) => JSX_2.Element;
|
|
47
|
-
|
|
48
|
-
export declare interface HvBarChartClasses extends HvBaseChartClasses {
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export declare interface HvBarChartProps extends HvBaseChartCommonProps, HvBaseChartBarProps {
|
|
52
|
-
/** A Jss Object used to override or extend the styles applied to the component. */
|
|
53
|
-
classes?: HvBarChartClasses;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** Bar chart props only */
|
|
57
|
-
declare interface HvBaseChartBarProps {
|
|
58
|
-
/** Columns to measure on the chart. */
|
|
59
|
-
measures: Arrayable<BarMeasuresField>;
|
|
60
|
-
/** Whether the bar chart should be horizontal. Defaults to `false`. */
|
|
61
|
-
horizontal?: boolean;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
declare type HvBaseChartClasses = ExtractNames<typeof useClasses>;
|
|
65
|
-
|
|
66
|
-
/** Line and bar chart common props */
|
|
67
|
-
declare interface HvBaseChartCommonProps {
|
|
68
|
-
/** Chart data. */
|
|
69
|
-
data: Map<string | number, (string | number)[]> | Record<string | number, (string | number)[]> | Record<string | number, string | number>[] | ColumnTable;
|
|
70
|
-
/** Columns to use to group the data. */
|
|
71
|
-
groupBy: Arrayable<GroupByField>;
|
|
48
|
+
/** Axis charts (line and bar) common props */
|
|
49
|
+
declare interface HvAxisChartCommonProps {
|
|
72
50
|
/** Columns to use to split the measures. */
|
|
73
|
-
splitBy?: Arrayable<
|
|
74
|
-
/** Columns to use to sort the data points. */
|
|
75
|
-
sortBy?: Arrayable<SortByField>;
|
|
51
|
+
splitBy?: Arrayable<string>;
|
|
76
52
|
/** Options for the xAxis, i.e. the horizontal axis. */
|
|
77
53
|
xAxis?: HvChartAxis;
|
|
78
54
|
/** Options for the yAxis, i.e. the vertical axis. */
|
|
79
55
|
yAxis?: HvChartAxis | [HvChartAxis, HvChartAxis];
|
|
80
|
-
/** Tooltip options. */
|
|
81
|
-
tooltip?: HvChartTooltip;
|
|
82
|
-
/** Legend options. */
|
|
83
|
-
legend?: {
|
|
84
|
-
/** Whether to show the legend or not. The legend will appear by default for multiple series. Otherwise, the legend will not be shown. */
|
|
85
|
-
show?: boolean;
|
|
86
|
-
};
|
|
87
|
-
/** Formatter for the series names used on the tooltips and legend. */
|
|
88
|
-
seriesNameFormatter?: (value?: string) => string;
|
|
89
56
|
/** Stack name to use when all the series should be stacked together. If not provided, the series are not stacked. */
|
|
90
57
|
stack?: string;
|
|
91
58
|
/** Ranger slider options for the horizontal axis. */
|
|
92
|
-
horizontalRangeSlider?:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
59
|
+
horizontalRangeSlider?: HvChartHorizontalRangeSlider;
|
|
60
|
+
/** Formatter for the series names used on the tooltips and legend. */
|
|
61
|
+
seriesNameFormatter?: (value?: string) => string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* A bar chart is a chart or graph that presents categorical data with rectangular bars.
|
|
66
|
+
*/
|
|
67
|
+
export declare const HvBarChart: ({ yAxis, xAxis, horizontal, horizontalRangeSlider, grid, data, groupBy, splitBy, sortBy, stack, seriesNameFormatter, measures, legend, tooltip, classes, }: HvBarChartProps) => JSX_2.Element;
|
|
68
|
+
|
|
69
|
+
export declare interface HvBarChartClasses extends HvChartTooltipClasses {
|
|
98
70
|
}
|
|
99
71
|
|
|
100
|
-
|
|
101
|
-
|
|
72
|
+
export declare type HvBarChartMeasures = string | BarFullMeasures;
|
|
73
|
+
|
|
74
|
+
export declare interface HvBarChartProps extends HvAxisChartCommonProps, HvChartCommonProps {
|
|
102
75
|
/** Columns to measure on the chart. */
|
|
103
|
-
measures: Arrayable<
|
|
104
|
-
/**
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
|
|
108
|
-
/** Sets opacity of the filled area if `area` is true. Defaults to `0.5`. */
|
|
109
|
-
areaOpacity?: number;
|
|
76
|
+
measures: Arrayable<HvBarChartMeasures>;
|
|
77
|
+
/** Whether the bar chart should be horizontal. Defaults to `false`. */
|
|
78
|
+
horizontal?: boolean;
|
|
79
|
+
/** A Jss Object used to override or extend the styles applied to the component. */
|
|
80
|
+
classes?: HvBarChartClasses;
|
|
110
81
|
}
|
|
111
82
|
|
|
112
83
|
/** Aggregation functions */
|
|
@@ -143,6 +114,25 @@ export declare interface HvChartAxis {
|
|
|
143
114
|
*/
|
|
144
115
|
export declare type HvChartAxisType = "continuous" | "categorical" | "time";
|
|
145
116
|
|
|
117
|
+
/** Props common among all charts. */
|
|
118
|
+
declare interface HvChartCommonProps {
|
|
119
|
+
/** Chart data. */
|
|
120
|
+
data: HvChartData;
|
|
121
|
+
/** Columns to use to group the data. */
|
|
122
|
+
groupBy: Arrayable<string>;
|
|
123
|
+
/** Columns to use to sort the data points. */
|
|
124
|
+
sortBy?: Arrayable<HvChartSortBy>;
|
|
125
|
+
/** Tooltip options. */
|
|
126
|
+
tooltip?: HvChartTooltip;
|
|
127
|
+
/** Legend options. */
|
|
128
|
+
legend?: HvChartLegend;
|
|
129
|
+
/** Grid options. */
|
|
130
|
+
grid?: HvChartGrid;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Chart data */
|
|
134
|
+
export declare type HvChartData = Map<string | number, (string | number)[]> | Record<string | number, (string | number)[]> | Record<string | number, string | number>[] | ColumnTable;
|
|
135
|
+
|
|
146
136
|
export declare type HvChartEmptyCellMode = (typeof emptyCellMode)[number];
|
|
147
137
|
|
|
148
138
|
export declare interface HvChartGrid {
|
|
@@ -156,12 +146,31 @@ export declare interface HvChartGrid {
|
|
|
156
146
|
bottom?: string | number;
|
|
157
147
|
}
|
|
158
148
|
|
|
149
|
+
export declare interface HvChartHorizontalRangeSlider {
|
|
150
|
+
/** Whether to show the ranger slider or not. Defaults to `false`. */
|
|
151
|
+
show?: boolean;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export declare interface HvChartLegend {
|
|
155
|
+
/** Whether to show the legend or not. The legend will appear by default for multiple series. Otherwise, the legend will not be shown. */
|
|
156
|
+
show?: boolean;
|
|
157
|
+
/** Direction of the legend. Defaults to `horizontal`. */
|
|
158
|
+
direction?: "vertical" | "horizontal";
|
|
159
|
+
/** Position of the legend. `x` defaults to `center` and `y` to `top`. */
|
|
160
|
+
position?: {
|
|
161
|
+
x?: "left" | "center" | "right";
|
|
162
|
+
y?: "top" | "center" | "bottom";
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
159
166
|
/** Order functions */
|
|
160
167
|
export declare type HvChartOrder = "asc" | "desc";
|
|
161
168
|
|
|
162
169
|
/** Sampling functions */
|
|
163
170
|
export declare type HvChartSampling = "none" | "average" | "min" | "max" | "sum" | "lttb";
|
|
164
171
|
|
|
172
|
+
export declare type HvChartSortBy = string | FullSortBy;
|
|
173
|
+
|
|
165
174
|
export declare interface HvChartTooltip {
|
|
166
175
|
/** Whether to show the tooltip or not. Defaults to `true`. */
|
|
167
176
|
show?: boolean;
|
|
@@ -175,6 +184,8 @@ export declare interface HvChartTooltip {
|
|
|
175
184
|
component?: string | ((params?: HvChartTooltipParams) => string | HTMLElement | HTMLElement[]);
|
|
176
185
|
}
|
|
177
186
|
|
|
187
|
+
declare type HvChartTooltipClasses = ExtractNames<typeof useClasses>;
|
|
188
|
+
|
|
178
189
|
export declare interface HvChartTooltipParams {
|
|
179
190
|
title?: string | number;
|
|
180
191
|
series?: {
|
|
@@ -186,16 +197,48 @@ export declare interface HvChartTooltipParams {
|
|
|
186
197
|
|
|
187
198
|
export declare type HvChartTooltipType = (typeof tooltipType)[number];
|
|
188
199
|
|
|
200
|
+
/**
|
|
201
|
+
* Donut charts nicely convey the part-whole relationship and they have become
|
|
202
|
+
* the most recognizable chart types for representing proportions in business and data statistics.
|
|
203
|
+
*/
|
|
204
|
+
export declare const HvDonutChart: ({ data, groupBy, classes, legend, tooltip, measure: measures, sortBy, grid, type, slicesNameFormatter, }: HvDonutChartProps) => JSX_2.Element;
|
|
205
|
+
|
|
206
|
+
export declare interface HvDonutChartClasses extends HvChartTooltipClasses {
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export declare type HvDonutChartMeasure = string | DonutFullMeasures;
|
|
210
|
+
|
|
211
|
+
export declare interface HvDonutChartProps extends HvChartCommonProps {
|
|
212
|
+
/** Column to measure. */
|
|
213
|
+
measure: HvDonutChartMeasure;
|
|
214
|
+
/** Type: regular or thin. Defaults to `regular`. */
|
|
215
|
+
type?: "regular" | "thin";
|
|
216
|
+
/** Formatter for the slices names used on the tooltips and legend. */
|
|
217
|
+
slicesNameFormatter?: (value?: string) => string;
|
|
218
|
+
/** A Jss Object used to override or extend the styles applied to the component. */
|
|
219
|
+
classes?: HvDonutChartClasses;
|
|
220
|
+
}
|
|
221
|
+
|
|
189
222
|
/**
|
|
190
223
|
* A line chart or line plot or line graph is a type of chart which displays information as a series of data points
|
|
191
224
|
* connected by straight line segments. It is a basic type of chart common in many fields.
|
|
192
225
|
*/
|
|
193
|
-
export declare const HvLineChart: ({ area, emptyCellMode, areaOpacity,
|
|
226
|
+
export declare const HvLineChart: ({ area, emptyCellMode, areaOpacity, yAxis, xAxis, horizontalRangeSlider, grid, data, groupBy, splitBy, sortBy, measures, stack, seriesNameFormatter, legend, classes, tooltip, }: HvLineChartProps) => JSX_2.Element;
|
|
194
227
|
|
|
195
|
-
export declare interface HvLineChartClasses extends
|
|
228
|
+
export declare interface HvLineChartClasses extends HvChartTooltipClasses {
|
|
196
229
|
}
|
|
197
230
|
|
|
198
|
-
export declare
|
|
231
|
+
export declare type HvLineChartMeasures = string | LineFullMeasures;
|
|
232
|
+
|
|
233
|
+
export declare interface HvLineChartProps extends HvAxisChartCommonProps, HvChartCommonProps {
|
|
234
|
+
/** Columns to measure on the chart. */
|
|
235
|
+
measures: Arrayable<HvLineChartMeasures>;
|
|
236
|
+
/** Strategy to use when there are empty cells. Defaults to `void`. */
|
|
237
|
+
emptyCellMode?: HvChartEmptyCellMode;
|
|
238
|
+
/** Whether the area under the lines should be filled. Defaults to `false`. */
|
|
239
|
+
area?: boolean;
|
|
240
|
+
/** Sets opacity of the filled area if `area` is true. Defaults to `0.5`. */
|
|
241
|
+
areaOpacity?: number;
|
|
199
242
|
/** A Jss Object used to override or extend the styles applied to the component. */
|
|
200
243
|
classes?: HvLineChartClasses;
|
|
201
244
|
}
|
|
@@ -236,7 +279,7 @@ export declare interface HvVizProviderProps {
|
|
|
236
279
|
children?: React.ReactNode;
|
|
237
280
|
}
|
|
238
281
|
|
|
239
|
-
declare interface
|
|
282
|
+
declare interface LineFullMeasures extends BaseMeasures, AxisMeasures {
|
|
240
283
|
/** Whether to hide the symbol for data points. Defaults to `false`. */
|
|
241
284
|
hideSymbol?: boolean;
|
|
242
285
|
/** Whether the area under the lines should be filled. If not specified, it defaults to the global `area` prop. */
|
|
@@ -247,12 +290,6 @@ declare interface LineFullMeasuresField extends BaseFullMeasuresField {
|
|
|
247
290
|
emptyCellMode?: HvChartEmptyCellMode;
|
|
248
291
|
}
|
|
249
292
|
|
|
250
|
-
declare type LineMeasuresField = string | LineFullMeasuresField;
|
|
251
|
-
|
|
252
|
-
declare type SortByField = string | FullSortByField;
|
|
253
|
-
|
|
254
|
-
declare type SplitByField = string;
|
|
255
|
-
|
|
256
293
|
/** Tooltip type */
|
|
257
294
|
declare const tooltipType: readonly ["single", "multiple"];
|
|
258
295
|
|