@hitachivantara/uikit-react-viz 6.1.6 → 6.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,93 +1,75 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { forwardRef } from "react";
3
- import { PieChart } from "echarts/charts";
4
- import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from "echarts/components";
5
- import * as echarts from "echarts/core";
1
+ import { HvBaseChart } from "../BaseChart/BaseChart.js";
2
+ import { useGrid } from "../hooks/useGrid.js";
6
3
  import { useData } from "../hooks/useData.js";
7
4
  import { useDataset } from "../hooks/useDataset.js";
8
5
  import { useSeries } from "../hooks/useSeries.js";
9
6
  import { useLegend } from "../hooks/useLegend.js";
10
7
  import { useTooltip } from "../hooks/tooltip/useTooltip.js";
11
- import { useGrid } from "../hooks/useGrid.js";
12
8
  import { useOption } from "../hooks/useOption.js";
13
- import { HvBaseChart } from "../BaseChart/BaseChart.js";
9
+ import { forwardRef } from "react";
10
+ import { DatasetComponent, GridComponent, LegendComponent, TooltipComponent } from "echarts/components";
11
+ import * as echarts from "echarts/core";
12
+ import { jsx } from "react/jsx-runtime";
13
+ import { PieChart } from "echarts/charts";
14
+ //#region src/DonutChart/DonutChart.tsx
14
15
  echarts.use([
15
- PieChart,
16
- DatasetComponent,
17
- GridComponent,
18
- TooltipComponent,
19
- LegendComponent
16
+ PieChart,
17
+ DatasetComponent,
18
+ GridComponent,
19
+ TooltipComponent,
20
+ LegendComponent
20
21
  ]);
21
- const HvDonutChart = forwardRef(
22
- function HvDonutChart2(props, ref) {
23
- const {
24
- data,
25
- groupBy,
26
- classes,
27
- legend,
28
- tooltip,
29
- measure: measures,
30
- sortBy,
31
- filters,
32
- grid,
33
- width,
34
- height,
35
- type = "regular",
36
- slicesNameFormatter,
37
- onOptionChange,
38
- ...others
39
- } = props;
40
- const { data: chartData, mapping: measuresMapping } = useData({
41
- data,
42
- groupBy,
43
- measures,
44
- sortBy,
45
- filters
46
- });
47
- const chartDataset = useDataset(chartData);
48
- const chartSeries = useSeries({
49
- type: "pie",
50
- data: chartData,
51
- groupBy,
52
- measuresMapping,
53
- radius: type === "thin" ? ["65%", "70%"] : ["55%", "70%"]
54
- });
55
- const chartLegend = useLegend({
56
- ...legend,
57
- show: legend?.show ?? true,
58
- icon: "square",
59
- series: chartSeries.series,
60
- formatter: slicesNameFormatter
61
- });
62
- const chartTooltip = useTooltip({
63
- ...tooltip,
64
- measuresMapping,
65
- classes,
66
- nameFormatter: slicesNameFormatter
67
- });
68
- const chartGrid = useGrid({ ...grid });
69
- const option = useOption({
70
- option: {
71
- ...chartSeries,
72
- ...chartDataset,
73
- ...chartLegend,
74
- ...chartTooltip,
75
- ...chartGrid
76
- },
77
- onOptionChange
78
- });
79
- return /* @__PURE__ */ jsx(
80
- HvBaseChart,
81
- {
82
- ref,
83
- option,
84
- width,
85
- height,
86
- ...others
87
- }
88
- );
89
- }
90
- );
91
- export {
92
- HvDonutChart
93
- };
22
+ /**
23
+ * Donut charts nicely convey the part-whole relationship and they have become
24
+ * the most recognizable chart types for representing proportions in business and data statistics.
25
+ */
26
+ var HvDonutChart = forwardRef(function HvDonutChart(props, ref) {
27
+ const { data, groupBy, classes, legend, tooltip, measure: measures, sortBy, filters, grid, width, height, type = "regular", slicesNameFormatter, onOptionChange, ...others } = props;
28
+ const { data: chartData, mapping: measuresMapping } = useData({
29
+ data,
30
+ groupBy,
31
+ measures,
32
+ sortBy,
33
+ filters
34
+ });
35
+ const chartDataset = useDataset(chartData);
36
+ const chartSeries = useSeries({
37
+ type: "pie",
38
+ data: chartData,
39
+ groupBy,
40
+ measuresMapping,
41
+ radius: type === "thin" ? ["65%", "70%"] : ["55%", "70%"]
42
+ });
43
+ const chartLegend = useLegend({
44
+ ...legend,
45
+ show: legend?.show ?? true,
46
+ icon: "square",
47
+ series: chartSeries.series,
48
+ formatter: slicesNameFormatter
49
+ });
50
+ const chartTooltip = useTooltip({
51
+ ...tooltip,
52
+ measuresMapping,
53
+ classes,
54
+ nameFormatter: slicesNameFormatter
55
+ });
56
+ const chartGrid = useGrid({ ...grid });
57
+ return /* @__PURE__ */ jsx(HvBaseChart, {
58
+ ref,
59
+ option: useOption({
60
+ option: {
61
+ ...chartSeries,
62
+ ...chartDataset,
63
+ ...chartLegend,
64
+ ...chartTooltip,
65
+ ...chartGrid
66
+ },
67
+ onOptionChange
68
+ }),
69
+ width,
70
+ height,
71
+ ...others
72
+ });
73
+ });
74
+ //#endregion
75
+ export { HvDonutChart };
@@ -1,42 +1,35 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { forwardRef } from "react";
3
- import { HeatmapChart } from "echarts/charts";
4
- import { TooltipComponent, VisualMapComponent } from "echarts/components";
5
- import * as echarts from "echarts/core";
6
- import { useTheme } from "@hitachivantara/uikit-react-utils";
7
- import { useClasses } from "./Heatmap.styles.js";
8
- import { useTooltip } from "../hooks/tooltip/useTooltip.js";
1
+ import { HvBaseChart } from "../BaseChart/BaseChart.js";
9
2
  import { useXAxis } from "../hooks/useXAxis.js";
