@gravitee/graphene-charts 0.0.0-add-filter-icon.51bc026
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/LICENSE +202 -0
- package/USAGE_GUIDE.md +479 -0
- package/dist/base/ChartCard/ChartCard.d.ts +14 -0
- package/dist/base/ChartCard/ChartCard.d.ts.map +1 -0
- package/dist/base/ChartCard/index.d.ts +3 -0
- package/dist/base/ChartCard/index.d.ts.map +1 -0
- package/dist/base/ChartContainer/ChartContainer.d.ts +23 -0
- package/dist/base/ChartContainer/ChartContainer.d.ts.map +1 -0
- package/dist/base/ChartContainer/index.d.ts +3 -0
- package/dist/base/ChartContainer/index.d.ts.map +1 -0
- package/dist/base/ChartLegend/ChartLegend.d.ts +30 -0
- package/dist/base/ChartLegend/ChartLegend.d.ts.map +1 -0
- package/dist/base/ChartLegend/index.d.ts +3 -0
- package/dist/base/ChartLegend/index.d.ts.map +1 -0
- package/dist/base/ChartTooltip/ChartTooltip.d.ts +43 -0
- package/dist/base/ChartTooltip/ChartTooltip.d.ts.map +1 -0
- package/dist/base/ChartTooltip/index.d.ts +3 -0
- package/dist/base/ChartTooltip/index.d.ts.map +1 -0
- package/dist/charts/AreaChart/AreaChart.d.ts +34 -0
- package/dist/charts/AreaChart/AreaChart.d.ts.map +1 -0
- package/dist/charts/AreaChart/index.d.ts +3 -0
- package/dist/charts/AreaChart/index.d.ts.map +1 -0
- package/dist/charts/BarChart/BarChart.d.ts +32 -0
- package/dist/charts/BarChart/BarChart.d.ts.map +1 -0
- package/dist/charts/BarChart/index.d.ts +3 -0
- package/dist/charts/BarChart/index.d.ts.map +1 -0
- package/dist/charts/DoughnutChart/DoughnutChart.d.ts +51 -0
- package/dist/charts/DoughnutChart/DoughnutChart.d.ts.map +1 -0
- package/dist/charts/DoughnutChart/index.d.ts +3 -0
- package/dist/charts/DoughnutChart/index.d.ts.map +1 -0
- package/dist/charts/LineChart/LineChart.d.ts +29 -0
- package/dist/charts/LineChart/LineChart.d.ts.map +1 -0
- package/dist/charts/LineChart/index.d.ts +3 -0
- package/dist/charts/LineChart/index.d.ts.map +1 -0
- package/dist/charts/Metric/Metric.d.ts +54 -0
- package/dist/charts/Metric/Metric.d.ts.map +1 -0
- package/dist/charts/Metric/index.d.ts +3 -0
- package/dist/charts/Metric/index.d.ts.map +1 -0
- package/dist/charts/MetricGroup/MetricGroup.d.ts +50 -0
- package/dist/charts/MetricGroup/MetricGroup.d.ts.map +1 -0
- package/dist/charts/MetricGroup/index.d.ts +3 -0
- package/dist/charts/MetricGroup/index.d.ts.map +1 -0
- package/dist/dashboard-grid/DashboardGrid.d.ts +5 -0
- package/dist/dashboard-grid/DashboardGrid.d.ts.map +1 -0
- package/dist/dashboard-grid/DashboardWidget.d.ts +36 -0
- package/dist/dashboard-grid/DashboardWidget.d.ts.map +1 -0
- package/dist/dashboard-grid/adapters.d.ts +13 -0
- package/dist/dashboard-grid/adapters.d.ts.map +1 -0
- package/dist/dashboard-grid/index.d.ts +7 -0
- package/dist/dashboard-grid/index.d.ts.map +1 -0
- package/dist/dashboard-grid/index.js +129 -0
- package/dist/dashboard-grid/styles.css +190 -0
- package/dist/dashboard-grid/types.d.ts +67 -0
- package/dist/dashboard-grid/types.d.ts.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2310 -0
- package/dist/lib/inferDataKeys.d.ts +8 -0
- package/dist/lib/inferDataKeys.d.ts.map +1 -0
- package/dist/lib/resolveChartState.d.ts +8 -0
- package/dist/lib/resolveChartState.d.ts.map +1 -0
- package/dist/lib/useContainerSize.d.ts +16 -0
- package/dist/lib/useContainerSize.d.ts.map +1 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/primitives/AreaChartSkeleton.d.ts +8 -0
- package/dist/primitives/AreaChartSkeleton.d.ts.map +1 -0
- package/dist/primitives/Axis.d.ts +35 -0
- package/dist/primitives/Axis.d.ts.map +1 -0
- package/dist/primitives/BarChartSkeleton.d.ts +8 -0
- package/dist/primitives/BarChartSkeleton.d.ts.map +1 -0
- package/dist/primitives/CartesianChart.d.ts +32 -0
- package/dist/primitives/CartesianChart.d.ts.map +1 -0
- package/dist/primitives/CartesianChartSkeleton.d.ts +13 -0
- package/dist/primitives/CartesianChartSkeleton.d.ts.map +1 -0
- package/dist/primitives/CartesianContext.d.ts +50 -0
- package/dist/primitives/CartesianContext.d.ts.map +1 -0
- package/dist/primitives/ChartEmptyState.d.ts +8 -0
- package/dist/primitives/ChartEmptyState.d.ts.map +1 -0
- package/dist/primitives/ChartSlots.d.ts +49 -0
- package/dist/primitives/ChartSlots.d.ts.map +1 -0
- package/dist/primitives/DoughnutChartSkeleton.d.ts +7 -0
- package/dist/primitives/DoughnutChartSkeleton.d.ts.map +1 -0
- package/dist/primitives/Grid.d.ts +23 -0
- package/dist/primitives/Grid.d.ts.map +1 -0
- package/dist/primitives/LineChartSkeleton.d.ts +8 -0
- package/dist/primitives/LineChartSkeleton.d.ts.map +1 -0
- package/dist/primitives/SkeletonBlock.d.ts +4 -0
- package/dist/primitives/SkeletonBlock.d.ts.map +1 -0
- package/dist/primitives/index.d.ts +36 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/roundedRect.d.ts +18 -0
- package/dist/primitives/roundedRect.d.ts.map +1 -0
- package/dist/primitives/useChartDimensions.d.ts +18 -0
- package/dist/primitives/useChartDimensions.d.ts.map +1 -0
- package/dist/primitives/useResolvedCssLength.d.ts +16 -0
- package/dist/primitives/useResolvedCssLength.d.ts.map +1 -0
- package/dist/primitives/useTooltipState.d.ts +40 -0
- package/dist/primitives/useTooltipState.d.ts.map +1 -0
- package/dist/series/AreaSeries.d.ts +15 -0
- package/dist/series/AreaSeries.d.ts.map +1 -0
- package/dist/series/BarSeries.d.ts +11 -0
- package/dist/series/BarSeries.d.ts.map +1 -0
- package/dist/series/LineSeries.d.ts +14 -0
- package/dist/series/LineSeries.d.ts.map +1 -0
- package/dist/series/curves.d.ts +7 -0
- package/dist/series/curves.d.ts.map +1 -0
- package/dist/series/index.d.ts +8 -0
- package/dist/series/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +48 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils-ySutDPYb.js +2 -0
- package/package.json +90 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
package/USAGE_GUIDE.md
ADDED
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
# Using Graphene Charts
|
|
2
|
+
|
|
3
|
+
> **Scope:** These rules only apply when working with `@gravitee/graphene-charts` components. For the rest of the design system (tokens, components, theming), see `@gravitee/graphene-core`'s usage guide.
|
|
4
|
+
|
|
5
|
+
Browse the live documentation and component catalog on the dedicated [Storybook](https://github.com/gravitee-io/gravitee-ui-graphene) (Charts project on Chromatic).
|
|
6
|
+
|
|
7
|
+
`@gravitee/graphene-charts` is a thin, headless chart library built on D3. It inherits the Graphene design system (tokens, typography, dark mode) and composes with shadcn-style primitives (`ChartContainer`, `ChartTooltip`, `ChartLegend`).
|
|
8
|
+
|
|
9
|
+
## Package exports
|
|
10
|
+
|
|
11
|
+
| Export | What it is |
|
|
12
|
+
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| `@gravitee/graphene-charts` | React chart components and primitives (`ChartCard`, `ChartContainer`, `ChartTooltip`, `ChartTooltipContent`, `ChartLegend`, `ChartLegendContent`, `AreaChart`, `BarChart`, `DoughnutChart`, `LineChart`, `Metric`, `CartesianChart`, `LineSeries`, `AreaSeries`, `BarSeries`, `Grid`, `XAxis`, `YAxis`) |
|
|
14
|
+
| `@gravitee/graphene-charts/dashboard-grid` | Dashboard layout engine (`DashboardGrid`, `DashboardWidget`) and adapter utilities |
|
|
15
|
+
| `@gravitee/graphene-charts/dashboard-grid/styles.css` | Required RGL stylesheet (import in your app entry) |
|
|
16
|
+
|
|
17
|
+
The package intentionally ships **no stylesheet entry**: `@gravitee/graphene-core` is the single source of truth for the Graphene theme (tokens, Tailwind preset, chart palette, fonts) and is a required peer dependency. Chart-component runtime styles (mount animation, focus ring) are injected at render time by the components themselves via React's `<style precedence>` hoisting, so consumers have nothing extra to import.
|
|
18
|
+
|
|
19
|
+
## Dependencies (what the host needs)
|
|
20
|
+
|
|
21
|
+
- **Required:** `react` and `react-dom` (^19).
|
|
22
|
+
- **Required:** `@gravitee/graphene-core` (^1.0.0-alpha.31). Chart primitives consume components (`Empty`, `cn`) and tokens (`--border`, `--muted-foreground`, `--chart-1..5`) from core. The host **must** import `@gravitee/graphene-core/styles` (or the `@gravitee/graphene-core/tailwind-theme` entry if the host runs its own Tailwind pipeline) for charts to render correctly.
|
|
23
|
+
- **Recommended:** `@fontsource/dm-sans` (>=5) if the app isn't already loading it through `@gravitee/graphene-core/fonts`.
|
|
24
|
+
- **Optional:** `tailwindcss` (^4) — only needed if the app runs its own Tailwind pipeline and wants the `bg-chart-1`, `text-chart-2`, … utilities.
|
|
25
|
+
|
|
26
|
+
## Authoring charts
|
|
27
|
+
|
|
28
|
+
- All components are named exports from `@gravitee/graphene-charts`:
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { AreaChart, BarChart, CartesianChart, ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartTooltipContent, DoughnutChart, Grid, LineChart, LineSeries, AreaSeries, XAxis, YAxis } from '@gravitee/graphene-charts';
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
- Never import from internal paths like `@gravitee/graphene-charts/primitives/*` or `@gravitee/graphene-charts/lib/*`. These are implementation details and may change without notice.
|
|
35
|
+
|
|
36
|
+
### Recipe: a bar chart with tooltip + legend
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import {
|
|
40
|
+
BarChart,
|
|
41
|
+
ChartContainer,
|
|
42
|
+
ChartLegend,
|
|
43
|
+
ChartLegendContent,
|
|
44
|
+
ChartTooltip,
|
|
45
|
+
ChartTooltipContent,
|
|
46
|
+
type ChartConfig,
|
|
47
|
+
} from '@gravitee/graphene-charts';
|
|
48
|
+
|
|
49
|
+
const data = [
|
|
50
|
+
{ category: 'Jan', desktop: 186, mobile: 80 },
|
|
51
|
+
{ category: 'Feb', desktop: 305, mobile: 120 },
|
|
52
|
+
{ category: 'Mar', desktop: 237, mobile: 95 },
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
const config: ChartConfig = {
|
|
56
|
+
desktop: { label: 'Desktop', color: 'var(--chart-1)' },
|
|
57
|
+
mobile: { label: 'Mobile', color: 'var(--chart-2)' },
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export function MonthlyVisits() {
|
|
61
|
+
return (
|
|
62
|
+
<ChartContainer config={config} className="h-[280px]">
|
|
63
|
+
<BarChart data={data}>
|
|
64
|
+
<ChartTooltip content={<ChartTooltipContent />} />
|
|
65
|
+
<ChartLegend content={<ChartLegendContent />} />
|
|
66
|
+
</BarChart>
|
|
67
|
+
</ChartContainer>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Recipe: a line chart with tooltip + legend
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
import {
|
|
76
|
+
LineChart,
|
|
77
|
+
ChartContainer,
|
|
78
|
+
ChartLegend,
|
|
79
|
+
ChartLegendContent,
|
|
80
|
+
ChartTooltip,
|
|
81
|
+
ChartTooltipContent,
|
|
82
|
+
type ChartConfig,
|
|
83
|
+
} from '@gravitee/graphene-charts';
|
|
84
|
+
|
|
85
|
+
const data = [
|
|
86
|
+
{ category: '00:00', latency: 120, throughput: 450 },
|
|
87
|
+
{ category: '04:00', latency: 95, throughput: 380 },
|
|
88
|
+
{ category: '08:00', latency: 210, throughput: 620 },
|
|
89
|
+
{ category: '12:00', latency: 185, throughput: 780 },
|
|
90
|
+
{ category: '16:00', latency: 310, throughput: 920 },
|
|
91
|
+
{ category: '20:00', latency: 145, throughput: 540 },
|
|
92
|
+
];
|
|
93
|
+
|
|
94
|
+
const config: ChartConfig = {
|
|
95
|
+
latency: { label: 'Latency (ms)', color: 'var(--chart-1)' },
|
|
96
|
+
throughput: { label: 'Throughput (req/s)', color: 'var(--chart-2)' },
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export function LatencyDashboard() {
|
|
100
|
+
return (
|
|
101
|
+
<ChartContainer config={config} className="h-[280px]">
|
|
102
|
+
<LineChart data={data} curveType="monotone" showDots>
|
|
103
|
+
<ChartTooltip content={<ChartTooltipContent />} />
|
|
104
|
+
<ChartLegend content={<ChartLegendContent />} />
|
|
105
|
+
</LineChart>
|
|
106
|
+
</ChartContainer>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Recipe: a stacked area chart with gradient
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
import {
|
|
115
|
+
AreaChart,
|
|
116
|
+
ChartContainer,
|
|
117
|
+
ChartLegend,
|
|
118
|
+
ChartLegendContent,
|
|
119
|
+
ChartTooltip,
|
|
120
|
+
ChartTooltipContent,
|
|
121
|
+
type ChartConfig,
|
|
122
|
+
} from '@gravitee/graphene-charts';
|
|
123
|
+
|
|
124
|
+
const data = [
|
|
125
|
+
{ category: '00:00', apim: 420, ai: 300, esm: 150 },
|
|
126
|
+
{ category: '04:00', apim: 180, ai: 450, esm: 280 },
|
|
127
|
+
{ category: '08:00', apim: 520, ai: 200, esm: 410 },
|
|
128
|
+
{ category: '12:00', apim: 310, ai: 580, esm: 190 },
|
|
129
|
+
{ category: '16:00', apim: 650, ai: 250, esm: 480 },
|
|
130
|
+
{ category: '20:00', apim: 280, ai: 420, esm: 350 },
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
const config: ChartConfig = {
|
|
134
|
+
apim: { label: 'APIM', color: 'var(--chart-1)' },
|
|
135
|
+
ai: { label: 'AI Agent', color: 'var(--chart-2)' },
|
|
136
|
+
esm: { label: 'ESM', color: 'var(--chart-3)' },
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export function TrafficOverview() {
|
|
140
|
+
return (
|
|
141
|
+
<ChartContainer config={config} className="h-[280px]">
|
|
142
|
+
<AreaChart data={data} stacked gradient>
|
|
143
|
+
<ChartTooltip content={<ChartTooltipContent />} />
|
|
144
|
+
<ChartLegend content={<ChartLegendContent />} />
|
|
145
|
+
</AreaChart>
|
|
146
|
+
</ChartContainer>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Recipe: mixed series with the composable API
|
|
152
|
+
|
|
153
|
+
```tsx
|
|
154
|
+
import {
|
|
155
|
+
CartesianChart,
|
|
156
|
+
AreaSeries,
|
|
157
|
+
LineSeries,
|
|
158
|
+
Grid,
|
|
159
|
+
XAxis,
|
|
160
|
+
YAxis,
|
|
161
|
+
ChartContainer,
|
|
162
|
+
ChartTooltip,
|
|
163
|
+
ChartTooltipContent,
|
|
164
|
+
type ChartConfig,
|
|
165
|
+
} from '@gravitee/graphene-charts';
|
|
166
|
+
|
|
167
|
+
const config: ChartConfig = {
|
|
168
|
+
traffic: { label: 'Traffic (req/s)', color: 'var(--chart-1)' },
|
|
169
|
+
latency: { label: 'Latency (ms)', color: 'var(--chart-2)' },
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export function MixedChart() {
|
|
173
|
+
return (
|
|
174
|
+
<ChartContainer config={config} className="h-[280px]">
|
|
175
|
+
<CartesianChart data={data}>
|
|
176
|
+
<Grid />
|
|
177
|
+
<AreaSeries dataKey="traffic" gradient />
|
|
178
|
+
<LineSeries dataKey="latency" curveType="step" showDots />
|
|
179
|
+
<XAxis />
|
|
180
|
+
<YAxis />
|
|
181
|
+
<ChartTooltip content={<ChartTooltipContent />} />
|
|
182
|
+
</CartesianChart>
|
|
183
|
+
</ChartContainer>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Recipe: a doughnut chart with center content + tooltip + legend
|
|
189
|
+
|
|
190
|
+
```tsx
|
|
191
|
+
import {
|
|
192
|
+
DoughnutChart,
|
|
193
|
+
ChartContainer,
|
|
194
|
+
ChartLegend,
|
|
195
|
+
ChartLegendContent,
|
|
196
|
+
ChartTooltip,
|
|
197
|
+
ChartTooltipContent,
|
|
198
|
+
type ChartConfig,
|
|
199
|
+
} from '@gravitee/graphene-charts';
|
|
200
|
+
|
|
201
|
+
const data = [
|
|
202
|
+
{ category: 'success', value: 8500 },
|
|
203
|
+
{ category: 'error', value: 320 },
|
|
204
|
+
{ category: 'timeout', value: 180 },
|
|
205
|
+
];
|
|
206
|
+
|
|
207
|
+
const config: ChartConfig = {
|
|
208
|
+
success: { label: 'Success', color: 'var(--chart-1)' },
|
|
209
|
+
error: { label: 'Error', color: 'var(--chart-2)' },
|
|
210
|
+
timeout: { label: 'Timeout', color: 'var(--chart-3)' },
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export function StatusBreakdown() {
|
|
214
|
+
return (
|
|
215
|
+
<ChartContainer config={config} className="h-[320px]">
|
|
216
|
+
<DoughnutChart
|
|
217
|
+
data={data}
|
|
218
|
+
centerContent={<span className="text-2xl font-bold">9,000</span>}
|
|
219
|
+
>
|
|
220
|
+
<ChartTooltip content={<ChartTooltipContent />} />
|
|
221
|
+
<ChartLegend content={<ChartLegendContent />} />
|
|
222
|
+
</DoughnutChart>
|
|
223
|
+
</ChartContainer>
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Recipe: a metric dashboard header
|
|
229
|
+
|
|
230
|
+
```tsx
|
|
231
|
+
import { Card, CardContent } from '@gravitee/graphene-core';
|
|
232
|
+
import { Metric } from '@gravitee/graphene-charts';
|
|
233
|
+
import { Activity, AlertTriangle, Clock, Coins } from 'lucide-react';
|
|
234
|
+
|
|
235
|
+
export function MetricHeader() {
|
|
236
|
+
return (
|
|
237
|
+
<div className="grid grid-cols-4 gap-4">
|
|
238
|
+
<Card>
|
|
239
|
+
<CardContent className="pt-4">
|
|
240
|
+
<Metric
|
|
241
|
+
value="12,450"
|
|
242
|
+
label="Total Requests"
|
|
243
|
+
icon={Activity}
|
|
244
|
+
trend={{ value: 12.5, direction: 'up' }}
|
|
245
|
+
sparklineData={[100, 120, 115, 140, 160, 155, 180]}
|
|
246
|
+
/>
|
|
247
|
+
</CardContent>
|
|
248
|
+
</Card>
|
|
249
|
+
<Card>
|
|
250
|
+
<CardContent className="pt-4">
|
|
251
|
+
<Metric
|
|
252
|
+
value="45ms"
|
|
253
|
+
label="Avg Latency"
|
|
254
|
+
icon={Clock}
|
|
255
|
+
trend={{ value: 3.2, direction: 'down' }}
|
|
256
|
+
/>
|
|
257
|
+
</CardContent>
|
|
258
|
+
</Card>
|
|
259
|
+
<Card>
|
|
260
|
+
<CardContent className="pt-4">
|
|
261
|
+
<Metric
|
|
262
|
+
value="2.1%"
|
|
263
|
+
label="Error Rate"
|
|
264
|
+
icon={AlertTriangle}
|
|
265
|
+
trend={{ value: 0.5, direction: 'up' }}
|
|
266
|
+
trendSentiment="lower-is-better"
|
|
267
|
+
/>
|
|
268
|
+
</CardContent>
|
|
269
|
+
</Card>
|
|
270
|
+
<Card>
|
|
271
|
+
<CardContent className="pt-4">
|
|
272
|
+
<Metric
|
|
273
|
+
value="8.2k"
|
|
274
|
+
label="Token Consumption"
|
|
275
|
+
icon={Coins}
|
|
276
|
+
sparklineData={[200, 310, 280, 420, 390, 510, 480]}
|
|
277
|
+
sparklineColor="var(--chart-3)"
|
|
278
|
+
/>
|
|
279
|
+
</CardContent>
|
|
280
|
+
</Card>
|
|
281
|
+
</div>
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
`Metric` is a standalone component — it does **not** use `ChartContainer` or `ChartConfig`. It renders no card wrapper by default; wrap in a `ChartCard` (see below) or a `Card` from `@gravitee/graphene-core` when you need a bordered, elevated container.
|
|
287
|
+
|
|
288
|
+
### Recipe: a ChartCard with metric + line chart
|
|
289
|
+
|
|
290
|
+
```tsx
|
|
291
|
+
import {
|
|
292
|
+
ChartCard,
|
|
293
|
+
ChartContainer,
|
|
294
|
+
ChartTooltip,
|
|
295
|
+
ChartTooltipContent,
|
|
296
|
+
LineChart,
|
|
297
|
+
Metric,
|
|
298
|
+
type ChartConfig,
|
|
299
|
+
} from '@gravitee/graphene-charts';
|
|
300
|
+
|
|
301
|
+
const config: ChartConfig = {
|
|
302
|
+
latency: { label: 'Latency (ms)', color: 'var(--chart-1)' },
|
|
303
|
+
throughput: { label: 'Throughput (req/s)', color: 'var(--chart-2)' },
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
export function RequestsWidget() {
|
|
307
|
+
return (
|
|
308
|
+
<ChartCard title="Total Requests" description="Last 24h">
|
|
309
|
+
<Metric
|
|
310
|
+
value="12,450"
|
|
311
|
+
label="Current"
|
|
312
|
+
trend={{ value: 12.5, direction: 'up' }}
|
|
313
|
+
/>
|
|
314
|
+
<ChartContainer config={config} className="h-[200px]">
|
|
315
|
+
<LineChart data={data}>
|
|
316
|
+
<ChartTooltip content={<ChartTooltipContent />} />
|
|
317
|
+
</LineChart>
|
|
318
|
+
</ChartContainer>
|
|
319
|
+
</ChartCard>
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### Recipe: a KPI dashboard with ChartCard
|
|
325
|
+
|
|
326
|
+
```tsx
|
|
327
|
+
import { ChartCard, Metric } from '@gravitee/graphene-charts';
|
|
328
|
+
import { Activity, AlertTriangle, Clock } from 'lucide-react';
|
|
329
|
+
|
|
330
|
+
export function KpiDashboard() {
|
|
331
|
+
return (
|
|
332
|
+
<div className="grid grid-cols-3 gap-4">
|
|
333
|
+
<ChartCard title="Total Requests">
|
|
334
|
+
<Metric
|
|
335
|
+
value="12,450"
|
|
336
|
+
label="Last 24h"
|
|
337
|
+
icon={Activity}
|
|
338
|
+
trend={{ value: 12.5, direction: 'up' }}
|
|
339
|
+
sparklineData={[100, 120, 115, 140, 160, 155, 180]}
|
|
340
|
+
/>
|
|
341
|
+
</ChartCard>
|
|
342
|
+
<ChartCard title="Avg Latency" description="p50 across all instances">
|
|
343
|
+
<Metric
|
|
344
|
+
value="45ms"
|
|
345
|
+
label="Current"
|
|
346
|
+
icon={Clock}
|
|
347
|
+
trend={{ value: 3.2, direction: 'down' }}
|
|
348
|
+
/>
|
|
349
|
+
</ChartCard>
|
|
350
|
+
<ChartCard title="Error Rate" description="Last 24h">
|
|
351
|
+
<Metric
|
|
352
|
+
value="2.1%"
|
|
353
|
+
label="Last 24h"
|
|
354
|
+
icon={AlertTriangle}
|
|
355
|
+
trend={{ value: 0.5, direction: 'up' }}
|
|
356
|
+
trendSentiment="lower-is-better"
|
|
357
|
+
/>
|
|
358
|
+
</ChartCard>
|
|
359
|
+
</div>
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
`ChartCard` is a layout shell — it does **not** manage `ChartContainer` or `ChartConfig` internally. The consumer wraps charts in `ChartContainer` as needed.
|
|
365
|
+
|
|
366
|
+
### Recipe: a dashboard with DashboardGrid + DashboardWidget
|
|
367
|
+
|
|
368
|
+
```tsx
|
|
369
|
+
import { DashboardGrid, DashboardWidget } from '@gravitee/graphene-charts/dashboard-grid';
|
|
370
|
+
import '@gravitee/graphene-charts/dashboard-grid/styles.css';
|
|
371
|
+
import { Metric, AreaChart, ChartContainer, ChartTooltip, ChartTooltipContent } from '@gravitee/graphene-charts';
|
|
372
|
+
|
|
373
|
+
const widgets = [
|
|
374
|
+
{ id: 'requests', x: 0, y: 0, cols: 3, rows: 1 },
|
|
375
|
+
{ id: 'latency', x: 3, y: 0, cols: 3, rows: 1 },
|
|
376
|
+
{ id: 'traffic', x: 0, y: 1, cols: 6, rows: 2 },
|
|
377
|
+
];
|
|
378
|
+
|
|
379
|
+
function renderWidget(widget) {
|
|
380
|
+
switch (widget.id) {
|
|
381
|
+
case 'requests':
|
|
382
|
+
return (
|
|
383
|
+
<DashboardWidget title="Total Requests" subtitle="Last 24h">
|
|
384
|
+
<Metric value="12.4k" label="" trend={{ value: 12, direction: 'up' }} />
|
|
385
|
+
</DashboardWidget>
|
|
386
|
+
);
|
|
387
|
+
case 'latency':
|
|
388
|
+
return (
|
|
389
|
+
<DashboardWidget title="Avg Latency" subtitle="p50 across instances">
|
|
390
|
+
<Metric value="58ms" label="" trend={{ value: 5, direction: 'down' }} trendSentiment="lower-is-better" />
|
|
391
|
+
</DashboardWidget>
|
|
392
|
+
);
|
|
393
|
+
case 'traffic':
|
|
394
|
+
return (
|
|
395
|
+
<DashboardWidget
|
|
396
|
+
title="Traffic"
|
|
397
|
+
action={<PeriodSelector />}
|
|
398
|
+
noPadding
|
|
399
|
+
footer={<MyLegend />}
|
|
400
|
+
>
|
|
401
|
+
<ChartContainer config={trafficConfig} className="h-full w-full">
|
|
402
|
+
<AreaChart data={trafficData}>
|
|
403
|
+
<ChartTooltip content={<ChartTooltipContent />} />
|
|
404
|
+
</AreaChart>
|
|
405
|
+
</ChartContainer>
|
|
406
|
+
</DashboardWidget>
|
|
407
|
+
);
|
|
408
|
+
default:
|
|
409
|
+
return null;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
export function Dashboard() {
|
|
414
|
+
return (
|
|
415
|
+
<DashboardGrid widgets={widgets} editable>
|
|
416
|
+
{renderWidget}
|
|
417
|
+
</DashboardGrid>
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
`DashboardWidget` is a premium tile shell with a standardized header (title, subtitle, icon, action slot), a flex body, and an optional footer for legends or status lines. It renders its own surface (not the core `Card`) with dashboard-optimized border/shadow treatment for both light and dark modes. Use it as the **single wrapper** for every widget type inside a `DashboardGrid`. `ChartCard` remains the right choice for standalone chart cards outside the grid context.
|
|
423
|
+
|
|
424
|
+
Key props:
|
|
425
|
+
- `title` / `subtitle` — Header text
|
|
426
|
+
- `icon` — Icon to the left of the title
|
|
427
|
+
- `action` — Top-right slot (period selector, dropdown, etc.)
|
|
428
|
+
- `footer` — Bottom slot (legend, status, links)
|
|
429
|
+
- `noPadding` — Removes horizontal padding for full-bleed charts
|
|
430
|
+
|
|
431
|
+
## Tokens you can rely on
|
|
432
|
+
|
|
433
|
+
`@gravitee/graphene-charts` reads the following variables from the shared Graphene preset. They are safe to override at the app root.
|
|
434
|
+
|
|
435
|
+
| Variable | Purpose |
|
|
436
|
+
| --------------------- | -------------------------------------------------------------------------------- |
|
|
437
|
+
| `--chart-1..5` | Default categorical palette used by `ChartConfig` |
|
|
438
|
+
| `--chart-bar-radius` | Corner radius of bar chart marks; defaults to `calc(var(--radius) + 0.125rem)` |
|
|
439
|
+
| `--border` | Color of grid lines |
|
|
440
|
+
| `--muted-foreground` | Color of axis tick labels |
|
|
441
|
+
| `--background` | Tooltip / legend background |
|
|
442
|
+
| `--foreground` | Tooltip / legend text |
|
|
443
|
+
| `--ring` | Focus ring on bars when navigating with the keyboard |
|
|
444
|
+
|
|
445
|
+
Per-series overrides always win (`ChartConfig[key].color` or `ChartConfig[key].theme`). Per-chart overrides of the radius are possible via the `barRadius` prop on `BarChart`.
|
|
446
|
+
|
|
447
|
+
## Animation
|
|
448
|
+
|
|
449
|
+
All chart types animate on mount — no JS animation engine, no extra dependencies.
|
|
450
|
+
|
|
451
|
+
- **BarChart** — bars fade and scale in via CSS `@starting-style`.
|
|
452
|
+
- **DoughnutChart** — segments scale in from center via CSS `@starting-style`.
|
|
453
|
+
- **LineChart** — lines draw in via progressive `stroke-dashoffset`.
|
|
454
|
+
|
|
455
|
+
Toggle with the `animated` prop (defaults to `true`). Replay by bumping the React `key`:
|
|
456
|
+
|
|
457
|
+
```tsx
|
|
458
|
+
const [replayKey, setReplayKey] = useState(0);
|
|
459
|
+
|
|
460
|
+
<button onClick={() => setReplayKey((k) => k + 1)}>Replay</button>
|
|
461
|
+
<LineChart key={replayKey} data={data} />
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
Users with `prefers-reduced-motion: reduce` get the instant render automatically — animation rules are wrapped in `@media` queries.
|
|
465
|
+
|
|
466
|
+
## Accessibility
|
|
467
|
+
|
|
468
|
+
Each chart ships with sensible defaults:
|
|
469
|
+
|
|
470
|
+
- `role="img"` and an `aria-label` on the root `<svg>` (override with the `ariaLabel` prop when the chart needs more specific context).
|
|
471
|
+
- **BarChart**: each bar is keyboard-focusable (`tabIndex={0}`), announces its value via `aria-label`, shows the tooltip on focus, and renders a visible focus ring derived from `--ring`.
|
|
472
|
+
- **DoughnutChart**: each segment is keyboard-focusable (`tabIndex={0}`), announces category, value, and percentage via `aria-label`, shows tooltip on focus, and renders a visible focus ring.
|
|
473
|
+
- **LineChart**: when `showDots` is enabled, each data-point circle is keyboard-focusable with `aria-label` and focus ring. The snap-to-nearest tooltip works on mouse hover regardless.
|
|
474
|
+
- A visually-hidden `<table>` under the chart with the full dataset, so assistive tech users can navigate the data tabularly.
|
|
475
|
+
|
|
476
|
+
## Versioning & support
|
|
477
|
+
|
|
478
|
+
- `@gravitee/graphene-charts` is published alongside `@gravitee/graphene-core` under the same release cycle (independent versions, identical tooling). See the repo's `CHANGELOG.md` per package.
|
|
479
|
+
- Chart APIs are still in `0.x`: minor breaking changes may ship under new alpha versions. Pin the exact version in production apps.
|