@calimero-network/mero-charts 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,19 +21,19 @@ import { Gauge, GaugeCard } from '@calimero/charts';
21
21
  <Gauge value={75} label="CPU" />
22
22
 
23
23
  // Gauge with custom thresholds
24
- <Gauge
25
- value={85}
26
- min={0}
27
- max={100}
24
+ <Gauge
25
+ value={85}
26
+ min={0}
27
+ max={100}
28
28
  thresholds={{ good: 60, warning: 80, max: 100 }}
29
29
  decimals={1}
30
30
  />
31
31
 
32
32
  // Gauge in a card
33
- <GaugeCard
34
- title="CPU Usage"
35
- value={73.4}
36
- suffix="%"
33
+ <GaugeCard
34
+ title="CPU Usage"
35
+ value={73.4}
36
+ suffix="%"
37
37
  />
38
38
  ```
39
39
 
@@ -51,7 +51,7 @@ import { Gauge, GaugeCard } from '@calimero/charts';
51
51
  A line chart component for displaying time-series data using Recharts.
52
52
 
53
53
  ```tsx
54
- import { SeriesCard, Series } from '@calimero/charts';
54
+ import { SeriesCard, Series } from "@calimero/charts";
55
55
 
56
56
  const data: Series[] = [
57
57
  {
@@ -59,16 +59,12 @@ const data: Series[] = [
59
59
  data: [
60
60
  { t: Date.now() - 60000, y: 12.5 },
61
61
  { t: Date.now() - 30000, y: 15.2 },
62
- { t: Date.now(), y: 13.8 }
63
- ]
64
- }
62
+ { t: Date.now(), y: 13.8 },
63
+ ],
64
+ },
65
65
  ];
66
66
 
67
- <SeriesCard
68
- title="API Requests"
69
- series={data}
70
- yLabel="req/s"
71
- />
67
+ <SeriesCard title="API Requests" series={data} yLabel="req/s" />;
72
68
  ```
73
69
 
74
70
  #### Props
@@ -82,7 +78,7 @@ const data: Series[] = [
82
78
  A table component for displaying Prometheus-style instant vector data.
83
79
 
84
80
  ```tsx
85
- import { VectorTable, PromVectorResult } from '@calimero/charts';
81
+ import { VectorTable, PromVectorResult } from "@calimero/charts";
86
82
 
87
83
  const vector: PromVectorResult = {
88
84
  status: "success",
@@ -90,22 +86,19 @@ const vector: PromVectorResult = {
90
86
  resultType: "vector",
91
87
  result: [
92
88
  {
93
- metric: {
94
- instance: "10.0.99.165:8429",
95
- container: "vmsingle",
96
- reason: "unsupported",
97
- path: "*"
89
+ metric: {
90
+ instance: "10.0.99.165:8429",
91
+ container: "vmsingle",
92
+ reason: "unsupported",
93
+ path: "*",
98
94
  },
99
- value: [1756235265, "0"]
100
- }
101
- ]
102
- }
95
+ value: [1756235265, "0"],
96
+ },
97
+ ],
98
+ },
103
99
  };
104
100
 
105
- <VectorTable
106
- title="HTTP Request Errors"
107
- vector={vector}
108
- />
101
+ <VectorTable title="HTTP Request Errors" vector={vector} />;
109
102
  ```
110
103
 
111
104
  #### Props
@@ -118,9 +111,9 @@ const vector: PromVectorResult = {
118
111
  Use the `ChartsDemo` component to see all chart types in action:
119
112
 
120
113
  ```tsx
121
- import { ChartsDemo } from '@calimero/charts';
114
+ import { ChartsDemo } from "@calimero/charts";
122
115
 
123
- <ChartsDemo />
116
+ <ChartsDemo />;
124
117
  ```
125
118
 
126
119
  ## Card Primitives
@@ -128,16 +121,14 @@ import { ChartsDemo } from '@calimero/charts';
128
121
  The package also exports card primitives that can be used independently:
129
122
 
130
123
  ```tsx
131
- import { Card, CardHeader, CardTitle, CardContent } from '@calimero/charts';
124
+ import { Card, CardHeader, CardTitle, CardContent } from "@calimero/charts";
132
125
 
133
126
  <Card>
134
127
  <CardHeader>
135
128
  <CardTitle>Custom Content</CardTitle>
136
129
  </CardHeader>
137
- <CardContent>
138
- Your content here
139
- </CardContent>
140
- </Card>
130
+ <CardContent>Your content here</CardContent>
131
+ </Card>;
141
132
  ```
142
133
 
143
134
  ## Styling
@@ -145,6 +136,7 @@ import { Card, CardHeader, CardTitle, CardContent } from '@calimero/charts';
145
136
  The charts use Calimero design tokens for consistent theming:
146
137
 
147
138
  ### Colors
139
+
148
140
  - **Success**: `#16a34a` (green) - Good zone
149
141
  - **Warning**: `#f59e0b` (orange) - Warning zone
150
142
  - **Error**: `#ef4444` (red) - Critical zone
package/dist/index.d.mts CHANGED
@@ -1,10 +1,18 @@
1
1
  import React from 'react';
2
2
 
3
3
  // Card primitives
