@trackunit/react-chart-components 2.17.37 → 2.17.39-alpha-b8d3d323d1a.0

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/index.cjs.js CHANGED
@@ -317,6 +317,7 @@ const LegendItem = ({ className, style, count, label, disabled = false, selected
317
317
  return (jsxRuntime.jsxs("div", { "aria-checked": isSwitch ? selected : undefined, className: cvaLegendItem({ disabled, selected, isClickable: isSwitch, className }), "data-testid": dataTestId, onClick: handleOnClick, onKeyDown: handleOnKeyDown, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, ref: ref, role: isSwitch ? "switch" : undefined, style: style, tabIndex: isSwitch ? 0 : undefined, children: [jsxRuntime.jsx(LegendItemSwatch, { color: color, dataTestId: dataTestId, indicator: indicator, symbol: symbol }), jsxRuntime.jsxs("p", { className: "truncate text-xs", children: [label, "\u00A0"] }), hideValue ? null : jsxRuntime.jsx("p", { className: "text-xs", children: `(${count ?? 0}${unit ?? ""})` })] }));
318
318
  };
319
319
 
320
+ const chartCategoryColorList = sharedUtils.objectValues(uiDesignTokens.CHART_CATEGORY);
320
321
  /**
321
322
  * Re-ordered chart colors to ensure that adjacent colors are visually different.
322
323
  *
@@ -324,7 +325,7 @@ const LegendItem = ({ className, style, count, label, disabled = false, selected
324
325
  */
325
326
  const useChartColor = () => {
326
327
  const chartColor = react.useCallback((index) => {
327
- return uiDesignTokens.DEFAULT_CHART_COLORS[index % uiDesignTokens.DEFAULT_CHART_COLORS.length] ?? "#000000";
328
+ return chartCategoryColorList[index % chartCategoryColorList.length] ?? "#000000";
328
329
  }, []);
329
330
  const chartColorArray = react.useCallback((total) => {
330
331
  return Array.from({ length: total }, (_, index) => chartColor(index));
@@ -600,7 +601,7 @@ const useLimitDataSet = (data, limit, autoSortData = true, othersName) => {
600
601
  name: othersName ?? "Others",
601
602
  selected: false,
602
603
  value: tail.reduce((acc, curr) => acc + (curr.value ?? 0), 0),
603
- color: uiDesignTokens.DEFAULT_CHART_OTHER,
604
+ color: uiDesignTokens.CHART_COLOR_OTHER,
604
605
  original: othersOriginal,
605
606
  });
606
607
  return result;
package/index.esm.js CHANGED
@@ -2,10 +2,10 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { cva } from '@trackunit/css-class-variance-utilities';
3
3
  import { toDateUtil } from '@trackunit/date-and-time-utils';
4
4
  import { useLocale, useDateAndTime } from '@trackunit/react-date-and-time-hooks';
5
- import { DEFAULT_CHART_COLORS, CHART_STATUS_COLORS, fontFamily, DEFAULT_CHART_OTHER } from '@trackunit/ui-design-tokens';
5
+ import { CHART_CATEGORY, CHART_STATUS_COLORS, fontFamily, CHART_COLOR_OTHER } from '@trackunit/ui-design-tokens';
6
6
  import { useRef, useCallback, useEffect, useMemo, useState } from 'react';
7
7
  import { useMergeRefs, Spinner, Text } from '@trackunit/react-components';
8
- import { objectKeys, exhaustiveCheck } from '@trackunit/shared-utils';
8
+ import { objectKeys, exhaustiveCheck, objectValues } from '@trackunit/shared-utils';
9
9
  import * as echarts from 'echarts';
10
10
 
11
11
  function isECElementEvent(value) {
@@ -296,6 +296,7 @@ const LegendItem = ({ className, style, count, label, disabled = false, selected
296
296
  return (jsxs("div", { "aria-checked": isSwitch ? selected : undefined, className: cvaLegendItem({ disabled, selected, isClickable: isSwitch, className }), "data-testid": dataTestId, onClick: handleOnClick, onKeyDown: handleOnKeyDown, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, ref: ref, role: isSwitch ? "switch" : undefined, style: style, tabIndex: isSwitch ? 0 : undefined, children: [jsx(LegendItemSwatch, { color: color, dataTestId: dataTestId, indicator: indicator, symbol: symbol }), jsxs("p", { className: "truncate text-xs", children: [label, "\u00A0"] }), hideValue ? null : jsx("p", { className: "text-xs", children: `(${count ?? 0}${unit ?? ""})` })] }));
297
297
  };
298
298
 
299
+ const chartCategoryColorList = objectValues(CHART_CATEGORY);
299
300
  /**
300
301
  * Re-ordered chart colors to ensure that adjacent colors are visually different.
301
302
  *
@@ -303,7 +304,7 @@ const LegendItem = ({ className, style, count, label, disabled = false, selected
303
304
  */
304
305
  const useChartColor = () => {
305
306
  const chartColor = useCallback((index) => {
306
- return DEFAULT_CHART_COLORS[index % DEFAULT_CHART_COLORS.length] ?? "#000000";
307
+ return chartCategoryColorList[index % chartCategoryColorList.length] ?? "#000000";
307
308
  }, []);
308
309
  const chartColorArray = useCallback((total) => {
309
310
  return Array.from({ length: total }, (_, index) => chartColor(index));
@@ -579,7 +580,7 @@ const useLimitDataSet = (data, limit, autoSortData = true, othersName) => {
579
580
  name: othersName ?? "Others",
580
581
  selected: false,
581
582
  value: tail.reduce((acc, curr) => acc + (curr.value ?? 0), 0),
582
- color: DEFAULT_CHART_OTHER,
583
+ color: CHART_COLOR_OTHER,
583
584
  original: othersOriginal,
584
585
  });
585
586
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-chart-components",
3
- "version": "2.17.37",
3
+ "version": "2.17.39-alpha-b8d3d323d1a.0",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "migrations": "./migrations.json",
@@ -9,12 +9,12 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "echarts": "5.6.0",
12
- "@trackunit/date-and-time-utils": "1.20.42",
13
- "@trackunit/react-date-and-time-hooks": "2.17.37",
14
- "@trackunit/ui-design-tokens": "1.21.39",
15
- "@trackunit/shared-utils": "1.22.41",
16
- "@trackunit/css-class-variance-utilities": "2.6.41",
17
- "@trackunit/react-components": "6.0.35"
12
+ "@trackunit/date-and-time-utils": "1.20.44-alpha-b8d3d323d1a.0",
13
+ "@trackunit/react-date-and-time-hooks": "2.17.39-alpha-b8d3d323d1a.0",
14
+ "@trackunit/ui-design-tokens": "1.21.41-alpha-b8d3d323d1a.0",
15
+ "@trackunit/shared-utils": "1.22.43-alpha-b8d3d323d1a.0",
16
+ "@trackunit/css-class-variance-utilities": "2.6.43-alpha-b8d3d323d1a.0",
17
+ "@trackunit/react-components": "6.0.37-alpha-b8d3d323d1a.0"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "@apollo/client": "^3.13.8",