@yamada-ui/charts 1.3.2 → 1.4.0-dev-20240802181515

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. package/dist/area-chart.js +23 -10
  2. package/dist/area-chart.js.map +1 -1
  3. package/dist/area-chart.mjs +4 -4
  4. package/dist/bar-chart.js +23 -10
  5. package/dist/bar-chart.js.map +1 -1
  6. package/dist/bar-chart.mjs +4 -4
  7. package/dist/chart-tooltip.d.mts +2 -1
  8. package/dist/chart-tooltip.d.ts +2 -1
  9. package/dist/chart-tooltip.js +15 -6
  10. package/dist/chart-tooltip.js.map +1 -1
  11. package/dist/chart-tooltip.mjs +1 -1
  12. package/dist/{chunk-J2HFHUKE.mjs → chunk-4MW4FB2T.mjs} +4 -4
  13. package/dist/{chunk-J2HFHUKE.mjs.map → chunk-4MW4FB2T.mjs.map} +1 -1
  14. package/dist/{chunk-UK6B6KJ7.mjs → chunk-AOGTJ4EN.mjs} +1 -1
  15. package/dist/chunk-AOGTJ4EN.mjs.map +1 -0
  16. package/dist/{chunk-TRB4RCSH.mjs → chunk-BNTTQQFO.mjs} +6 -5
  17. package/dist/chunk-BNTTQQFO.mjs.map +1 -0
  18. package/dist/{chunk-MR2GQ4BK.mjs → chunk-DKZISSE6.mjs} +10 -5
  19. package/dist/chunk-DKZISSE6.mjs.map +1 -0
  20. package/dist/{chunk-3RQT2QR6.mjs → chunk-IF4O4CBA.mjs} +5 -5
  21. package/dist/chunk-IF4O4CBA.mjs.map +1 -0
  22. package/dist/{chunk-62QDC3QC.mjs → chunk-LF3ENX7Z.mjs} +8 -5
  23. package/dist/chunk-LF3ENX7Z.mjs.map +1 -0
  24. package/dist/{chunk-FVMZPU4D.mjs → chunk-LHW3WK3C.mjs} +7 -6
  25. package/dist/chunk-LHW3WK3C.mjs.map +1 -0
  26. package/dist/{chunk-PSJKBKOF.mjs → chunk-MT5JI4OR.mjs} +16 -7
  27. package/dist/chunk-MT5JI4OR.mjs.map +1 -0
  28. package/dist/{chunk-CBNHQGSK.mjs → chunk-OHTXO2ZF.mjs} +10 -5
  29. package/dist/chunk-OHTXO2ZF.mjs.map +1 -0
  30. package/dist/{chunk-QHABNDK6.mjs → chunk-U2HWHZYI.mjs} +6 -5
  31. package/dist/chunk-U2HWHZYI.mjs.map +1 -0
  32. package/dist/{chunk-XHDDK4ZU.mjs → chunk-VK4VQQYY.mjs} +3 -4
  33. package/dist/chunk-VK4VQQYY.mjs.map +1 -0
  34. package/dist/{chunk-DMVH7PWL.mjs → chunk-WY5PI2CR.mjs} +10 -5
  35. package/dist/chunk-WY5PI2CR.mjs.map +1 -0
  36. package/dist/donut-chart.js +23 -13
  37. package/dist/donut-chart.js.map +1 -1
  38. package/dist/donut-chart.mjs +5 -5
  39. package/dist/index.js +55 -26
  40. package/dist/index.js.map +1 -1
  41. package/dist/index.mjs +12 -12
  42. package/dist/line-chart.js +23 -10
  43. package/dist/line-chart.js.map +1 -1
  44. package/dist/line-chart.mjs +4 -4
  45. package/dist/pie-chart-label.d.mts +1 -1
  46. package/dist/pie-chart-label.d.ts +1 -1
  47. package/dist/pie-chart-label.js +3 -3
  48. package/dist/pie-chart-label.js.map +1 -1
  49. package/dist/pie-chart-label.mjs +1 -1
  50. package/dist/pie-chart.d.mts +1 -5
  51. package/dist/pie-chart.d.ts +1 -5
  52. package/dist/pie-chart.js +23 -13
  53. package/dist/pie-chart.js.map +1 -1
  54. package/dist/pie-chart.mjs +5 -5
  55. package/dist/radar-chart.d.mts +1 -1
  56. package/dist/radar-chart.d.ts +1 -1
  57. package/dist/radar-chart.js +25 -12
  58. package/dist/radar-chart.js.map +1 -1
  59. package/dist/radar-chart.mjs +4 -4
  60. package/dist/use-chart-axis.d.mts +7 -3
  61. package/dist/use-chart-axis.d.ts +7 -3
  62. package/dist/use-chart-axis.js +2 -3
  63. package/dist/use-chart-axis.js.map +1 -1
  64. package/dist/use-chart-axis.mjs +1 -1
  65. package/dist/use-chart-tooltip.d.mts +8 -0
  66. package/dist/use-chart-tooltip.d.ts +8 -0
  67. package/dist/use-chart-tooltip.js.map +1 -1
  68. package/dist/use-chart-tooltip.mjs +1 -1
  69. package/dist/use-pie-chart.d.mts +3 -3
  70. package/dist/use-pie-chart.d.ts +3 -3
  71. package/dist/use-pie-chart.js +6 -6
  72. package/dist/use-pie-chart.js.map +1 -1
  73. package/dist/use-pie-chart.mjs +2 -2
  74. package/dist/use-radar-chart.d.mts +7 -3
  75. package/dist/use-radar-chart.d.ts +7 -3
  76. package/dist/use-radar-chart.js +6 -5
  77. package/dist/use-radar-chart.js.map +1 -1
  78. package/dist/use-radar-chart.mjs +1 -1
  79. package/package.json +1 -1
  80. package/dist/chunk-3RQT2QR6.mjs.map +0 -1
  81. package/dist/chunk-62QDC3QC.mjs.map +0 -1
  82. package/dist/chunk-CBNHQGSK.mjs.map +0 -1
  83. package/dist/chunk-DMVH7PWL.mjs.map +0 -1
  84. package/dist/chunk-FVMZPU4D.mjs.map +0 -1
  85. package/dist/chunk-MR2GQ4BK.mjs.map +0 -1
  86. package/dist/chunk-PSJKBKOF.mjs.map +0 -1
  87. package/dist/chunk-QHABNDK6.mjs.map +0 -1
  88. package/dist/chunk-TRB4RCSH.mjs.map +0 -1
  89. package/dist/chunk-UK6B6KJ7.mjs.map +0 -1
  90. package/dist/chunk-XHDDK4ZU.mjs.map +0 -1