4
- declare function Card(props: React.PropsWithChildren<{ className?: string }>): JSX.Element;
5
- declare function CardHeader(props: React.PropsWithChildren<{ className?: string }>): JSX.Element;
6
- declare function CardTitle(props: React.PropsWithChildren<{ className?: string }>): JSX.Element;
7
- declare function CardContent(props: React.PropsWithChildren<{ className?: string }>): JSX.Element;
4
+ declare function Card(
5
+ props: React.PropsWithChildren<{ className?: string }>,
6
+ ): JSX.Element;
7
+ declare function CardHeader(
8
+ props: React.PropsWithChildren<{ className?: string }>,
9
+ ): JSX.Element;
10
+ declare function CardTitle(
11
+ props: React.PropsWithChildren<{ className?: string }>,
12
+ ): JSX.Element;
13
+ declare function CardContent(
14
+ props: React.PropsWithChildren<{ className?: string }>,
15
+ ): JSX.Element;
8
16
 
9
17
  // Gauge chart
10
18
  declare type Thresholds = { good: number; warn: number; bad: number };
@@ -41,7 +49,7 @@ declare type PromVectorResult = {
41
49
  data: {
42
50
  resultType: "vector";
43
51
  result: Array<{ metric: Record<string, string>; value: [number, string] }>;
44
- }
52
+ };
45
53
  };
46
54
  declare function VectorTable(props: {
47
55
  vector: PromVectorResult;
package/dist/index.d.ts CHANGED
@@ -1,10 +1,18 @@
1
1
  import React from 'react';
2
2
 
3
3
  // Card primitives
4
- declare function Card(props: React.PropsWithChildren<{ className?: string }>): JSX.Element;
5
- declare function CardHeader(props: React.PropsWithChildren<{ className?: string }>): JSX.Element;
6
- declare function CardTitle(props: React.PropsWithChildren<{ className?: string }>): JSX.Element;
7
- declare function CardContent(props: React.PropsWithChildren<{ className?: string }>): JSX.Element;
4
+ declare function Card(
5
+ props: React.PropsWithChildren<{ className?: string }>,
6
+ ): JSX.Element;
7
+ declare function CardHeader(
8
+ props: React.PropsWithChildren<{ className?: string }>,
9
+ ): JSX.Element;
10
+ declare function CardTitle(
11
+ props: React.PropsWithChildren<{ className?: string }>,
12
+ ): JSX.Element;
13
+ declare function CardContent(
14
+ props: React.PropsWithChildren<{ className?: string }>,
15
+ ): JSX.Element;
8
16
 
9
17
  // Gauge chart
10
18
  declare type Thresholds = { good: number; warn: number; bad: number };
@@ -41,7 +49,7 @@ declare type PromVectorResult = {
41
49
  data: {
42
50
  resultType: "vector";
43
51
  result: Array<{ metric: Record<string, string>; value: [number, string] }>;
44
- }
52
+ };
45
53
  };
46
54
  declare function VectorTable(props: {
47
55
  vector: PromVectorResult;
package/dist/index.js CHANGED
@@ -46,56 +46,114 @@ function Gauge({
46
46
  return "#ef4444";
47
47
  };
48
48
  const valueColor = getValueColor(pct);
49
- return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { width: "100%", display: "flex", flexDirection: "column", alignItems: "center" }, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 240 160", style: { width: "100%" }, children: [
50
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: arcPath(cx, cy, arcRadius, startAngle, endAngle), stroke: "#6B7280", strokeOpacity: 0.3, strokeWidth: 18, fill: "none", strokeLinecap: "butt" }),
51
- /* @__PURE__ */ jsxRuntime.jsx(
52
- "path",
53
- {
54
- d: arcPath(cx, cy, arcRadius, startAngle, valueEndAngle),
55
- stroke: valueColor,
56
- strokeWidth: 18,
57
- fill: "none",
58
- strokeLinecap: "butt"
59
- }
60
- ),
61
- /* @__PURE__ */ jsxRuntime.jsx(
62
- "path",
63
- {
64
- d: arcPath(cx, cy, arcRadius + 15, startAngle, startAngle + thresholds.warning / 100 * (endAngle - startAngle)),
65
- stroke: "#A5FF11",
66
- strokeOpacity: 0.3,
67
- strokeWidth: 4,
68
- fill: "none",
69
- strokeLinecap: "butt"
70
- }
71
- ),
72
- /* @__PURE__ */ jsxRuntime.jsx(
73
- "path",
74
- {
75
- d: arcPath(cx, cy, arcRadius + 15, startAngle + thresholds.warning / 100 * (endAngle - startAngle), startAngle + thresholds.danger / 100 * (endAngle - startAngle)),
76
- stroke: "#f59e0b",
77
- strokeOpacity: 0.3,
78
- strokeWidth: 4,
79
- fill: "none",
80
- strokeLinecap: "butt"
81
- }
82
- ),
83
- /* @__PURE__ */ jsxRuntime.jsx(
84
- "path",
85
- {
86
- d: arcPath(cx, cy, arcRadius + 15, startAngle + thresholds.danger / 100 * (endAngle - startAngle), endAngle),
87
- stroke: "#ef4444",
88
- strokeOpacity: 0.3,
89
- strokeWidth: 4,
90
- fill: "none",
91
- strokeLinecap: "butt"
92
- }
93
- ),
94
- /* @__PURE__ */ jsxRuntime.jsx("circle", { cx, cy, r: inner, fill: "#1F2A15" }),
95
- " ",
96
- /* @__PURE__ */ jsxRuntime.jsx("text", { x: cx, y: cy - 8, textAnchor: "middle", dominantBaseline: "middle", style: { fontWeight: 600, fontSize: "28px", fill: valueColor }, children: valueText }),
97
- label && /* @__PURE__ */ jsxRuntime.jsx("text", { x: cx, y: cy + 14, textAnchor: "middle", style: { fontSize: "12px", fill: valueColor }, children: label })
98
- ] }) });
49
+ return /* @__PURE__ */ jsxRuntime.jsx(
50
+ "div",
51
+ {
52
+ style: {
53
+ width: "100%",
54
+ display: "flex",
55
+ flexDirection: "column",
56
+ alignItems: "center"
57
+ },
58
+ children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 240 160", style: { width: "100%" }, children: [
59
+ /* @__PURE__ */ jsxRuntime.jsx(
60
+ "path",
61
+ {
62
+ d: arcPath(cx, cy, arcRadius, startAngle, endAngle),
63
+ stroke: "#6B7280",
64
+ strokeOpacity: 0.3,
65
+ strokeWidth: 18,
66
+ fill: "none",
67
+ strokeLinecap: "butt"
68
+ }
69
+ ),
70
+ /* @__PURE__ */ jsxRuntime.jsx(
71
+ "path",
72
+ {
73
+ d: arcPath(cx, cy, arcRadius, startAngle, valueEndAngle),
74
+ stroke: valueColor,
75
+ strokeWidth: 18,
76
+ fill: "none",
77
+ strokeLinecap: "butt"
78
+ }
79
+ ),
80
+ /* @__PURE__ */ jsxRuntime.jsx(
81
+ "path",
82
+ {
83
+ d: arcPath(
84
+ cx,
85
+ cy,
86
+ arcRadius + 15,
87
+ startAngle,
88
+ startAngle + thresholds.warning / 100 * (endAngle - startAngle)
89
+ ),
90
+ stroke: "#A5FF11",
91
+ strokeOpacity: 0.3,
92
+ strokeWidth: 4,
93
+ fill: "none",
94
+ strokeLinecap: "butt"
95
+ }
96
+ ),
97
+ /* @__PURE__ */ jsxRuntime.jsx(
98
+ "path",
99
+ {
100
+ d: arcPath(
101
+ cx,
102
+ cy,
103
+ arcRadius + 15,
104
+ startAngle + thresholds.warning / 100 * (endAngle - startAngle),
105
+ startAngle + thresholds.danger / 100 * (endAngle - startAngle)
106
+ ),
107
+ stroke: "#f59e0b",
108
+ strokeOpacity: 0.3,
109
+ strokeWidth: 4,
110
+ fill: "none",
111
+ strokeLinecap: "butt"
112
+ }
113
+ ),
114
+ /* @__PURE__ */ jsxRuntime.jsx(
115
+ "path",
116
+ {
117
+ d: arcPath(
118
+ cx,
119
+ cy,
120
+ arcRadius + 15,
121
+ startAngle + thresholds.danger / 100 * (endAngle - startAngle),
122
+ endAngle
123
+ ),
124
+ stroke: "#ef4444",
125
+ strokeOpacity: 0.3,
126
+ strokeWidth: 4,
127
+ fill: "none",
128
+ strokeLinecap: "butt"
129
+ }
130
+ ),
131
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx, cy, r: inner, fill: "#1F2A15" }),
132
+ " ",
133
+ /* @__PURE__ */ jsxRuntime.jsx(
134
+ "text",
135
+ {
136
+ x: cx,
137
+ y: cy - 8,
138
+ textAnchor: "middle",
139
+ dominantBaseline: "middle",
140
+ style: { fontWeight: 600, fontSize: "28px", fill: valueColor },
141
+ children: valueText
142
+ }
143
+ ),
144
+ label && /* @__PURE__ */ jsxRuntime.jsx(
145
+ "text",
146
+ {
147
+ x: cx,
148
+ y: cy + 14,
149
+ textAnchor: "middle",
150
+ style: { fontSize: "12px", fill: valueColor },
151
+ children: label
152
+ }
153
+ )
154
+ ] })
155
+ }
156
+ );
99
157
  }
