@tetrascience-npm/tetrascience-react-ui 0.6.0-beta.82.1 → 0.6.0-beta.84.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.
Files changed (87) hide show
  1. package/dist/components/charts/AreaGraph/AreaGraph.cjs +1 -1
  2. package/dist/components/charts/AreaGraph/AreaGraph.cjs.map +1 -1
  3. package/dist/components/charts/AreaGraph/AreaGraph.js +132 -98
  4. package/dist/components/charts/AreaGraph/AreaGraph.js.map +1 -1
  5. package/dist/components/charts/BarGraph/BarGraph.cjs +1 -1
  6. package/dist/components/charts/BarGraph/BarGraph.cjs.map +1 -1
  7. package/dist/components/charts/BarGraph/BarGraph.js +63 -57
  8. package/dist/components/charts/BarGraph/BarGraph.js.map +1 -1
  9. package/dist/components/charts/Boxplot/Boxplot.cjs +1 -1
  10. package/dist/components/charts/Boxplot/Boxplot.cjs.map +1 -1
  11. package/dist/components/charts/Boxplot/Boxplot.js +83 -74
  12. package/dist/components/charts/Boxplot/Boxplot.js.map +1 -1
  13. package/dist/components/charts/ChartTooltip/ChartTooltip.cjs +2 -0
  14. package/dist/components/charts/ChartTooltip/ChartTooltip.cjs.map +1 -0
  15. package/dist/components/charts/ChartTooltip/ChartTooltip.js +163 -0
  16. package/dist/components/charts/ChartTooltip/ChartTooltip.js.map +1 -0
  17. package/dist/components/charts/ChartTooltip/lines.cjs +2 -0
  18. package/dist/components/charts/ChartTooltip/lines.cjs.map +1 -0
  19. package/dist/components/charts/ChartTooltip/lines.js +29 -0
  20. package/dist/components/charts/ChartTooltip/lines.js.map +1 -0
  21. package/dist/components/charts/Chromatogram/Chromatogram.cjs +1 -1
  22. package/dist/components/charts/Chromatogram/Chromatogram.cjs.map +1 -1
  23. package/dist/components/charts/Chromatogram/Chromatogram.js +75 -61
  24. package/dist/components/charts/Chromatogram/Chromatogram.js.map +1 -1
  25. package/dist/components/charts/ChromatogramChart/ChromatogramChart.cjs +1 -1
  26. package/dist/components/charts/ChromatogramChart/ChromatogramChart.cjs.map +1 -1
  27. package/dist/components/charts/ChromatogramChart/ChromatogramChart.js +116 -108
  28. package/dist/components/charts/ChromatogramChart/ChromatogramChart.js.map +1 -1
  29. package/dist/components/charts/ChromatogramChart/annotations.cjs +1 -1
  30. package/dist/components/charts/ChromatogramChart/annotations.cjs.map +1 -1
  31. package/dist/components/charts/ChromatogramChart/annotations.js +32 -32
  32. package/dist/components/charts/ChromatogramChart/annotations.js.map +1 -1
  33. package/dist/components/charts/ChromatogramChart/boundaryMarkers.cjs +1 -1
  34. package/dist/components/charts/ChromatogramChart/boundaryMarkers.cjs.map +1 -1
  35. package/dist/components/charts/ChromatogramChart/boundaryMarkers.js +6 -6
  36. package/dist/components/charts/ChromatogramChart/boundaryMarkers.js.map +1 -1
  37. package/dist/components/charts/ChromatogramChart/constants.cjs +1 -1
  38. package/dist/components/charts/ChromatogramChart/constants.cjs.map +1 -1
  39. package/dist/components/charts/ChromatogramChart/constants.js +11 -5
  40. package/dist/components/charts/ChromatogramChart/constants.js.map +1 -1
  41. package/dist/components/charts/ChromatogramChart/dataProcessing.cjs +1 -1
  42. package/dist/components/charts/ChromatogramChart/dataProcessing.cjs.map +1 -1
  43. package/dist/components/charts/ChromatogramChart/dataProcessing.js +38 -49
  44. package/dist/components/charts/ChromatogramChart/dataProcessing.js.map +1 -1
  45. package/dist/components/charts/DotPlot/DotPlot.cjs +1 -1
  46. package/dist/components/charts/DotPlot/DotPlot.cjs.map +1 -1
  47. package/dist/components/charts/DotPlot/DotPlot.js +57 -63
  48. package/dist/components/charts/DotPlot/DotPlot.js.map +1 -1
  49. package/dist/components/charts/Histogram/Histogram.cjs +1 -1
  50. package/dist/components/charts/Histogram/Histogram.cjs.map +1 -1
  51. package/dist/components/charts/Histogram/Histogram.js +98 -104
  52. package/dist/components/charts/Histogram/Histogram.js.map +1 -1
  53. package/dist/components/charts/LineGraph/LineGraph.cjs +1 -1
  54. package/dist/components/charts/LineGraph/LineGraph.cjs.map +1 -1
  55. package/dist/components/charts/LineGraph/LineGraph.js +97 -88
  56. package/dist/components/charts/LineGraph/LineGraph.js.map +1 -1
  57. package/dist/components/charts/PieChart/PieChart.cjs +1 -1
  58. package/dist/components/charts/PieChart/PieChart.cjs.map +1 -1
  59. package/dist/components/charts/PieChart/PieChart.js +65 -68
  60. package/dist/components/charts/PieChart/PieChart.js.map +1 -1
  61. package/dist/components/charts/PlateMap/PlateMap.cjs +1 -1
  62. package/dist/components/charts/PlateMap/PlateMap.cjs.map +1 -1
  63. package/dist/components/charts/PlateMap/PlateMap.js +271 -256
  64. package/dist/components/charts/PlateMap/PlateMap.js.map +1 -1
  65. package/dist/components/charts/PlateMap/constants.cjs +1 -1
  66. package/dist/components/charts/PlateMap/constants.cjs.map +1 -1
  67. package/dist/components/charts/PlateMap/constants.js +20 -29
  68. package/dist/components/charts/PlateMap/constants.js.map +1 -1
  69. package/dist/components/charts/ScatterGraph/ScatterGraph.cjs +1 -1
  70. package/dist/components/charts/ScatterGraph/ScatterGraph.cjs.map +1 -1
  71. package/dist/components/charts/ScatterGraph/ScatterGraph.js +113 -89
  72. package/dist/components/charts/ScatterGraph/ScatterGraph.js.map +1 -1
  73. package/dist/hooks/use-plotly-theme.cjs +1 -1
  74. package/dist/hooks/use-plotly-theme.cjs.map +1 -1
  75. package/dist/hooks/use-plotly-theme.js +4 -2
  76. package/dist/hooks/use-plotly-theme.js.map +1 -1
  77. package/dist/index.cjs +1 -1
  78. package/dist/index.css +1 -1
  79. package/dist/index.d.ts +156 -76
  80. package/dist/index.js +587 -581
  81. package/dist/index.js.map +1 -1
  82. package/dist/index.tailwind.css +1 -1
  83. package/dist/utils/colors.cjs +1 -1
  84. package/dist/utils/colors.cjs.map +1 -1
  85. package/dist/utils/colors.js +38 -93
  86. package/dist/utils/colors.js.map +1 -1
  87. package/package.json +1 -1