10
3
  import { useYAxis } from "../hooks/useYAxis.js";
11
4
  import { useVisualMap } from "../hooks/useVisualMap.js";
5
+ import { useTooltip } from "../hooks/tooltip/useTooltip.js";
12
6
  import { useOption } from "../hooks/useOption.js";
13
- import { HvBaseChart } from "../BaseChart/BaseChart.js";
14
- echarts.use([HeatmapChart, TooltipComponent, VisualMapComponent]);
15
- const HvHeatmap = forwardRef(
16
- function HvHeatmap2(props, ref) {
17
- const {
18
- name,
19
- data,
20
- min,
21
- max,
22
- colorScale,
23
- xAxis,
24
- yAxis,
25
- classes: classesProp,
26
- tooltip,
27
- width,
28
- height,
29
- onOptionChange,
30
- ...others
31
- } = props;
32
- const { classes } = useClasses(classesProp);
33
- const { colors } = useTheme();
34
- const chartTooltip = useTooltip({
35
- component: (params) => {
36
- const value = params?.value;
37
- const title = params?.title;
38
- const valueToShow = value ? `${yAxis?.data?.[Number(value[1])]} - ${xAxis?.data?.[Number(value[0])]}: ${params?.series?.[0]?.name}` : "-";
39
- return `
7
+ import { useClasses } from "./Heatmap.styles.js";
8
+ import { forwardRef } from "react";
9
+ import { TooltipComponent, VisualMapComponent } from "echarts/components";
10
+ import * as echarts from "echarts/core";
11
+ import { useTheme } from "@hitachivantara/uikit-react-utils";
12
+ import { jsx } from "react/jsx-runtime";
13
+ import { HeatmapChart } from "echarts/charts";
14
+ //#region src/Heatmap/Heatmap.tsx
15
+ echarts.use([
16
+ HeatmapChart,
17
+ TooltipComponent,
18
+ VisualMapComponent
19
+ ]);
20
+ /**
21
+ * A Heatmap uses color gradients to represent data intensity across a surface.
22
+ */
23
+ var HvHeatmap = forwardRef(function HvHeatmap(props, ref) {
24
+ const { name, data, min, max, colorScale, xAxis, yAxis, classes: classesProp, tooltip, width, height, onOptionChange, ...others } = props;
25
+ const { classes } = useClasses(classesProp);
26
+ const { colors } = useTheme();
27
+ const chartTooltip = useTooltip({
28
+ component: (params) => {
29
+ const value = params?.value;
30
+ const title = params?.title;
31
+ const valueToShow = value ? `${yAxis?.data?.[Number(value[1])]} - ${xAxis?.data?.[Number(value[0])]}: ${params?.series?.[0]?.name}` : "-";
32
+ return `
40
33
  <div class="${classes.tooltipRoot}">
41
34
  <div class="${classes.tooltipContainer}">
42
35
  <div>
@@ -45,65 +38,56 @@ const HvHeatmap = forwardRef(
45
38
  </div>
46
39
  </div>
47
40
  </div>`;
48
- },
49
- ...tooltip
50
- });
51
- const chartXAxis = useXAxis({ type: "categorical", ...xAxis });
52
- const chartYAxis = useYAxis({
53
- defaultType: "categorical",
54
- axes: yAxis ? [yAxis] : []
55
- });
56
- const convertedColors = colorScale?.map(
57
- (color) => colors?.[color] || color
58
- );
59
- const chartVisualMap = useVisualMap({
60
- min,
61
- max,
62
- orient: "horizontal",
63
- left: "center",
64
- calculable: true,
65
- position: {
66
- y: "bottom"
67
- },
68
- colorScale: convertedColors || ["#2D4B87", "#95AFE8", "#E7EDF9"]
69
- });
70
- const option = useOption({
71
- option: {
72
- xAxis: chartXAxis.xAxis,
73
- yAxis: chartYAxis.yAxis,
74
- visualMap: chartVisualMap.visualMap,
75
- series: [
76
- {
77
- name,
78
- type: "heatmap",
79
- data,
80
- label: {
81
- show: true
82
- },
83
- emphasis: {
84
- itemStyle: {
85
- shadowBlur: 10,
86
- shadowColor: "rgba(0, 0, 0, 0.5)"
87
- }
88
- }
89
- }
90
- ],
91
- ...chartTooltip
92
- },
93
- onOptionChange
94
- });
95
- return /* @__PURE__ */ jsx(
96
- HvBaseChart,
97
- {
98
- ref,
99
- option,
100
- width,
101
- height,
102
- ...others
103
- }
104
- );
105
- }
106
- );
107
- export {
108
- HvHeatmap
109
- };
41
+ },
42
+ ...tooltip
43
+ });
44
+ const chartXAxis = useXAxis({
45
+ type: "categorical",
46
+ ...xAxis
47
+ });
48
+ const chartYAxis = useYAxis({
49
+ defaultType: "categorical",
50
+ axes: yAxis ? [yAxis] : []
51
+ });
52
+ const convertedColors = colorScale?.map((color) => colors?.[color] || color);
53
+ const chartVisualMap = useVisualMap({
54
+ min,
55
+ max,
56
+ orient: "horizontal",
57
+ left: "center",
58
+ calculable: true,
59
+ position: { y: "bottom" },
60
+ colorScale: convertedColors || [
61
+ "#2D4B87",
62
+ "#95AFE8",
63
+ "#E7EDF9"
64
+ ]
65
+ });
66
+ return /* @__PURE__ */ jsx(HvBaseChart, {
67
+ ref,
68
+ option: useOption({
69
+ option: {
70
+ xAxis: chartXAxis.xAxis,
71
+ yAxis: chartYAxis.yAxis,
72
+ visualMap: chartVisualMap.visualMap,
73
+ series: [{
74
+ name,
75
+ type: "heatmap",
76
+ data,
77
+ label: { show: true },
78
+ emphasis: { itemStyle: {
79
+ shadowBlur: 10,
80
+ shadowColor: "rgba(0, 0, 0, 0.5)"
81
+ } }
82
+ }],
83
+ ...chartTooltip
84
+ },
85
+ onOptionChange
86
+ }),
87
+ width,
88
+ height,
89
+ ...others
90
+ });
91
+ });
92
+ //#endregion
93
+ export { HvHeatmap };
@@ -1,26 +1,25 @@
1
1
  import { createClasses } from "@hitachivantara/uikit-react-utils";
2
2
  import { theme } from "@hitachivantara/uikit-styles";
3
- const { useClasses, staticClasses } = createClasses("HvHeatmap", {
4
- tooltipRoot: {
5
- backgroundColor: theme.colors.bgContainer,
6
- width: "fit-content",
7
- minWidth: 150,
8
- boxShadow: theme.colors.shadow,
9
- zIndex: theme.zIndices.sticky
10
- },
11
- tooltipContainer: {
12
- padding: theme.spacing("15px", "sm"),
13
- display: "flex",
14
- flexDirection: "column"
15
- },
16
- tooltipText: {
17
- fontFamily: theme.fontFamily.body,
18
- fontWeight: theme.fontWeights.normal,
19
- fontSize: theme.fontSizes.sm,
20
- color: theme.colors.text
21
- }
3
+ //#region src/Heatmap/Heatmap.styles.tsx
4
+ var { useClasses, staticClasses } = createClasses("HvHeatmap", {
5
+ tooltipRoot: {
6
+ backgroundColor: theme.colors.bgContainer,
7
+ width: "fit-content",
8
+ minWidth: 150,
9
+ boxShadow: theme.colors.shadow,
10
+ zIndex: theme.zIndices.sticky
11
+ },
12
+ tooltipContainer: {
13
+ padding: theme.spacing("15px", "sm"),
14
+ display: "flex",
15
+ flexDirection: "column"
16
+ },
17
+ tooltipText: {
18
+ fontFamily: theme.fontFamily.body,
19
+ fontWeight: theme.fontWeights.normal,
20
+ fontSize: theme.fontSizes.sm,
21
+ color: theme.colors.text
22
+ }
22
23
  });
23
- export {
24
- staticClasses,
25
- useClasses
26
- };
24
+ //#endregion
25
+ export { useClasses };
@@ -1,118 +1,92 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { forwardRef } from "react";
3
- import { LineChart } from "echarts/charts";
4
- import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent, DataZoomSliderComponent, DataZoomInsideComponent, MarkLineComponent } from "echarts/components";
5
- import * as echarts from "echarts/core";
6
- import { useData } from "../hooks/useData.js";
7
- import { useDataset } from "../hooks/useDataset.js";
8
- import { useYAxis } from "../hooks/useYAxis.js";
9
- import { useXAxis } from "../hooks/useXAxis.js";
1
+ import { HvBaseChart } from "../BaseChart/BaseChart.js";
10
2
  import { useDataZoom } from "../hooks/useDataZoom.js";
3
+ import { useXAxis } from "../hooks/useXAxis.js";
4
+ import { useYAxis } from "../hooks/useYAxis.js";
11
5
  import { useGrid } from "../hooks/useGrid.js";
6
+ import { useData } from "../hooks/useData.js";
7
+ import { useDataset } from "../hooks/useDataset.js";
12
8
  import { useSeries } from "../hooks/useSeries.js";
13
9
  import { useLegend } from "../hooks/useLegend.js";
14
10
  import { useTooltip } from "../hooks/tooltip/useTooltip.js";
15
11
  import { useOption } from "../hooks/useOption.js";
16
- import { HvBaseChart } from "../BaseChart/BaseChart.js";
12
+ import { forwardRef } from "react";
13
+ import { DataZoomInsideComponent, DataZoomSliderComponent, DatasetComponent, GridComponent, LegendComponent, MarkLineComponent, TooltipComponent } from "echarts/components";
14
+ import * as echarts from "echarts/core";
15
+ import { jsx } from "react/jsx-runtime";
16
+ import { LineChart } from "echarts/charts";
17
+ //#region src/LineChart/LineChart.tsx
17
18
  echarts.use([
18
- LineChart,
19
- DatasetComponent,
20
- GridComponent,
21
- TooltipComponent,
22
- LegendComponent,
23
- DataZoomSliderComponent,
24
- DataZoomInsideComponent,
25
- MarkLineComponent
19
+ LineChart,
20
+ DatasetComponent,
21
+ GridComponent,
22
+ TooltipComponent,
23
+ LegendComponent,
24
+ DataZoomSliderComponent,
25
+ DataZoomInsideComponent,
26
+ MarkLineComponent
26
27
  ]);
27
- const HvLineChart = forwardRef(
28
- function HvLineChart2(props, ref) {
29
- const {
30
- area = false,
31
- emptyCellMode = "void",
32
- areaOpacity = 0.5,
33
- yAxis,
34
- xAxis,
35
- horizontalRangeSlider,
36
- grid,
37
- data,
38
- groupBy,
39
- splitBy,
40
- sortBy,
41
- filters,
42
- measures,
43
- stack,
44
- seriesNameFormatter,
45
- legend,
46
- classes,
47
- tooltip,
48
- width,
49
- height,
50
- onOptionChange,
51
- ...others
52
- } = props;
53
- const { data: chartData, mapping: measuresMapping } = useData({
54
- data,
55
- groupBy,
56
- measures,
57
- splitBy,
58
- sortBy,
59
- filters
60
- });
61
- const chartDataset = useDataset(chartData);
62
- const chartYAxis = useYAxis({
63
- axes: Array.isArray(yAxis) || yAxis == null ? yAxis : [yAxis]
64
- });
65
- const chartXAxis = useXAxis({ ...xAxis, scale: true });
66
- const chartSlider = useDataZoom({
67
- showHorizontal: horizontalRangeSlider?.show
68
- });
69
- const chartGrid = useGrid({ ...grid });
70
- const chartSeries = useSeries({
71
- type: "line",
72
- data: chartData,
73
- groupBy,
74
- measuresMapping,
75
- area,
76
- areaOpacity,
77
- emptyCellMode,
78
- stack,
79
- nameFormatter: seriesNameFormatter
80
- });
81
- const chartLegend = useLegend({
82
- ...legend,
83
- series: chartSeries.series
84
- });
85
- const chartTooltip = useTooltip({
86
- ...tooltip,
87
- trigger: "axis",
88
- measuresMapping,
89
- classes
90
- });
91
- const option = useOption({
92
- option: {
93
- ...chartYAxis,
94
- ...chartXAxis,
95
- ...chartSlider,
96
- ...chartGrid,
97
- ...chartDataset,
98
- ...chartSeries,
99
- ...chartLegend,
100
- ...chartTooltip
101
- },
102
- onOptionChange
103
- });
104
- return /* @__PURE__ */ jsx(
105
- HvBaseChart,
106
- {
107
- ref,
108
- option,
109
- width,
110
- height,
111
- ...others
112
- }
113
- );
114
- }
115
- );
116
- export {
117
- HvLineChart
118
- };
28
+ /**
29
+ * A line chart or line plot or line graph is a type of chart which displays information as a series of data points
30
+ * connected by straight line segments.
31
+ */
32
+ var HvLineChart = forwardRef(function HvLineChart(props, ref) {
33
+ const { area = false, emptyCellMode = "void", areaOpacity = .5, yAxis, xAxis, horizontalRangeSlider, grid, data, groupBy, splitBy, sortBy, filters, measures, stack, seriesNameFormatter, legend, classes, tooltip, width, height, onOptionChange, ...others } = props;
34
+ const { data: chartData, mapping: measuresMapping } = useData({
35
+ data,
36
+ groupBy,
37
+ measures,
38
+ splitBy,
39
+ sortBy,
40
+ filters
41
+ });
42
+ const chartDataset = useDataset(chartData);
43
+ const chartYAxis = useYAxis({ axes: Array.isArray(yAxis) || yAxis == null ? yAxis : [yAxis] });
44
+ const chartXAxis = useXAxis({
45
+ ...xAxis,
46
+ scale: true
47
+ });
48
+ const chartSlider = useDataZoom({ showHorizontal: horizontalRangeSlider?.show });
49
+ const chartGrid = useGrid({ ...grid });
50
+ const chartSeries = useSeries({
51
+ type: "line",
52
+ data: chartData,
53
+ groupBy,
54
+ measuresMapping,
55
+ area,
56
+ areaOpacity,
57
+ emptyCellMode,
58
+ stack,
59
+ nameFormatter: seriesNameFormatter
60
+ });
61
+ const chartLegend = useLegend({
62
+ ...legend,
63
+ series: chartSeries.series
64
+ });
65
+ const chartTooltip = useTooltip({
66
+ ...tooltip,
67
+ trigger: "axis",
68
+ measuresMapping,
69
+ classes
70
+ });
71
+ return /* @__PURE__ */ jsx(HvBaseChart, {
72
+ ref,
73
+ option: useOption({
74
+ option: {
75
+ ...chartYAxis,
76
+ ...chartXAxis,
77
+ ...chartSlider,
78
+ ...chartGrid,
79
+ ...chartDataset,
80
+ ...chartSeries,
81
+ ...chartLegend,
82
+ ...chartTooltip
83
+ },
84
+ onOptionChange
85
+ }),
86
+ width,
87
+ height,
88
+ ...others
89
+ });
90
+ });
91
+ //#endregion
92
+ export { HvLineChart };