100
158
  function calculateMean(series) {
101
159
  if (!series.data.length) return 0;
@@ -137,7 +195,10 @@ var generateColors = (count) => {
137
195
  "#ef4444"
138
196
  // Red
139
197
  ];
140
- return Array.from({ length: count }, (_, i) => baseColors[i % baseColors.length]);
198
+ return Array.from(
199
+ { length: count },
200
+ (_, i) => baseColors[i % baseColors.length]
201
+ );
141
202
  };
142
203
  function TimeSeries({
143
204
  series,
@@ -163,42 +224,61 @@ function TimeSeries({
163
224
  });
164
225
  }, [series]);
165
226
  const finalColors = colors || generateColors(series.length);
166
- return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.ComposedChart, { data: rows, margin: { left: 12, right: 12, top: 5, bottom: 5 }, children: [
167
- /* @__PURE__ */ jsxRuntime.jsx(recharts.XAxis, { dataKey: "t", tickFormatter: formatTime, minTickGap: 32 }),
168
- /* @__PURE__ */ jsxRuntime.jsx(recharts.YAxis, { domain: domainY, tickFormatter: (v) => `${v}` }),
169
- /* @__PURE__ */ jsxRuntime.jsx(recharts.Tooltip, { labelFormatter: (l) => `Time: ${formatTime(l)}`, formatter: (v) => [v, yLabel ?? "value"] }),
170
- showLegend && /* @__PURE__ */ jsxRuntime.jsx(recharts.Legend, {}),
171
- series.map((s, index) => {
172
- const color = finalColors[index];
173
- if (s.fill) {
174
- return /* @__PURE__ */ jsxRuntime.jsx(
175
- recharts.Area,
227
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(
228
+ recharts.ComposedChart,
229
+ {
230
+ data: rows,
231
+ margin: { left: 12, right: 12, top: 5, bottom: 5 },
232
+ children: [
233
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.XAxis, { dataKey: "t", tickFormatter: formatTime, minTickGap: 32 }),
234
+ /* @__PURE__ */ jsxRuntime.jsx(
235
+ recharts.YAxis,
176
236
  {
177
- type: "monotone",
178
- dataKey: s.name,
179
- stroke: color,
180
- fill: color,
181
- fillOpacity: 0.1,
182
- strokeWidth: 2
183
- },
184
- s.name
185
- );
186
- } else {
187
- return /* @__PURE__ */ jsxRuntime.jsx(
188
- recharts.Line,
237
+ domain: domainY,
238
+ tickFormatter: (v) => `${v}`
239
+ }
240
+ ),
241
+ /* @__PURE__ */ jsxRuntime.jsx(
242
+ recharts.Tooltip,
189
243
  {
190
- type: "monotone",
191
- dataKey: s.name,
192
- dot: false,
193
- strokeWidth: 2,
194
- stroke: color,
195
- fill: "none"
196
- },
197
- s.name
198
- );
199
- }
200
- })
201
- ] }) }) });
244
+ labelFormatter: (l) => `Time: ${formatTime(l)}`,
245
+ formatter: (v) => [v, yLabel ?? "value"]
246
+ }
247
+ ),
248
+ showLegend && /* @__PURE__ */ jsxRuntime.jsx(recharts.Legend, {}),
249
+ series.map((s, index) => {
250
+ const color = finalColors[index];
251
+ if (s.fill) {
252
+ return /* @__PURE__ */ jsxRuntime.jsx(
253
+ recharts.Area,
254
+ {
255
+ type: "monotone",
256
+ dataKey: s.name,
257
+ stroke: color,
258
+ fill: color,
259
+ fillOpacity: 0.1,
260
+ strokeWidth: 2
261
+ },
262
+ s.name
263
+ );
264
+ } else {
265
+ return /* @__PURE__ */ jsxRuntime.jsx(
266
+ recharts.Line,
267
+ {
268
+ type: "monotone",
269
+ dataKey: s.name,
270
+ dot: false,
271
+ strokeWidth: 2,
272
+ stroke: color,
273
+ fill: "none"
274
+ },
275
+ s.name
276
+ );
277
+ }
278
+ })
279
+ ]
280
+ }
281
+ ) }) });
202
282
  }