@@ -1,58 +1,60 @@
1
- import { jsx as z } from "react/jsx-runtime";
2
- import N from "plotly.js-dist";
3
- import { useRef as A, useMemo as s, useEffect as L } from "react";
4
- import { usePlotlyTheme as P } from "../../../hooks/use-plotly-theme.js";
5
- const B = ({
6
- dataSeries: i,
7
- width: y = 1e3,
8
- height: g = 600,
9
- xRange: p,
10
- yRange: c,
11
- variant: m = "lines",
12
- xTitle: x = "Columns",
13
- yTitle: k = "Rows",
14
- title: M = "Line Graph"
1
+ import { jsxs as v, jsx as A } from "react/jsx-runtime";
2
+ import z from "plotly.js-dist";
3
+ import { useRef as P, useMemo as c, useEffect as U } from "react";
4
+ import { useChartTooltip as V } from "../ChartTooltip/ChartTooltip.js";
5
+ import { usePlotlyTheme as X } from "../../../hooks/use-plotly-theme.js";
6
+ import { seriesColor as B } from "../../../utils/colors.js";
7
+ const q = ({
8
+ dataSeries: l,
9
+ width: M = 1e3,
10
+ height: w = 600,
11
+ xRange: d,
12
+ yRange: m,
13
+ variant: f = "lines",
14
+ xTitle: y = "Columns",
15
+ yTitle: g = "Rows",
16
+ title: b = "Line Graph"
15
17
  }) => {
16
- const h = A(null), o = P(), { yMin: w, yMax: b } = s(() => {
17
- let r = Number.MAX_VALUE, t = Number.MIN_VALUE, l = Number.MAX_VALUE, n = Number.MIN_VALUE;
18
- i.forEach((I) => {
19
- I.x.forEach((f) => {
20
- r = Math.min(r, f), t = Math.max(t, f);
21
- }), I.y.forEach((f) => {
22
- l = Math.min(l, f), n = Math.max(n, f);
18
+ const p = P(null), o = X(), { bindTooltip: C, tooltipElement: N } = V({ xLabel: y, yLabel: g }), { yMin: E, yMax: _ } = c(() => {
19
+ let r = Number.MAX_VALUE, t = Number.MIN_VALUE, i = Number.MAX_VALUE, e = Number.MIN_VALUE;
20
+ l.forEach((a) => {
21
+ a.x.forEach((h) => {
22
+ r = Math.min(r, h), t = Math.max(t, h);
23
+ }), a.y.forEach((h) => {
24
+ i = Math.min(i, h), e = Math.max(e, h);
23
25
  });
24
26
  });
25
- const e = (t - r) * 0.1, C = (n - l) * 0.1;
27
+ const n = (t - r) * 0.1, u = (e - i) * 0.1;
26
28
  return {
27
- xMin: r - e,
28
- xMax: t + e,
29
- yMin: l - C,
30
- yMax: n + C
29
+ xMin: r - n,
30
+ xMax: t + n,
31
+ yMin: i - u,
32
+ yMax: e + u
31
33
  };
32
- }, [i]), a = s(
33
- () => c || [w, b],
34
- [c, w, b]
35
- ), _ = s(() => {
36
- const r = a[1] - a[0];
34
+ }, [l]), s = c(
35
+ () => m || [E, _],
36
+ [m, E, _]
37
+ ), I = c(() => {
38
+ const r = s[1] - s[0];
37
39
  let t = Math.pow(10, Math.floor(Math.log10(r)));
38
40
  r / t > 10 && (t = t * 2), r / t < 4 && (t = t / 2);
39
- const l = [];
40
- let n = Math.ceil(a[0] / t) * t;
41
- for (; n <= a[1]; )
42
- l.push(n), n += t;
43
- return l;
44
- }, [a]), u = s(
45
- () => [...new Set(i.flatMap((r) => r.x))],
46
- [i]
47
- ), E = s(() => {
48
- switch (m) {
41
+ const i = [];
42
+ let e = Math.ceil(s[0] / t) * t;
43
+ for (; e <= s[1]; )
44
+ i.push(e), e += t;
45
+ return i;
46
+ }, [s]), x = c(
47
+ () => [...new Set(l.flatMap((r) => r.x))],
48
+ [l]
49
+ ), L = c(() => {
50
+ switch (f) {
49
51
  case "lines+markers":
50
52
  case "lines+markers+error_bars":
51
53
  return "lines+markers";
52
54
  default:
53
55
  return "lines";
54
56
  }
55
- }, [m]), d = s(
57
+ }, [f]), k = c(
56
58
  () => ({
57
59
  tickcolor: o.tickColor,
58
60
  ticklen: 12,
@@ -71,42 +73,46 @@ const B = ({
71
73
  }),
72
74
  [o]
73
75
  );
74
- return L(() => {
75
- if (!h.current) return;
76
- const r = i.map((e) => ({
77
- x: e.x,
78
- y: e.y,
79
- type: "scatter",
80
- mode: E,
81
- name: e.name,
82
- line: {
83
- color: e.color,
84
- width: 1.5
85
- },
86
- marker: m === "lines" ? { opacity: 0 } : {
87
- color: e.color,
88
- size: 8,
89
- symbol: e.symbol || "triangle-up"
90
- },
91
- error_y: m === "lines+markers+error_bars" ? e.error_y || {
92
- type: "data",
93
- array: e.y.map(() => 10),
94
- visible: !0,
95
- color: e.color,
96
- thickness: 1,
97
- width: 5
98
- } : void 0
99
- })), t = {
76
+ return U(() => {
77
+ if (!p.current) return;
78
+ const r = l.map((n, u) => {
79
+ const a = B(u, n.color);
80
+ return {
81
+ x: n.x,
82
+ y: n.y,
83
+ type: "scatter",
84
+ mode: L,
85
+ name: n.name,
86
+ hoverinfo: "none",
87
+ line: {
88
+ color: a,
89
+ width: 1.5
90
+ },
91
+ marker: f === "lines" ? { opacity: 0 } : {
92
+ color: a,
93
+ size: 8,
94
+ symbol: n.symbol || "triangle-up"
95
+ },
96
+ error_y: f === "lines+markers+error_bars" ? n.error_y || {
97
+ type: "data",
98
+ array: n.y.map(() => 10),
99
+ visible: !0,
100
+ color: a,
101
+ thickness: 1,
102
+ width: 5
103
+ } : void 0
104
+ };
105
+ }), t = {
100
106
  title: {
101
- text: M,
107
+ text: b,
102
108
  font: {
103
109
  size: 32,
104
110
  family: "Inter, sans-serif",
105
111
  color: o.textColor
106
112
  }
107
113
  },
108
- width: y,
109
- height: g,
114
+ width: M,
115
+ height: w,
110
116
  margin: { l: 80, r: 30, b: 80, t: 60, pad: 10 },
111
117
  paper_bgcolor: o.paperBg,
112
118
  plot_bgcolor: o.plotBg,
@@ -116,7 +122,7 @@ const B = ({
116
122
  dragmode: !1,
117
123
  xaxis: {
118
124
  title: {
119
- text: x,
125
+ text: y,
120
126
  font: {
121
127
  size: 16,
122
128
  color: o.textSecondary,
@@ -126,17 +132,17 @@ const B = ({
126
132
  standoff: 32
127
133
  },
128
134
  gridcolor: o.gridColor,
129
- range: p,
130
- autorange: !p,
135
+ range: d,
136
+ autorange: !d,
131
137
  tickmode: "array",
132
- tickvals: u,
133
- ticktext: u.map(String),
138
+ tickvals: x,
139
+ ticktext: x.map(String),
134
140
  showgrid: !0,
135
- ...d
141
+ ...k
136
142
  },
137
143
  yaxis: {
138
144
  title: {
139
- text: k,
145
+ text: g,
140
146
  font: {
141
147
  size: 16,
142
148
  color: o.textSecondary,
@@ -146,12 +152,12 @@ const B = ({
146
152
  standoff: 30
147
153
  },
148
154
  gridcolor: o.gridColor,
149
- range: c,
150
- autorange: !c,
155
+ range: m,
156
+ autorange: !m,
151
157
  tickmode: "array",
152
- tickvals: _,
158
+ tickvals: I,
153
159
  showgrid: !0,
154
- ...d
160
+ ...k
155
161
  },
156
162
  legend: {
157
163
  x: 0.5,
@@ -167,19 +173,22 @@ const B = ({
167
173
  }
168
174
  },
169
175
  showlegend: !0
170
- }, l = {
176
+ }, i = {
171
177
  responsive: !0,
172
178
  displayModeBar: !1,
173
179
  displaylogo: !1
174
180
  };
175
- N.newPlot(h.current, r, t, l);
176
- const n = h.current;
181
+ z.newPlot(p.current, r, t, i), C(p.current);
182
+ const e = p.current;
177
183
  return () => {
178
- n && N.purge(n);
184
+ e && z.purge(e);
179
185
  };
180
- }, [i, y, g, p, c, x, k, M, E, d, u, _, a, m, o]), /* @__PURE__ */ z("div", { className: "chart-container", children: /* @__PURE__ */ z("div", { ref: h, style: { width: "100%", height: "100%" } }) });
186
+ }, [l, M, w, d, m, y, g, b, L, k, x, I, s, f, o, C]), /* @__PURE__ */ v("div", { className: "chart-container relative", children: [
187
+ /* @__PURE__ */ A("div", { ref: p, style: { width: "100%", height: "100%" } }),
188
+ N
189
+ ] });
181
190
  };
182
191
  export {
183
- B as LineGraph
192
+ q as LineGraph
184
193
  };
185
194
  //# sourceMappingURL=LineGraph.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LineGraph.js","sources":["../../../../src/components/charts/LineGraph/LineGraph.tsx"],"sourcesContent":["import Plotly from \"plotly.js-dist\";\nimport React, { useEffect, useRef, useMemo } from \"react\";\n\nimport { usePlotlyTheme } from \"@/hooks/use-plotly-theme\";\n\ntype MarkerSymbol =\n | \"circle\"\n | \"circle-open\"\n | \"circle-dot\"\n | \"circle-open-dot\"\n | \"square\"\n | \"square-open\"\n | \"square-dot\"\n | \"square-open-dot\"\n | \"diamond\"\n | \"diamond-open\"\n | \"diamond-dot\"\n | \"diamond-open-dot\"\n | \"cross\"\n | \"cross-open\"\n | \"cross-dot\"\n | \"cross-open-dot\"\n | \"x\"\n | \"x-open\"\n | \"x-dot\"\n | \"x-open-dot\"\n | \"triangle-up\"\n | \"triangle-up-open\"\n | \"triangle-up-dot\"\n | \"triangle-up-open-dot\"\n | \"triangle-down\"\n | \"triangle-down-open\"\n | \"triangle-down-dot\"\n | \"triangle-down-open-dot\"\n | \"triangle-left\"\n | \"triangle-left-open\"\n | \"triangle-left-dot\"\n | \"triangle-left-open-dot\"\n | \"triangle-right\"\n | \"triangle-right-open\"\n | \"triangle-right-dot\"\n | \"triangle-right-open-dot\"\n | \"triangle-ne\"\n | \"triangle-ne-open\"\n | \"triangle-ne-dot\"\n | \"triangle-ne-open-dot\"\n | \"triangle-se\"\n | \"triangle-se-open\"\n | \"triangle-se-dot\"\n | \"triangle-se-open-dot\"\n | \"triangle-sw\"\n | \"triangle-sw-open\"\n | \"triangle-sw-dot\"\n | \"triangle-sw-open-dot\"\n | \"triangle-nw\"\n | \"triangle-nw-open\"\n | \"triangle-nw-dot\"\n | \"triangle-nw-open-dot\"\n | \"pentagon\"\n | \"pentagon-open\"\n | \"pentagon-dot\"\n | \"pentagon-open-dot\"\n | \"hexagon\"\n | \"hexagon-open\"\n | \"hexagon-dot\"\n | \"hexagon-open-dot\"\n | \"hexagon2\"\n | \"hexagon2-open\"\n | \"hexagon2-dot\"\n | \"hexagon2-open-dot\"\n | \"octagon\"\n | \"octagon-open\"\n | \"octagon-dot\"\n | \"octagon-open-dot\"\n | \"star\"\n | \"star-open\"\n | \"star-dot\"\n | \"star-open-dot\"\n | \"hexagram\"\n | \"hexagram-open\"\n | \"hexagram-dot\"\n | \"hexagram-open-dot\"\n | \"star-triangle-up\"\n | \"star-triangle-up-open\"\n | \"star-triangle-up-dot\"\n | \"star-triangle-up-open-dot\"\n | \"star-triangle-down\"\n | \"star-triangle-down-open\"\n | \"star-triangle-down-dot\"\n | \"star-triangle-down-open-dot\"\n | \"star-square\"\n | \"star-square-open\"\n | \"star-square-dot\"\n | \"star-square-open-dot\"\n | \"star-diamond\"\n | \"star-diamond-open\"\n | \"star-diamond-dot\"\n | \"star-diamond-open-dot\"\n | \"diamond-tall\"\n | \"diamond-tall-open\"\n | \"diamond-tall-dot\"\n | \"diamond-tall-open-dot\"\n | \"diamond-wide\"\n | \"diamond-wide-open\"\n | \"diamond-wide-dot\"\n | \"diamond-wide-open-dot\"\n | \"hourglass\"\n | \"hourglass-open\"\n | \"bowtie\"\n | \"bowtie-open\"\n | \"circle-cross\"\n | \"circle-cross-open\"\n | \"circle-x\"\n | \"circle-x-open\"\n | \"square-cross\"\n | \"square-cross-open\"\n | \"square-x\"\n | \"square-x-open\"\n | \"diamond-cross\"\n | \"diamond-cross-open\"\n | \"diamond-x\"\n | \"diamond-x-open\"\n | \"cross-thin\"\n | \"cross-thin-open\"\n | \"x-thin\"\n | \"x-thin-open\"\n | \"asterisk\"\n | \"asterisk-open\"\n | \"hash\"\n | \"hash-open\"\n | \"hash-dot\"\n | \"hash-open-dot\"\n | \"y-up\"\n | \"y-up-open\"\n | \"y-down\"\n | \"y-down-open\"\n | \"y-left\"\n | \"y-left-open\"\n | \"y-right\"\n | \"y-right-open\"\n | \"line-ew\"\n | \"line-ew-open\"\n | \"line-ns\"\n | \"line-ns-open\"\n | \"line-ne\"\n | \"line-ne-open\"\n | \"line-nw\"\n | \"line-nw-open\"\n | \"arrow\"\n | \"arrow-open\"\n | \"arrow-wide\"\n | \"arrow-wide-open\";\n\ninterface LineDataSeries {\n x: number[];\n y: number[];\n name: string;\n color: string;\n symbol?: MarkerSymbol;\n error_y?: {\n type: \"data\";\n array: number[];\n visible: boolean;\n };\n}\n\ntype LineGraphVariant = \"lines\" | \"lines+markers\" | \"lines+markers+error_bars\";\n\ntype LineGraphProps = {\n dataSeries: LineDataSeries[];\n width?: number;\n height?: number;\n xRange?: [number, number];\n yRange?: [number, number];\n variant?: LineGraphVariant;\n xTitle?: string;\n yTitle?: string;\n title?: string;\n};\n\nconst LineGraph: React.FC<LineGraphProps> = ({\n dataSeries,\n width = 1000,\n height = 600,\n xRange,\n yRange,\n variant = \"lines\",\n xTitle = \"Columns\",\n yTitle = \"Rows\",\n title = \"Line Graph\",\n}) => {\n const plotRef = useRef<HTMLDivElement>(null);\n const theme = usePlotlyTheme();\n\n const { yMin, yMax } = useMemo(() => {\n let minX = Number.MAX_VALUE;\n let maxX = Number.MIN_VALUE;\n let minY = Number.MAX_VALUE;\n let maxY = Number.MIN_VALUE;\n\n dataSeries.forEach((series) => {\n series.x.forEach((x) => {\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n });\n series.y.forEach((y) => {\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n });\n });\n\n const xPadding = (maxX - minX) * 0.1;\n const yPadding = (maxY - minY) * 0.1;\n\n return {\n xMin: minX - xPadding,\n xMax: maxX + xPadding,\n yMin: minY - yPadding,\n yMax: maxY + yPadding,\n };\n }, [dataSeries]);\n\n const effectiveYRange = useMemo(\n () => yRange || [yMin, yMax],\n [yRange, yMin, yMax],\n );\n\n const yTicks = useMemo(() => {\n const range = effectiveYRange[1] - effectiveYRange[0];\n let step = Math.pow(10, Math.floor(Math.log10(range)));\n\n if (range / step > 10) step = step * 2;\n if (range / step < 4) step = step / 2;\n\n const ticks = [];\n let current = Math.ceil(effectiveYRange[0] / step) * step;\n while (current <= effectiveYRange[1]) {\n ticks.push(current);\n current += step;\n }\n return ticks;\n }, [effectiveYRange]);\n\n const xTicks = useMemo(\n () => [...new Set(dataSeries.flatMap((s) => s.x))],\n [dataSeries],\n );\n\n const mode = useMemo((): \"lines\" | \"lines+markers\" => {\n switch (variant) {\n case \"lines+markers\":\n case \"lines+markers+error_bars\":\n return \"lines+markers\";\n default:\n return \"lines\";\n }\n }, [variant]);\n\n const tickOptions = useMemo(\n () => ({\n tickcolor: theme.tickColor,\n ticklen: 12,\n tickwidth: 1,\n ticks: \"outside\" as const,\n tickfont: {\n size: 16,\n color: theme.textColor,\n family: \"Inter, sans-serif\",\n weight: 400,\n },\n linecolor: theme.lineColor,\n linewidth: 1,\n position: 0,\n zeroline: false,\n }),\n [theme],\n );\n\n useEffect(() => {\n if (!plotRef.current) return;\n\n const plotData = dataSeries.map((series) => ({\n x: series.x,\n y: series.y,\n type: \"scatter\" as const,\n mode: mode,\n name: series.name,\n line: {\n color: series.color,\n width: 1.5,\n },\n marker:\n variant === \"lines\"\n ? { opacity: 0 }\n : {\n color: series.color,\n size: 8,\n symbol: series.symbol || \"triangle-up\",\n },\n error_y:\n variant === \"lines+markers+error_bars\"\n ? series.error_y || {\n type: \"data\" as const,\n array: series.y.map(() => 10),\n visible: true,\n color: series.color,\n thickness: 1,\n width: 5,\n }\n : undefined,\n }));\n\n const layout = {\n title: {\n text: title,\n font: {\n size: 32,\n family: \"Inter, sans-serif\",\n color: theme.textColor,\n },\n },\n width,\n height,\n margin: { l: 80, r: 30, b: 80, t: 60, pad: 10 },\n paper_bgcolor: theme.paperBg,\n plot_bgcolor: theme.plotBg,\n font: {\n family: \"Inter, sans-serif\",\n },\n dragmode: false as const,\n xaxis: {\n title: {\n text: xTitle,\n font: {\n size: 16,\n color: theme.textSecondary,\n family: \"Inter, sans-serif\",\n weight: 400,\n },\n standoff: 32,\n },\n gridcolor: theme.gridColor,\n range: xRange,\n autorange: !xRange,\n tickmode: \"array\" as const,\n tickvals: xTicks,\n ticktext: xTicks.map(String),\n showgrid: true,\n ...tickOptions,\n },\n yaxis: {\n title: {\n text: yTitle,\n font: {\n size: 16,\n color: theme.textSecondary,\n family: \"Inter, sans-serif\",\n weight: 400,\n },\n standoff: 30,\n },\n gridcolor: theme.gridColor,\n range: yRange,\n autorange: !yRange,\n tickmode: \"array\" as const,\n tickvals: yTicks,\n showgrid: true,\n ...tickOptions,\n },\n legend: {\n x: 0.5,\n y: -0.2,\n xanchor: \"center\" as const,\n yanchor: \"top\" as const,\n orientation: \"h\" as const,\n font: {\n size: 16,\n color: theme.legendColor,\n family: \"Inter, sans-serif\",\n weight: 500,\n },\n },\n showlegend: true,\n };\n\n const config = {\n responsive: true,\n displayModeBar: false,\n displaylogo: false,\n };\n\n Plotly.newPlot(plotRef.current, plotData, layout, config);\n\n // Capture ref value for cleanup\n const plotElement = plotRef.current;\n\n return () => {\n if (plotElement) {\n Plotly.purge(plotElement);\n }\n };\n }, [dataSeries, width, height, xRange, yRange, xTitle, yTitle, title, mode, tickOptions, xTicks, yTicks, effectiveYRange, variant, theme]);\n\n return (\n <div className=\"chart-container\">\n <div ref={plotRef} style={{ width: \"100%\", height: \"100%\" }} />\n </div>\n );\n};\n\nexport { LineGraph };\nexport type { LineDataSeries, LineGraphVariant, LineGraphProps, MarkerSymbol };\n"],"names":["LineGraph","dataSeries","width","height","xRange","yRange","variant","xTitle","yTitle","title","plotRef","useRef","theme","usePlotlyTheme","yMin","yMax","useMemo","minX","maxX","minY","maxY","series","x","y","xPadding","yPadding","effectiveYRange","yTicks","range","step","ticks","current","xTicks","s","mode","tickOptions","useEffect","plotData","layout","config","Plotly","plotElement","jsx"],"mappings":";;;;AAoLA,MAAMA,IAAsC,CAAC;AAAA,EAC3C,YAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,QAAAC,IAAS;AAAA,EACT,QAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,QAAAC,IAAS;AAAA,EACT,QAAAC,IAAS;AAAA,EACT,OAAAC,IAAQ;AACV,MAAM;AACJ,QAAMC,IAAUC,EAAuB,IAAI,GACrCC,IAAQC,EAAA,GAER,EAAE,MAAAC,GAAM,MAAAC,EAAA,IAASC,EAAQ,MAAM;AACnC,QAAIC,IAAO,OAAO,WACdC,IAAO,OAAO,WACdC,IAAO,OAAO,WACdC,IAAO,OAAO;AAElB,IAAAnB,EAAW,QAAQ,CAACoB,MAAW;AAC7B,MAAAA,EAAO,EAAE,QAAQ,CAACC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QAAA;AAAA,MACV;AAAA,MAEF,YAAY;AAAA,IAAA,GAGR2B,IAAS;AAAA,MACb,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,aAAa;AAAA,IAAA;AAGf,IAAAC,EAAO,QAAQ9B,EAAQ,SAAS2B,GAAUC,GAAQC,CAAM;AAGxD,UAAME,IAAc/B,EAAQ;AAE5B,WAAO,MAAM;AACX,MAAI+B,KACFD,EAAO,MAAMC,CAAW;AAAA,IAE5B;AAAA,EACF,GAAG,CAACxC,GAAYC,GAAOC,GAAQC,GAAQC,GAAQE,GAAQC,GAAQC,GAAOyB,GAAMC,GAAaH,GAAQL,GAAQD,GAAiBpB,GAASM,CAAK,CAAC,GAGvI,gBAAA8B,EAAC,OAAA,EAAI,WAAU,mBACb,4BAAC,OAAA,EAAI,KAAKhC,GAAS,OAAO,EAAE,OAAO,QAAQ,QAAQ,OAAA,GAAU,GAC/D;AAEJ;"}
1
+ {"version":3,"file":"LineGraph.js","sources":["../../../../src/components/charts/LineGraph/LineGraph.tsx"],"sourcesContent":["import Plotly from \"plotly.js-dist\";\nimport React, { useEffect, useRef, useMemo } from \"react\";\n\nimport { useChartTooltip } from \"../ChartTooltip\";\n\nimport { usePlotlyTheme } from \"@/hooks/use-plotly-theme\";\nimport { seriesColor } from \"@/utils/colors\";\n\ntype MarkerSymbol =\n | \"circle\"\n | \"circle-open\"\n | \"circle-dot\"\n | \"circle-open-dot\"\n | \"square\"\n | \"square-open\"\n | \"square-dot\"\n | \"square-open-dot\"\n | \"diamond\"\n | \"diamond-open\"\n | \"diamond-dot\"\n | \"diamond-open-dot\"\n | \"cross\"\n | \"cross-open\"\n | \"cross-dot\"\n | \"cross-open-dot\"\n | \"x\"\n | \"x-open\"\n | \"x-dot\"\n | \"x-open-dot\"\n | \"triangle-up\"\n | \"triangle-up-open\"\n | \"triangle-up-dot\"\n | \"triangle-up-open-dot\"\n | \"triangle-down\"\n | \"triangle-down-open\"\n | \"triangle-down-dot\"\n | \"triangle-down-open-dot\"\n | \"triangle-left\"\n | \"triangle-left-open\"\n | \"triangle-left-dot\"\n | \"triangle-left-open-dot\"\n | \"triangle-right\"\n | \"triangle-right-open\"\n | \"triangle-right-dot\"\n | \"triangle-right-open-dot\"\n | \"triangle-ne\"\n | \"triangle-ne-open\"\n | \"triangle-ne-dot\"\n | \"triangle-ne-open-dot\"\n | \"triangle-se\"\n | \"triangle-se-open\"\n | \"triangle-se-dot\"\n | \"triangle-se-open-dot\"\n | \"triangle-sw\"\n | \"triangle-sw-open\"\n | \"triangle-sw-dot\"\n | \"triangle-sw-open-dot\"\n | \"triangle-nw\"\n | \"triangle-nw-open\"\n | \"triangle-nw-dot\"\n | \"triangle-nw-open-dot\"\n | \"pentagon\"\n | \"pentagon-open\"\n | \"pentagon-dot\"\n | \"pentagon-open-dot\"\n | \"hexagon\"\n | \"hexagon-open\"\n | \"hexagon-dot\"\n | \"hexagon-open-dot\"\n | \"hexagon2\"\n | \"hexagon2-open\"\n | \"hexagon2-dot\"\n | \"hexagon2-open-dot\"\n | \"octagon\"\n | \"octagon-open\"\n | \"octagon-dot\"\n | \"octagon-open-dot\"\n | \"star\"\n | \"star-open\"\n | \"star-dot\"\n | \"star-open-dot\"\n | \"hexagram\"\n | \"hexagram-open\"\n | \"hexagram-dot\"\n | \"hexagram-open-dot\"\n | \"star-triangle-up\"\n | \"star-triangle-up-open\"\n | \"star-triangle-up-dot\"\n | \"star-triangle-up-open-dot\"\n | \"star-triangle-down\"\n | \"star-triangle-down-open\"\n | \"star-triangle-down-dot\"\n | \"star-triangle-down-open-dot\"\n | \"star-square\"\n | \"star-square-open\"\n | \"star-square-dot\"\n | \"star-square-open-dot\"\n | \"star-diamond\"\n | \"star-diamond-open\"\n | \"star-diamond-dot\"\n | \"star-diamond-open-dot\"\n | \"diamond-tall\"\n | \"diamond-tall-open\"\n | \"diamond-tall-dot\"\n | \"diamond-tall-open-dot\"\n | \"diamond-wide\"\n | \"diamond-wide-open\"\n | \"diamond-wide-dot\"\n | \"diamond-wide-open-dot\"\n | \"hourglass\"\n | \"hourglass-open\"\n | \"bowtie\"\n | \"bowtie-open\"\n | \"circle-cross\"\n | \"circle-cross-open\"\n | \"circle-x\"\n | \"circle-x-open\"\n | \"square-cross\"\n | \"square-cross-open\"\n | \"square-x\"\n | \"square-x-open\"\n | \"diamond-cross\"\n | \"diamond-cross-open\"\n | \"diamond-x\"\n | \"diamond-x-open\"\n | \"cross-thin\"\n | \"cross-thin-open\"\n | \"x-thin\"\n | \"x-thin-open\"\n | \"asterisk\"\n | \"asterisk-open\"\n | \"hash\"\n | \"hash-open\"\n | \"hash-dot\"\n | \"hash-open-dot\"\n | \"y-up\"\n | \"y-up-open\"\n | \"y-down\"\n | \"y-down-open\"\n | \"y-left\"\n | \"y-left-open\"\n | \"y-right\"\n | \"y-right-open\"\n | \"line-ew\"\n | \"line-ew-open\"\n | \"line-ns\"\n | \"line-ns-open\"\n | \"line-ne\"\n | \"line-ne-open\"\n | \"line-nw\"\n | \"line-nw-open\"\n | \"arrow\"\n | \"arrow-open\"\n | \"arrow-wide\"\n | \"arrow-wide-open\";\n\ninterface LineDataSeries {\n x: number[];\n y: number[];\n name: string;\n /** Optional color override (auto-assigned from CHART_COLORS if not provided) */\n color?: string;\n symbol?: MarkerSymbol;\n error_y?: {\n type: \"data\";\n array: number[];\n visible: boolean;\n };\n}\n\ntype LineGraphVariant = \"lines\" | \"lines+markers\" | \"lines+markers+error_bars\";\n\ntype LineGraphProps = {\n dataSeries: LineDataSeries[];\n width?: number;\n height?: number;\n xRange?: [number, number];\n yRange?: [number, number];\n variant?: LineGraphVariant;\n xTitle?: string;\n yTitle?: string;\n title?: string;\n};\n\nconst LineGraph: React.FC<LineGraphProps> = ({\n dataSeries,\n width = 1000,\n height = 600,\n xRange,\n yRange,\n variant = \"lines\",\n xTitle = \"Columns\",\n yTitle = \"Rows\",\n title = \"Line Graph\",\n}) => {\n const plotRef = useRef<HTMLDivElement>(null);\n const theme = usePlotlyTheme();\n const { bindTooltip, tooltipElement } = useChartTooltip({ xLabel: xTitle, yLabel: yTitle });\n\n const { yMin, yMax } = useMemo(() => {\n let minX = Number.MAX_VALUE;\n let maxX = Number.MIN_VALUE;\n let minY = Number.MAX_VALUE;\n let maxY = Number.MIN_VALUE;\n\n dataSeries.forEach((series) => {\n series.x.forEach((x) => {\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n });\n series.y.forEach((y) => {\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n });\n });\n\n const xPadding = (maxX - minX) * 0.1;\n const yPadding = (maxY - minY) * 0.1;\n\n return {\n xMin: minX - xPadding,\n xMax: maxX + xPadding,\n yMin: minY - yPadding,\n yMax: maxY + yPadding,\n };\n }, [dataSeries]);\n\n const effectiveYRange = useMemo(\n () => yRange || [yMin, yMax],\n [yRange, yMin, yMax],\n );\n\n const yTicks = useMemo(() => {\n const range = effectiveYRange[1] - effectiveYRange[0];\n let step = Math.pow(10, Math.floor(Math.log10(range)));\n\n if (range / step > 10) step = step * 2;\n if (range / step < 4) step = step / 2;\n\n const ticks = [];\n let current = Math.ceil(effectiveYRange[0] / step) * step;\n while (current <= effectiveYRange[1]) {\n ticks.push(current);\n current += step;\n }\n return ticks;\n }, [effectiveYRange]);\n\n const xTicks = useMemo(\n () => [...new Set(dataSeries.flatMap((s) => s.x))],\n [dataSeries],\n );\n\n const mode = useMemo((): \"lines\" | \"lines+markers\" => {\n switch (variant) {\n case \"lines+markers\":\n case \"lines+markers+error_bars\":\n return \"lines+markers\";\n default:\n return \"lines\";\n }\n }, [variant]);\n\n const tickOptions = useMemo(\n () => ({\n tickcolor: theme.tickColor,\n ticklen: 12,\n tickwidth: 1,\n ticks: \"outside\" as const,\n tickfont: {\n size: 16,\n color: theme.textColor,\n family: \"Inter, sans-serif\",\n weight: 400,\n },\n linecolor: theme.lineColor,\n linewidth: 1,\n position: 0,\n zeroline: false,\n }),\n [theme],\n );\n\n useEffect(() => {\n if (!plotRef.current) return;\n\n const plotData = dataSeries.map((series, index) => {\n const color = seriesColor(index, series.color);\n return {\n x: series.x,\n y: series.y,\n type: \"scatter\" as const,\n mode: mode,\n name: series.name,\n hoverinfo: \"none\" as const,\n line: {\n color,\n width: 1.5,\n },\n marker:\n variant === \"lines\"\n ? { opacity: 0 }\n : {\n color,\n size: 8,\n symbol: series.symbol || \"triangle-up\",\n },\n error_y:\n variant === \"lines+markers+error_bars\"\n ? series.error_y || {\n type: \"data\" as const,\n array: series.y.map(() => 10),\n visible: true,\n color,\n thickness: 1,\n width: 5,\n }\n : undefined,\n };\n });\n\n const layout = {\n title: {\n text: title,\n font: {\n size: 32,\n family: \"Inter, sans-serif\",\n color: theme.textColor,\n },\n },\n width,\n height,\n margin: { l: 80, r: 30, b: 80, t: 60, pad: 10 },\n paper_bgcolor: theme.paperBg,\n plot_bgcolor: theme.plotBg,\n font: {\n family: \"Inter, sans-serif\",\n },\n dragmode: false as const,\n xaxis: {\n title: {\n text: xTitle,\n font: {\n size: 16,\n color: theme.textSecondary,\n family: \"Inter, sans-serif\",\n weight: 400,\n },\n standoff: 32,\n },\n gridcolor: theme.gridColor,\n range: xRange,\n autorange: !xRange,\n tickmode: \"array\" as const,\n tickvals: xTicks,\n ticktext: xTicks.map(String),\n showgrid: true,\n ...tickOptions,\n },\n yaxis: {\n title: {\n text: yTitle,\n font: {\n size: 16,\n color: theme.textSecondary,\n family: \"Inter, sans-serif\",\n weight: 400,\n },\n standoff: 30,\n },\n gridcolor: theme.gridColor,\n range: yRange,\n autorange: !yRange,\n tickmode: \"array\" as const,\n tickvals: yTicks,\n showgrid: true,\n ...tickOptions,\n },\n legend: {\n x: 0.5,\n y: -0.2,\n xanchor: \"center\" as const,\n yanchor: \"top\" as const,\n orientation: \"h\" as const,\n font: {\n size: 16,\n color: theme.legendColor,\n family: \"Inter, sans-serif\",\n weight: 500,\n },\n },\n showlegend: true,\n };\n\n const config = {\n responsive: true,\n displayModeBar: false,\n displaylogo: false,\n };\n\n Plotly.newPlot(plotRef.current, plotData, layout, config);\n bindTooltip(plotRef.current);\n\n // Capture ref value for cleanup\n const plotElement = plotRef.current;\n\n return () => {\n if (plotElement) {\n Plotly.purge(plotElement);\n }\n };\n }, [dataSeries, width, height, xRange, yRange, xTitle, yTitle, title, mode, tickOptions, xTicks, yTicks, effectiveYRange, variant, theme, bindTooltip]);\n\n return (\n <div className=\"chart-container relative\">\n <div ref={plotRef} style={{ width: \"100%\", height: \"100%\" }} />\n {tooltipElement}\n </div>\n );\n};\n\nexport { LineGraph };\nexport type { LineDataSeries, LineGraphVariant, LineGraphProps, MarkerSymbol };\n"],"names":["LineGraph","dataSeries","width","height","xRange","yRange","variant","xTitle","yTitle","title","plotRef","useRef","theme","usePlotlyTheme","bindTooltip","tooltipElement","useChartTooltip","yMin","yMax","useMemo","minX","maxX","minY","maxY","series","x","y","xPadding","yPadding","effectiveYRange","yTicks","range","step","ticks","current","xTicks","s","mode","tickOptions","useEffect","plotData","index","color","seriesColor","layout","config","Plotly","plotElement","jsxs","jsx"],"mappings":";;;;;;AAwLA,MAAMA,IAAsC,CAAC;AAAA,EAC3C,YAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,QAAAC,IAAS;AAAA,EACT,QAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,QAAAC,IAAS;AAAA,EACT,QAAAC,IAAS;AAAA,EACT,OAAAC,IAAQ;AACV,MAAM;AACJ,QAAMC,IAAUC,EAAuB,IAAI,GACrCC,IAAQC,EAAA,GACR,EAAE,aAAAC,GAAa,gBAAAC,EAAA,IAAmBC,EAAgB,EAAE,QAAQT,GAAQ,QAAQC,GAAQ,GAEpF,EAAE,MAAAS,GAAM,MAAAC,EAAA,IAASC,EAAQ,MAAM;AACnC,QAAIC,IAAO,OAAO,WACdC,IAAO,OAAO,WACdC,IAAO,OAAO,WACdC,IAAO,OAAO;AAElB,IAAAtB,EAAW,QAAQ,CAACuB,MAAW;AAC7B,MAAAA,EAAO,E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AAAA,QACb,MAAM;AAAA,UACJ,MAAM;AAAA,UACN,OAAO1B,EAAM;AAAA,UACb,QAAQ;AAAA,UACR,QAAQ;AAAA,QAAA;AAAA,MACV;AAAA,MAEF,YAAY;AAAA,IAAA,GAGRiC,IAAS;AAAA,MACb,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,aAAa;AAAA,IAAA;AAGf,IAAAC,EAAO,QAAQpC,EAAQ,SAAS8B,GAAUI,GAAQC,CAAM,GACxD/B,EAAYJ,EAAQ,OAAO;AAG3B,UAAMqC,IAAcrC,EAAQ;AAE5B,WAAO,MAAM;AACX,MAAIqC,KACFD,EAAO,MAAMC,CAAW;AAAA,IAE5B;AAAA,EACF,GAAG,CAAC9C,GAAYC,GAAOC,GAAQC,GAAQC,GAAQE,GAAQC,GAAQC,GAAO4B,GAAMC,GAAaH,GAAQL,GAAQD,GAAiBvB,GAASM,GAAOE,CAAW,CAAC,GAGpJ,gBAAAkC,EAAC,OAAA,EAAI,WAAU,4BACb,UAAA;AAAA,IAAA,gBAAAC,EAAC,OAAA,EAAI,KAAKvC,GAAS,OAAO,EAAE,OAAO,QAAQ,QAAQ,OAAA,EAAO,CAAG;AAAA,IAC5DK;AAAA,EAAA,GACH;AAEJ;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),R=require("plotly.js-dist"),u=require("react"),y=require("../../../hooks/use-plotly-theme.cjs"),t=require("../../../utils/colors.cjs"),b=[t.COLORS.BLUE,t.COLORS.GREEN,t.COLORS.ORANGE,t.COLORS.RED,t.COLORS.YELLOW,t.COLORS.PURPLE],C=({dataSeries:e,width:m=400,height:h=400,title:f="Pie Chart",textInfo:p="percent",hole:x=0,rotation:O=0})=>{const i=u.useRef(null),a=y.usePlotlyTheme(),g=u.useMemo(()=>{if(e.colors&&e.colors.length>=e.labels.length)return e.colors;const s=[...e.colors||[]],r=e.labels.length-s.length;if(r<=0)return s;for(let n=0;n<r;n++)s.push(b[n%b.length]);return s},[e.colors,e.labels.length]);u.useEffect(()=>{if(!i.current)return;const s=[{type:"pie",labels:e.labels,values:e.values,name:e.name,marker:{colors:g},textinfo:p,hoverinfo:"label+text+value",insidetextfont:{size:0,family:"Inter, sans-serif",color:"transparent"},hole:x,rotation:O}],r={width:m,height:h,font:{family:"Inter, sans-serif",color:a.textColor},showlegend:!1,margin:{l:40,r:40,b:40,t:40},paper_bgcolor:a.paperBg,plot_bgcolor:a.plotBg},n={responsive:!0,displayModeBar:!1,displaylogo:!1};R.newPlot(i.current,s,r,n);const c=i.current;return()=>{c&&R.purge(c)}},[g,e.labels,e.name,e.values,m,h,p,x,O,a]);const j=({labels:s,colors:r})=>{const n=s.map((o,v)=>l.jsx(u.Fragment,{children:l.jsxs("div",{className:"legend-item",children:[l.jsx("span",{className:"color-box",style:{background:r[v]}}),o,v<s.length-1&&l.jsx("span",{className:"divider"})]})},o)),c=6,d=[];for(let o=0;o<n.length;o+=c)d.push(l.jsx("div",{className:"legend-row",children:n.slice(o,o+c)},o));return l.jsx("div",{className:"legend-container",children:d})};return l.jsx("div",{className:"card-container",style:{width:m},children:l.jsxs("div",{className:"chart-container",children:[f&&l.jsx("div",{className:"title-container",children:l.jsx("h2",{className:"title",children:f})}),l.jsx("div",{ref:i,style:{width:"100%",height:"100%",margin:"0"}}),l.jsx(j,{labels:e.labels,colors:g})]})})};exports.PieChart=C;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),j=require("plotly.js-dist"),a=require("react"),P=require("../ChartTooltip/ChartTooltip.cjs"),T=require("../../../hooks/use-plotly-theme.cjs"),R=require("../../../utils/colors.cjs"),y=R.CHART_COLORS,q=({dataSeries:e,width:u=400,height:h=400,title:g="Pie Chart",textInfo:p="percent",hole:f=0,rotation:d=0})=>{const t=a.useRef(null),i=T.usePlotlyTheme(),{bindTooltip:x,tooltipElement:C}=P.useChartTooltip({followCursor:!0}),m=a.useMemo(()=>{if(e.colors&&e.colors.length>=e.labels.length)return e.colors;const s=[...e.colors||[]],r=e.labels.length-s.length;if(r<=0)return s;for(let o=0;o<r;o++)s.push(y[o%y.length]);return s},[e.colors,e.labels.length]);a.useEffect(()=>{if(!t.current)return;const s=[{type:"pie",labels:e.labels,values:e.values,name:e.name,marker:{colors:m},textinfo:p,hoverinfo:"none",insidetextfont:{size:0,family:"Inter, sans-serif",color:"transparent"},hole:f,rotation:d}],r={width:u,height:h,font:{family:"Inter, sans-serif",color:i.textColor},showlegend:!1,margin:{l:40,r:40,b:40,t:40},paper_bgcolor:i.paperBg,plot_bgcolor:i.plotBg},o={responsive:!0,displayModeBar:!1,displaylogo:!1};j.newPlot(t.current,s,r,o),x(t.current);const c=t.current;return()=>{c&&j.purge(c)}},[m,e.labels,e.name,e.values,u,h,p,f,d,i,x]);const N=({labels:s,colors:r})=>{const o=s.map((n,b)=>l.jsx(a.Fragment,{children:l.jsxs("div",{className:"legend-item",children:[l.jsx("span",{className:"color-box",style:{background:r[b]}}),n,b<s.length-1&&l.jsx("span",{className:"divider"})]})},n)),c=6,v=[];for(let n=0;n<o.length;n+=c)v.push(l.jsx("div",{className:"legend-row",children:o.slice(n,n+c)},n));return l.jsx("div",{className:"legend-container",children:v})};return l.jsxs("div",{className:"card-container relative",style:{width:u},children:[l.jsxs("div",{className:"chart-container",children:[g&&l.jsx("div",{className:"title-container",children:l.jsx("h2",{className:"title",children:g})}),l.jsx("div",{ref:t,style:{width:"100%",height:"100%",margin:"0"}}),l.jsx(N,{labels:e.labels,colors:m})]}),C]})};exports.PieChart=q;
2
2
  //# sourceMappingURL=PieChart.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PieChart.cjs","sources":["../../../../src/components/charts/PieChart/PieChart.tsx"],"sourcesContent":["import Plotly from \"plotly.js-dist\";\nimport React, { useEffect, useRef, useMemo } from \"react\";\n\nimport { usePlotlyTheme } from \"@/hooks/use-plotly-theme\";\nimport { COLORS } from \"@/utils/colors\";\n\ninterface PieDataSeries {\n labels: string[];\n values: number[];\n name: string;\n colors?: string[];\n}\n\ntype PieTextInfo =\n | \"none\"\n | \"label\"\n | \"percent\"\n | \"value\"\n | \"label+percent\"\n | \"label+value\"\n | \"value+percent\"\n | \"label+value+percent\";\n\ntype PieChartProps = {\n dataSeries: PieDataSeries;\n width?: number;\n height?: number;\n title?: string;\n textInfo?: PieTextInfo;\n hole?: number;\n rotation?: number;\n};\n\nconst DEFAULT_COLORS = [\n COLORS.BLUE,\n COLORS.GREEN,\n COLORS.ORANGE,\n COLORS.RED,\n COLORS.YELLOW,\n COLORS.PURPLE,\n];\n\nconst PieChart: React.FC<PieChartProps> = ({\n dataSeries,\n width = 400,\n height = 400,\n title = \"Pie Chart\",\n textInfo = \"percent\",\n hole = 0,\n rotation = 0,\n}) => {\n const plotRef = useRef<HTMLDivElement>(null);\n const theme = usePlotlyTheme();\n\n const colors = useMemo(() => {\n if (\n dataSeries.colors &&\n dataSeries.colors.length >= dataSeries.labels.length\n ) {\n return dataSeries.colors;\n }\n\n const result = [...(dataSeries.colors || [])];\n const missingColors = dataSeries.labels.length - result.length;\n\n if (missingColors <= 0) return result;\n\n for (let i = 0; i < missingColors; i++) {\n result.push(DEFAULT_COLORS[i % DEFAULT_COLORS.length]);\n }\n\n return result;\n }, [dataSeries.colors, dataSeries.labels.length]);\n\n useEffect(() => {\n if (!plotRef.current) return;\n\n const plotData = [\n {\n type: \"pie\" as const,\n labels: dataSeries.labels,\n values: dataSeries.values,\n name: dataSeries.name,\n marker: {\n colors: colors,\n },\n textinfo: textInfo,\n hoverinfo: \"label+text+value\" as const,\n insidetextfont: {\n size: 0,\n family: \"Inter, sans-serif\",\n color: \"transparent\",\n },\n hole: hole,\n rotation: rotation,\n },\n ];\n\n const layout = {\n width,\n height,\n font: {\n family: \"Inter, sans-serif\",\n color: theme.textColor,\n },\n showlegend: false,\n margin: { l: 40, r: 40, b: 40, t: 40 },\n paper_bgcolor: theme.paperBg,\n plot_bgcolor: theme.plotBg,\n };\n\n const config = {\n responsive: true,\n displayModeBar: false,\n displaylogo: false,\n };\n\n Plotly.newPlot(plotRef.current, plotData, layout, config);\n\n // Capture ref value for cleanup\n const plotElement = plotRef.current;\n\n return () => {\n if (plotElement) {\n Plotly.purge(plotElement);\n }\n };\n }, [colors, dataSeries.labels, dataSeries.name, dataSeries.values, width, height, textInfo, hole, rotation, theme]);\n\n const PieChartLegend: React.FC<{ labels: string[]; colors: string[] }> = ({\n labels,\n colors,\n }) => {\n const items = labels.map((label, i) => (\n <React.Fragment key={label}>\n <div className=\"legend-item\">\n <span className=\"color-box\" style={{ background: colors[i] }} />\n {label}\n {i < labels.length - 1 && <span className=\"divider\" />}\n </div>\n </React.Fragment>\n ));\n\n const rowSize = 6;\n const rows = [];\n for (let i = 0; i < items.length; i += rowSize) {\n rows.push(\n <div className=\"legend-row\" key={i}>\n {items.slice(i, i + rowSize)}\n </div>\n );\n }\n return <div className=\"legend-container\">{rows}</div>;\n };\n\n return (\n <div className=\"card-container\" style={{ width: width }}>\n <div className=\"chart-container\">\n {title && (\n <div className=\"title-container\">\n <h2 className=\"title\">{title}</h2>\n </div>\n )}\n <div\n ref={plotRef}\n style={{\n width: \"100%\",\n height: \"100%\",\n margin: \"0\",\n }}\n />\n <PieChartLegend labels={dataSeries.labels} colors={colors} />\n </div>\n </div>\n );\n};\n\nexport { PieChart };\nexport type { PieDataSeries, PieTextInfo, PieChartProps };\n"],"names":["DEFAULT_COLORS","COLORS","PieChart","dataSeries","width","height","title","textInfo","hole","rotation","plotRef","useRef","theme","usePlotlyTheme","colors","useMemo","result","missingColors","i","useEffect","plotData","layout","config","Plotly","plotElement","PieChartLegend","labels","items","label","jsx","React","jsxs","rowSize","rows"],"mappings":"4PAiCMA,EAAiB,CACrBC,EAAAA,OAAO,KACPA,EAAAA,OAAO,MACPA,EAAAA,OAAO,OACPA,EAAAA,OAAO,IACPA,EAAAA,OAAO,OACPA,SAAO,MACT,EAEMC,EAAoC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FmB,EAAAA,IAACJ,EAAA,CAAe,OAAQtB,EAAW,OAAQ,OAAAW,CAAA,CAAgB,CAAA,CAAA,CAC7D,CAAA,CACF,CAEJ"}
1
+ {"version":3,"file":"PieChart.cjs","sources":["../../../../src/components/charts/PieChart/PieChart.tsx"],"sourcesContent":["import Plotly from \"plotly.js-dist\";\nimport React, { useEffect, useRef, useMemo } from \"react\";\n\nimport { useChartTooltip } from \"../ChartTooltip\";\n\nimport { usePlotlyTheme } from \"@/hooks/use-plotly-theme\";\nimport { CHART_COLORS } from \"@/utils/colors\";\n\ninterface PieDataSeries {\n labels: string[];\n values: number[];\n name: string;\n colors?: string[];\n}\n\ntype PieTextInfo =\n | \"none\"\n | \"label\"\n | \"percent\"\n | \"value\"\n | \"label+percent\"\n | \"label+value\"\n | \"value+percent\"\n | \"label+value+percent\";\n\ntype PieChartProps = {\n dataSeries: PieDataSeries;\n width?: number;\n height?: number;\n title?: string;\n textInfo?: PieTextInfo;\n hole?: number;\n rotation?: number;\n};\n\nconst DEFAULT_COLORS = CHART_COLORS;\n\nconst PieChart: React.FC<PieChartProps> = ({\n dataSeries,\n width = 400,\n height = 400,\n title = \"Pie Chart\",\n textInfo = \"percent\",\n hole = 0,\n rotation = 0,\n}) => {\n const plotRef = useRef<HTMLDivElement>(null);\n const theme = usePlotlyTheme();\n // Slices are large hover targets, so the tooltip tracks the cursor (clamped\n // to the viewport) rather than pinning to the slice centroid\n const { bindTooltip, tooltipElement } = useChartTooltip({ followCursor: true });\n\n const colors = useMemo(() => {\n if (\n dataSeries.colors &&\n dataSeries.colors.length >= dataSeries.labels.length\n ) {\n return dataSeries.colors;\n }\n\n const result = [...(dataSeries.colors || [])];\n const missingColors = dataSeries.labels.length - result.length;\n\n if (missingColors <= 0) return result;\n\n for (let i = 0; i < missingColors; i++) {\n result.push(DEFAULT_COLORS[i % DEFAULT_COLORS.length]);\n }\n\n return result;\n }, [dataSeries.colors, dataSeries.labels.length]);\n\n useEffect(() => {\n if (!plotRef.current) return;\n\n const plotData = [\n {\n type: \"pie\" as const,\n labels: dataSeries.labels,\n values: dataSeries.values,\n name: dataSeries.name,\n marker: {\n colors: colors,\n },\n textinfo: textInfo,\n hoverinfo: \"none\" as const,\n insidetextfont: {\n size: 0,\n family: \"Inter, sans-serif\",\n color: \"transparent\",\n },\n hole: hole,\n rotation: rotation,\n },\n ];\n\n const layout = {\n width,\n height,\n font: {\n family: \"Inter, sans-serif\",\n color: theme.textColor,\n },\n showlegend: false,\n margin: { l: 40, r: 40, b: 40, t: 40 },\n paper_bgcolor: theme.paperBg,\n plot_bgcolor: theme.plotBg,\n };\n\n const config = {\n responsive: true,\n displayModeBar: false,\n displaylogo: false,\n };\n\n Plotly.newPlot(plotRef.current, plotData, layout, config);\n bindTooltip(plotRef.current);\n\n // Capture ref value for cleanup\n const plotElement = plotRef.current;\n\n return () => {\n if (plotElement) {\n Plotly.purge(plotElement);\n }\n };\n }, [colors, dataSeries.labels, dataSeries.name, dataSeries.values, width, height, textInfo, hole, rotation, theme, bindTooltip]);\n\n const PieChartLegend: React.FC<{ labels: string[]; colors: string[] }> = ({\n labels,\n colors,\n }) => {\n const items = labels.map((label, i) => (\n <React.Fragment key={label}>\n <div className=\"legend-item\">\n <span className=\"color-box\" style={{ background: colors[i] }} />\n {label}\n {i < labels.length - 1 && <span className=\"divider\" />}\n </div>\n </React.Fragment>\n ));\n\n const rowSize = 6;\n const rows = [];\n for (let i = 0; i < items.length; i += rowSize) {\n rows.push(\n <div className=\"legend-row\" key={i}>\n {items.slice(i, i + rowSize)}\n </div>\n );\n }\n return <div className=\"legend-container\">{rows}</div>;\n };\n\n return (\n <div className=\"card-container relative\" style={{ width: width }}>\n <div className=\"chart-container\">\n {title && (\n <div className=\"title-container\">\n <h2 className=\"title\">{title}</h2>\n </div>\n )}\n <div\n ref={plotRef}\n style={{\n width: \"100%\",\n height: \"100%\",\n margin: \"0\",\n }}\n />\n <PieChartLegend labels={dataSeries.labels} colors={colors} />\n </div>\n {tooltipElement}\n </div>\n );\n};\n\nexport { PieChart };\nexport type { PieDataSeries, PieTextInfo, PieChartProps };\n"],"names":["DEFAULT_COLORS","CHART_COLORS","PieChart","dataSeries","width","height","title","textInfo","hole","rotation","plotRef","useRef","theme","usePlotlyTheme","bindTooltip","tooltipElement","useChartTooltip","colors","useMemo","result","missingColors","i","useEffect","plotData","layout","config","Plotly","plotElement","PieChartLegend","labels","items","label","jsx","React","jsxs","rowSize","rows"],"mappings":"0SAmCMA,EAAiBC,EAAAA,aAEjBC,EAAoC,CAAC,CACzC,WAAAC,EACA,MAAAC,EAAQ,IACR,OAAAC,EAAS,IACT,MAAAC,EAAQ,YACR,SAAAC,EAAW,UACX,KAAAC,EAAO,EACP,SAAAC,EAAW,CACb,IAAM,CACJ,MAAMC,EAAUC,EAAAA,OAAuB,IAAI,EACrCC,EAAQC,EAAAA,eAAA,EAGR,CAAE,YAAAC,EAAa,eAAAC,CAAA,EAAmBC,EAAAA,gBAAgB,CAAE,aAAc,GAAM,EAExEC,EAASC,EAAAA,QAAQ,IAAM,CAC3B,GACEf,EAAW,QACXA,EAAW,OAAO,QAAUA,EAAW,OAAO,OAE9C,OAAOA,EAAW,OAGpB,MAAMgB,EAAS,CAAC,GAAIhB,EAAW,QAAU,CAAA,CAAG,EACtCiB,EAAgBjB,EAAW,OAAO,OAASgB,EAAO,OAExD,GAAIC,GAAiB,EAAG,OAAOD,EAE/B,QAASE,EAAI,EAAGA,EAAID,EAAeC,IACjCF,EAAO,KAAKnB,EAAeqB,EAAIrB,EAAe,MAAM,CAAC,EAGvD,OAAOmB,CACT,EAAG,CAAChB,EAAW,OAAQA,EAAW,OAAO,MAAM,CAAC,EAEhDmB,EAAAA,UAAU,IAAM,CACd,GAAI,CAACZ,EAAQ,QAAS,OAEtB,MAAMa,EAAW,CACf,CACE,KAAM,MACN,OAAQpB,EAAW,OACnB,OAAQA,EAAW,OACnB,KAAMA,EAAW,KACjB,OAAQ,CACN,OAAAc,CAAA,EAEF,SAAUV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CAAO,CAAA,EADId,CAEjC,CAAA,EAGJ,OAAOW,EAAAA,IAAC,MAAA,CAAI,UAAU,mBAAoB,SAAAI,EAAK,CACjD,EAEA,cACG,MAAA,CAAI,UAAU,0BAA0B,MAAO,CAAE,MAAAhC,GAChD,SAAA,CAAA8B,EAAAA,KAAC,MAAA,CAAI,UAAU,kBACZ,SAAA,CAAA5B,GACC0B,EAAAA,IAAC,OAAI,UAAU,kBACb,eAAC,KAAA,CAAG,UAAU,QAAS,SAAA1B,CAAA,CAAM,CAAA,CAC/B,EAEF0B,EAAAA,IAAC,MAAA,CACC,IAAKtB,EACL,MAAO,CACL,MAAO,OACP,OAAQ,OACR,OAAQ,GAAA,CACV,CAAA,EAEFsB,EAAAA,IAACJ,EAAA,CAAe,OAAQzB,EAAW,OAAQ,OAAAc,CAAA,CAAgB,CAAA,EAC7D,EACCF,CAAA,EACH,CAEJ"}
@@ -1,106 +1,103 @@
1
- import { jsx as l, jsxs as y } from "react/jsx-runtime";
2
- import N from "plotly.js-dist";
3
- import L, { useRef as P, useMemo as R, useEffect as C } from "react";
4
- import { usePlotlyTheme as x } from "../../../hooks/use-plotly-theme.js";
5
- import { COLORS as t } from "../../../utils/colors.js";
6
- const E = [
7
- t.BLUE,
8
- t.GREEN,
9
- t.ORANGE,
10
- t.RED,
11
- t.YELLOW,
12
- t.PURPLE
13
- ], j = ({
1
+ import { jsxs as p, jsx as o } from "react/jsx-runtime";
2
+ import C from "plotly.js-dist";
3
+ import x, { useRef as R, useMemo as _, useEffect as w } from "react";
4
+ import { useChartTooltip as L } from "../ChartTooltip/ChartTooltip.js";
5
+ import { usePlotlyTheme as T } from "../../../hooks/use-plotly-theme.js";
6
+ import { CHART_COLORS as E } from "../../../utils/colors.js";
7
+ const N = E, F = ({
14
8
  dataSeries: e,
15
- width: m = 400,
16
- height: p = 400,
9
+ width: a = 400,
10
+ height: f = 400,
17
11
  title: u = "Pie Chart",
18
- textInfo: g = "percent",
19
- hole: h = 0,
12
+ textInfo: h = "percent",
13
+ hole: g = 0,
20
14
  rotation: d = 0
21
15
  }) => {
22
- const i = P(null), a = x(), f = R(() => {
16
+ const s = R(null), i = T(), { bindTooltip: v, tooltipElement: P } = L({ followCursor: !0 }), m = _(() => {
23
17
  if (e.colors && e.colors.length >= e.labels.length)
24
18
  return e.colors;
25
- const o = [...e.colors || []], s = e.labels.length - o.length;
26
- if (s <= 0) return o;
27
- for (let n = 0; n < s; n++)
28
- o.push(E[n % E.length]);
29
- return o;
19
+ const l = [...e.colors || []], t = e.labels.length - l.length;
20
+ if (t <= 0) return l;
21
+ for (let n = 0; n < t; n++)
22
+ l.push(N[n % N.length]);
23
+ return l;
30
24
  }, [e.colors, e.labels.length]);
31
- return C(() => {
32
- if (!i.current) return;
33
- const o = [
25
+ return w(() => {
26
+ if (!s.current) return;
27
+ const l = [
34
28
  {
35
29
  type: "pie",
36
30
  labels: e.labels,
37
31
  values: e.values,
38
32
  name: e.name,
39
33
  marker: {
40
- colors: f
34
+ colors: m
41
35
  },
42
- textinfo: g,
43
- hoverinfo: "label+text+value",
36
+ textinfo: h,
37
+ hoverinfo: "none",
44
38
  insidetextfont: {
45
39
  size: 0,
46
40
  family: "Inter, sans-serif",
47
41
  color: "transparent"
48
42
  },
49
- hole: h,
43
+ hole: g,
50
44
  rotation: d
51
45
  }
52
- ], s = {
53
- width: m,
54
- height: p,
46
+ ], t = {
47
+ width: a,
48
+ height: f,
55
49
  font: {
56
50
  family: "Inter, sans-serif",
57
- color: a.textColor
51
+ color: i.textColor
58
52
  },
59
53
  showlegend: !1,
60
54
  margin: { l: 40, r: 40, b: 40, t: 40 },
61
- paper_bgcolor: a.paperBg,
62
- plot_bgcolor: a.plotBg
55
+ paper_bgcolor: i.paperBg,
56
+ plot_bgcolor: i.plotBg
63
57
  }, n = {
64
58
  responsive: !0,
65
59
  displayModeBar: !1,
66
60
  displaylogo: !1
67
61
  };
68
- N.newPlot(i.current, o, s, n);
69
- const c = i.current;
62
+ C.newPlot(s.current, l, t, n), v(s.current);
63
+ const c = s.current;
70
64
  return () => {
71
- c && N.purge(c);
65
+ c && C.purge(c);
72
66
  };
73
- }, [f, e.labels, e.name, e.values, m, p, g, h, d, a]), /* @__PURE__ */ l("div", { className: "card-container", style: { width: m }, children: /* @__PURE__ */ y("div", { className: "chart-container", children: [
74
- u && /* @__PURE__ */ l("div", { className: "title-container", children: /* @__PURE__ */ l("h2", { className: "title", children: u }) }),
75
- /* @__PURE__ */ l(
76
- "div",
77
- {
78
- ref: i,
79
- style: {
80
- width: "100%",
81
- height: "100%",
82
- margin: "0"
67
+ }, [m, e.labels, e.name, e.values, a, f, h, g, d, i, v]), /* @__PURE__ */ p("div", { className: "card-container relative", style: { width: a }, children: [
68
+ /* @__PURE__ */ p("div", { className: "chart-container", children: [
69
+ u && /* @__PURE__ */ o("div", { className: "title-container", children: /* @__PURE__ */ o("h2", { className: "title", children: u }) }),
70
+ /* @__PURE__ */ o(
71
+ "div",
72
+ {
73
+ ref: s,
74
+ style: {
75
+ width: "100%",
76
+ height: "100%",
77
+ margin: "0"
78
+ }
83
79
  }
84
- }
85
- ),
86
- /* @__PURE__ */ l(({
87
- labels: o,
88
- colors: s
89
- }) => {
90
- const n = o.map((r, b) => /* @__PURE__ */ l(L.Fragment, { children: /* @__PURE__ */ y("div", { className: "legend-item", children: [
91
- /* @__PURE__ */ l("span", { className: "color-box", style: { background: s[b] } }),
92
- r,
93
- b < o.length - 1 && /* @__PURE__ */ l("span", { className: "divider" })
94
- ] }) }, r)), c = 6, v = [];
95
- for (let r = 0; r < n.length; r += c)
96
- v.push(
97
- /* @__PURE__ */ l("div", { className: "legend-row", children: n.slice(r, r + c) }, r)
98
- );
99
- return /* @__PURE__ */ l("div", { className: "legend-container", children: v });
100
- }, { labels: e.labels, colors: f })
101
- ] }) });
80
+ ),
81
+ /* @__PURE__ */ o(({
82
+ labels: l,
83
+ colors: t
84
+ }) => {
85
+ const n = l.map((r, y) => /* @__PURE__ */ o(x.Fragment, { children: /* @__PURE__ */ p("div", { className: "legend-item", children: [
86
+ /* @__PURE__ */ o("span", { className: "color-box", style: { background: t[y] } }),
87
+ r,
88
+ y < l.length - 1 && /* @__PURE__ */ o("span", { className: "divider" })
89
+ ] }) }, r)), c = 6, b = [];
90
+ for (let r = 0; r < n.length; r += c)
91
+ b.push(
92
+ /* @__PURE__ */ o("div", { className: "legend-row", children: n.slice(r, r + c) }, r)
93
+ );
94
+ return /* @__PURE__ */ o("div", { className: "legend-container", children: b });
95
+ }, { labels: e.labels, colors: m })
96
+ ] }),
97
+ P
98
+ ] });
102
99
  };
103
100
  export {
104
- j as PieChart
101
+ F as PieChart
105
102
  };
106
103
  //# sourceMappingURL=PieChart.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PieChart.js","sources":["../../../../src/components/charts/PieChart/PieChart.tsx"],"sourcesContent":["import Plotly from \"plotly.js-dist\";\nimport React, { useEffect, useRef, useMemo } from \"react\";\n\nimport { usePlotlyTheme } from \"@/hooks/use-plotly-theme\";\nimport { COLORS } from \"@/utils/colors\";\n\ninterface PieDataSeries {\n labels: string[];\n values: number[];\n name: string;\n colors?: string[];\n}\n\ntype PieTextInfo =\n | \"none\"\n | \"label\"\n | \"percent\"\n | \"value\"\n | \"label+percent\"\n | \"label+value\"\n | \"value+percent\"\n | \"label+value+percent\";\n\ntype PieChartProps = {\n dataSeries: PieDataSeries;\n width?: number;\n height?: number;\n title?: string;\n textInfo?: PieTextInfo;\n hole?: number;\n rotation?: number;\n};\n\nconst DEFAULT_COLORS = [\n COLORS.BLUE,\n COLORS.GREEN,\n COLORS.ORANGE,\n COLORS.RED,\n COLORS.YELLOW,\n COLORS.PURPLE,\n];\n\nconst PieChart: React.FC<PieChartProps> = ({\n dataSeries,\n width = 400,\n height = 400,\n title = \"Pie Chart\",\n textInfo = \"percent\",\n hole = 0,\n rotation = 0,\n}) => {\n const plotRef = useRef<HTMLDivElement>(null);\n const theme = usePlotlyTheme();\n\n const colors = useMemo(() => {\n if (\n dataSeries.colors &&\n dataSeries.colors.length >= dataSeries.labels.length\n ) {\n return dataSeries.colors;\n }\n\n const result = [...(dataSeries.colors || [])];\n const missingColors = dataSeries.labels.length - result.length;\n\n if (missingColors <= 0) return result;\n\n for (let i = 0; i < missingColors; i++) {\n result.push(DEFAULT_COLORS[i % DEFAULT_COLORS.length]);\n }\n\n return result;\n }, [dataSeries.colors, dataSeries.labels.length]);\n\n useEffect(() => {\n if (!plotRef.current) return;\n\n const plotData = [\n {\n type: \"pie\" as const,\n labels: dataSeries.labels,\n values: dataSeries.values,\n name: dataSeries.name,\n marker: {\n colors: colors,\n },\n textinfo: textInfo,\n hoverinfo: \"label+text+value\" as const,\n insidetextfont: {\n size: 0,\n family: \"Inter, sans-serif\",\n color: \"transparent\",\n },\n hole: hole,\n rotation: rotation,\n },\n ];\n\n const layout = {\n width,\n height,\n font: {\n family: \"Inter, sans-serif\",\n color: theme.textColor,\n },\n showlegend: false,\n margin: { l: 40, r: 40, b: 40, t: 40 },\n paper_bgcolor: theme.paperBg,\n plot_bgcolor: theme.plotBg,\n };\n\n const config = {\n responsive: true,\n displayModeBar: false,\n displaylogo: false,\n };\n\n Plotly.newPlot(plotRef.current, plotData, layout, config);\n\n // Capture ref value for cleanup\n const plotElement = plotRef.current;\n\n return () => {\n if (plotElement) {\n Plotly.purge(plotElement);\n }\n };\n }, [colors, dataSeries.labels, dataSeries.name, dataSeries.values, width, height, textInfo, hole, rotation, theme]);\n\n const PieChartLegend: React.FC<{ labels: string[]; colors: string[] }> = ({\n labels,\n colors,\n }) => {\n const items = labels.map((label, i) => (\n <React.Fragment key={label}>\n <div className=\"legend-item\">\n <span className=\"color-box\" style={{ background: colors[i] }} />\n {label}\n {i < labels.length - 1 && <span className=\"divider\" />}\n </div>\n </React.Fragment>\n ));\n\n const rowSize = 6;\n const rows = [];\n for (let i = 0; i < items.length; i += rowSize) {\n rows.push(\n <div className=\"legend-row\" key={i}>\n {items.slice(i, i + rowSize)}\n </div>\n );\n }\n return <div className=\"legend-container\">{rows}</div>;\n };\n\n return (\n <div className=\"card-container\" style={{ width: width }}>\n <div className=\"chart-container\">\n {title && (\n <div className=\"title-container\">\n <h2 className=\"title\">{title}</h2>\n </div>\n )}\n <div\n ref={plotRef}\n style={{\n width: \"100%\",\n height: \"100%\",\n margin: \"0\",\n }}\n />\n <PieChartLegend labels={dataSeries.labels} colors={colors} />\n </div>\n </div>\n );\n};\n\nexport { PieChart };\nexport type { PieDataSeries, PieTextInfo, PieChartProps };\n"],"names":["DEFAULT_COLORS","COLORS","PieChart","dataSeries","width","height","title","textInfo","hole","rotation","plotRef","useRef","theme","usePlotlyTheme","colors","useMemo","result","missingColors","i","useEffect","plotData","layout","config","Plotly","plotElement","jsx","jsxs","labels","items","label","React","rowSize","rows"],"mappings":";;;;;AAiCA,MAAMA,IAAiB;AAAA,EACrBC,EAAO;AAAA,EACPA,EAAO;AAAA,EACPA,EAAO;AAAA,EACPA,EAAO;AAAA,EACPA,EAAO;AAAA,EACPA,EAAO;AACT,GAEMC,IAAoC,CAAC;AAAA,EACzC,YAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,QAAAC,IAAS;AAAA,EACT,OAAAC,IAAQ;AAAA,EACR,UAAAC,IAAW;AAAA,EACX,MAAAC,IAAO;AAAA,EACP,UAAAC,IAAW;AACb,MAAM;AACJ,QAAMC,IAAUC,EAAuB,IAAI,GACrCC,IAAQC,EAAA,GAERC,IAASC,EAAQ,MAAM;AAC3B,QACEZ,EAAW,UACXA,EAAW,OAAO,UAAUA,EAAW,OAAO;AAE9C,aAAOA,EAAW;AAGpB,UAAMa,IAAS,CAAC,GAAIb,EAAW,UAAU,CAAA,CAAG,GACtCc,IAAgBd,EAAW,OAAO,SAASa,EAAO;AAExD,QAAIC,KAAiB,EAAG,QAAOD;AAE/B,aAASE,IAAI,GAAGA,IAAID,GAAeC;AACjC,MAAAF,EAAO,KAAKhB,EAAekB,IAAIlB,EAAe,MAAM,CAAC;AAGvD,WAAOgB;AAAA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"plotly.js-dist\";\nimport React, { useEffect, useRef, useMemo } from \"react\";\n\nimport { useChartTooltip } from \"../ChartTooltip\";\n\nimport { usePlotlyTheme } from \"@/hooks/use-plotly-theme\";\nimport { CHART_COLORS } from \"@/utils/colors\";\n\ninterface PieDataSeries {\n labels: string[];\n values: number[];\n name: string;\n colors?: string[];\n}\n\ntype PieTextInfo =\n | \"none\"\n | \"label\"\n | \"percent\"\n | \"value\"\n | \"label+percent\"\n | \"label+value\"\n | \"value+percent\"\n | \"label+value+percent\";\n\ntype PieChartProps = {\n dataSeries: PieDataSeries;\n width?: number;\n height?: number;\n title?: string;\n textInfo?: PieTextInfo;\n hole?: number;\n rotation?: number;\n};\n\nconst DEFAULT_COLORS = CHART_COLORS;\n\nconst PieChart: React.FC<PieChartProps> = ({\n dataSeries,\n width = 400,\n height = 400,\n title = \"Pie Chart\",\n textInfo = \"percent\",\n hole = 0,\n rotation = 0,\n}) => {\n const plotRef = useRef<HTMLDivElement>(null);\n const theme = usePlotlyTheme();\n // Slices are large hover targets, so the tooltip tracks the cursor (clamped\n // to the viewport) rather than pinning to the slice centroid\n const { bindTooltip, tooltipElement } = useChartTooltip({ followCursor: true });\n\n const colors = useMemo(() => {\n if (\n dataSeries.colors &&\n dataSeries.colors.length >= dataSeries.labels.length\n ) {\n return dataSeries.colors;\n }\n\n const result = [...(dataSeries.colors || [])];\n const missingColors = dataSeries.labels.length - result.length;\n\n if (missingColors <= 0) return result;\n\n for (let i = 0; i < missingColors; i++) {\n result.push(DEFAULT_COLORS[i % DEFAULT_COLORS.length]);\n }\n\n return result;\n }, [dataSeries.colors, dataSeries.labels.length]);\n\n useEffect(() => {\n if (!plotRef.current) return;\n\n const plotData = [\n {\n type: \"pie\" as const,\n labels: dataSeries.labels,\n values: dataSeries.values,\n name: dataSeries.name,\n marker: {\n colors: colors,\n },\n textinfo: textInfo,\n hoverinfo: \"none\" as const,\n insidetextfont: {\n size: 0,\n family: \"Inter, sans-serif\",\n color: \"transparent\",\n },\n hole: hole,\n rotation: rotation,\n },\n ];\n\n const layout = {\n width,\n height,\n font: {\n family: \"Inter, sans-serif\",\n color: theme.textColor,\n },\n showlegend: false,\n margin: { l: 40, r: 40, b: 40, t: 40 },\n paper_bgcolor: theme.paperBg,\n plot_bgcolor: theme.plotBg,\n };\n\n const config = {\n responsive: true,\n displayModeBar: false,\n displaylogo: false,\n };\n\n Plotly.newPlot(plotRef.current, plotData, layout, config);\n bindTooltip(plotRef.current);\n\n // Capture ref value for cleanup\n const plotElement = plotRef.current;\n\n return () => {\n if (plotElement) {\n Plotly.purge(plotElement);\n }\n };\n }, [colors, dataSeries.labels, dataSeries.name, dataSeries.values, width, height, textInfo, hole, rotation, theme, bindTooltip]);\n\n const PieChartLegend: React.FC<{ labels: string[]; colors: string[] }> = ({\n labels,\n colors,\n }) => {\n const items = labels.map((label, i) => (\n <React.Fragment key={label}>\n <div className=\"legend-item\">\n <span className=\"color-box\" style={{ background: colors[i] }} />\n {label}\n {i < labels.length - 1 && <span className=\"divider\" />}\n </div>\n </React.Fragment>\n ));\n\n const rowSize = 6;\n const rows = [];\n for (let i = 0; i < items.length; i += rowSize) {\n rows.push(\n <div className=\"legend-row\" key={i}>\n {items.slice(i, i + rowSize)}\n </div>\n );\n }\n return <div className=\"legend-container\">{rows}</div>;\n };\n\n return (\n <div className=\"card-container relative\" style={{ width: width }}>\n <div className=\"chart-container\">\n {title && (\n <div className=\"title-container\">\n <h2 className=\"title\">{title}</h2>\n </div>\n )}\n <div\n ref={plotRef}\n style={{\n width: \"100%\",\n height: \"100%\",\n margin: \"0\",\n }}\n />\n <PieChartLegend labels={dataSeries.labels} colors={colors} />\n </div>\n {tooltipElement}\n </div>\n );\n};\n\nexport { PieChart };\nexport type { PieDataSeries, PieTextInfo, PieChartProps };\n"],"names":["DEFAULT_COLORS","CHART_COLORS","PieChart","dataSeries","width","height","title","textInfo","hole","rotation","plotRef","useRef","theme","usePlotlyTheme","bindTooltip","tooltipElement","useChartTooltip","colors","useMemo","result","missingColors","i","useEffect","plotData","layout","config","Plotly","plotElement","jsxs","jsx","labels","items","label","React","rowSize","rows"],"mappings":";;;;;;AAmCA,MAAMA,IAAiBC,GAEjBC,IAAoC,CAAC;AAAA,EACzC,YAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,QAAAC,IAAS;AAAA,EACT,OAAAC,IAAQ;AAAA,EACR,UAAAC,IAAW;AAAA,EACX,MAAAC,IAAO;AAAA,EACP,UAAAC,IAAW;AACb,MAAM;AACJ,QAAMC,IAAUC,EAAuB,IAAI,GACrCC,IAAQC,EAAA,GAGR,EAAE,aAAAC,GAAa,gBAAAC,EAAA,IAAmBC,EAAgB,EAAE,cAAc,IAAM,GAExEC,IAASC,EAAQ,MAAM;AAC3B,QACEf,EAAW,UACXA,EAAW,OAAO,UAAUA,EAAW,OAAO;AAE9C,aAAOA,EAAW;AAGpB,UAAMgB,IAAS,CAAC,GAAIhB,EAAW,UAAU,CAAA,CAAG,GACtCiB,IAAgBjB,EAAW,OAAO,SAASgB,EAAO;AAExD,QAAIC,KAAiB,EAAG,QAAOD;AAE/B,aAASE,IAAI,GAAGA,IAAID,GAAeC;AACjC,MAAAF,EAAO,KAAKnB,EAAeqB,IAAIrB,EAAe,MAAM,CAAC;AAGvD,WAAOmB;AAAA,EACT,GAAG,CAAChB,EAAW,QAAQA,EAAW,OAAO,MAAM,CAAC;AAEhD,SAAAmB,EAAU,MAAM;AACd,QAAI,CAACZ,EAAQ,QAAS;AAEtB,UAAMa,IAAW;AAAA,MACf;AAAA,QACE,MAAM;AAAA,QACN,QAAQpB,EAAW;AAAA,QACnB,QAAQA,EAAW;AAAA,QACnB,MAAMA,EAAW;AAAA,QACjB,QAAQ;AAAA,UACN,QAAAc;AAAA,QAAA;AAAA,QAEF,UAAUV;AAAA,QACV,WAAW;AAAA,QACX,gBAAgB;AAAA,UACd,MAAM;AAAA,UACN,QAAQ;AAAA,UACR,OAAO;AAAA,QAAA;AAAA,QAET,MAAAC;AAAA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