@geotab/zenith 3.8.0 → 3.8.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/README.md
CHANGED
|
@@ -45,31 +45,28 @@ Now components are ready for usage.
|
|
|
45
45
|
|
|
46
46
|
Zenith library provides components defined in Zenith Design System. It includes very basic blocks like colors, icons, font presets, atom components like buttons, checkboxes etc and high order components - header, table, filters bar etc. List of existing components can be found in [Storybook](https://developers.geotab.com/zenith-storybook/index.html).
|
|
47
47
|
|
|
48
|
-
##
|
|
48
|
+
## Change log
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
- [Build Process](docs/BUILD.md) - How the build system works
|
|
52
|
-
- [Release Process](docs/RELEASE.md) - How to publish new versions of Zenith
|
|
53
|
-
- [Translations](docs/TRANSLATIONS.md) - How translations work and how to manage them
|
|
50
|
+
### 3.8.1
|
|
54
51
|
|
|
55
|
-
|
|
52
|
+
- Fix horizontal pie chart center text scaling and legend toggle
|
|
56
53
|
|
|
57
54
|
### 3.8.0
|
|
58
55
|
|
|
59
|
-
- Create FileUpload component
|
|
60
|
-
- Improve Accordion component Storybook documentation
|
|
61
|
-
- Improve Divider component Storybook documentation
|
|
62
|
-
- Improve accessibility for DataGrid sorting
|
|
63
|
-
- Create Chip component documentation
|
|
64
|
-
- Update sort controls in mobile Table
|
|
65
|
-
- Improve accessibility for Radio button
|
|
66
|
-
- Improve accessibility for
|
|
67
|
-
- Accessibility updates for Dropdown
|
|
56
|
+
- Create `FileUpload` component
|
|
57
|
+
- Improve `Accordion` component Storybook documentation
|
|
58
|
+
- Improve `Divider` component Storybook documentation
|
|
59
|
+
- Improve accessibility for `DataGrid` sorting
|
|
60
|
+
- Create `Chip` component documentation
|
|
61
|
+
- Update sort controls in mobile `Table`
|
|
62
|
+
- Improve accessibility for `Radio` button
|
|
63
|
+
- Improve accessibility for `SummaryTile`
|
|
64
|
+
- Accessibility updates for `Dropdown`, `MobileSheet`, `ControlledPopup`
|
|
68
65
|
- Add Prettier CI job to Zenith pipeline
|
|
69
|
-
- SummaryTile refactor, documentation updates
|
|
66
|
+
- `SummaryTile` refactor, documentation updates
|
|
70
67
|
- Updated translations
|
|
71
68
|
- Add multiline table header support (word wrap for long strings)
|
|
72
|
-
- SidePanel outside click improvements
|
|
69
|
+
- `SidePanel` outside click improvements
|
|
73
70
|
|
|
74
71
|
### 3.7.0
|
|
75
72
|
|
|
@@ -16,16 +16,23 @@ const centerTextPlugin = (centerText) => ({
|
|
|
16
16
|
const css = (name) => getCssVar(chart.canvas, name);
|
|
17
17
|
const fontFamily = css("--main-font");
|
|
18
18
|
const hasLabel = !!centerText.label;
|
|
19
|
-
const
|
|
19
|
+
const meta = chart.getDatasetMeta(0);
|
|
20
|
+
const controllerRadius = meta.controller.innerRadius;
|
|
21
|
+
const innerRadius = typeof controllerRadius === "number" && controllerRadius > 0 ? controllerRadius : Math.min(width, height) * 0.325;
|
|
22
|
+
const maxValueFont = parseFloat(css("--pie-center-value-font-size")) || 28;
|
|
23
|
+
const maxLabelFont = parseFloat(css("--pie-center-label-font-size")) || 14;
|
|
24
|
+
const valueFontSize = Math.max(10, Math.min(maxValueFont, innerRadius * 0.45));
|
|
25
|
+
const labelFontSize = Math.max(8, Math.min(maxLabelFont, innerRadius * 0.22));
|
|
26
|
+
const valueY = hasLabel ? centerY - valueFontSize * 0.5 : centerY;
|
|
20
27
|
ctx.textAlign = "center";
|
|
21
28
|
ctx.textBaseline = "middle";
|
|
22
|
-
ctx.font = `${css("--pie-center-value-font-weight")} ${
|
|
29
|
+
ctx.font = `${css("--pie-center-value-font-weight")} ${valueFontSize}px ${fontFamily}`;
|
|
23
30
|
ctx.fillStyle = css("--text-primary");
|
|
24
31
|
ctx.fillText(String(centerText.value), centerX, valueY);
|
|
25
32
|
if (hasLabel) {
|
|
26
|
-
ctx.font = `${css("--pie-center-label-font-weight")} ${
|
|
33
|
+
ctx.font = `${css("--pie-center-label-font-weight")} ${labelFontSize}px ${fontFamily}`;
|
|
27
34
|
ctx.fillStyle = css("--text-secondary");
|
|
28
|
-
ctx.fillText(String(centerText.label), centerX, centerY +
|
|
35
|
+
ctx.fillText(String(centerText.label), centerX, centerY + labelFontSize * 1.1);
|
|
29
36
|
}
|
|
30
37
|
ctx.restore();
|
|
31
38
|
}
|
package/dist/chart/pieChart.js
CHANGED
|
@@ -59,7 +59,16 @@ const PieChart = (_a) => {
|
|
|
59
59
|
}, [fontSize, dark]);
|
|
60
60
|
const defOptions = (0, react_1.useMemo)(() => (0, getDefaultOptions_1.getDefaultOptions)(), []);
|
|
61
61
|
const chartOptions = (0, utils_1.deepMerge)(defOptions, options);
|
|
62
|
-
const { isHidden, toggleHidden } = (0, useHidden_1.useHidden)();
|
|
62
|
+
const { isHidden, toggleHidden: rawToggle } = (0, useHidden_1.useHidden)();
|
|
63
|
+
const pieData = data.datasets[0].data;
|
|
64
|
+
const toggleHidden = (0, react_1.useCallback)((index) => {
|
|
65
|
+
if (!isHidden(index)) {
|
|
66
|
+
const visibleCount = pieData.filter((_, i) => !isHidden(i)).length;
|
|
67
|
+
if (visibleCount <= 1)
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
rawToggle(index);
|
|
71
|
+
}, [isHidden, rawToggle, pieData]);
|
|
63
72
|
const chartData = (0, react_1.useMemo)(() => {
|
|
64
73
|
const chData = Object.assign({}, data);
|
|
65
74
|
chData.datasets = chData.datasets.map(ds => (0, getDefaultDatasetStyle_1.getDefaultDatasetStyle)(ds));
|
|
@@ -13,16 +13,23 @@ export const centerTextPlugin = (centerText) => ({
|
|
|
13
13
|
const css = (name) => getCssVar(chart.canvas, name);
|
|
14
14
|
const fontFamily = css("--main-font");
|
|
15
15
|
const hasLabel = !!centerText.label;
|
|
16
|
-
const
|
|
16
|
+
const meta = chart.getDatasetMeta(0);
|
|
17
|
+
const controllerRadius = meta.controller.innerRadius;
|
|
18
|
+
const innerRadius = typeof controllerRadius === "number" && controllerRadius > 0 ? controllerRadius : Math.min(width, height) * 0.325;
|
|
19
|
+
const maxValueFont = parseFloat(css("--pie-center-value-font-size")) || 28;
|
|
20
|
+
const maxLabelFont = parseFloat(css("--pie-center-label-font-size")) || 14;
|
|
21
|
+
const valueFontSize = Math.max(10, Math.min(maxValueFont, innerRadius * 0.45));
|
|
22
|
+
const labelFontSize = Math.max(8, Math.min(maxLabelFont, innerRadius * 0.22));
|
|
23
|
+
const valueY = hasLabel ? centerY - valueFontSize * 0.5 : centerY;
|
|
17
24
|
ctx.textAlign = "center";
|
|
18
25
|
ctx.textBaseline = "middle";
|
|
19
|
-
ctx.font = `${css("--pie-center-value-font-weight")} ${
|
|
26
|
+
ctx.font = `${css("--pie-center-value-font-weight")} ${valueFontSize}px ${fontFamily}`;
|
|
20
27
|
ctx.fillStyle = css("--text-primary");
|
|
21
28
|
ctx.fillText(String(centerText.value), centerX, valueY);
|
|
22
29
|
if (hasLabel) {
|
|
23
|
-
ctx.font = `${css("--pie-center-label-font-weight")} ${
|
|
30
|
+
ctx.font = `${css("--pie-center-label-font-weight")} ${labelFontSize}px ${fontFamily}`;
|
|
24
31
|
ctx.fillStyle = css("--text-secondary");
|
|
25
|
-
ctx.fillText(String(centerText.label), centerX, centerY +
|
|
32
|
+
ctx.fillText(String(centerText.label), centerX, centerY + labelFontSize * 1.1);
|
|
26
33
|
}
|
|
27
34
|
ctx.restore();
|
|
28
35
|
}
|
package/esm/chart/pieChart.js
CHANGED
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { useContext, useEffect, useId, useMemo, useRef } from "react";
|
|
13
|
+
import { useCallback, useContext, useEffect, useId, useMemo, useRef } from "react";
|
|
14
14
|
import { Pie } from "../react-chartjs/typedCharts";
|
|
15
15
|
import { Chart as ChartJS, PieController, ArcElement } from "chart.js/auto";
|
|
16
16
|
import "../react-chartjs/dateAdapter";
|
|
@@ -56,7 +56,16 @@ export const PieChart = (_a) => {
|
|
|
56
56
|
}, [fontSize, dark]);
|
|
57
57
|
const defOptions = useMemo(() => getDefaultOptions(), []);
|
|
58
58
|
const chartOptions = deepMerge(defOptions, options);
|
|
59
|
-
const { isHidden, toggleHidden } = useHidden();
|
|
59
|
+
const { isHidden, toggleHidden: rawToggle } = useHidden();
|
|
60
|
+
const pieData = data.datasets[0].data;
|
|
61
|
+
const toggleHidden = useCallback((index) => {
|
|
62
|
+
if (!isHidden(index)) {
|
|
63
|
+
const visibleCount = pieData.filter((_, i) => !isHidden(i)).length;
|
|
64
|
+
if (visibleCount <= 1)
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
rawToggle(index);
|
|
68
|
+
}, [isHidden, rawToggle, pieData]);
|
|
60
69
|
const chartData = useMemo(() => {
|
|
61
70
|
const chData = Object.assign({}, data);
|
|
62
71
|
chData.datasets = chData.datasets.map(ds => getDefaultDatasetStyle(ds));
|