203
283
  function VectorTableRaw({
204
284
  data,
@@ -214,26 +294,54 @@ function VectorTableRaw({
214
294
  return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { overflow: "auto" }, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { style: { width: "100%", fontSize: "14px" }, children: [
215
295
  /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { style: { textAlign: "left", color: "#94a3b8" }, children: [
216
296
  /* @__PURE__ */ jsxRuntime.jsx("th", { style: { padding: "8px 12px 8px 0", fontWeight: "500" }, children: "Name" }),
217
- finalColumns.map((column, index) => /* @__PURE__ */ jsxRuntime.jsx("th", { style: { padding: "8px 12px", fontWeight: "500", textAlign: "right" }, children: column.title }, index))
297
+ finalColumns.map((column, index) => /* @__PURE__ */ jsxRuntime.jsx(
298
+ "th",
299
+ {
300
+ style: {
301
+ padding: "8px 12px",
302
+ fontWeight: "500",
303
+ textAlign: "right"
304
+ },
305
+ children: column.title
306
+ },
307
+ index
308
+ ))
218
309
  ] }) }),
219
310
  /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: data.map((row, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { style: { borderTop: "1px solid #374151" }, children: [
220
311
  /* @__PURE__ */ jsxRuntime.jsxs("td", { style: { padding: "8px 12px 8px 0", position: "relative" }, children: [
221
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
222
- position: "absolute",
223
- left: "0",
224
- top: "50%",
225
- transform: "translateY(-50%)",
226
- width: "4px",
227
- height: "12px",
228
- backgroundColor: colors?.[index] || row.color || "#A5FF11",
229
- borderRadius: "2px"
230
- } }),
312
+ /* @__PURE__ */ jsxRuntime.jsx(
313
+ "div",
314
+ {
315
+ style: {
316
+ position: "absolute",
317
+ left: "0",
318
+ top: "50%",
319
+ transform: "translateY(-50%)",
320
+ width: "4px",
321
+ height: "12px",
322
+ backgroundColor: colors?.[index] || row.color || "#A5FF11",
323
+ borderRadius: "2px"
324
+ }
325
+ }
326
+ ),
231
327
  /* @__PURE__ */ jsxRuntime.jsx("span", { style: { marginLeft: "16px", color: "white" }, children: row.name })
232
328
  ] }),
233
329
  finalColumns.map((column, colIndex) => {
234
330
  const key = column.title.toLowerCase().replace(/\s+/g, "_");
235
331
  const value = row[key] || 0;
236
- return /* @__PURE__ */ jsxRuntime.jsx("td", { style: { padding: "8px 12px", textAlign: "right", color: "white", fontVariantNumeric: "tabular-nums" }, children: typeof value === "number" ? value.toFixed(3) : value }, colIndex);
332
+ return /* @__PURE__ */ jsxRuntime.jsx(
333
+ "td",
334
+ {
335
+ style: {
336
+ padding: "8px 12px",
337
+ textAlign: "right",
338
+ color: "white",
339
+ fontVariantNumeric: "tabular-nums"
340
+ },
341
+ children: typeof value === "number" ? value.toFixed(3) : value
342
+ },
343
+ colIndex
344
+ );
237
345
  })
238
346
  ] }, index)) })
