@entropix/data 0.0.0 → 1.0.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.
- package/dist/area-chart.cjs +14 -0
- package/dist/area-chart.css +144 -0
- package/dist/area-chart.d.cts +19 -0
- package/dist/area-chart.d.ts +19 -0
- package/dist/area-chart.js +5 -0
- package/dist/bar-chart.cjs +14 -0
- package/dist/bar-chart.css +144 -0
- package/dist/bar-chart.d.cts +18 -0
- package/dist/bar-chart.d.ts +18 -0
- package/dist/bar-chart.js +5 -0
- package/dist/chunk-42HKJHUY.js +96 -0
- package/dist/chunk-4WXLJDQU.js +74 -0
- package/dist/chunk-6YAOO76S.cjs +142 -0
- package/dist/chunk-CMAQ7DZD.js +135 -0
- package/dist/chunk-FQACLZYR.js +137 -0
- package/dist/chunk-GCZSXJAA.cjs +77 -0
- package/dist/chunk-K6ZRQYSZ.cjs +131 -0
- package/dist/chunk-QBI5NOHT.cjs +126 -0
- package/dist/chunk-SDCNTA7E.cjs +275 -0
- package/dist/chunk-VCSKHJLZ.js +124 -0
- package/dist/chunk-VGT2QF7D.cjs +98 -0
- package/dist/chunk-WOVSQALY.cjs +137 -0
- package/dist/chunk-X7GZD7KZ.js +129 -0
- package/dist/chunk-YINCJQN6.js +271 -0
- package/dist/data-table.cjs +20 -0
- package/dist/data-table.css +227 -0
- package/dist/data-table.d.cts +20 -0
- package/dist/data-table.d.ts +20 -0
- package/dist/data-table.js +3 -0
- package/dist/index.cjs +36 -269
- package/dist/index.css +144 -0
- package/dist/index.d.cts +8 -21
- package/dist/index.d.ts +8 -21
- package/dist/index.js +7 -269
- package/dist/line-chart.cjs +14 -0
- package/dist/line-chart.css +144 -0
- package/dist/line-chart.d.cts +19 -0
- package/dist/line-chart.d.ts +19 -0
- package/dist/line-chart.js +5 -0
- package/dist/pie-chart.cjs +13 -0
- package/dist/pie-chart.css +144 -0
- package/dist/pie-chart.d.cts +15 -0
- package/dist/pie-chart.d.ts +15 -0
- package/dist/pie-chart.js +4 -0
- package/dist/styles/chart.css +1 -0
- package/dist/styles/data-table.css +1 -304
- package/package.json +54 -3
- package/dist/index.cjs.map +0 -1
- package/dist/index.css.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkWOVSQALY_cjs = require('./chunk-WOVSQALY.cjs');
|
|
4
|
+
require('./chunk-GCZSXJAA.cjs');
|
|
5
|
+
require('./chunk-6YAOO76S.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "AreaChart", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return chunkWOVSQALY_cjs.AreaChart; }
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=area-chart.cjs.map
|
|
14
|
+
//# sourceMappingURL=area-chart.cjs.map
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/* src/styles/chart.css */
|
|
2
|
+
:root {
|
|
3
|
+
--chart-bg: var(--entropix-color-bg-primary, #ffffff);
|
|
4
|
+
--chart-border-color: var(--entropix-color-border-default, #e5e7eb);
|
|
5
|
+
--chart-grid-color: var(--entropix-color-border-subtle, #f3f4f6);
|
|
6
|
+
--chart-text-color: var(--entropix-color-text-secondary, #6b7280);
|
|
7
|
+
--chart-tooltip-bg: var(--entropix-color-bg-inverse, #1f2937);
|
|
8
|
+
--chart-tooltip-text: var(--entropix-color-text-inverse, #ffffff);
|
|
9
|
+
--chart-font-size: var(--entropix-font-size-xs, 0.75rem);
|
|
10
|
+
--chart-series-1: var(--entropix-color-action-primary-default, #3b82f6);
|
|
11
|
+
--chart-series-2: var(--entropix-color-chart-2, #ef4444);
|
|
12
|
+
--chart-series-3: var(--entropix-color-chart-3, #22c55e);
|
|
13
|
+
--chart-series-4: var(--entropix-color-chart-4, #f59e0b);
|
|
14
|
+
--chart-series-5: var(--entropix-color-chart-5, #a855f7);
|
|
15
|
+
--chart-series-6: var(--entropix-color-chart-6, #06b6d4);
|
|
16
|
+
--chart-series-7: var(--entropix-color-chart-7, #f97316);
|
|
17
|
+
--chart-series-8: var(--entropix-color-chart-8, #ec4899);
|
|
18
|
+
}
|
|
19
|
+
.entropix-chart {
|
|
20
|
+
position: relative;
|
|
21
|
+
width: 100%;
|
|
22
|
+
background: var(--chart-bg);
|
|
23
|
+
font-family: var(--entropix-font-family-sans, system-ui, sans-serif);
|
|
24
|
+
font-size: var(--chart-font-size);
|
|
25
|
+
color: var(--chart-text-color);
|
|
26
|
+
}
|
|
27
|
+
.entropix-chart__svg {
|
|
28
|
+
display: block;
|
|
29
|
+
overflow: visible;
|
|
30
|
+
}
|
|
31
|
+
.entropix-chart__axis-text {
|
|
32
|
+
fill: var(--chart-text-color);
|
|
33
|
+
font-size: var(--chart-font-size);
|
|
34
|
+
font-family: inherit;
|
|
35
|
+
user-select: none;
|
|
36
|
+
}
|
|
37
|
+
.entropix-chart__grid-line {
|
|
38
|
+
stroke: var(--chart-grid-color);
|
|
39
|
+
stroke-width: 1;
|
|
40
|
+
shape-rendering: crispEdges;
|
|
41
|
+
}
|
|
42
|
+
.entropix-chart__tooltip {
|
|
43
|
+
position: absolute;
|
|
44
|
+
background: var(--chart-tooltip-bg);
|
|
45
|
+
color: var(--chart-tooltip-text);
|
|
46
|
+
padding: 6px 10px;
|
|
47
|
+
border-radius: 6px;
|
|
48
|
+
font-size: var(--chart-font-size);
|
|
49
|
+
line-height: 1.4;
|
|
50
|
+
white-space: nowrap;
|
|
51
|
+
pointer-events: none;
|
|
52
|
+
z-index: 10;
|
|
53
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
|
54
|
+
opacity: 0;
|
|
55
|
+
transition: opacity 0.15s ease-in-out;
|
|
56
|
+
}
|
|
57
|
+
.entropix-chart__tooltip--visible {
|
|
58
|
+
opacity: 1;
|
|
59
|
+
}
|
|
60
|
+
.entropix-chart__tooltip-row {
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
gap: 6px;
|
|
64
|
+
}
|
|
65
|
+
.entropix-chart__tooltip-swatch {
|
|
66
|
+
display: inline-block;
|
|
67
|
+
width: 8px;
|
|
68
|
+
height: 8px;
|
|
69
|
+
border-radius: 50%;
|
|
70
|
+
flex-shrink: 0;
|
|
71
|
+
}
|
|
72
|
+
.entropix-chart__legend {
|
|
73
|
+
display: flex;
|
|
74
|
+
flex-wrap: wrap;
|
|
75
|
+
gap: 12px;
|
|
76
|
+
padding: 8px 0 0;
|
|
77
|
+
justify-content: center;
|
|
78
|
+
}
|
|
79
|
+
.entropix-chart__legend-item {
|
|
80
|
+
display: inline-flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
gap: 6px;
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
user-select: none;
|
|
85
|
+
font-size: var(--chart-font-size);
|
|
86
|
+
color: var(--chart-text-color);
|
|
87
|
+
transition: opacity 0.15s ease-in-out;
|
|
88
|
+
}
|
|
89
|
+
.entropix-chart__legend-item--inactive {
|
|
90
|
+
opacity: 0.4;
|
|
91
|
+
}
|
|
92
|
+
.entropix-chart__legend-swatch {
|
|
93
|
+
display: inline-block;
|
|
94
|
+
width: 10px;
|
|
95
|
+
height: 10px;
|
|
96
|
+
border-radius: 50%;
|
|
97
|
+
flex-shrink: 0;
|
|
98
|
+
}
|
|
99
|
+
.entropix-chart__bar {
|
|
100
|
+
transition: opacity 0.15s ease-in-out;
|
|
101
|
+
}
|
|
102
|
+
.entropix-chart__bar:hover {
|
|
103
|
+
opacity: 0.8;
|
|
104
|
+
}
|
|
105
|
+
.entropix-chart__line {
|
|
106
|
+
fill: none;
|
|
107
|
+
stroke-width: 2;
|
|
108
|
+
stroke-linejoin: round;
|
|
109
|
+
stroke-linecap: round;
|
|
110
|
+
}
|
|
111
|
+
.entropix-chart__area {
|
|
112
|
+
stroke: none;
|
|
113
|
+
stroke-linejoin: round;
|
|
114
|
+
}
|
|
115
|
+
.entropix-chart__point {
|
|
116
|
+
stroke: var(--chart-bg);
|
|
117
|
+
stroke-width: 2;
|
|
118
|
+
transition: r 0.15s ease-in-out;
|
|
119
|
+
}
|
|
120
|
+
.entropix-chart__point:hover {
|
|
121
|
+
r: 5;
|
|
122
|
+
}
|
|
123
|
+
.entropix-chart__arc {
|
|
124
|
+
transition: opacity 0.15s ease-in-out, transform 0.15s ease-in-out;
|
|
125
|
+
transform-origin: center;
|
|
126
|
+
}
|
|
127
|
+
.entropix-chart__arc:hover {
|
|
128
|
+
opacity: 0.85;
|
|
129
|
+
transform: scale(1.03);
|
|
130
|
+
}
|
|
131
|
+
@container (max-width: 400px) {
|
|
132
|
+
.entropix-chart {
|
|
133
|
+
font-size: 0.625rem;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
@media (max-width: 480px) {
|
|
137
|
+
.entropix-chart {
|
|
138
|
+
font-size: 0.625rem;
|
|
139
|
+
}
|
|
140
|
+
.entropix-chart__legend {
|
|
141
|
+
gap: 8px;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/*# sourceMappingURL=area-chart.css.map */
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ChartData, AxisConfig } from '@entropix/core';
|
|
3
|
+
|
|
4
|
+
interface AreaChartProps {
|
|
5
|
+
data: ChartData;
|
|
6
|
+
height?: number;
|
|
7
|
+
colors?: string[];
|
|
8
|
+
curved?: boolean;
|
|
9
|
+
opacity?: number;
|
|
10
|
+
showGrid?: boolean;
|
|
11
|
+
showTooltip?: boolean;
|
|
12
|
+
showLegend?: boolean;
|
|
13
|
+
xAxis?: AxisConfig;
|
|
14
|
+
yAxis?: AxisConfig;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
declare function AreaChart({ data, height, colors, curved, opacity, showGrid, showTooltip, showLegend, xAxis, yAxis, className, }: AreaChartProps): react_jsx_runtime.JSX.Element;
|
|
18
|
+
|
|
19
|
+
export { AreaChart, type AreaChartProps };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ChartData, AxisConfig } from '@entropix/core';
|
|
3
|
+
|
|
4
|
+
interface AreaChartProps {
|
|
5
|
+
data: ChartData;
|
|
6
|
+
height?: number;
|
|
7
|
+
colors?: string[];
|
|
8
|
+
curved?: boolean;
|
|
9
|
+
opacity?: number;
|
|
10
|
+
showGrid?: boolean;
|
|
11
|
+
showTooltip?: boolean;
|
|
12
|
+
showLegend?: boolean;
|
|
13
|
+
xAxis?: AxisConfig;
|
|
14
|
+
yAxis?: AxisConfig;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
declare function AreaChart({ data, height, colors, curved, opacity, showGrid, showTooltip, showLegend, xAxis, yAxis, className, }: AreaChartProps): react_jsx_runtime.JSX.Element;
|
|
18
|
+
|
|
19
|
+
export { AreaChart, type AreaChartProps };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkK6ZRQYSZ_cjs = require('./chunk-K6ZRQYSZ.cjs');
|
|
4
|
+
require('./chunk-GCZSXJAA.cjs');
|
|
5
|
+
require('./chunk-6YAOO76S.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "BarChart", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return chunkK6ZRQYSZ_cjs.BarChart; }
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=bar-chart.cjs.map
|
|
14
|
+
//# sourceMappingURL=bar-chart.cjs.map
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/* src/styles/chart.css */
|
|
2
|
+
:root {
|
|
3
|
+
--chart-bg: var(--entropix-color-bg-primary, #ffffff);
|
|
4
|
+
--chart-border-color: var(--entropix-color-border-default, #e5e7eb);
|
|
5
|
+
--chart-grid-color: var(--entropix-color-border-subtle, #f3f4f6);
|
|
6
|
+
--chart-text-color: var(--entropix-color-text-secondary, #6b7280);
|
|
7
|
+
--chart-tooltip-bg: var(--entropix-color-bg-inverse, #1f2937);
|
|
8
|
+
--chart-tooltip-text: var(--entropix-color-text-inverse, #ffffff);
|
|
9
|
+
--chart-font-size: var(--entropix-font-size-xs, 0.75rem);
|
|
10
|
+
--chart-series-1: var(--entropix-color-action-primary-default, #3b82f6);
|
|
11
|
+
--chart-series-2: var(--entropix-color-chart-2, #ef4444);
|
|
12
|
+
--chart-series-3: var(--entropix-color-chart-3, #22c55e);
|
|
13
|
+
--chart-series-4: var(--entropix-color-chart-4, #f59e0b);
|
|
14
|
+
--chart-series-5: var(--entropix-color-chart-5, #a855f7);
|
|
15
|
+
--chart-series-6: var(--entropix-color-chart-6, #06b6d4);
|
|
16
|
+
--chart-series-7: var(--entropix-color-chart-7, #f97316);
|
|
17
|
+
--chart-series-8: var(--entropix-color-chart-8, #ec4899);
|
|
18
|
+
}
|
|
19
|
+
.entropix-chart {
|
|
20
|
+
position: relative;
|
|
21
|
+
width: 100%;
|
|
22
|
+
background: var(--chart-bg);
|
|
23
|
+
font-family: var(--entropix-font-family-sans, system-ui, sans-serif);
|
|
24
|
+
font-size: var(--chart-font-size);
|
|
25
|
+
color: var(--chart-text-color);
|
|
26
|
+
}
|
|
27
|
+
.entropix-chart__svg {
|
|
28
|
+
display: block;
|
|
29
|
+
overflow: visible;
|
|
30
|
+
}
|
|
31
|
+
.entropix-chart__axis-text {
|
|
32
|
+
fill: var(--chart-text-color);
|
|
33
|
+
font-size: var(--chart-font-size);
|
|
34
|
+
font-family: inherit;
|
|
35
|
+
user-select: none;
|
|
36
|
+
}
|
|
37
|
+
.entropix-chart__grid-line {
|
|
38
|
+
stroke: var(--chart-grid-color);
|
|
39
|
+
stroke-width: 1;
|
|
40
|
+
shape-rendering: crispEdges;
|
|
41
|
+
}
|
|
42
|
+
.entropix-chart__tooltip {
|
|
43
|
+
position: absolute;
|
|
44
|
+
background: var(--chart-tooltip-bg);
|
|
45
|
+
color: var(--chart-tooltip-text);
|
|
46
|
+
padding: 6px 10px;
|
|
47
|
+
border-radius: 6px;
|
|
48
|
+
font-size: var(--chart-font-size);
|
|
49
|
+
line-height: 1.4;
|
|
50
|
+
white-space: nowrap;
|
|
51
|
+
pointer-events: none;
|
|
52
|
+
z-index: 10;
|
|
53
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
|
54
|
+
opacity: 0;
|
|
55
|
+
transition: opacity 0.15s ease-in-out;
|
|
56
|
+
}
|
|
57
|
+
.entropix-chart__tooltip--visible {
|
|
58
|
+
opacity: 1;
|
|
59
|
+
}
|
|
60
|
+
.entropix-chart__tooltip-row {
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
gap: 6px;
|
|
64
|
+
}
|
|
65
|
+
.entropix-chart__tooltip-swatch {
|
|
66
|
+
display: inline-block;
|
|
67
|
+
width: 8px;
|
|
68
|
+
height: 8px;
|
|
69
|
+
border-radius: 50%;
|
|
70
|
+
flex-shrink: 0;
|
|
71
|
+
}
|
|
72
|
+
.entropix-chart__legend {
|
|
73
|
+
display: flex;
|
|
74
|
+
flex-wrap: wrap;
|
|
75
|
+
gap: 12px;
|
|
76
|
+
padding: 8px 0 0;
|
|
77
|
+
justify-content: center;
|
|
78
|
+
}
|
|
79
|
+
.entropix-chart__legend-item {
|
|
80
|
+
display: inline-flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
gap: 6px;
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
user-select: none;
|
|
85
|
+
font-size: var(--chart-font-size);
|
|
86
|
+
color: var(--chart-text-color);
|
|
87
|
+
transition: opacity 0.15s ease-in-out;
|
|
88
|
+
}
|
|
89
|
+
.entropix-chart__legend-item--inactive {
|
|
90
|
+
opacity: 0.4;
|
|
91
|
+
}
|
|
92
|
+
.entropix-chart__legend-swatch {
|
|
93
|
+
display: inline-block;
|
|
94
|
+
width: 10px;
|
|
95
|
+
height: 10px;
|
|
96
|
+
border-radius: 50%;
|
|
97
|
+
flex-shrink: 0;
|
|
98
|
+
}
|
|
99
|
+
.entropix-chart__bar {
|
|
100
|
+
transition: opacity 0.15s ease-in-out;
|
|
101
|
+
}
|
|
102
|
+
.entropix-chart__bar:hover {
|
|
103
|
+
opacity: 0.8;
|
|
104
|
+
}
|
|
105
|
+
.entropix-chart__line {
|
|
106
|
+
fill: none;
|
|
107
|
+
stroke-width: 2;
|
|
108
|
+
stroke-linejoin: round;
|
|
109
|
+
stroke-linecap: round;
|
|
110
|
+
}
|
|
111
|
+
.entropix-chart__area {
|
|
112
|
+
stroke: none;
|
|
113
|
+
stroke-linejoin: round;
|
|
114
|
+
}
|
|
115
|
+
.entropix-chart__point {
|
|
116
|
+
stroke: var(--chart-bg);
|
|
117
|
+
stroke-width: 2;
|
|
118
|
+
transition: r 0.15s ease-in-out;
|
|
119
|
+
}
|
|
120
|
+
.entropix-chart__point:hover {
|
|
121
|
+
r: 5;
|
|
122
|
+
}
|
|
123
|
+
.entropix-chart__arc {
|
|
124
|
+
transition: opacity 0.15s ease-in-out, transform 0.15s ease-in-out;
|
|
125
|
+
transform-origin: center;
|
|
126
|
+
}
|
|
127
|
+
.entropix-chart__arc:hover {
|
|
128
|
+
opacity: 0.85;
|
|
129
|
+
transform: scale(1.03);
|
|
130
|
+
}
|
|
131
|
+
@container (max-width: 400px) {
|
|
132
|
+
.entropix-chart {
|
|
133
|
+
font-size: 0.625rem;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
@media (max-width: 480px) {
|
|
137
|
+
.entropix-chart {
|
|
138
|
+
font-size: 0.625rem;
|
|
139
|
+
}
|
|
140
|
+
.entropix-chart__legend {
|
|
141
|
+
gap: 8px;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/*# sourceMappingURL=bar-chart.css.map */
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ChartData, AxisConfig } from '@entropix/core';
|
|
3
|
+
|
|
4
|
+
interface BarChartProps {
|
|
5
|
+
data: ChartData;
|
|
6
|
+
height?: number;
|
|
7
|
+
colors?: string[];
|
|
8
|
+
stacked?: boolean;
|
|
9
|
+
showGrid?: boolean;
|
|
10
|
+
showTooltip?: boolean;
|
|
11
|
+
showLegend?: boolean;
|
|
12
|
+
xAxis?: AxisConfig;
|
|
13
|
+
yAxis?: AxisConfig;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
declare function BarChart({ data, height, colors, stacked, showGrid, showTooltip, showLegend, xAxis, yAxis, className, }: BarChartProps): react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { BarChart, type BarChartProps };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ChartData, AxisConfig } from '@entropix/core';
|
|
3
|
+
|
|
4
|
+
interface BarChartProps {
|
|
5
|
+
data: ChartData;
|
|
6
|
+
height?: number;
|
|
7
|
+
colors?: string[];
|
|
8
|
+
stacked?: boolean;
|
|
9
|
+
showGrid?: boolean;
|
|
10
|
+
showTooltip?: boolean;
|
|
11
|
+
showLegend?: boolean;
|
|
12
|
+
xAxis?: AxisConfig;
|
|
13
|
+
yAxis?: AxisConfig;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
declare function BarChart({ data, height, colors, stacked, showGrid, showTooltip, showLegend, xAxis, yAxis, className, }: BarChartProps): react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { BarChart, type BarChartProps };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { CSS_CHART_COLORS, ChartContainer, ChartTooltip, ChartLegend } from './chunk-FQACLZYR.js';
|
|
2
|
+
import { useState, useRef, useCallback } from 'react';
|
|
3
|
+
import { getSeriesColor, computeArcGeometry } from '@entropix/core';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
function PieChart({
|
|
7
|
+
data,
|
|
8
|
+
height = 300,
|
|
9
|
+
colors,
|
|
10
|
+
innerRadius = 0,
|
|
11
|
+
showTooltip = true,
|
|
12
|
+
showLegend = true,
|
|
13
|
+
className
|
|
14
|
+
}) {
|
|
15
|
+
const [hiddenSlices, setHiddenSlices] = useState(/* @__PURE__ */ new Set());
|
|
16
|
+
const [tooltip, setTooltip] = useState(null);
|
|
17
|
+
const containerRef = useRef(null);
|
|
18
|
+
const toggleSlice = useCallback((name) => {
|
|
19
|
+
setHiddenSlices((prev) => {
|
|
20
|
+
const next = new Set(prev);
|
|
21
|
+
if (next.has(name)) next.delete(name);
|
|
22
|
+
else next.add(name);
|
|
23
|
+
return next;
|
|
24
|
+
});
|
|
25
|
+
}, []);
|
|
26
|
+
const palette = colors ?? CSS_CHART_COLORS;
|
|
27
|
+
const coloredData = data.map((d, i) => ({
|
|
28
|
+
...d,
|
|
29
|
+
color: getSeriesColor(i, palette)
|
|
30
|
+
}));
|
|
31
|
+
const visibleData = coloredData.filter((d) => !hiddenSlices.has(d.label));
|
|
32
|
+
const legendItems = coloredData.map((d) => ({
|
|
33
|
+
name: d.label,
|
|
34
|
+
color: d.color,
|
|
35
|
+
active: !hiddenSlices.has(d.label)
|
|
36
|
+
}));
|
|
37
|
+
const handleArcEnter = useCallback(
|
|
38
|
+
(label, value, percentage, color, cx, cy) => {
|
|
39
|
+
if (!showTooltip) return;
|
|
40
|
+
setTooltip({
|
|
41
|
+
x: cx,
|
|
42
|
+
y: cy,
|
|
43
|
+
series: `${(percentage * 100).toFixed(1)}%`,
|
|
44
|
+
label,
|
|
45
|
+
value,
|
|
46
|
+
color
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
[showTooltip]
|
|
50
|
+
);
|
|
51
|
+
const handleArcLeave = useCallback(() => {
|
|
52
|
+
setTooltip(null);
|
|
53
|
+
}, []);
|
|
54
|
+
return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: className ? `entropix-chart ${className}` : "entropix-chart", style: { position: "relative" }, children: [
|
|
55
|
+
/* @__PURE__ */ jsx(ChartContainer, { height, children: (width, h) => {
|
|
56
|
+
const cx = width / 2;
|
|
57
|
+
const cy = h / 2;
|
|
58
|
+
const outerRadius = Math.min(cx, cy) - 10;
|
|
59
|
+
if (outerRadius <= 0) return null;
|
|
60
|
+
const slices = computeArcGeometry(
|
|
61
|
+
visibleData,
|
|
62
|
+
outerRadius,
|
|
63
|
+
innerRadius
|
|
64
|
+
);
|
|
65
|
+
return /* @__PURE__ */ jsx("g", { transform: `translate(${cx}, ${cy})`, children: slices.map((slice, i) => {
|
|
66
|
+
const midAngle = (slice.startAngle + slice.endAngle) / 2;
|
|
67
|
+
const tooltipX = cx + outerRadius * 0.6 * Math.cos(midAngle);
|
|
68
|
+
const tooltipY = cy + outerRadius * 0.6 * Math.sin(midAngle);
|
|
69
|
+
return /* @__PURE__ */ jsx(
|
|
70
|
+
"path",
|
|
71
|
+
{
|
|
72
|
+
className: "entropix-chart__arc",
|
|
73
|
+
d: slice.path,
|
|
74
|
+
fill: slice.color,
|
|
75
|
+
onMouseEnter: () => handleArcEnter(
|
|
76
|
+
slice.label,
|
|
77
|
+
slice.value,
|
|
78
|
+
slice.percentage,
|
|
79
|
+
slice.color,
|
|
80
|
+
tooltipX,
|
|
81
|
+
tooltipY
|
|
82
|
+
),
|
|
83
|
+
onMouseLeave: handleArcLeave
|
|
84
|
+
},
|
|
85
|
+
i
|
|
86
|
+
);
|
|
87
|
+
}) });
|
|
88
|
+
} }),
|
|
89
|
+
showTooltip && /* @__PURE__ */ jsx(ChartTooltip, { data: tooltip, containerRef }),
|
|
90
|
+
showLegend && /* @__PURE__ */ jsx(ChartLegend, { items: legendItems, onToggle: toggleSlice })
|
|
91
|
+
] });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export { PieChart };
|
|
95
|
+
//# sourceMappingURL=chunk-42HKJHUY.js.map
|
|
96
|
+
//# sourceMappingURL=chunk-42HKJHUY.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
// src/components/chart-primitives/x-axis.tsx
|
|
4
|
+
function XAxis({ scale, y, height: _height, formatter }) {
|
|
5
|
+
const domain = scale.domain();
|
|
6
|
+
const bandwidth = scale.bandwidth();
|
|
7
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
8
|
+
domain.map((label) => {
|
|
9
|
+
const x = scale(label) + bandwidth / 2;
|
|
10
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${x}, ${y})`, children: [
|
|
11
|
+
/* @__PURE__ */ jsx("line", { y2: 6, stroke: "currentColor", strokeWidth: 1 }),
|
|
12
|
+
/* @__PURE__ */ jsx(
|
|
13
|
+
"text",
|
|
14
|
+
{
|
|
15
|
+
className: "entropix-chart__axis-text",
|
|
16
|
+
y: 18,
|
|
17
|
+
textAnchor: "middle",
|
|
18
|
+
dominantBaseline: "auto",
|
|
19
|
+
children: formatter ? formatter(label) : label
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
] }, label);
|
|
23
|
+
}),
|
|
24
|
+
/* @__PURE__ */ jsx(
|
|
25
|
+
"line",
|
|
26
|
+
{
|
|
27
|
+
x1: scale.range()[0],
|
|
28
|
+
x2: scale.range()[1],
|
|
29
|
+
y1: y,
|
|
30
|
+
y2: y,
|
|
31
|
+
stroke: "currentColor",
|
|
32
|
+
strokeWidth: 1
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
] });
|
|
36
|
+
}
|
|
37
|
+
function YAxis({
|
|
38
|
+
scale,
|
|
39
|
+
x,
|
|
40
|
+
width,
|
|
41
|
+
formatter,
|
|
42
|
+
showGrid = true
|
|
43
|
+
}) {
|
|
44
|
+
const ticks = scale.ticks();
|
|
45
|
+
return /* @__PURE__ */ jsx("g", { children: ticks.map((tick) => {
|
|
46
|
+
const y = scale(tick);
|
|
47
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${x}, ${y})`, children: [
|
|
48
|
+
/* @__PURE__ */ jsx(
|
|
49
|
+
"text",
|
|
50
|
+
{
|
|
51
|
+
className: "entropix-chart__axis-text",
|
|
52
|
+
x: -8,
|
|
53
|
+
textAnchor: "end",
|
|
54
|
+
dominantBaseline: "middle",
|
|
55
|
+
children: formatter ? formatter(tick) : String(tick)
|
|
56
|
+
}
|
|
57
|
+
),
|
|
58
|
+
showGrid && /* @__PURE__ */ jsx(
|
|
59
|
+
"line",
|
|
60
|
+
{
|
|
61
|
+
className: "entropix-chart__grid-line",
|
|
62
|
+
x1: 0,
|
|
63
|
+
x2: width,
|
|
64
|
+
y1: 0,
|
|
65
|
+
y2: 0
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
] }, tick);
|
|
69
|
+
}) });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export { XAxis, YAxis };
|
|
73
|
+
//# sourceMappingURL=chunk-4WXLJDQU.js.map
|
|
74
|
+
//# sourceMappingURL=chunk-4WXLJDQU.js.map
|