@trackunit/react-chart-components 1.7.44 → 1.7.45

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
@@ -284,7 +284,7 @@ const useLimitDataSet = (data, limit, autoSortData = true) => {
284
284
  * @param {DonutChartProps} props - The props for the Chart component
285
285
  * @returns {ReactElement} Chart component
286
286
  */
287
- const DonutChart = ({ data, size = "full", loading = false, onClick, className, dataTestId, legendPosition = "Right", maxDataPoints = 6, showOthers = true, unit, overrideTotal, autoSortData = true, hideLegendValues = false, }) => {
287
+ const DonutChart = ({ data, size = "full", loading = false, onClick, className, dataTestId, maxDataPoints = 6, showOthers = true, unit, overrideTotal, autoSortData = true, hideLegendValues = false, }) => {
288
288
  const containerRef = react.useRef(null);
289
289
  const chartRef = react.useRef(null);
290
290
  const totalValue = react.useMemo(() => overrideTotal ?? data?.map(item => item.value ?? 0).reduce((a, b) => a + b, 0) ?? 0, [data, overrideTotal]);
@@ -410,30 +410,20 @@ const DonutChart = ({ data, size = "full", loading = false, onClick, className,
410
410
  if (loading) {
411
411
  return jsxRuntime.jsx(reactComponents.Spinner, { centering: "centered", dataTestId: dataTestId ? `${dataTestId}-loading` : "donut-chart-loading" });
412
412
  }
413
- return (jsxRuntime.jsxs("div", { className: cvaChartRoot$1({ className, legendPosition }), "data-testid": dataTestId, ref: containerRef, children: [jsxRuntime.jsx("div", { className: cvaChartContainer({ legendPosition }), children: jsxRuntime.jsx(Chart, { className: cvaChart({ legendPosition, size }), dataTestId: dataTestId ? `chart-${dataTestId}` : undefined, onChartReady: handleChartReady, onClick: handleChartClick, onEvents: handleChartEvents, options: chartOptions, style: { width: "100%", height: "100%" } }) }), size === "full" && (jsxRuntime.jsx("div", { className: cvaLegend({ legendPosition }), "data-testid": "legend", children: limitedData.map((item, index) => (jsxRuntime.jsx(LegendItem, { className: "p-1.5 py-0.5", color: item.color ?? chartColor(index), count: item.value, dataTestId: `legend-${item.id}`, disabled: (item.value ?? 0) === 0, hideValue: hideLegendValues, label: item.name, onClick: onClick ? () => onClick(item) : undefined, onMouseEnter: () => handleLegendMouseEnter(item), onMouseLeave: handleLegendMouseLeave, selected: item.selected, unit: unit }, item.id))) }))] }));
413
+ return (jsxRuntime.jsxs("div", { className: cvaChartRoot$1({ className }), "data-testid": dataTestId, ref: containerRef, children: [jsxRuntime.jsx("div", { className: cvaChartContainer(), children: jsxRuntime.jsx(Chart, { className: cvaChart({ size }), dataTestId: dataTestId ? `chart-${dataTestId}` : undefined, onChartReady: handleChartReady, onClick: handleChartClick, onEvents: handleChartEvents, options: chartOptions, style: { width: "100%", height: "100%" } }) }), size === "full" && (jsxRuntime.jsx("div", { className: cvaLegend(), "data-testid": "legend", children: limitedData.map((item, index) => (jsxRuntime.jsx(LegendItem, { className: "p-1.5 py-0.5", color: item.color ?? chartColor(index), count: item.value, dataTestId: `legend-${item.id}`, disabled: (item.value ?? 0) === 0, hideValue: hideLegendValues, label: item.name, onClick: onClick ? () => onClick(item) : undefined, onMouseEnter: () => handleLegendMouseEnter(item), onMouseLeave: handleLegendMouseLeave, selected: item.selected, unit: unit }, item.id))) }))] }));
414
414
  };
415
- const cvaChartRoot$1 = cssClassVarianceUtilities.cvaMerge(["flex", "w-full", "h-full", "gap-4"], {
416
- variants: {
417
- legendPosition: {
418
- Right: ["items-center", "justify-items-stretch", "flex-row"],
419
- Bottom: ["items-center", "flex-col"],
420
- },
421
- },
422
- });
423
- const cvaChartContainer = cssClassVarianceUtilities.cvaMerge(["flex-1", "h-full"], {
424
- variants: {
425
- legendPosition: {
426
- Right: ["justify-end"],
427
- Bottom: ["flex", "items-center", "w-full"],
428
- },
429
- },
430
- });
415
+ const cvaChartRoot$1 = cssClassVarianceUtilities.cvaMerge([
416
+ "flex",
417
+ "w-full",
418
+ "h-full",
419
+ "gap-4",
420
+ "items-center",
421
+ "justify-items-stretch",
422
+ "flex-row",
423
+ ]);
424
+ const cvaChartContainer = cssClassVarianceUtilities.cvaMerge(["flex-1", "h-full", "justify-end"]);
431
425
  const cvaChart = cssClassVarianceUtilities.cvaMerge(["flex-0", "max-w-[200px]", "max-h-[200px]", "place-self-center"], {
432
426
  variants: {
433
- legendPosition: {
434
- Right: [],
435
- Bottom: ["max-h-[230px]"],
436
- },
437
427
  size: {
438
428
  full: ["min-h-[140px]"],
439
429
  compact: ["w-[60px]", "h-[60px]"],
@@ -443,17 +433,7 @@ const cvaChart = cssClassVarianceUtilities.cvaMerge(["flex-0", "max-w-[200px]",
443
433
  size: "full",
444
434
  },
445
435
  });
446
- const cvaLegend = cssClassVarianceUtilities.cvaMerge(["flex", "overflow-auto"], {
447
- variants: {
448
- legendPosition: {
449
- Right: ["justify-start", "flex-col", "flex-1"],
450
- Bottom: ["flex-wrap", "justify-end", "flex-row"],
451
- },
452
- },
453
- defaultVariants: {
454
- legendPosition: "Right",
455
- },
456
- });
436
+ const cvaLegend = cssClassVarianceUtilities.cvaMerge(["flex", "overflow-auto", "justify-start", "flex-col", "flex-1"]);
457
437
 
458
438
  /**
459
439
  * Create a BarChart with legends. Based on Chart component
package/index.esm.js CHANGED
@@ -263,7 +263,7 @@ const useLimitDataSet = (data, limit, autoSortData = true) => {
263
263
  * @param {DonutChartProps} props - The props for the Chart component
264
264
  * @returns {ReactElement} Chart component
265
265
  */
266
- const DonutChart = ({ data, size = "full", loading = false, onClick, className, dataTestId, legendPosition = "Right", maxDataPoints = 6, showOthers = true, unit, overrideTotal, autoSortData = true, hideLegendValues = false, }) => {
266
+ const DonutChart = ({ data, size = "full", loading = false, onClick, className, dataTestId, maxDataPoints = 6, showOthers = true, unit, overrideTotal, autoSortData = true, hideLegendValues = false, }) => {
267
267
  const containerRef = useRef(null);
268
268
  const chartRef = useRef(null);
269
269
  const totalValue = useMemo(() => overrideTotal ?? data?.map(item => item.value ?? 0).reduce((a, b) => a + b, 0) ?? 0, [data, overrideTotal]);
@@ -389,30 +389,20 @@ const DonutChart = ({ data, size = "full", loading = false, onClick, className,
389
389
  if (loading) {
390
390
  return jsx(Spinner, { centering: "centered", dataTestId: dataTestId ? `${dataTestId}-loading` : "donut-chart-loading" });
391
391
  }
392
- return (jsxs("div", { className: cvaChartRoot$1({ className, legendPosition }), "data-testid": dataTestId, ref: containerRef, children: [jsx("div", { className: cvaChartContainer({ legendPosition }), children: jsx(Chart, { className: cvaChart({ legendPosition, size }), dataTestId: dataTestId ? `chart-${dataTestId}` : undefined, onChartReady: handleChartReady, onClick: handleChartClick, onEvents: handleChartEvents, options: chartOptions, style: { width: "100%", height: "100%" } }) }), size === "full" && (jsx("div", { className: cvaLegend({ legendPosition }), "data-testid": "legend", children: limitedData.map((item, index) => (jsx(LegendItem, { className: "p-1.5 py-0.5", color: item.color ?? chartColor(index), count: item.value, dataTestId: `legend-${item.id}`, disabled: (item.value ?? 0) === 0, hideValue: hideLegendValues, label: item.name, onClick: onClick ? () => onClick(item) : undefined, onMouseEnter: () => handleLegendMouseEnter(item), onMouseLeave: handleLegendMouseLeave, selected: item.selected, unit: unit }, item.id))) }))] }));
392
+ return (jsxs("div", { className: cvaChartRoot$1({ className }), "data-testid": dataTestId, ref: containerRef, children: [jsx("div", { className: cvaChartContainer(), children: jsx(Chart, { className: cvaChart({ size }), dataTestId: dataTestId ? `chart-${dataTestId}` : undefined, onChartReady: handleChartReady, onClick: handleChartClick, onEvents: handleChartEvents, options: chartOptions, style: { width: "100%", height: "100%" } }) }), size === "full" && (jsx("div", { className: cvaLegend(), "data-testid": "legend", children: limitedData.map((item, index) => (jsx(LegendItem, { className: "p-1.5 py-0.5", color: item.color ?? chartColor(index), count: item.value, dataTestId: `legend-${item.id}`, disabled: (item.value ?? 0) === 0, hideValue: hideLegendValues, label: item.name, onClick: onClick ? () => onClick(item) : undefined, onMouseEnter: () => handleLegendMouseEnter(item), onMouseLeave: handleLegendMouseLeave, selected: item.selected, unit: unit }, item.id))) }))] }));
393
393
  };
394
- const cvaChartRoot$1 = cvaMerge(["flex", "w-full", "h-full", "gap-4"], {
395
- variants: {
396
- legendPosition: {
397
- Right: ["items-center", "justify-items-stretch", "flex-row"],
398
- Bottom: ["items-center", "flex-col"],
399
- },
400
- },
401
- });
402
- const cvaChartContainer = cvaMerge(["flex-1", "h-full"], {
403
- variants: {
404
- legendPosition: {
405
- Right: ["justify-end"],
406
- Bottom: ["flex", "items-center", "w-full"],
407
- },
408
- },
409
- });
394
+ const cvaChartRoot$1 = cvaMerge([
395
+ "flex",
396
+ "w-full",
397
+ "h-full",
398
+ "gap-4",
399
+ "items-center",
400
+ "justify-items-stretch",
401
+ "flex-row",
402
+ ]);
403
+ const cvaChartContainer = cvaMerge(["flex-1", "h-full", "justify-end"]);
410
404
  const cvaChart = cvaMerge(["flex-0", "max-w-[200px]", "max-h-[200px]", "place-self-center"], {
411
405
  variants: {
412
- legendPosition: {
413
- Right: [],
414
- Bottom: ["max-h-[230px]"],
415
- },
416
406
  size: {
417
407
  full: ["min-h-[140px]"],
418
408
  compact: ["w-[60px]", "h-[60px]"],
@@ -422,17 +412,7 @@ const cvaChart = cvaMerge(["flex-0", "max-w-[200px]", "max-h-[200px]", "place-se
422
412
  size: "full",
423
413
  },
424
414
  });
425
- const cvaLegend = cvaMerge(["flex", "overflow-auto"], {
426
- variants: {
427
- legendPosition: {
428
- Right: ["justify-start", "flex-col", "flex-1"],
429
- Bottom: ["flex-wrap", "justify-end", "flex-row"],
430
- },
431
- },
432
- defaultVariants: {
433
- legendPosition: "Right",
434
- },
435
- });
415
+ const cvaLegend = cvaMerge(["flex", "overflow-auto", "justify-start", "flex-col", "flex-1"]);
436
416
 
437
417
  /**
438
418
  * Create a BarChart with legends. Based on Chart component
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-chart-components",
3
- "version": "1.7.44",
3
+ "version": "1.7.45",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -44,10 +44,6 @@ export interface DonutChartProps<TProps extends object> extends CommonProps {
44
44
  * When compact, the chart is smaller and legends are hidden.
45
45
  */
46
46
  size?: Size;
47
- /**
48
- * The position of the legend. Defaults to "Right"
49
- */
50
- legendPosition?: "Right" | "Bottom";
51
47
  /**
52
48
  * Maximum number of data points to show in the chart.
53
49
  * The remaining will be grouped into a catogory called "others".
@@ -94,5 +90,5 @@ export interface DonutChartProps<TProps extends object> extends CommonProps {
94
90
  * @param {DonutChartProps} props - The props for the Chart component
95
91
  * @returns {ReactElement} Chart component
96
92
  */
97
- export declare const DonutChart: <TProps extends object>({ data, size, loading, onClick, className, dataTestId, legendPosition, maxDataPoints, showOthers, unit, overrideTotal, autoSortData, hideLegendValues, }: DonutChartProps<TProps>) => ReactElement;
93
+ export declare const DonutChart: <TProps extends object>({ data, size, loading, onClick, className, dataTestId, maxDataPoints, showOthers, unit, overrideTotal, autoSortData, hideLegendValues, }: DonutChartProps<TProps>) => ReactElement;
98
94
  export {};