239
347
  ] }) });
@@ -261,7 +369,10 @@ var generateColors2 = (count) => {
261
369
  "#ef4444"
262
370
  // Red
263
371
  ];
264
- return Array.from({ length: count }, (_, i) => baseColors[i % baseColors.length]);
372
+ return Array.from(
373
+ { length: count },
374
+ (_, i) => baseColors[i % baseColors.length]
375
+ );
265
376
  };
266
377
  function TimeSeriesWithTable({
267
378
  timeSeriesData,
@@ -294,35 +405,53 @@ function TimeSeriesWithTable({
294
405
  return row;
295
406
  });
296
407
  }, [vectorTableData, timeSeriesData, columns]);
297
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
298
- display: "flex",
299
- flexDirection: layout === "side-by-side" ? "row" : "column",
300
- gap: "24px",
301
- minHeight: "240px"
302
- }, children: [
303
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
304
- height: layout === "side-by-side" ? "240px" : "240px",
305
- flex: layout === "side-by-side" ? "1" : "none"
306
- }, children: /* @__PURE__ */ jsxRuntime.jsx(
307
- TimeSeries,
308
- {
309
- series: timeSeriesData,
310
- yLabel: timeSeriesYLabel,
311
- colors: finalColors,
312
- showLegend: showTimeSeriesLegend
313
- }
314
- ) }),
315
- (layout === "table-below" || layout === "side-by-side") && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
316
- flex: layout === "side-by-side" ? "1" : "none"
317
- }, children: /* @__PURE__ */ jsxRuntime.jsx(
318
- VectorTableRaw,
319
- {
320
- data: finalTableData,
321
- colors: finalColors,
322
- columns
323
- }
324
- ) })
325
- ] });
408
+ return /* @__PURE__ */ jsxRuntime.jsxs(
409
+ "div",
410
+ {
411
+ style: {
412
+ display: "flex",
413
+ flexDirection: layout === "side-by-side" ? "row" : "column",
414
+ gap: "24px",
415
+ minHeight: "240px"
416
+ },
417
+ children: [
418
+ /* @__PURE__ */ jsxRuntime.jsx(
419
+ "div",
420
+ {
421
+ style: {
422
+ height: layout === "side-by-side" ? "240px" : "240px",
423
+ flex: layout === "side-by-side" ? "1" : "none"
424
+ },
425
+ children: /* @__PURE__ */ jsxRuntime.jsx(
426
+ TimeSeries,
427
+ {
428
+ series: timeSeriesData,
429
+ yLabel: timeSeriesYLabel,
430
+ colors: finalColors,
431
+ showLegend: showTimeSeriesLegend
432
+ }
433
+ )
434
+ }
435
+ ),
436
+ (layout === "table-below" || layout === "side-by-side") && /* @__PURE__ */ jsxRuntime.jsx(
437
+ "div",
438
+ {
439
+ style: {
440
+ flex: layout === "side-by-side" ? "1" : "none"
441
+ },
442
+ children: /* @__PURE__ */ jsxRuntime.jsx(
443
+ VectorTableRaw,
444
+ {
445
+ data: finalTableData,
446
+ colors: finalColors,
447
+ columns
448
+ }
449
+ )
450
+ }
451
+ )
452
+ ]
453
+ }
454
+ );
326
455
  }
327
456
 
328
457
  exports.Gauge = Gauge;