package/dist/index.js CHANGED
@@ -601,20 +601,29 @@ var import_core4 = require("@yamada-ui/core");
601
601
  var import_utils4 = require("@yamada-ui/utils");
602
602
  var import_jsx_runtime2 = require("react/jsx-runtime");
603
603
  var ChartTooltip = (0, import_core4.forwardRef)(
604
- ({ label, className, payload = [], valueFormatter, unit, ...rest }, ref) => {
604
+ ({
605
+ label,
606
+ className,
607
+ payload = [],
608
+ valueFormatter,
609
+ labelFormatter,
610
+ unit,
611
+ ...rest
612
+ }, ref) => {
613
+ var _a;
605
614
  const { styles } = useTooltip();
606
615
  const items = payload.map(
607
616
  ({ color: colorProp, name, value: valueProp, payload: payload2 } = {}, index) => {
608
- var _a;
617
+ var _a2;
609
618
  const color = colorProp != null ? colorProp : payload2 == null ? void 0 : payload2.color;
610
619
  let value;
611
620
  if ((0, import_utils4.isArray)(valueProp)) {
612
621
  value = valueProp.map((value2) => {
613
- var _a2;
614
- return `${(_a2 = valueFormatter == null ? void 0 : valueFormatter(value2)) != null ? _a2 : value2}`;
622
+ var _a3;
623
+ return `${(_a3 = valueFormatter == null ? void 0 : valueFormatter(value2)) != null ? _a3 : value2}`;
615
624
  }).join(" - ");
616
625
  } else {
617
- value = (_a = valueFormatter == null ? void 0 : valueFormatter(valueProp)) != null ? _a : valueProp;
626
+ value = (_a2 = valueFormatter == null ? void 0 : valueFormatter(valueProp)) != null ? _a2 : valueProp;
618
627
  }
619
628
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
620
629
  import_core4.ui.div,
@@ -663,7 +672,7 @@ var ChartTooltip = (0, import_core4.forwardRef)(
663
672
  __css: styles.tooltip,
664
673
  ...rest,
665
674
  children: [
666
- label ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core4.ui.p, { className: "ui-chart__tooltip-title", __css: styles.tooltipTitle, children: label }) : null,
675
+ label ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core4.ui.p, { className: "ui-chart__tooltip-title", __css: styles.tooltipTitle, children: (_a = labelFormatter == null ? void 0 : labelFormatter(label)) != null ? _a : label }) : null,
667
676
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core4.ui.div, { className: "ui-chart__tooltip-list", __css: styles.tooltipList, children: items })
668
677
  ]
669
678
  }
@@ -686,7 +695,8 @@ var useChartAxis = ({
686
695
  xAxisLabel: xAxisLabelProp,
687
696
  yAxisLabel: yAxisLabelProp,
688
697
  unit,
689
- valueFormatter,
698
+ yAxisTickFormatter = type === "percent" && layoutType === "horizontal" ? valueToPercent : void 0,
699
+ xAxisTickFormatter = type === "percent" && layoutType === "vertical" ? valueToPercent : void 0,
690
700
  styles,
691
701
  ...rest
692
702
  }) => {
@@ -705,8 +715,6 @@ var useChartAxis = ({
705
715
  const getTickLine = (withTickLine) => withTickLine ? { stroke: "currentColor" } : false;
706
716
  const xTickLine = getTickLine(withXTickLine);
707
717
  const yTickLine = getTickLine(withYTickLine);
708
- const yAxisTickFormatter = type === "percent" && layoutType !== "vertical" ? valueToPercent : valueFormatter;
709
- const xAxisTickFormatter = type === "percent" && layoutType === "vertical" ? valueToPercent : valueFormatter;
710
718
  const xAxisLabel = layoutType === "vertical" ? yAxisLabelProp : xAxisLabelProp;
711
719
  const yAxisLabel = layoutType === "vertical" ? xAxisLabelProp : yAxisLabelProp;
712
720
  const [xAxisProps, xAxisClassName] = getComponentProps(
@@ -1221,7 +1229,10 @@ var LineChart = (0, import_core10.forwardRef)((props, ref) => {
1221
1229
  xAxisLabelProps,
1222
1230
  yAxisLabelProps,
1223
1231
  unit,
1232
+ yAxisTickFormatter,
1233
+ xAxisTickFormatter,
1224
1234
  valueFormatter,
1235
+ labelFormatter,
1225
1236
  referenceLineProps,
1226
1237
  tooltipProps,
1227
1238
  tooltipAnimationDuration,
@@ -1280,7 +1291,8 @@ var LineChart = (0, import_core10.forwardRef)((props, ref) => {
1280
1291
  xAxisLabelProps,
1281
1292
  yAxisLabelProps,
1282
1293
  unit,
1283
- valueFormatter,
1294
+ yAxisTickFormatter,
1295
+ xAxisTickFormatter,
1284
1296
  styles
1285
1297
  });
1286
1298
  const { getReferenceLineProps } = useChartReferenceLine({
@@ -1388,6 +1400,7 @@ var LineChart = (0, import_core10.forwardRef)((props, ref) => {
1388
1400
  label,
1389
1401
  payload,
1390
1402
  valueFormatter,
1403
+ labelFormatter,
1391
1404
  unit,
1392
1405
  ...computedTooltipProps
1393
1406
  }
@@ -1643,7 +1656,10 @@ var BarChart = (0, import_core12.forwardRef)((props, ref) => {
1643
1656
  withLegend = false,
1644
1657
  containerProps,
1645
1658
  unit,
1659
+ yAxisTickFormatter,
1660
+ xAxisTickFormatter,
1646
1661
  valueFormatter,
1662
+ labelFormatter,
1647
1663
  tooltipProps,
1648
1664
  tooltipAnimationDuration,
1649
1665
  legendProps,
@@ -1691,7 +1707,8 @@ var BarChart = (0, import_core12.forwardRef)((props, ref) => {
1691
1707
  xAxisLabelProps,
1692
1708
  yAxisLabelProps,
1693
1709
  unit,
1694
- valueFormatter,
1710
+ yAxisTickFormatter,
1711
+ xAxisTickFormatter,
1695
1712
  styles
1696
1713
  });
1697
1714
  const { getReferenceLineProps } = useChartReferenceLine({
@@ -1801,6 +1818,7 @@ var BarChart = (0, import_core12.forwardRef)((props, ref) => {
1801
1818
  label,
1802
1819
  payload,
1803
1820
  valueFormatter,
1821
+ labelFormatter,
1804
1822
  unit,
1805
1823
  ...computedTooltipProps
1806
1824
  }
@@ -2219,7 +2237,10 @@ var AreaChart = (0, import_core14.forwardRef)((props, ref) => {
2219
2237
  unit,
2220
2238
  gridProps,
2221
2239
  strokeDasharray,
2240
+ yAxisTickFormatter,
2241
+ xAxisTickFormatter,
2222
2242
  valueFormatter,
2243
+ labelFormatter,
2223
2244
  tooltipProps,
2224
2245
  tooltipAnimationDuration,
2225
2246
  legendProps,
@@ -2288,7 +2309,8 @@ var AreaChart = (0, import_core14.forwardRef)((props, ref) => {
2288
2309
  xAxisLabelProps,
2289
2310
  yAxisLabelProps,
2290
2311
  unit,
2291
- valueFormatter,
2312
+ yAxisTickFormatter,
2313
+ xAxisTickFormatter,
2292
2314
  styles
2293
2315
  });
2294
2316
  const { getReferenceLineProps } = useChartReferenceLine({
@@ -2399,6 +2421,7 @@ var AreaChart = (0, import_core14.forwardRef)((props, ref) => {
2399
2421
  label,
2400
2422
  payload,
2401
2423
  valueFormatter,
2424
+ labelFormatter,
2402
2425
  unit,
2403
2426
  ...computedTooltipProps
2404
2427
  }
@@ -2436,7 +2459,8 @@ var useRadarChart = ({
2436
2459
  withActiveDots = false,
2437
2460
  strokeWidth = 2,
2438
2461
  fillOpacity = 0.4,
2439
- valueFormatter,
2462
+ polarAngleAxisTickFormatter,
2463
+ polarRadiusAxisTickFormatter,
2440
2464
  strokeDasharray,
2441
2465
  styles,
2442
2466
  ...rest
@@ -2705,7 +2729,7 @@ var useRadarChart = ({
2705
2729
  polarAngleAxisTickClassName
2706
2730
  )
2707
2731
  },
2708
- tickFormatter: valueFormatter,
2732
+ tickFormatter: polarAngleAxisTickFormatter,
2709
2733
  tickSize: 16,
2710
2734
  ...props,
2711
2735
  ...polarAngleAxisProps
@@ -2715,7 +2739,7 @@ var useRadarChart = ({
2715
2739
  polarAngleAxisClassName,
2716
2740
  polarAngleAxisProps,
2717
2741
  polarAngleAxisTickClassName,
2718
- valueFormatter
2742
+ polarAngleAxisTickFormatter
2719
2743
  ]
2720
2744
  );
2721
2745
  const getPolarRadiusAxisProps = (0, import_react13.useCallback)(
@@ -2728,7 +2752,7 @@ var useRadarChart = ({
2728
2752
  polarRadiusAxisTickClassName
2729
2753
  )
2730
2754
  },
2731
- tickFormatter: valueFormatter,
2755
+ tickFormatter: polarRadiusAxisTickFormatter,
2732
2756
  ...props,
2733
2757
  ...polarRadiusAxisProps
2734
2758
  }),
@@ -2736,7 +2760,7 @@ var useRadarChart = ({
2736
2760
  polarRadiusAxisClassName,
2737
2761
  polarRadiusAxisProps,
2738
2762
  polarRadiusAxisTickClassName,
2739
- valueFormatter
2763
+ polarRadiusAxisTickFormatter
2740
2764
  ]
2741
2765
  );
2742
2766
  return {
@@ -2772,6 +2796,8 @@ var RadarChart = (0, import_core16.forwardRef)((props, ref) => {
2772
2796
  tooltipAnimationDuration,
2773
2797
  unit,
2774
2798
  valueFormatter,
2799
+ polarAngleAxisTickFormatter,
2800
+ polarRadiusAxisTickFormatter,
2775
2801
  strokeDasharray,
2776
2802
  withDots,
2777
2803
  withActiveDots,
@@ -2807,7 +2833,8 @@ var RadarChart = (0, import_core16.forwardRef)((props, ref) => {
2807
2833
  withActiveDots,
2808
2834
  strokeWidth,
2809
2835
  fillOpacity,
2810
- valueFormatter,
2836
+ polarAngleAxisTickFormatter,
2837
+ polarRadiusAxisTickFormatter,
2811
2838
  strokeDasharray,
2812
2839
  styles
2813
2840
  });
@@ -2943,7 +2970,7 @@ var pieChartLabel = ({
2943
2970
  labelOffset: labelOffsetProp,
2944
2971
  isPercent,
2945
2972
  labelProps,
2946
- valueFormatter,
2973
+ labelFormatter,
2947
2974
  styles
2948
2975
  }) => {
2949
2976
  const labelOffset = labelOffsetProp != null ? labelOffsetProp : (outerRadius - innerRadius) * 0.5 + DEFAULT_LABEL_OFFSET;
@@ -2953,8 +2980,8 @@ var pieChartLabel = ({
2953
2980
  const displayLabel = () => {
2954
2981
  if (isPercent) {
2955
2982
  return parseFloat((percent * 100).toFixed(0)) > 0 && `${(percent * 100).toFixed(0)}%`;
2956
- } else if (!(0, import_utils18.isUndefined)(valueFormatter)) {
2957
- return valueFormatter(value);
2983
+ } else if (!(0, import_utils18.isUndefined)(labelFormatter)) {
2984
+ return labelFormatter(value);
2958
2985
  } else {
2959
2986
  return value;
2960
2987
  }
@@ -3015,7 +3042,7 @@ var usePieChart = ({
3015
3042
  paddingAngle = 0,
3016
3043
  startAngle = 90,
3017
3044
  endAngle = -270,
3018
- valueFormatter,
3045
+ labelFormatter,
3019
3046
  styles,
3020
3047
  ...rest
3021
3048
  }) => {
@@ -3095,11 +3122,11 @@ var usePieChart = ({
3095
3122
  labelOffset,
3096
3123
  isPercent,
3097
3124
  labelProps,
3098
- valueFormatter,
3125
+ labelFormatter,
3099
3126
  styles: styles.label,
3100
3127
  ...props
3101
3128
  }),
3102
- [isPercent, labelOffset, labelProps, styles.label, valueFormatter]
3129
+ [isPercent, labelOffset, labelProps, styles.label, labelFormatter]
3103
3130
  );
3104
3131
  const labelLine = (0, import_react15.useCallback)(
3105
3132
  (props) => {
@@ -3228,6 +3255,7 @@ var DonutChart = (0, import_core19.forwardRef)((props, ref) => {
3228
3255
  tooltipAnimationDuration,
3229
3256
  tooltipDataSource = "all",
3230
3257
  valueFormatter,
3258
+ labelFormatter,
3231
3259
  unit,
3232
3260
  paddingAngle,
3233
3261
  startAngle,
@@ -3263,7 +3291,7 @@ var DonutChart = (0, import_core19.forwardRef)((props, ref) => {
3263
3291
  withLabelLines,
3264
3292
  labelOffset,
3265
3293
  isPercent,
3266
- valueFormatter,
3294
+ labelFormatter,
3267
3295
  styles
3268
3296
  });
3269
3297
  const { getContainerProps } = useChart({ containerProps });
@@ -3373,6 +3401,7 @@ var PieChart = (0, import_core20.forwardRef)((props, ref) => {
3373
3401
  tooltipAnimationDuration,
3374
3402
  tooltipDataSource = "all",
3375
3403
  valueFormatter,
3404
+ labelFormatter,
3376
3405
  unit,
3377
3406
  innerRadius,
3378
3407
  outerRadius,
@@ -3408,7 +3437,7 @@ var PieChart = (0, import_core20.forwardRef)((props, ref) => {
3408
3437
  withLabelLines,
3409
3438
  labelOffset,
3410
3439
  isPercent,
3411
- valueFormatter,
3440
+ labelFormatter,
3412
3441
  styles
3413
3442
  });
3414
3443
  const { getContainerProps } = useChart({ containerProps });