@tetrascience-npm/tetrascience-react-ui 0.6.0-beta.82.1 → 0.6.0-beta.83.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 (70) 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 +79 -75
  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 +37 -36
  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 +84 -80
  12. package/dist/components/charts/Boxplot/Boxplot.js.map +1 -1
  13. package/dist/components/charts/Chromatogram/Chromatogram.cjs +1 -1
  14. package/dist/components/charts/Chromatogram/Chromatogram.cjs.map +1 -1
  15. package/dist/components/charts/Chromatogram/Chromatogram.js +51 -46
  16. package/dist/components/charts/Chromatogram/Chromatogram.js.map +1 -1
  17. package/dist/components/charts/ChromatogramChart/ChromatogramChart.cjs +1 -1
  18. package/dist/components/charts/ChromatogramChart/ChromatogramChart.cjs.map +1 -1
  19. package/dist/components/charts/ChromatogramChart/ChromatogramChart.js +47 -47
  20. package/dist/components/charts/ChromatogramChart/ChromatogramChart.js.map +1 -1
  21. package/dist/components/charts/ChromatogramChart/annotations.cjs +1 -1
  22. package/dist/components/charts/ChromatogramChart/annotations.cjs.map +1 -1
  23. package/dist/components/charts/ChromatogramChart/annotations.js +32 -32
  24. package/dist/components/charts/ChromatogramChart/annotations.js.map +1 -1
  25. package/dist/components/charts/ChromatogramChart/boundaryMarkers.cjs +1 -1
  26. package/dist/components/charts/ChromatogramChart/boundaryMarkers.cjs.map +1 -1
  27. package/dist/components/charts/ChromatogramChart/boundaryMarkers.js +6 -6
  28. package/dist/components/charts/ChromatogramChart/boundaryMarkers.js.map +1 -1
  29. package/dist/components/charts/ChromatogramChart/constants.cjs +1 -1
  30. package/dist/components/charts/ChromatogramChart/constants.cjs.map +1 -1
  31. package/dist/components/charts/ChromatogramChart/constants.js +11 -5
  32. package/dist/components/charts/ChromatogramChart/constants.js.map +1 -1
  33. package/dist/components/charts/DotPlot/DotPlot.cjs +1 -1
  34. package/dist/components/charts/DotPlot/DotPlot.cjs.map +1 -1
  35. package/dist/components/charts/DotPlot/DotPlot.js +49 -59
  36. package/dist/components/charts/DotPlot/DotPlot.js.map +1 -1
  37. package/dist/components/charts/Histogram/Histogram.cjs +1 -1
  38. package/dist/components/charts/Histogram/Histogram.cjs.map +1 -1
  39. package/dist/components/charts/Histogram/Histogram.js +53 -63
  40. package/dist/components/charts/Histogram/Histogram.js.map +1 -1
  41. package/dist/components/charts/LineGraph/LineGraph.cjs +1 -1
  42. package/dist/components/charts/LineGraph/LineGraph.cjs.map +1 -1
  43. package/dist/components/charts/LineGraph/LineGraph.js +87 -83
  44. package/dist/components/charts/LineGraph/LineGraph.js.map +1 -1
  45. package/dist/components/charts/PieChart/PieChart.cjs +1 -1
  46. package/dist/components/charts/PieChart/PieChart.cjs.map +1 -1
  47. package/dist/components/charts/PieChart/PieChart.js +41 -48
  48. package/dist/components/charts/PieChart/PieChart.js.map +1 -1
  49. package/dist/components/charts/PlateMap/constants.cjs +1 -1
  50. package/dist/components/charts/PlateMap/constants.cjs.map +1 -1
  51. package/dist/components/charts/PlateMap/constants.js +20 -29
  52. package/dist/components/charts/PlateMap/constants.js.map +1 -1
  53. package/dist/components/charts/ScatterGraph/ScatterGraph.cjs +1 -1
  54. package/dist/components/charts/ScatterGraph/ScatterGraph.cjs.map +1 -1
  55. package/dist/components/charts/ScatterGraph/ScatterGraph.js +40 -39
  56. package/dist/components/charts/ScatterGraph/ScatterGraph.js.map +1 -1
  57. package/dist/hooks/use-plotly-theme.cjs +1 -1
  58. package/dist/hooks/use-plotly-theme.cjs.map +1 -1
  59. package/dist/hooks/use-plotly-theme.js +4 -2
  60. package/dist/hooks/use-plotly-theme.js.map +1 -1
  61. package/dist/index.cjs +1 -1
  62. package/dist/index.css +1 -1
  63. package/dist/index.d.ts +26 -76
  64. package/dist/index.js +37 -36
  65. package/dist/index.tailwind.css +1 -1
  66. package/dist/utils/colors.cjs +1 -1
  67. package/dist/utils/colors.cjs.map +1 -1
  68. package/dist/utils/colors.js +38 -93
  69. package/dist/utils/colors.js.map +1 -1
  70. package/package.json +1 -1