package/dist/index.mjs CHANGED
@@ -44,56 +44,114 @@ function Gauge({
44
44
  return "#ef4444";
45
45
  };
46
46
  const valueColor = getValueColor(pct);
47
- return /* @__PURE__ */ jsx("div", { style: { width: "100%", display: "flex", flexDirection: "column", alignItems: "center" }, children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 240 160", style: { width: "100%" }, children: [
48
- /* @__PURE__ */ jsx("path", { d: arcPath(cx, cy, arcRadius, startAngle, endAngle), stroke: "#6B7280", strokeOpacity: 0.3, strokeWidth: 18, fill: "none", strokeLinecap: "butt" }),
49
- /* @__PURE__ */ jsx(
50
- "path",
51
- {
52
- d: arcPath(cx, cy, arcRadius, startAngle, valueEndAngle),
53
- stroke: valueColor,
54
- strokeWidth: 18,
55
- fill: "none",
56
- strokeLinecap: "butt"
57
- }
58
- ),
59
- /* @__PURE__ */ jsx(
60
- "path",
61
- {
62
- d: arcPath(cx, cy, arcRadius + 15, startAngle, startAngle + thresholds.warning / 100 * (endAngle - startAngle)),
63
- stroke: "#A5FF11",
64
- strokeOpacity: 0.3,
65
- strokeWidth: 4,
66
- fill: "none",
67
- strokeLinecap: "butt"
68
- }
69
- ),
70
- /* @__PURE__ */ jsx(
71
- "path",
72
- {
73
- d: arcPath(cx, cy, arcRadius + 15, startAngle + thresholds.warning / 100 * (endAngle - startAngle), startAngle + thresholds.danger / 100 * (endAngle - startAngle)),
74
- stroke: "#f59e0b",
75
- strokeOpacity: 0.3,
76
- strokeWidth: 4,
77
- fill: "none",
78
- strokeLinecap: "butt"
79
- }
80
- ),
81
- /* @__PURE__ */ jsx(
82
- "path",
83
- {
84
- d: arcPath(cx, cy, arcRadius + 15, startAngle + thresholds.danger / 100 * (endAngle - startAngle), endAngle),
85
- stroke: "#ef4444",
86
- strokeOpacity: 0.3,
87
- strokeWidth: 4,
88
- fill: "none",
89
- strokeLinecap: "butt"
90
- }
91
- ),
92
- /* @__PURE__ */ jsx("circle", { cx, cy, r: inner, fill: "#1F2A15" }),
93
- " ",
94
- /* @__PURE__ */ jsx("text", { x: cx, y: cy - 8, textAnchor: "middle", dominantBaseline: "middle", style: { fontWeight: 600, fontSize: "28px", fill: valueColor }, children: valueText }),
95
- label && /* @__PURE__ */ jsx("text", { x: cx, y: cy + 14, textAnchor: "middle", style: { fontSize: "12px", fill: valueColor }, children: label })
96
- ] }) });
47
+ return /* @__PURE__ */ jsx(
48
+ "div",
49
+ {
50
+ style: {
51
+ width: "100%",
52
+ display: "flex",
53
+ flexDirection: "column",
54
+ alignItems: "center"
55
+ },
56
+ children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 240 160", style: { width: "100%" }, children: [
57
+ /* @__PURE__ */ jsx(
58
+ "path",
59
+ {
60
+ d: arcPath(cx, cy, arcRadius, startAngle, endAngle),
61
+ stroke: "#6B7280",
62
+ strokeOpacity: 0.3,
63
+ strokeWidth: 18,
64
+ fill: "none",
65
+ strokeLinecap: "butt"
66
+ }
67
+ ),
68
+ /* @__PURE__ */ jsx(
69
+ "path",
70
+ {
71
+ d: arcPath(cx, cy, arcRadius, startAngle, valueEndAngle),
72
+ stroke: valueColor,
73
+ strokeWidth: 18,
74
+ fill: "none",
75
+ strokeLinecap: "butt"
76
+ }
77
+ ),
78
+ /* @__PURE__ */ jsx(
79
+ "path",
80
+ {
81
+ d: arcPath(
82
+ cx,
83
+ cy,
84
+ arcRadius + 15,
85
+ startAngle,
86
+ startAngle + thresholds.warning / 100 * (endAngle - startAngle)
87
+ ),
88
+ stroke: "#A5FF11",
89
+ strokeOpacity: 0.3,
90
+ strokeWidth: 4,
91
+ fill: "none",
92
+ strokeLinecap: "butt"
93
+ }
94
+ ),
95
+ /* @__PURE__ */ jsx(
96
+ "path",
97
+ {
98
+ d: arcPath(
99
+ cx,
100
+ cy,
101
+ arcRadius + 15,
102
+ startAngle + thresholds.warning / 100 * (endAngle - startAngle),
103
+ startAngle + thresholds.danger / 100 * (endAngle - startAngle)
104
+ ),
105
+ stroke: "#f59e0b",
106
+ strokeOpacity: 0.3,
107
+ strokeWidth: 4,
108
+ fill: "none",
109
+ strokeLinecap: "butt"
110
+ }
111
+ ),
112
+ /* @__PURE__ */ jsx(
113
+ "path",
114
+ {
115
+ d: arcPath(
116
+ cx,
117
+ cy,
118
+ arcRadius + 15,
119
+ startAngle + thresholds.danger / 100 * (endAngle - startAngle),
120
+ endAngle
121
+ ),
122
+ stroke: "#ef4444",
123
+ strokeOpacity: 0.3,
124
+ strokeWidth: 4,
125
+ fill: "none",
126
+ strokeLinecap: "butt"
127
+ }
128
+ ),
129
+ /* @__PURE__ */ jsx("circle", { cx, cy, r: inner, fill: "#1F2A15" }),
130
+ " ",
131
+ /* @__PURE__ */ jsx(
132
+ "text",
133
+ {
134
+ x: cx,
135
+ y: cy - 8,
136
+ textAnchor: "middle",
137
+ dominantBaseline: "middle",
138
+ style: { fontWeight: 600, fontSize: "28px", fill: valueColor },
139
+ children: valueText
140
+ }
141
+ ),
142
+ label && /* @__PURE__ */ jsx(
143
+ "text",
144
+ {
145
+ x: cx,
146
+ y: cy + 14,
147
+ textAnchor: "middle",
148
+ style: { fontSize: "12px", fill: valueColor },
149
+ children: label
150
+ }
151
+ )
152
+ ] })
153
+ }
154
+ );
97
155
  }
98
156
  function calculateMean(series) {
99
157
  if (!series.data.length) return 0;
@@ -135,7 +193,10 @@ var generateColors = (count) => {
135
193
  "#ef4444"
136
194
  // Red
137
195
  ];
138
- return Array.from({ length: count }, (_, i) => baseColors[i % baseColors.length]);
196
+ return Array.from(
197
+ { length: count },
198
+ (_, i) => baseColors[i % baseColors.length]
199
+ );
139
200
  };
140
201
  function TimeSeries({
141
202
  series,
@@ -161,42 +222,61 @@ function TimeSeries({
161
222
  });
162
223
  }, [series]);
163
224
  const finalColors = colors || generateColors(series.length);
164
- return /* @__PURE__ */ jsx("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(ComposedChart, { data: rows, margin: { left: 12, right: 12, top: 5, bottom: 5 }, children: [
165
- /* @__PURE__ */ jsx(XAxis, { dataKey: "t", tickFormatter: formatTime, minTickGap: 32 }),
166
- /* @__PURE__ */ jsx(YAxis, { domain: domainY, tickFormatter: (v) => `${v}` }),
167
- /* @__PURE__ */ jsx(Tooltip, { labelFormatter: (l) => `Time: ${formatTime(l)}`, formatter: (v) => [v, yLabel ?? "value"] }),
168
- showLegend && /* @__PURE__ */ jsx(Legend, {}),
169
- series.map((s, index) => {
170
- const color = finalColors[index];
171
- if (s.fill) {
172
- return /* @__PURE__ */ jsx(
173
- Area,
225
+ return /* @__PURE__ */ jsx("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(
226
+ ComposedChart,
227
+ {
228
+ data: rows,
229
+ margin: { left: 12, right: 12, top: 5, bottom: 5 },
230
+ children: [
231
+ /* @__PURE__ */ jsx(XAxis, { dataKey: "t", tickFormatter: formatTime, minTickGap: 32 }),
232
+ /* @__PURE__ */ jsx(
233
+ YAxis,
174
234
  {
175
- type: "monotone",
176
- dataKey: s.name,
177
- stroke: color,
178
- fill: color,
179
- fillOpacity: 0.1,
180
- strokeWidth: 2
181
- },
182
- s.name
183
- );
184
- } else {
185
- return /* @__PURE__ */ jsx(
186
- Line,
235
+ domain: domainY,
236
+ tickFormatter: (v) => `${v}`
237
+ }
238
+ ),
239
+ /* @__PURE__ */ jsx(
240
+ Tooltip,
187
241
  {
188
- type: "monotone",
189
- dataKey: s.name,
190
- dot: false,
191
- strokeWidth: 2,
192
- stroke: color,
193
- fill: "none"
194
- },
195
- s.name
196
- );
197
- }
198
- })
199
- ] }) }) });
242
+ labelFormatter: (l) => `Time: ${formatTime(l)}`,
243
+ formatter: (v) => [v, yLabel ?? "value"]
244
+ }
245
+ ),
246
+ showLegend && /* @__PURE__ */ jsx(Legend, {}),
247
+ series.map((s, index) => {
248
+ const color = finalColors[index];
249
+ if (s.fill) {
250
+ return /* @__PURE__ */ jsx(
251
+ Area,
252
+ {
253
+ type: "monotone",
254
+ dataKey: s.name,
255
+ stroke: color,
256
+ fill: color,
257
+ fillOpacity: 0.1,
258
+ strokeWidth: 2
259
+ },
260
+ s.name
261
+ );
262
+ } else {
263
+ return /* @__PURE__ */ jsx(
264
+ Line,
265
+ {
266
+ type: "monotone",
267
+ dataKey: s.name,
268
+ dot: false,
269
+ strokeWidth: 2,
270
+ stroke: color,
271
+ fill: "none"
272
+ },
273
+ s.name
274
+ );
275
+ }
276
+ })
277
+ ]
278
+ }
279
+ ) }) });
200
280
  }
201
281
  function VectorTableRaw({
202
282
  data,
@@ -212,26 +292,54 @@ function VectorTableRaw({
212
292
  return /* @__PURE__ */ jsx("div", { style: { overflow: "auto" }, children: /* @__PURE__ */ jsxs("table", { style: { width: "100%", fontSize: "14px" }, children: [
213
293
  /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { style: { textAlign: "left", color: "#94a3b8" }, children: [
214
294
  /* @__PURE__ */ jsx("th", { style: { padding: "8px 12px 8px 0", fontWeight: "500" }, children: "Name" }),
215
- finalColumns.map((column, index) => /* @__PURE__ */ jsx("th", { style: { padding: "8px 12px", fontWeight: "500", textAlign: "right" }, children: column.title }, index))
295
+ finalColumns.map((column, index) => /* @__PURE__ */ jsx(
296
+ "th",
297
+ {
298
+ style: {
299
+ padding: "8px 12px",
300
+ fontWeight: "500",
301
+ textAlign: "right"
302
+ },
303
+ children: column.title
304
+ },
305
+ index
306
+ ))
216
307
  ] }) }),
217
308
  /* @__PURE__ */ jsx("tbody", { children: data.map((row, index) => /* @__PURE__ */ jsxs("tr", { style: { borderTop: "1px solid #374151" }, children: [
218
309
  /* @__PURE__ */ jsxs("td", { style: { padding: "8px 12px 8px 0", position: "relative" }, children: [
219
- /* @__PURE__ */ jsx("div", { style: {
220
- position: "absolute",
221
- left: "0",
222
- top: "50%",
223
- transform: "translateY(-50%)",
224
- width: "4px",
225
- height: "12px",
226
- backgroundColor: colors?.[index] || row.color || "#A5FF11",
227
- borderRadius: "2px"
228
- } }),
310
+ /* @__PURE__ */ jsx(
311
+ "div",
312
+ {
313
+ style: {
314
+ position: "absolute",
315
+ left: "0",
316
+ top: "50%",
317
+ transform: "translateY(-50%)",
318
+ width: "4px",
319
+ height: "12px",
320
+ backgroundColor: colors?.[index] || row.color || "#A5FF11",
321
+ borderRadius: "2px"
322
+ }
323
+ }
324
+ ),
229
325
  /* @__PURE__ */ jsx("span", { style: { marginLeft: "16px", color: "white" }, children: row.name })
230
326
  ] }),
231
327
  finalColumns.map((column, colIndex) => {
232
328
  const key = column.title.toLowerCase().replace(/\s+/g, "_");
233
329
  const value = row[key] || 0;
234
- return /* @__PURE__ */ jsx("td", { style: { padding: "8px 12px", textAlign: "right", color: "white", fontVariantNumeric: "tabular-nums" }, children: typeof value === "number" ? value.toFixed(3) : value }, colIndex);
330
+ return /* @__PURE__ */ jsx(
331
+ "td",
332
+ {
333
+ style: {
334
+ padding: "8px 12px",
335
+ textAlign: "right",
336
+ color: "white",
337
+ fontVariantNumeric: "tabular-nums"
338
+ },
339
+ children: typeof value === "number" ? value.toFixed(3) : value
340
+ },
341
+ colIndex
342
+ );
235
343
  })
236
344
  ] }, index)) })
237
345
  ] }) });
@@ -259,7 +367,10 @@ var generateColors2 = (count) => {
259
367
  "#ef4444"
260
368
  // Red
261
369
  ];
262
- return Array.from({ length: count }, (_, i) => baseColors[i % baseColors.length]);
370
+ return Array.from(
371
+ { length: count },
372
+ (_, i) => baseColors[i % baseColors.length]
373
+ );
263
374
  };