@@ -1,32 +1,22 @@
1
- import { jsx as E } from "react/jsx-runtime";
2
- import R from "plotly.js-dist";
3
- import { useRef as k, useMemo as r, useEffect as P } from "react";
4
- import { usePlotlyTheme as I } from "../../../hooks/use-plotly-theme.js";
5
- import { COLORS as e } from "../../../utils/colors.js";
6
- const v = ({
7
- dataSeries: l,
8
- width: f = 1e3,
9
- height: d = 600,
10
- title: u = "Dot Plot",
11
- xTitle: n = "Columns",
12
- yTitle: i = "Rows",
13
- variant: h = "default",
14
- markerSize: m = 8
1
+ import { jsx as z } from "react/jsx-runtime";
2
+ import k from "plotly.js-dist";
3
+ import { useRef as I, useMemo as r, useEffect as P } from "react";
4
+ import { usePlotlyTheme as R } from "../../../hooks/use-plotly-theme.js";
5
+ import { CHART_COLORS as A } from "../../../utils/colors.js";
6
+ const $ = ({
7
+ dataSeries: e,
8
+ width: a = 1e3,
9
+ height: g = 600,
10
+ title: d = "Dot Plot",
11
+ xTitle: l = "Columns",
12
+ yTitle: n = "Rows",
13
+ variant: u = "default",
14
+ markerSize: f = 8
15
15
  }) => {
16
- const s = k(null), t = I(), x = r(
17
- () => Array.isArray(l) ? l : [l],
18
- [l]
19
- ), c = r(
20
- () => [
21
- e.ORANGE,
22
- e.RED,
23
- e.GREEN,
24
- e.BLUE,
25
- e.YELLOW,
26
- e.PURPLE
27
- ],
28
- []
29
- ), p = r(
16
+ const i = I(null), t = R(), h = r(
17
+ () => Array.isArray(e) ? e : [e],
18
+ [e]
19
+ ), s = A, m = r(
30
20
  () => [
31
21
  "circle",
32
22
  "square",
@@ -36,18 +26,18 @@ const v = ({
36
26
  "star"
37
27
  ],
38
28
  []
39
- ), w = r(() => x.map((o, a) => h === "default" ? {
29
+ ), x = r(() => h.map((o, c) => u === "default" ? {
40
30
  ...o,
41
- color: o.color || c[0],
31
+ color: o.color || s[0],
42
32
  symbol: "circle",
43
- size: o.size || m
33
+ size: o.size || f
44
34
  } : {
45
35
  ...o,
46
- color: o.color || c[a % c.length],
47
- symbol: o.symbol || p[a % p.length],
48
- size: o.size || m
49
- }), [x, h, m, c, p]), y = t.gridColor, C = r(
50
- () => w.map((o) => ({
36
+ color: o.color || s[c % s.length],
37
+ symbol: o.symbol || m[c % m.length],
38
+ size: o.size || f
39
+ }), [h, u, f, s, m]), p = t.gridColor, C = r(
40
+ () => x.map((o) => ({
51
41
  type: "scatter",
52
42
  x: o.x,
53
43
  y: o.y,
@@ -62,10 +52,10 @@ const v = ({
62
52
  width: 1
63
53
  }
64
54
  },
65
- hovertemplate: `${n}: %{x}<br>${i}: %{y}<extra>${o.name}</extra>`
55
+ hovertemplate: `${l}: %{x}<br>${n}: %{y}<extra>${o.name}</extra>`
66
56
  })),
67
- [w, n, i, t]
68
- ), g = r(
57
+ [x, l, n, t]
58
+ ), y = r(
69
59
  () => ({
70
60
  tickcolor: t.tickColor,
71
61
  ticklen: 12,
@@ -83,9 +73,9 @@ const v = ({
83
73
  zeroline: !1
84
74
  }),
85
75
  [t]
86
- ), b = r(
76
+ ), w = r(
87
77
  () => ({
88
- text: u,
78
+ text: d,
89
79
  x: 0.5,
90
80
  y: 0.95,
91
81
  xanchor: "center",
@@ -99,17 +89,17 @@ const v = ({
99
89
  standoff: 30
100
90
  }
101
91
  }),
102
- [u, t]
92
+ [d, t]
103
93
  );
104
94
  return P(() => {
105
- if (!s.current) return;
95
+ if (!i.current) return;
106
96
  const o = {
107
- width: f,
108
- height: d,
97
+ width: a,
98
+ height: g,
109
99
  font: {
110
100
  family: "Inter, sans-serif"
111
101
  },
112
- title: b,
102
+ title: w,
113
103
  margin: { l: 80, r: 40, b: 80, t: 80, pad: 0 },
114
104
  showlegend: !0,
115
105
  legend: {
@@ -128,7 +118,7 @@ const v = ({
128
118
  },
129
119
  xaxis: {
130
120
  title: {
131
- text: n,
121
+ text: l,
132
122
  font: {
133
123
  size: 16,
134
124
  color: t.textSecondary,
@@ -137,12 +127,12 @@ const v = ({
137
127
  },
138
128
  standoff: 15
139
129
  },
140
- gridcolor: y,
141
- ...g
130
+ gridcolor: p,
131
+ ...y
142
132
  },
143
133
  yaxis: {
144
134
  title: {
145
- text: i,
135
+ text: n,
146
136
  font: {
147
137
  size: 16,
148
138
  color: t.textSecondary,
@@ -151,25 +141,25 @@ const v = ({
151
141
  },
152
142
  standoff: 15
153
143
  },
154
- gridcolor: y,
155
- ...g
144
+ gridcolor: p,
145
+ ...y
156
146
  },
157
147
  paper_bgcolor: t.paperBg,
158
148
  plot_bgcolor: t.plotBg
159
- }, a = {
149
+ }, c = {
160
150
  responsive: !0,
161
151
  displayModeBar: !1,
162
152
  displaylogo: !1
163
153
  };
164
- R.newPlot(s.current, C, o, a);
165
- const z = s.current;
154
+ k.newPlot(i.current, C, o, c);
155
+ const b = i.current;
166
156
  return () => {
167
- z && R.purge(z);
157
+ b && k.purge(b);
168
158
  };
169
- }, [f, d, n, i, C, b, g, y, t]), /* @__PURE__ */ E("div", { className: "dotplot-container", style: { width: f }, children: /* @__PURE__ */ E(
159
+ }, [a, g, l, n, C, w, y, p, t]), /* @__PURE__ */ z("div", { className: "dotplot-container", style: { width: a }, children: /* @__PURE__ */ z(
170
160
  "div",
171
161
  {
172
- ref: s,
162
+ ref: i,
173
163
  style: {
174
164
  width: "100%",
175
165
  height: "100%",
@@ -179,6 +169,6 @@ const v = ({
179
169
  ) });
180
170
  };
181
171
  export {
182
- v as DotPlot
172
+ $ as DotPlot
183
173
  };
184
174
  //# sourceMappingURL=DotPlot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DotPlot.js","sources":["../../../../src/components/charts/DotPlot/DotPlot.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\ntype MarkerSymbol =\n | \"circle\"\n | \"square\"\n | \"diamond\"\n | \"triangle-up\"\n | \"triangle-down\"\n | \"star\";\n\ninterface DotPlotDataSeries {\n x: number[];\n y: number[];\n name: string;\n color?: string;\n symbol?: MarkerSymbol;\n size?: number;\n}\n\ntype DotPlotVariant = \"default\" | \"stacked\";\n\ntype DotPlotProps = {\n dataSeries: DotPlotDataSeries | DotPlotDataSeries[];\n width?: number;\n height?: number;\n title?: string;\n xTitle?: string;\n yTitle?: string;\n variant?: DotPlotVariant;\n markerSize?: number;\n};\n\nconst DotPlot: React.FC<DotPlotProps> = ({\n dataSeries,\n width = 1000,\n height = 600,\n title = \"Dot Plot\",\n xTitle = \"Columns\",\n yTitle = \"Rows\",\n variant = \"default\",\n markerSize = 8,\n}) => {\n const plotRef = useRef<HTMLDivElement>(null);\n const theme = usePlotlyTheme();\n const seriesArray = useMemo(\n () => (Array.isArray(dataSeries) ? dataSeries : [dataSeries]),\n [dataSeries],\n );\n\n const defaultColors = useMemo(\n () => [\n COLORS.ORANGE,\n COLORS.RED,\n COLORS.GREEN,\n COLORS.BLUE,\n COLORS.YELLOW,\n COLORS.PURPLE,\n ],\n [],\n );\n\n const defaultSymbols: MarkerSymbol[] = useMemo(\n () => [\n \"circle\",\n \"square\",\n \"diamond\",\n \"triangle-up\",\n \"triangle-down\",\n \"star\",\n ],\n [],\n );\n\n const seriesWithColors = useMemo(() => {\n return seriesArray.map((series, index) => {\n if (variant === \"default\") {\n // Default variant: all circles, use first color or series color\n return {\n ...series,\n color: series.color || defaultColors[0],\n symbol: \"circle\" as MarkerSymbol,\n size: series.size || markerSize,\n };\n } else {\n // Stacked variant: different symbols and colors for each series\n return {\n ...series,\n color: series.color || defaultColors[index % defaultColors.length],\n symbol:\n series.symbol || defaultSymbols[index % defaultSymbols.length],\n size: series.size || markerSize,\n };\n }\n });\n }, [seriesArray, variant, markerSize, defaultColors, defaultSymbols]);\n\n const gridColor = theme.gridColor;\n\n const plotData = useMemo(\n () =>\n seriesWithColors.map((series) => ({\n type: \"scatter\" as const,\n x: series.x,\n y: series.y,\n mode: \"markers\" as const,\n name: series.name,\n marker: {\n color: series.color,\n size: series.size,\n symbol: series.symbol,\n line: {\n color: theme.paperBg,\n width: 1,\n },\n },\n hovertemplate: `${xTitle}: %{x}<br>${yTitle}: %{y}<extra>${series.name}</extra>`,\n })),\n [seriesWithColors, xTitle, yTitle, theme],\n );\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 const titleOptions = useMemo(\n () => ({\n text: title,\n x: 0.5,\n y: 0.95,\n xanchor: \"center\" as const,\n yanchor: \"top\" as const,\n font: {\n size: 32,\n weight: 600,\n family: \"Inter, sans-serif\",\n color: theme.textColor,\n lineheight: 1.2,\n standoff: 30,\n },\n }),\n [title, theme],\n );\n\n useEffect(() => {\n if (!plotRef.current) return;\n\n const layout = {\n width,\n height,\n font: {\n family: \"Inter, sans-serif\",\n },\n title: titleOptions,\n margin: { l: 80, r: 40, b: 80, t: 80, pad: 0 },\n showlegend: true,\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: 13,\n color: theme.legendColor,\n family: \"Inter, sans-serif\",\n weight: 500,\n lineheight: 18,\n },\n },\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: 15,\n },\n gridcolor: gridColor,\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: 15,\n },\n gridcolor: gridColor,\n ...tickOptions,\n },\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 }, [width, height, xTitle, yTitle, plotData, titleOptions, tickOptions, gridColor, theme]);\n\n return (\n <div className=\"dotplot-container\" style={{ width: width }}>\n <div\n ref={plotRef}\n style={{\n width: \"100%\",\n height: \"100%\",\n margin: \"0\",\n }}\n />\n </div>\n );\n};\n\nexport { DotPlot };\nexport type { DotPlotDataSeries, DotPlotProps, DotPlotVariant, MarkerSymbol };\n"],"names":["DotPlot","dataSeries","width","height","title","xTitle","yTitle","variant","markerSize","plotRef","useRef","theme","usePlotlyTheme","seriesArray","useMemo","defaultColors","COLORS","defaultSymbols","seriesWithColors","series","index","gridColor","plotData","tickOptions","titleOptions","useEffect","layout","config","Plotly","plotElement","jsx"],"mappings":";;;;;AAoCA,MAAMA,IAAkC,CAAC;AAAA,EACvC,YAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,QAAAC,IAAS;AAAA,EACT,OAAAC,IAAQ;AAAA,EACR,QAAAC,IAAS;AAAA,EACT,QAAAC,IAAS;AAAA,EACT,SAAAC,IAAU;AAAA,EACV,YAAAC,IAAa;AACf,MAAM;AACJ,QAAMC,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AAAA,IACV;AAAA,EAAA,GAEJ;AAEJ;"}
1
+ {"version":3,"file":"DotPlot.js","sources":["../../../../src/components/charts/DotPlot/DotPlot.tsx"],"sourcesContent":["import Plotly from \"plotly.js-dist\";\nimport React, { useEffect, useRef, useMemo } from \"react\";\n\nimport { usePlotlyTheme } from \"@/hooks/use-plotly-theme\";\nimport { CHART_COLORS } from \"@/utils/colors\";\n\ntype MarkerSymbol =\n | \"circle\"\n | \"square\"\n | \"diamond\"\n | \"triangle-up\"\n | \"triangle-down\"\n | \"star\";\n\ninterface DotPlotDataSeries {\n x: number[];\n y: number[];\n name: string;\n color?: string;\n symbol?: MarkerSymbol;\n size?: number;\n}\n\ntype DotPlotVariant = \"default\" | \"stacked\";\n\ntype DotPlotProps = {\n dataSeries: DotPlotDataSeries | DotPlotDataSeries[];\n width?: number;\n height?: number;\n title?: string;\n xTitle?: string;\n yTitle?: string;\n variant?: DotPlotVariant;\n markerSize?: number;\n};\n\nconst DotPlot: React.FC<DotPlotProps> = ({\n dataSeries,\n width = 1000,\n height = 600,\n title = \"Dot Plot\",\n xTitle = \"Columns\",\n yTitle = \"Rows\",\n variant = \"default\",\n markerSize = 8,\n}) => {\n const plotRef = useRef<HTMLDivElement>(null);\n const theme = usePlotlyTheme();\n const seriesArray = useMemo(\n () => (Array.isArray(dataSeries) ? dataSeries : [dataSeries]),\n [dataSeries],\n );\n\n const defaultColors = CHART_COLORS;\n\n const defaultSymbols: MarkerSymbol[] = useMemo(\n () => [\n \"circle\",\n \"square\",\n \"diamond\",\n \"triangle-up\",\n \"triangle-down\",\n \"star\",\n ],\n [],\n );\n\n const seriesWithColors = useMemo(() => {\n return seriesArray.map((series, index) => {\n if (variant === \"default\") {\n // Default variant: all circles, use first color or series color\n return {\n ...series,\n color: series.color || defaultColors[0],\n symbol: \"circle\" as MarkerSymbol,\n size: series.size || markerSize,\n };\n } else {\n // Stacked variant: different symbols and colors for each series\n return {\n ...series,\n color: series.color || defaultColors[index % defaultColors.length],\n symbol:\n series.symbol || defaultSymbols[index % defaultSymbols.length],\n size: series.size || markerSize,\n };\n }\n });\n }, [seriesArray, variant, markerSize, defaultColors, defaultSymbols]);\n\n const gridColor = theme.gridColor;\n\n const plotData = useMemo(\n () =>\n seriesWithColors.map((series) => ({\n type: \"scatter\" as const,\n x: series.x,\n y: series.y,\n mode: \"markers\" as const,\n name: series.name,\n marker: {\n color: series.color,\n size: series.size,\n symbol: series.symbol,\n line: {\n color: theme.paperBg,\n width: 1,\n },\n },\n hovertemplate: `${xTitle}: %{x}<br>${yTitle}: %{y}<extra>${series.name}</extra>`,\n })),\n [seriesWithColors, xTitle, yTitle, theme],\n );\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 const titleOptions = useMemo(\n () => ({\n text: title,\n x: 0.5,\n y: 0.95,\n xanchor: \"center\" as const,\n yanchor: \"top\" as const,\n font: {\n size: 32,\n weight: 600,\n family: \"Inter, sans-serif\",\n color: theme.textColor,\n lineheight: 1.2,\n standoff: 30,\n },\n }),\n [title, theme],\n );\n\n useEffect(() => {\n if (!plotRef.current) return;\n\n const layout = {\n width,\n height,\n font: {\n family: \"Inter, sans-serif\",\n },\n title: titleOptions,\n margin: { l: 80, r: 40, b: 80, t: 80, pad: 0 },\n showlegend: true,\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: 13,\n color: theme.legendColor,\n family: \"Inter, sans-serif\",\n weight: 500,\n lineheight: 18,\n },\n },\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: 15,\n },\n gridcolor: gridColor,\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: 15,\n },\n gridcolor: gridColor,\n ...tickOptions,\n },\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 }, [width, height, xTitle, yTitle, plotData, titleOptions, tickOptions, gridColor, theme]);\n\n return (\n <div className=\"dotplot-container\" style={{ width: width }}>\n <div\n ref={plotRef}\n style={{\n width: \"100%\",\n height: \"100%\",\n margin: \"0\",\n }}\n />\n </div>\n );\n};\n\nexport { DotPlot };\nexport type { DotPlotDataSeries, DotPlotProps, DotPlotVariant, MarkerSymbol };\n"],"names":["DotPlot","dataSeries","width","height","title","xTitle","yTitle","variant","markerSize","plotRef","useRef","theme","usePlotlyTheme","seriesArray","useMemo","defaultColors","CHART_COLORS","defaultSymbols","seriesWithColors","series","index","gridColor","plotData","tickOptions","titleOptions","useEffect","layout","config","Plotly","plotElement","jsx"],"mappings":";;;;;AAoCA,MAAMA,IAAkC,CAAC;AAAA,EACvC,YAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,QAAAC,IAAS;AAAA,EACT,OAAAC,IAAQ;AAAA,EACR,QAAAC,IAAS;AAAA,EACT,QAAAC,IAAS;AAAA,EACT,SAAAC,IAAU;AAAA,EACV,YAAAC,IAAa;AACf,MAAM;AACJ,QAAMC,IAAUC,EAAuB,IAAI,GACrCC,IAAQC,EAAA,GACRC,IAAcC;AAAA,IAClB,MAAO,MAAM,QAAQb,CAAU,IAAIA,IAAa,CAACA,CAAU;AAAA,IAC3D,CAACA,CAAU;AAAA,EAAA,GAGPc,IAA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A;AAAA,QAEZ,WAAWU;AAAA,QACX,GAAGE;AAAA,MAAA;AAAA,MAEL,OAAO;AAAA,QACL,OAAO;AAAA,UACL,MAAMjB;AAAA,UACN,MAAM;AAAA,YACJ,MAAM;AAAA,YACN,OAAOK,EAAM;AAAA,YACb,QAAQ;AAAA,YACR,QAAQ;AAAA,UAAA;AAAA,UAEV,UAAU;AAAA,QAAA;AAAA,QAEZ,WAAWU;AAAA,QACX,GAAGE;AAAA,MAAA;AAAA,MAEL,eAAeZ,EAAM;AAAA,MACrB,cAAcA,EAAM;AAAA,IAAA,GAGhBgB,IAAS;AAAA,MACb,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,aAAa;AAAA,IAAA;AAGf,IAAAC,EAAO,QAAQnB,EAAQ,SAASa,GAAUI,GAAQC,CAAM;AAGxD,UAAME,IAAcpB,EAAQ;AAE5B,WAAO,MAAM;AACX,MAAIoB,KACFD,EAAO,MAAMC,CAAW;AAAA,IAE5B;AAAA,EACF,GAAG,CAAC3B,GAAOC,GAAQE,GAAQC,GAAQgB,GAAUE,GAAcD,GAAaF,GAAWV,CAAK,CAAC,qBAGtF,OAAA,EAAI,WAAU,qBAAoB,OAAO,EAAE,OAAAT,KAC1C,UAAA,gBAAA4B;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAKrB;AAAA,MACL,OAAO;AAAA,QACL,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,QAAQ;AAAA,MAAA;AAAA,IACV;AAAA,EAAA,GAEJ;AAEJ;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),k=require("plotly.js-dist"),d=require("react"),S=require("../../../hooks/use-plotly-theme.cjs"),p=require("../../../utils/colors.cjs");;/* empty css */const z=-.5,B=n=>n.reduce((e,u)=>e+u,0)/n.length,I=(n,a)=>{const u=n.map(r=>Math.pow(r-a,2)).reduce((r,l)=>r+l,0)/n.length;return Math.sqrt(u)},A=(n,a,e,u,r=100)=>{const l=[],x=[],f=(u-e)/(r-1);for(let s=0;s<r;s++){const o=e+s*f;l.push(o);const g=z*Math.pow((o-n)/a,2),C=1/(a*Math.sqrt(2*Math.PI))*Math.exp(g);x.push(C)}return{x:l,y:x}},F=(n,a,e)=>{const u=Math.ceil((e.end-e.start)/e.size),r=Array(u).fill(0);a.forEach(s=>{if(s>=e.start&&s<=e.end){const o=Math.floor((s-e.start)/e.size);r[o]++}});const l=Math.max(...r),x=Math.max(...n),f=l/x;return n.map(s=>s*f)},W=({dataSeries:n,width:a=480,height:e=480,title:u="Histogram",xTitle:r="X Axis",yTitle:l="Frequency",bargap:x=.2,showDistributionLine:f=!1})=>{const s=d.useRef(null),o=S.usePlotlyTheme(),g=d.useMemo(()=>Array.isArray(n)?n:[n],[n]),C=d.useMemo(()=>g.length>1?"stack":void 0,[g.length]),O=d.useMemo(()=>[p.COLORS.ORANGE,p.COLORS.RED,p.COLORS.BLUE,p.COLORS.GREEN,p.COLORS.PURPLE,p.COLORS.YELLOW],[]),y=d.useMemo(()=>g.map((t,h)=>{const m=typeof t.showDistributionLine>"u"?f:t.showDistributionLine;return{...t,color:t.color||O[h%O.length],opacity:m?.5:t.opacity||1,showDistributionLine:m,lineWidth:t.lineWidth||3}}),[g,f,O]),v=o.gridColor,w=d.useMemo(()=>y.map(t=>({type:"histogram",x:t.x,name:t.name,marker:{color:t.color,line:{color:o.paperBg,width:1},opacity:t.opacity},autobinx:t.autobinx,xbins:t.xbins,hovertemplate:`${r}: %{x}<br>${l}: %{y}<extra>${t.name}</extra>`})),[y,r,l,o]),L=d.useMemo(()=>y.filter(t=>t.showDistributionLine).map(t=>{const h=B(t.x),m=I(t.x,h),M=Math.min(...t.x),c=Math.max(...t.x),b=c-M,R=M-b*.1,j=c+b*.1,E=t.xbins||{start:R,end:j,size:b/10},D=A(h,m,R,j,100),P=F(D.y,t.x,E);return{type:"scatter",x:D.x,y:P,mode:"lines",name:`${t.name} Distribution`,line:{color:t.color,width:t.lineWidth},hoverinfo:"none"}}),[y]),N=d.useMemo(()=>[...w,...L],[w,L]);d.useEffect(()=>{if(!s.current)return;const t={width:a,height:e,font:{family:"Inter, sans-serif"},showlegend:!1,margin:{l:90,r:40,b:80,t:40},xaxis:{title:{text:r,font:{size:16,color:o.textSecondary,family:"Inter, sans-serif",weight:400},standoff:20},gridcolor:v,tickcolor:o.tickColor,ticklen:8,tickwidth:1,ticks:"outside",linecolor:o.lineColor,linewidth:1,zeroline:!1},yaxis:{title:{text:l,font:{size:16,color:o.textSecondary,family:"Inter, sans-serif",weight:400},standoff:20},gridcolor:v,tickcolor:o.tickColor,ticklen:8,tickwidth:1,ticks:"outside",linecolor:o.lineColor,linewidth:1,zeroline:!1,rangemode:"tozero"},barmode:C,bargap:x,paper_bgcolor:o.paperBg,plot_bgcolor:o.plotBg},h={responsive:!0,displayModeBar:!1,displaylogo:!1};k.newPlot(s.current,N,t,h);const m=s.current;return()=>{m&&k.purge(m)}},[a,e,r,l,x,N,C,v,o]);const q=({series:t})=>{const h=t.map((c,b)=>i.jsx(d.Fragment,{children:i.jsxs("div",{className:"legend-item",children:[i.jsx("span",{className:"color-box",style:{background:c.color}}),c.name,b<t.length-1&&i.jsx("span",{className:"divider"})]})},c.name)),m=[],M=6;for(let c=0;c<h.length;c+=M)m.push(i.jsx("div",{className:"legend-row",children:h.slice(c,c+M)},c));return i.jsx("div",{className:"legend-container",children:m})};return i.jsx("div",{className:"histogram-container",style:{width:a},children:i.jsxs("div",{className:"chart-container",children:[u&&i.jsx("div",{className:"title-container",children:i.jsx("h2",{className:"title",children:u})}),i.jsx("div",{ref:s,style:{width:"100%",height:"100%",margin:"0"}}),i.jsx(q,{series:y})]})})};exports.Histogram=W;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),z=require("plotly.js-dist"),h=require("react"),R=require("../../../hooks/use-plotly-theme.cjs"),A=require("../../../utils/colors.cjs");;/* empty css */const B=-.5,F=n=>n.reduce((e,u)=>e+u,0)/n.length,O=(n,a)=>{const u=n.map(r=>Math.pow(r-a,2)).reduce((r,l)=>r+l,0)/n.length;return Math.sqrt(u)},E=(n,a,e,u,r=100)=>{const l=[],x=[],f=(u-e)/(r-1);for(let s=0;s<r;s++){const o=e+s*f;l.push(o);const g=B*Math.pow((o-n)/a,2),b=1/(a*Math.sqrt(2*Math.PI))*Math.exp(g);x.push(b)}return{x:l,y:x}},_=(n,a,e)=>{const u=Math.ceil((e.end-e.start)/e.size),r=Array(u).fill(0);a.forEach(s=>{if(s>=e.start&&s<=e.end){const o=Math.floor((s-e.start)/e.size);r[o]++}});const l=Math.max(...r),x=Math.max(...n),f=l/x;return n.map(s=>s*f)},S=({dataSeries:n,width:a=480,height:e=480,title:u="Histogram",xTitle:r="X Axis",yTitle:l="Frequency",bargap:x=.2,showDistributionLine:f=!1})=>{const s=h.useRef(null),o=R.usePlotlyTheme(),g=h.useMemo(()=>Array.isArray(n)?n:[n],[n]),b=h.useMemo(()=>g.length>1?"stack":void 0,[g.length]),v=A.CHART_COLORS,p=h.useMemo(()=>g.map((t,d)=>{const m=typeof t.showDistributionLine>"u"?f:t.showDistributionLine;return{...t,color:t.color||v[d%v.length],opacity:m?.5:t.opacity||1,showDistributionLine:m,lineWidth:t.lineWidth||3}}),[g,f,v]),w=o.gridColor,C=h.useMemo(()=>p.map(t=>({type:"histogram",x:t.x,name:t.name,marker:{color:t.color,line:{color:o.paperBg,width:1},opacity:t.opacity},autobinx:t.autobinx,xbins:t.xbins,hovertemplate:`${r}: %{x}<br>${l}: %{y}<extra>${t.name}</extra>`})),[p,r,l,o]),j=h.useMemo(()=>p.filter(t=>t.showDistributionLine).map(t=>{const d=F(t.x),m=O(t.x,d),y=Math.min(...t.x),c=Math.max(...t.x),M=c-y,k=y-M*.1,q=c+M*.1,I=t.xbins||{start:k,end:q,size:M/10},D=E(d,m,k,q,100),L=_(D.y,t.x,I);return{type:"scatter",x:D.x,y:L,mode:"lines",name:`${t.name} Distribution`,line:{color:t.color,width:t.lineWidth},hoverinfo:"none"}}),[p]),N=h.useMemo(()=>[...C,...j],[C,j]);h.useEffect(()=>{if(!s.current)return;const t={width:a,height:e,font:{family:"Inter, sans-serif"},showlegend:!1,margin:{l:90,r:40,b:80,t:40},xaxis:{title:{text:r,font:{size:16,color:o.textSecondary,family:"Inter, sans-serif",weight:400},standoff:20},gridcolor:w,tickcolor:o.tickColor,ticklen:8,tickwidth:1,ticks:"outside",linecolor:o.lineColor,linewidth:1,zeroline:!1},yaxis:{title:{text:l,font:{size:16,color:o.textSecondary,family:"Inter, sans-serif",weight:400},standoff:20},gridcolor:w,tickcolor:o.tickColor,ticklen:8,tickwidth:1,ticks:"outside",linecolor:o.lineColor,linewidth:1,zeroline:!1,rangemode:"tozero"},barmode:b,bargap:x,paper_bgcolor:o.paperBg,plot_bgcolor:o.plotBg},d={responsive:!0,displayModeBar:!1,displaylogo:!1};z.newPlot(s.current,N,t,d);const m=s.current;return()=>{m&&z.purge(m)}},[a,e,r,l,x,N,b,w,o]);const P=({series:t})=>{const d=t.map((c,M)=>i.jsx(h.Fragment,{children:i.jsxs("div",{className:"legend-item",children:[i.jsx("span",{className:"color-box",style:{background:c.color}}),c.name,M<t.length-1&&i.jsx("span",{className:"divider"})]})},c.name)),m=[],y=6;for(let c=0;c<d.length;c+=y)m.push(i.jsx("div",{className:"legend-row",children:d.slice(c,c+y)},c));return i.jsx("div",{className:"legend-container",children:m})};return i.jsx("div",{className:"histogram-container",style:{width:a},children:i.jsxs("div",{className:"chart-container",children:[u&&i.jsx("div",{className:"title-container",children:i.jsx("h2",{className:"title",children:u})}),i.jsx("div",{ref:s,style:{width:"100%",height:"100%",margin:"0"}}),i.jsx(P,{series:p})]})})};exports.Histogram=S;
2
2
  //# sourceMappingURL=Histogram.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Histogram.cjs","sources":["../../../../src/components/charts/Histogram/Histogram.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\";\nimport \"./Histogram.scss\";\n\n/** Exponent coefficient for normal distribution calculation */\nconst NORMAL_DISTRIBUTION_EXPONENT_COEFF = -0.5;\n\ninterface HistogramDataSeries {\n x: number[];\n name: string;\n color?: string;\n autobinx?: boolean;\n xbins?: {\n start: number;\n end: number;\n size: number;\n };\n opacity?: number;\n showDistributionLine?: boolean;\n lineWidth?: number;\n}\n\ntype HistogramProps = {\n dataSeries: HistogramDataSeries | HistogramDataSeries[];\n width?: number;\n height?: number;\n title?: string;\n xTitle?: string;\n yTitle?: string;\n bargap?: number;\n showDistributionLine?: boolean;\n};\n\nconst calculateMean = (data: number[]): number => {\n const sum = data.reduce((acc, val) => acc + val, 0);\n return sum / data.length;\n};\n\nconst calculateStdDev = (data: number[], mean: number): number => {\n const squaredDiffs = data.map((value) => Math.pow(value - mean, 2));\n const variance =\n squaredDiffs.reduce((acc, val) => acc + val, 0) / data.length;\n return Math.sqrt(variance);\n};\n\nconst generateNormalDistributionPoints = (\n mean: number,\n stdDev: number,\n start: number,\n end: number,\n points = 100\n): { x: number[]; y: number[] } => {\n const xValues: number[] = [];\n const yValues: number[] = [];\n\n const step = (end - start) / (points - 1);\n\n for (let i = 0; i < points; i++) {\n const x = start + i * step;\n xValues.push(x);\n\n const exponent = NORMAL_DISTRIBUTION_EXPONENT_COEFF * Math.pow((x - mean) / stdDev, 2);\n const y = (1 / (stdDev * Math.sqrt(2 * Math.PI))) * Math.exp(exponent);\n yValues.push(y);\n }\n\n return { x: xValues, y: yValues };\n};\n\nconst scaleDistributionCurve = (\n yValues: number[],\n histogramData: number[],\n bins: { start: number; end: number; size: number }\n): number[] => {\n const binCount = Math.ceil((bins.end - bins.start) / bins.size);\n const binFrequencies = Array(binCount).fill(0);\n\n histogramData.forEach((value) => {\n if (value >= bins.start && value <= bins.end) {\n const binIndex = Math.floor((value - bins.start) / bins.size);\n binFrequencies[binIndex]++;\n }\n });\n\n const maxBinFrequency = Math.max(...binFrequencies);\n const maxCurveValue = Math.max(...yValues);\n\n const scaleFactor = maxBinFrequency / maxCurveValue;\n\n return yValues.map((y) => y * scaleFactor);\n};\n\nconst Histogram: React.FC<HistogramProps> = ({\n dataSeries,\n width = 480,\n height = 480,\n title = \"Histogram\",\n xTitle = \"X Axis\",\n yTitle = \"Frequency\",\n bargap = 0.2,\n showDistributionLine = false,\n}) => {\n const plotRef = useRef<HTMLDivElement>(null);\n const theme = usePlotlyTheme();\n const seriesArray = useMemo(\n () => (Array.isArray(dataSeries) ? dataSeries : [dataSeries]),\n [dataSeries],\n );\n const effectiveBarMode = useMemo<\n \"stack\" | \"group\" | \"overlay\" | \"relative\" | undefined\n >(() => (seriesArray.length > 1 ? \"stack\" : undefined), [seriesArray.length]);\n\n const defaultColors = useMemo(\n () => [\n COLORS.ORANGE,\n COLORS.RED,\n COLORS.BLUE,\n COLORS.GREEN,\n COLORS.PURPLE,\n COLORS.YELLOW,\n ],\n [],\n );\n\n const seriesWithColors = useMemo(() => {\n return seriesArray.map((series, index) => {\n const hasDistributionLine =\n typeof series.showDistributionLine === \"undefined\"\n ? showDistributionLine\n : series.showDistributionLine;\n\n return {\n ...series,\n color: series.color || defaultColors[index % defaultColors.length],\n opacity: hasDistributionLine ? 0.5 : series.opacity || 1,\n showDistributionLine: hasDistributionLine,\n lineWidth: series.lineWidth || 3,\n };\n });\n }, [seriesArray, showDistributionLine, defaultColors]);\n\n const gridColor = theme.gridColor;\n\n const histogramData = useMemo(\n () =>\n seriesWithColors.map((series) => ({\n type: \"histogram\" as const,\n x: series.x,\n name: series.name,\n marker: {\n color: series.color,\n line: {\n color: theme.paperBg,\n width: 1,\n },\n opacity: series.opacity,\n },\n autobinx: series.autobinx,\n xbins: series.xbins,\n hovertemplate: `${xTitle}: %{x}<br>${yTitle}: %{y}<extra>${series.name}</extra>`,\n })),\n [seriesWithColors, xTitle, yTitle, theme],\n );\n\n const distributionLines = useMemo(\n () =>\n seriesWithColors\n .filter((series) => series.showDistributionLine)\n .map((series) => {\n const mean = calculateMean(series.x);\n const stdDev = calculateStdDev(series.x, mean);\n\n const min = Math.min(...series.x);\n const max = Math.max(...series.x);\n const range = max - min;\n const start = min - range * 0.1;\n const end = max + range * 0.1;\n\n const bins = series.xbins || {\n start: start,\n end: end,\n size: range / 10,\n };\n\n const curvePoints = generateNormalDistributionPoints(\n mean,\n stdDev,\n start,\n end,\n 100,\n );\n\n const scaledYValues = scaleDistributionCurve(\n curvePoints.y,\n series.x,\n bins,\n );\n\n return {\n type: \"scatter\" as const,\n x: curvePoints.x,\n y: scaledYValues,\n mode: \"lines\" as const,\n name: `${series.name} Distribution`,\n line: {\n color: series.color,\n width: series.lineWidth,\n },\n hoverinfo: \"none\" as const,\n };\n }),\n [seriesWithColors],\n );\n\n const plotData = useMemo(\n () => [...histogramData, ...distributionLines],\n [histogramData, distributionLines],\n );\n\n useEffect(() => {\n if (!plotRef.current) return;\n\n const layout = {\n width,\n height,\n font: {\n family: \"Inter, sans-serif\",\n },\n showlegend: false,\n margin: { l: 90, r: 40, b: 80, t: 40 },\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: 20,\n },\n gridcolor: gridColor,\n tickcolor: theme.tickColor,\n ticklen: 8,\n tickwidth: 1,\n ticks: \"outside\" as const,\n linecolor: theme.lineColor,\n linewidth: 1,\n zeroline: false,\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: 20,\n },\n gridcolor: gridColor,\n tickcolor: theme.tickColor,\n ticklen: 8,\n tickwidth: 1,\n ticks: \"outside\" as const,\n linecolor: theme.lineColor,\n linewidth: 1,\n zeroline: false,\n rangemode: \"tozero\" as const,\n },\n barmode: effectiveBarMode,\n bargap: bargap,\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 }, [width, height, xTitle, yTitle, bargap, plotData, effectiveBarMode, gridColor, theme]);\n\n const ChartLegend: React.FC<{\n series: Array<{ name: string; color: string }>;\n }> = ({ series }) => {\n const items = series.map((item, i) => (\n <React.Fragment key={item.name}>\n <div className=\"legend-item\">\n <span className=\"color-box\" style={{ background: item.color }} />\n {item.name}\n {i < series.length - 1 && <span className=\"divider\" />}\n </div>\n </React.Fragment>\n ));\n\n const rows = [];\n const rowSize = 6;\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\n return <div className=\"legend-container\">{rows}</div>;\n };\n\n return (\n <div className=\"histogram-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 <ChartLegend series={seriesWithColors} />\n </div>\n </div>\n );\n};\n\nexport { Histogram };\nexport type { HistogramDataSeries, HistogramProps };\n"],"names":["NORMAL_DISTRIBUTION_EXPONENT_COEFF","calculateMean","data","acc","val","calculateStdDev","mean","variance","value","generateNormalDistributionPoints","stdDev","start","end","points","xValues","yValues","step","i","x","exponent","y","scaleDistributionCurve","histogramData","bins","binCount","binFrequencies","binIndex","maxBinFrequency","maxCurveValue","scaleFactor","Histogram","dataSeries","width","height","title","xTitle","yTitle","bargap","showDistributionLine","plotRef","useRef","theme","usePlotlyTheme","seriesArray","useMemo","effectiveBarMode","defaultColors","COLORS","seriesWithColors","series","index","hasDistributionLine","gridColor","distributionLines","min","max","range","curvePoints","scaledYValues","plotData","useEffect","layout","config","Plotly","plotElement","ChartLegend","items","item","jsx","React","jsxs","rows","rowSize"],"mappings":"4RAQA,MAAMA,EAAqC,IA4BrCC,EAAiBC,GACTA,EAAK,OAAO,CAACC,EAAKC,IAAQD,EAAMC,EAAK,CAAC,EACrCF,EAAK,OAGdG,EAAkB,CAACH,EAAgBI,IAAyB,CAEhE,MAAMC,EADeL,EAAK,IAAKM,GAAU,KAAK,IAAIA,EAAQF,EAAM,CAAC,CAAC,EAEnD,OAAO,CAACH,EAAKC,IAAQD,EAAMC,EAAK,CAAC,EAAIF,EAAK,OACzD,OAAO,KAAK,KAAKK,CAAQ,CAC3B,EAEME,EAAmC,CACvCH,EACAI,EACAC,EACAC,EACAC,EAAS,MACwB,CACjC,MAAMC,EAAoB,CAAA,EACpBC,EAAoB,CAAA,EAEpBC,GAAQJ,EAAMD,IAAUE,EAAS,GAEvC,QAASI,EAAI,EAAGA,EAAIJ,EAAQI,IAAK,CAC/B,MAAMC,EAAIP,EAAQM,EAAID,EACtBF,EAAQ,KAAKI,CAAC,EAEd,MAAMC,EAAWnB,EAAqC,KAAK,KAAKkB,EAAIZ,GAAQI,EAAQ,CAAC,EAC/EU,EAAK,GAAKV,EAAS,KAAK,KAAK,EAAI,KAAK,EAAE,GAAM,KAAK,IAAIS,CAAQ,EACrEJ,EAAQ,KAAKK,CAAC,CAChB,CAEA,MAAO,CAAE,EAAGN,EAAS,EAAGC,CAAA,CAC1B,EAEMM,EAAyB,CAC7BN,EACAO,EACAC,IACa,CACb,MAAMC,EAAW,KAAK,MAAMD,EAAK,IAAMA,EAAK,OAASA,EAAK,IAAI,EACxDE,EAAiB,MAAMD,CAAQ,EAAE,KAAK,CAAC,EAE7CF,EAAc,QAASd,GAAU,CAC/B,GAAIA,GAASe,EAAK,OAASf,GAASe,EAAK,IAAK,CAC5C,MAAMG,EAAW,KAAK,OAAOlB,EAAQe,EA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AO,CAAE,WAAYD,EAAK,OAAS,EAC9DA,EAAK,KACLlD,EAAIgC,EAAO,OAAS,GAAKmB,EAAAA,IAAC,OAAA,CAAK,UAAU,SAAA,CAAU,CAAA,CAAA,CACtD,CAAA,EALmBD,EAAK,IAM1B,CACD,EAEKI,EAAO,CAAA,EACPC,EAAU,EAChB,QAASvD,EAAI,EAAGA,EAAIiD,EAAM,OAAQjD,GAAKuD,EACrCD,EAAK,KACHH,EAAAA,IAAC,MAAA,CAAI,UAAU,aACZ,SAAAF,EAAM,MAAMjD,EAAGA,EAAIuD,CAAO,CAAA,EADIvD,CAEjC,CAAA,EAIJ,OAAOmD,EAAAA,IAAC,MAAA,CAAI,UAAU,mBAAoB,SAAAG,EAAK,CACjD,EAEA,OACEH,EAAAA,IAAC,MAAA,CAAI,UAAU,sBAAsB,MAAO,CAAE,MAAApC,CAAA,EAC5C,SAAAsC,EAAAA,KAAC,MAAA,CAAI,UAAU,kBACZ,SAAA,CAAApC,GACCkC,EAAAA,IAAC,OAAI,UAAU,kBACb,eAAC,KAAA,CAAG,UAAU,QAAS,SAAAlC,CAAA,CAAM,CAAA,CAC/B,EAEFkC,EAAAA,IAAC,MAAA,CACC,IAAK7B,EACL,MAAO,CACL,MAAO,OACP,OAAQ,OACR,OAAQ,GAAA,CACV,CAAA,EAEF6B,EAAAA,IAACH,EAAA,CAAY,OAAQjB,CAAA,CAAkB,CAAA,CAAA,CACzC,CAAA,CACF,CAEJ"}
1
+ {"version":3,"file":"Histogram.cjs","sources":["../../../../src/components/charts/Histogram/Histogram.tsx"],"sourcesContent":["import Plotly from \"plotly.js-dist\";\nimport React, { useEffect, useRef, useMemo } from \"react\";\n\nimport { usePlotlyTheme } from \"@/hooks/use-plotly-theme\";\nimport { CHART_COLORS } from \"@/utils/colors\";\nimport \"./Histogram.scss\";\n\n/** Exponent coefficient for normal distribution calculation */\nconst NORMAL_DISTRIBUTION_EXPONENT_COEFF = -0.5;\n\ninterface HistogramDataSeries {\n x: number[];\n name: string;\n color?: string;\n autobinx?: boolean;\n xbins?: {\n start: number;\n end: number;\n size: number;\n };\n opacity?: number;\n showDistributionLine?: boolean;\n lineWidth?: number;\n}\n\ntype HistogramProps = {\n dataSeries: HistogramDataSeries | HistogramDataSeries[];\n width?: number;\n height?: number;\n title?: string;\n xTitle?: string;\n yTitle?: string;\n bargap?: number;\n showDistributionLine?: boolean;\n};\n\nconst calculateMean = (data: number[]): number => {\n const sum = data.reduce((acc, val) => acc + val, 0);\n return sum / data.length;\n};\n\nconst calculateStdDev = (data: number[], mean: number): number => {\n const squaredDiffs = data.map((value) => Math.pow(value - mean, 2));\n const variance =\n squaredDiffs.reduce((acc, val) => acc + val, 0) / data.length;\n return Math.sqrt(variance);\n};\n\nconst generateNormalDistributionPoints = (\n mean: number,\n stdDev: number,\n start: number,\n end: number,\n points = 100\n): { x: number[]; y: number[] } => {\n const xValues: number[] = [];\n const yValues: number[] = [];\n\n const step = (end - start) / (points - 1);\n\n for (let i = 0; i < points; i++) {\n const x = start + i * step;\n xValues.push(x);\n\n const exponent = NORMAL_DISTRIBUTION_EXPONENT_COEFF * Math.pow((x - mean) / stdDev, 2);\n const y = (1 / (stdDev * Math.sqrt(2 * Math.PI))) * Math.exp(exponent);\n yValues.push(y);\n }\n\n return { x: xValues, y: yValues };\n};\n\nconst scaleDistributionCurve = (\n yValues: number[],\n histogramData: number[],\n bins: { start: number; end: number; size: number }\n): number[] => {\n const binCount = Math.ceil((bins.end - bins.start) / bins.size);\n const binFrequencies = Array(binCount).fill(0);\n\n histogramData.forEach((value) => {\n if (value >= bins.start && value <= bins.end) {\n const binIndex = Math.floor((value - bins.start) / bins.size);\n binFrequencies[binIndex]++;\n }\n });\n\n const maxBinFrequency = Math.max(...binFrequencies);\n const maxCurveValue = Math.max(...yValues);\n\n const scaleFactor = maxBinFrequency / maxCurveValue;\n\n return yValues.map((y) => y * scaleFactor);\n};\n\nconst Histogram: React.FC<HistogramProps> = ({\n dataSeries,\n width = 480,\n height = 480,\n title = \"Histogram\",\n xTitle = \"X Axis\",\n yTitle = \"Frequency\",\n bargap = 0.2,\n showDistributionLine = false,\n}) => {\n const plotRef = useRef<HTMLDivElement>(null);\n const theme = usePlotlyTheme();\n const seriesArray = useMemo(\n () => (Array.isArray(dataSeries) ? dataSeries : [dataSeries]),\n [dataSeries],\n );\n const effectiveBarMode = useMemo<\n \"stack\" | \"group\" | \"overlay\" | \"relative\" | undefined\n >(() => (seriesArray.length > 1 ? \"stack\" : undefined), [seriesArray.length]);\n\n const defaultColors = CHART_COLORS;\n\n const seriesWithColors = useMemo(() => {\n return seriesArray.map((series, index) => {\n const hasDistributionLine =\n typeof series.showDistributionLine === \"undefined\"\n ? showDistributionLine\n : series.showDistributionLine;\n\n return {\n ...series,\n color: series.color || defaultColors[index % defaultColors.length],\n opacity: hasDistributionLine ? 0.5 : series.opacity || 1,\n showDistributionLine: hasDistributionLine,\n lineWidth: series.lineWidth || 3,\n };\n });\n }, [seriesArray, showDistributionLine, defaultColors]);\n\n const gridColor = theme.gridColor;\n\n const histogramData = useMemo(\n () =>\n seriesWithColors.map((series) => ({\n type: \"histogram\" as const,\n x: series.x,\n name: series.name,\n marker: {\n color: series.color,\n line: {\n color: theme.paperBg,\n width: 1,\n },\n opacity: series.opacity,\n },\n autobinx: series.autobinx,\n xbins: series.xbins,\n hovertemplate: `${xTitle}: %{x}<br>${yTitle}: %{y}<extra>${series.name}</extra>`,\n })),\n [seriesWithColors, xTitle, yTitle, theme],\n );\n\n const distributionLines = useMemo(\n () =>\n seriesWithColors\n .filter((series) => series.showDistributionLine)\n .map((series) => {\n const mean = calculateMean(series.x);\n const stdDev = calculateStdDev(series.x, mean);\n\n const min = Math.min(...series.x);\n const max = Math.max(...series.x);\n const range = max - min;\n const start = min - range * 0.1;\n const end = max + range * 0.1;\n\n const bins = series.xbins || {\n start: start,\n end: end,\n size: range / 10,\n };\n\n const curvePoints = generateNormalDistributionPoints(\n mean,\n stdDev,\n start,\n end,\n 100,\n );\n\n const scaledYValues = scaleDistributionCurve(\n curvePoints.y,\n series.x,\n bins,\n );\n\n return {\n type: \"scatter\" as const,\n x: curvePoints.x,\n y: scaledYValues,\n mode: \"lines\" as const,\n name: `${series.name} Distribution`,\n line: {\n color: series.color,\n width: series.lineWidth,\n },\n hoverinfo: \"none\" as const,\n };\n }),\n [seriesWithColors],\n );\n\n const plotData = useMemo(\n () => [...histogramData, ...distributionLines],\n [histogramData, distributionLines],\n );\n\n useEffect(() => {\n if (!plotRef.current) return;\n\n const layout = {\n width,\n height,\n font: {\n family: \"Inter, sans-serif\",\n },\n showlegend: false,\n margin: { l: 90, r: 40, b: 80, t: 40 },\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: 20,\n },\n gridcolor: gridColor,\n tickcolor: theme.tickColor,\n ticklen: 8,\n tickwidth: 1,\n ticks: \"outside\" as const,\n linecolor: theme.lineColor,\n linewidth: 1,\n zeroline: false,\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: 20,\n },\n gridcolor: gridColor,\n tickcolor: theme.tickColor,\n ticklen: 8,\n tickwidth: 1,\n ticks: \"outside\" as const,\n linecolor: theme.lineColor,\n linewidth: 1,\n zeroline: false,\n rangemode: \"tozero\" as const,\n },\n barmode: effectiveBarMode,\n bargap: bargap,\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 }, [width, height, xTitle, yTitle, bargap, plotData, effectiveBarMode, gridColor, theme]);\n\n const ChartLegend: React.FC<{\n series: Array<{ name: string; color: string }>;\n }> = ({ series }) => {\n const items = series.map((item, i) => (\n <React.Fragment key={item.name}>\n <div className=\"legend-item\">\n <span className=\"color-box\" style={{ background: item.color }} />\n {item.name}\n {i < series.length - 1 && <span className=\"divider\" />}\n </div>\n </React.Fragment>\n ));\n\n const rows = [];\n const rowSize = 6;\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\n return <div className=\"legend-container\">{rows}</div>;\n };\n\n return (\n <div className=\"histogram-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 <ChartLegend series={seriesWithColors} />\n </div>\n </div>\n );\n};\n\nexport { Histogram };\nexport type { HistogramDataSeries, HistogramProps };\n"],"names":["NORMAL_DISTRIBUTION_EXPONENT_COEFF","calculateMean","data","acc","val","calculateStdDev","mean","variance","value","generateNormalDistributionPoints","stdDev","start","end","points","xValues","yValues","step","i","x","exponent","y","scaleDistributionCurve","histogramData","bins","binCount","binFrequencies","binIndex","maxBinFrequency","maxCurveValue","scaleFactor","Histogram","dataSeries","width","height","title","xTitle","yTitle","bargap","showDistributionLine","plotRef","useRef","theme","usePlotlyTheme","seriesArray","useMemo","effectiveBarMode","defaultColors","CHART_COLORS","seriesWithColors","series","index","hasDistributionLine","gridColor","distributionLines","min","max","range","curvePoints","scaledYValues","plotData","useEffect","layout","config","Plotly","plotElement","ChartLegend","items","item","jsx","React","jsxs","rows","rowSize"],"mappings":"4RAQA,MAAMA,EAAqC,IA4BrCC,EAAiBC,GACTA,EAAK,OAAO,CAACC,EAAKC,IAAQD,EAAMC,EAAK,CAAC,EACrCF,EAAK,OAGdG,EAAkB,CAACH,EAAgBI,IAAyB,CAEhE,MAAMC,EADeL,EAAK,IAAKM,GAAU,KAAK,IAAIA,EAAQ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AAA,IAAC,MAAA,CAAI,UAAU,sBAAsB,MAAO,CAAE,MAAApC,CAAA,EAC5C,SAAAsC,EAAAA,KAAC,MAAA,CAAI,UAAU,kBACZ,SAAA,CAAApC,GACCkC,EAAAA,IAAC,OAAI,UAAU,kBACb,eAAC,KAAA,CAAG,UAAU,QAAS,SAAAlC,CAAA,CAAM,CAAA,CAC/B,EAEFkC,EAAAA,IAAC,MAAA,CACC,IAAK7B,EACL,MAAO,CACL,MAAO,OACP,OAAQ,OACR,OAAQ,GAAA,CACV,CAAA,EAEF6B,EAAAA,IAACH,EAAA,CAAY,OAAQjB,CAAA,CAAkB,CAAA,CAAA,CACzC,CAAA,CACF,CAEJ"}
@@ -1,22 +1,22 @@
1
- import { jsx as d, jsxs as z } from "react/jsx-runtime";
2
- import P from "plotly.js-dist";
3
- import O, { useRef as q, useMemo as f, useEffect as A } from "react";
4
- import { usePlotlyTheme as F } from "../../../hooks/use-plotly-theme.js";
5
- import { COLORS as x } from "../../../utils/colors.js";
1
+ import { jsx as d, jsxs as I } from "react/jsx-runtime";
2
+ import _ from "plotly.js-dist";
3
+ import B, { useRef as F, useMemo as g, useEffect as P } from "react";
4
+ import { usePlotlyTheme as R } from "../../../hooks/use-plotly-theme.js";
5
+ import { CHART_COLORS as E } from "../../../utils/colors.js";
6
6
  /* empty css */
7
- const _ = -0.5, W = (e) => e.reduce((n, l) => n + l, 0) / e.length, $ = (e, i) => {
7
+ const O = -0.5, W = (e) => e.reduce((n, l) => n + l, 0) / e.length, $ = (e, i) => {
8
8
  const l = e.map((r) => Math.pow(r - i, 2)).reduce((r, s) => r + s, 0) / e.length;
9
9
  return Math.sqrt(l);
10
- }, S = (e, i, n, l, r = 100) => {
11
- const s = [], u = [], p = (l - n) / (r - 1);
10
+ }, H = (e, i, n, l, r = 100) => {
11
+ const s = [], u = [], f = (l - n) / (r - 1);
12
12
  for (let c = 0; c < r; c++) {
13
- const o = n + c * p;
13
+ const o = n + c * f;
14
14
  s.push(o);
15
- const g = _ * Math.pow((o - e) / i, 2), M = 1 / (i * Math.sqrt(2 * Math.PI)) * Math.exp(g);
16
- u.push(M);
15
+ const p = O * Math.pow((o - e) / i, 2), w = 1 / (i * Math.sqrt(2 * Math.PI)) * Math.exp(p);
16
+ u.push(w);
17
17
  }
18
18
  return { x: s, y: u };
19
- }, U = (e, i, n) => {
19
+ }, S = (e, i, n) => {
20
20
  const l = Math.ceil((n.end - n.start) / n.size), r = Array(l).fill(0);
21
21
  i.forEach((c) => {
22
22
  if (c >= n.start && c <= n.end) {
@@ -24,8 +24,8 @@ const _ = -0.5, W = (e) => e.reduce((n, l) => n + l, 0) / e.length, $ = (e, i) =
24
24
  r[o]++;
25
25
  }
26
26
  });
27
- const s = Math.max(...r), u = Math.max(...e), p = s / u;
28
- return e.map((c) => c * p);
27
+ const s = Math.max(...r), u = Math.max(...e), f = s / u;
28
+ return e.map((c) => c * f);
29
29
  }, K = ({
30
30
  dataSeries: e,
31
31
  width: i = 480,
@@ -34,32 +34,22 @@ const _ = -0.5, W = (e) => e.reduce((n, l) => n + l, 0) / e.length, $ = (e, i) =
34
34
  xTitle: r = "X Axis",
35
35
  yTitle: s = "Frequency",
36
36
  bargap: u = 0.2,
37
- showDistributionLine: p = !1
37
+ showDistributionLine: f = !1
38
38
  }) => {
39
- const c = q(null), o = F(), g = f(
39
+ const c = F(null), o = R(), p = g(
40
40
  () => Array.isArray(e) ? e : [e],
41
41
  [e]
42
- ), M = f(() => g.length > 1 ? "stack" : void 0, [g.length]), v = f(
43
- () => [
44
- x.ORANGE,
45
- x.RED,
46
- x.BLUE,
47
- x.GREEN,
48
- x.PURPLE,
49
- x.YELLOW
50
- ],
51
- []
52
- ), y = f(() => g.map((t, h) => {
53
- const m = typeof t.showDistributionLine > "u" ? p : t.showDistributionLine;
42
+ ), w = g(() => p.length > 1 ? "stack" : void 0, [p.length]), M = E, x = g(() => p.map((t, h) => {
43
+ const m = typeof t.showDistributionLine > "u" ? f : t.showDistributionLine;
54
44
  return {
55
45
  ...t,
56
- color: t.color || v[h % v.length],
46
+ color: t.color || M[h % M.length],
57
47
  opacity: m ? 0.5 : t.opacity || 1,
58
48
  showDistributionLine: m,
59
49
  lineWidth: t.lineWidth || 3
60
50
  };
61
- }), [g, p, v]), N = o.gridColor, C = f(
62
- () => y.map((t) => ({
51
+ }), [p, f, M]), v = o.gridColor, C = g(
52
+ () => x.map((t) => ({
63
53
  type: "histogram",
64
54
  x: t.x,
65
55
  name: t.name,
@@ -75,28 +65,28 @@ const _ = -0.5, W = (e) => e.reduce((n, l) => n + l, 0) / e.length, $ = (e, i) =
75
65
  xbins: t.xbins,
76
66
  hovertemplate: `${r}: %{x}<br>${s}: %{y}<extra>${t.name}</extra>`
77
67
  })),
78
- [y, r, s, o]
79
- ), D = f(
80
- () => y.filter((t) => t.showDistributionLine).map((t) => {
81
- const h = W(t.x), m = $(t.x, h), b = Math.min(...t.x), a = Math.max(...t.x), w = a - b, E = b - w * 0.1, L = a + w * 0.1, B = t.xbins || {
82
- start: E,
83
- end: L,
84
- size: w / 10
85
- }, R = S(
68
+ [x, r, s, o]
69
+ ), N = g(
70
+ () => x.filter((t) => t.showDistributionLine).map((t) => {
71
+ const h = W(t.x), m = $(t.x, h), y = Math.min(...t.x), a = Math.max(...t.x), b = a - y, D = y - b * 0.1, z = a + b * 0.1, q = t.xbins || {
72
+ start: D,
73
+ end: z,
74
+ size: b / 10
75
+ }, L = H(
86
76
  h,
87
77
  m,
88
- E,
89
- L,
78
+ D,
79
+ z,
90
80
  100
91
- ), I = U(
92
- R.y,
81
+ ), A = S(
82
+ L.y,
93
83
  t.x,
94
- B
84
+ q
95
85
  );
96
86
  return {
97
87
  type: "scatter",
98
- x: R.x,
99
- y: I,
88
+ x: L.x,
89
+ y: A,
100
90
  mode: "lines",
101
91
  name: `${t.name} Distribution`,
102
92
  line: {
@@ -106,12 +96,12 @@ const _ = -0.5, W = (e) => e.reduce((n, l) => n + l, 0) / e.length, $ = (e, i) =
106
96
  hoverinfo: "none"
107
97
  };
108
98
  }),
109
- [y]
110
- ), k = f(
111
- () => [...C, ...D],
112
- [C, D]
99
+ [x]
100
+ ), k = g(
101
+ () => [...C, ...N],
102
+ [C, N]
113
103
  );
114
- return A(() => {
104
+ return P(() => {
115
105
  if (!c.current) return;
116
106
  const t = {
117
107
  width: i,
@@ -132,7 +122,7 @@ const _ = -0.5, W = (e) => e.reduce((n, l) => n + l, 0) / e.length, $ = (e, i) =
132
122
  },
133
123
  standoff: 20
134
124
  },
135
- gridcolor: N,
125
+ gridcolor: v,
136
126
  tickcolor: o.tickColor,
137
127
  ticklen: 8,
138
128
  tickwidth: 1,
@@ -152,7 +142,7 @@ const _ = -0.5, W = (e) => e.reduce((n, l) => n + l, 0) / e.length, $ = (e, i) =
152
142
  },
153
143
  standoff: 20
154
144
  },
155
- gridcolor: N,
145
+ gridcolor: v,
156
146
  tickcolor: o.tickColor,
157
147
  ticklen: 8,
158
148
  tickwidth: 1,
@@ -162,7 +152,7 @@ const _ = -0.5, W = (e) => e.reduce((n, l) => n + l, 0) / e.length, $ = (e, i) =
162
152
  zeroline: !1,
163
153
  rangemode: "tozero"
164
154
  },
165
- barmode: M,
155
+ barmode: w,
166
156
  bargap: u,
167
157
  paper_bgcolor: o.paperBg,
168
158
  plot_bgcolor: o.plotBg
@@ -171,12 +161,12 @@ const _ = -0.5, W = (e) => e.reduce((n, l) => n + l, 0) / e.length, $ = (e, i) =
171
161
  displayModeBar: !1,
172
162
  displaylogo: !1
173
163
  };
174
- P.newPlot(c.current, k, t, h);
164
+ _.newPlot(c.current, k, t, h);
175
165
  const m = c.current;
176
166
  return () => {
177
- m && P.purge(m);
167
+ m && _.purge(m);
178
168
  };
179
- }, [i, n, r, s, u, k, M, N, o]), /* @__PURE__ */ d("div", { className: "histogram-container", style: { width: i }, children: /* @__PURE__ */ z("div", { className: "chart-container", children: [
169
+ }, [i, n, r, s, u, k, w, v, o]), /* @__PURE__ */ d("div", { className: "histogram-container", style: { width: i }, children: /* @__PURE__ */ I("div", { className: "chart-container", children: [
180
170
  l && /* @__PURE__ */ d("div", { className: "title-container", children: /* @__PURE__ */ d("h2", { className: "title", children: l }) }),
181
171
  /* @__PURE__ */ d(
182
172
  "div",
@@ -190,17 +180,17 @@ const _ = -0.5, W = (e) => e.reduce((n, l) => n + l, 0) / e.length, $ = (e, i) =
190
180
  }
191
181
  ),
192
182
  /* @__PURE__ */ d(({ series: t }) => {
193
- const h = t.map((a, w) => /* @__PURE__ */ d(O.Fragment, { children: /* @__PURE__ */ z("div", { className: "legend-item", children: [
183
+ const h = t.map((a, b) => /* @__PURE__ */ d(B.Fragment, { children: /* @__PURE__ */ I("div", { className: "legend-item", children: [
194
184
  /* @__PURE__ */ d("span", { className: "color-box", style: { background: a.color } }),
195
185
  a.name,
196
- w < t.length - 1 && /* @__PURE__ */ d("span", { className: "divider" })
197
- ] }) }, a.name)), m = [], b = 6;
198
- for (let a = 0; a < h.length; a += b)
186
+ b < t.length - 1 && /* @__PURE__ */ d("span", { className: "divider" })
187
+ ] }) }, a.name)), m = [], y = 6;
188
+ for (let a = 0; a < h.length; a += y)
199
189
  m.push(
200
- /* @__PURE__ */ d("div", { className: "legend-row", children: h.slice(a, a + b) }, a)
190
+ /* @__PURE__ */ d("div", { className: "legend-row", children: h.slice(a, a + y) }, a)
201
191
  );
202
192
  return /* @__PURE__ */ d("div", { className: "legend-container", children: m });
203
- }, { series: y })
193
+ }, { series: x })
204
194
  ] }) });
205
195
  };
206
196
  export {