264
375
  function TimeSeriesWithTable({
265
376
  timeSeriesData,
@@ -292,35 +403,53 @@ function TimeSeriesWithTable({
292
403
  return row;
293
404
  });
294
405
  }, [vectorTableData, timeSeriesData, columns]);
295
- return /* @__PURE__ */ jsxs("div", { style: {
296
- display: "flex",
297
- flexDirection: layout === "side-by-side" ? "row" : "column",
298
- gap: "24px",
299
- minHeight: "240px"
300
- }, children: [
301
- /* @__PURE__ */ jsx("div", { style: {
302
- height: layout === "side-by-side" ? "240px" : "240px",
303
- flex: layout === "side-by-side" ? "1" : "none"
304
- }, children: /* @__PURE__ */ jsx(
305
- TimeSeries,
306
- {
307
- series: timeSeriesData,
308
- yLabel: timeSeriesYLabel,
309
- colors: finalColors,
310
- showLegend: showTimeSeriesLegend
311
- }
312
- ) }),
313
- (layout === "table-below" || layout === "side-by-side") && /* @__PURE__ */ jsx("div", { style: {
314
- flex: layout === "side-by-side" ? "1" : "none"
315
- }, children: /* @__PURE__ */ jsx(
316
- VectorTableRaw,
317
- {
318
- data: finalTableData,
319
- colors: finalColors,
320
- columns
321
- }
322
- ) })
323
- ] });
406
+ return /* @__PURE__ */ jsxs(
407
+ "div",
408
+ {
409
+ style: {
410
+ display: "flex",
411
+ flexDirection: layout === "side-by-side" ? "row" : "column",
412
+ gap: "24px",
413
+ minHeight: "240px"
414
+ },
415
+ children: [
416
+ /* @__PURE__ */ jsx(
417
+ "div",
418
+ {
419
+ style: {
420
+ height: layout === "side-by-side" ? "240px" : "240px",
421
+ flex: layout === "side-by-side" ? "1" : "none"
422
+ },
423
+ children: /* @__PURE__ */ jsx(
424
+ TimeSeries,
425
+ {
426
+ series: timeSeriesData,
427
+ yLabel: timeSeriesYLabel,
428
+ colors: finalColors,
429
+ showLegend: showTimeSeriesLegend
430
+ }
431
+ )
432
+ }
433
+ ),
434
+ (layout === "table-below" || layout === "side-by-side") && /* @__PURE__ */ jsx(
435
+ "div",
436
+ {
437
+ style: {
438
+ flex: layout === "side-by-side" ? "1" : "none"
439
+ },
440
+ children: /* @__PURE__ */ jsx(
441
+ VectorTableRaw,
442
+ {
443
+ data: finalTableData,
444
+ colors: finalColors,
445
+ columns
446
+ }
447
+ )
448
+ }
449
+ )
450
+ ]
451
+ }
452
+ );
324
453
  }
325
454
 
326
455
  export { Gauge, TimeSeries, TimeSeriesWithTable, VectorTableRaw, calculateLast, calculateMax, calculateMean };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.0.10",
6
+ "version": "0.0.11",
7
7
  "description": "Chart components for Calimero design system",
8
8
  "main": "./dist/index.js",
9
9
  "module": "./dist/index.mjs",
@@ -22,7 +22,7 @@
22
22
  "react": "^18.3.1",
23
23
  "react-dom": "^18.3.1",
24
24
  "recharts": "^2.8.0",
25
- "@calimero-network/mero-ui": "0.3.6"
25
+ "@calimero-network/mero-ui": "0.3.7"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/react": "^18.3.12",