@gravitee/graphene-charts 0.0.1-graphene-92.ffb4eff
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/USAGE_GUIDE.md +151 -0
- package/dist/components/BarChart/BarChart.d.ts +60 -0
- package/dist/components/BarChart/BarChart.d.ts.map +1 -0
- package/dist/components/BarChart/index.d.ts +3 -0
- package/dist/components/BarChart/index.d.ts.map +1 -0
- package/dist/components/ChartContainer/ChartContainer.d.ts +21 -0
- package/dist/components/ChartContainer/ChartContainer.d.ts.map +1 -0
- package/dist/components/ChartContainer/index.d.ts +3 -0
- package/dist/components/ChartContainer/index.d.ts.map +1 -0
- package/dist/components/ChartLegend/ChartLegend.d.ts +28 -0
- package/dist/components/ChartLegend/ChartLegend.d.ts.map +1 -0
- package/dist/components/ChartLegend/index.d.ts +3 -0
- package/dist/components/ChartLegend/index.d.ts.map +1 -0
- package/dist/components/ChartTooltip/ChartTooltip.d.ts +43 -0
- package/dist/components/ChartTooltip/ChartTooltip.d.ts.map +1 -0
- package/dist/components/ChartTooltip/index.d.ts +3 -0
- package/dist/components/ChartTooltip/index.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +543 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/primitives/Axis.d.ts +26 -0
- package/dist/primitives/Axis.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/Grid.d.ts +22 -0
- package/dist/primitives/Grid.d.ts.map +1 -0
- package/dist/primitives/index.d.ts +19 -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 +14 -0
- package/dist/primitives/useResolvedCssLength.d.ts.map +1 -0
- package/dist/primitives/useTooltipState.d.ts +37 -0
- package/dist/primitives/useTooltipState.d.ts.map +1 -0
- package/dist/styles/globals.css +2 -0
- package/dist/types/index.d.ts +31 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +73 -0
package/USAGE_GUIDE.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Using Graphene Charts
|
|
2
|
+
|
|
3
|
+
> **Scope:** These rules only apply when working with `@gravitee/graphene-charts` components and styles. For the rest of the design system, 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 (`ChartContainer`, `ChartTooltip`, `ChartTooltipContent`, `ChartLegend`, `ChartLegendContent`, `BarChart`, …) |
|
|
14
|
+
| `@gravitee/graphene-charts/styles` | Pre-built CSS: tokens, Tailwind theme bindings, and chart palette. Import once if the host is **not** already importing `@gravitee/graphene-core/styles` or `@gravitee/graphene-core/tailwind-theme`. |
|
|
15
|
+
|
|
16
|
+
## Dependencies (what the host needs)
|
|
17
|
+
|
|
18
|
+
- **Required:** `react` and `react-dom` (^19).
|
|
19
|
+
- **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.
|
|
20
|
+
- **Recommended:** `@fontsource/dm-sans` (>=5) if the app isn't already loading it through `@gravitee/graphene-core/fonts`.
|
|
21
|
+
- **Optional:** `tailwindcss` (^4) — only needed if the app runs its own Tailwind pipeline and wants the `bg-chart-1`, `text-chart-2`, … utilities.
|
|
22
|
+
|
|
23
|
+
Graphene Charts ships pre-compiled `styles`; the host does **not** need PostCSS or `postcss-import` for the chart CSS file itself.
|
|
24
|
+
|
|
25
|
+
## Integration tiers
|
|
26
|
+
|
|
27
|
+
### Tier 1 — Graphene Core + Charts (recommended)
|
|
28
|
+
|
|
29
|
+
If the host already imports `@gravitee/graphene-core/styles` you already have the chart tokens (`--chart-1..5`). The charts package only needs to be installed and imported; no extra CSS is required.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
// main.ts (order as below)
|
|
33
|
+
import '@gravitee/graphene-core/fonts';
|
|
34
|
+
import '@gravitee/graphene-core/styles';
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { ChartContainer, BarChart, ChartTooltip, ChartTooltipContent } from '@gravitee/graphene-charts';
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Tier 2 — Charts standalone (no Graphene Core styles)
|
|
42
|
+
|
|
43
|
+
If the host does not load `@gravitee/graphene-core/styles`, import the charts stylesheet directly so token variables and base layer rules are available.
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import '@gravitee/graphene-core/fonts';
|
|
47
|
+
import '@gravitee/graphene-charts/styles';
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Note: this stylesheet pulls in the full Graphene Tailwind preset, so Graphene utilities (`text-foreground`, `bg-muted`, …) become available for your own app code as well.
|
|
51
|
+
|
|
52
|
+
### Tier 3 — App uses Tailwind v4 for local code
|
|
53
|
+
|
|
54
|
+
Use the constrained theme from `@gravitee/graphene-core/tailwind-theme` as usual. Chart tokens are part of the shared preset, so `var(--chart-1)` and the `bg-chart-1` / `text-chart-1` utilities work out of the box.
|
|
55
|
+
|
|
56
|
+
```css
|
|
57
|
+
@import 'tailwindcss';
|
|
58
|
+
@import '@gravitee/graphene-core/tailwind-theme';
|
|
59
|
+
@source './**/*.{ts,tsx}';
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Authoring charts
|
|
63
|
+
|
|
64
|
+
- All components are named exports from `@gravitee/graphene-charts`:
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import { ChartContainer, BarChart, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent } from '@gravitee/graphene-charts';
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
- Never import from internal paths like `@gravitee/graphene-charts/primitives/*` or `@gravitee/graphene-charts/lib/*`. These are implementation details and may change without notice.
|
|
71
|
+
|
|
72
|
+
### Recipe: a bar chart with tooltip + legend
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
import {
|
|
76
|
+
BarChart,
|
|
77
|
+
ChartContainer,
|
|
78
|
+
ChartLegend,
|
|
79
|
+
ChartLegendContent,
|
|
80
|
+
ChartTooltip,
|
|
81
|
+
ChartTooltipContent,
|
|
82
|
+
type ChartConfig,
|
|
83
|
+
} from '@gravitee/graphene-charts';
|
|
84
|
+
|
|
85
|
+
const data = [
|
|
86
|
+
{ category: 'Jan', desktop: 186, mobile: 80 },
|
|
87
|
+
{ category: 'Feb', desktop: 305, mobile: 120 },
|
|
88
|
+
{ category: 'Mar', desktop: 237, mobile: 95 },
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
const config: ChartConfig = {
|
|
92
|
+
desktop: { label: 'Desktop', color: 'var(--chart-1)' },
|
|
93
|
+
mobile: { label: 'Mobile', color: 'var(--chart-2)' },
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export function MonthlyVisits() {
|
|
97
|
+
return (
|
|
98
|
+
<ChartContainer config={config} className="h-[280px]">
|
|
99
|
+
<BarChart data={data}>
|
|
100
|
+
<ChartTooltip content={<ChartTooltipContent />} />
|
|
101
|
+
<ChartLegend content={<ChartLegendContent />} />
|
|
102
|
+
</BarChart>
|
|
103
|
+
</ChartContainer>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Tokens you can rely on
|
|
109
|
+
|
|
110
|
+
`@gravitee/graphene-charts` reads the following variables from the shared Graphene preset. They are safe to override at the app root.
|
|
111
|
+
|
|
112
|
+
| Variable | Purpose |
|
|
113
|
+
| --------------------- | -------------------------------------------------------------------------------- |
|
|
114
|
+
| `--chart-1..5` | Default categorical palette used by `ChartConfig` |
|
|
115
|
+
| `--chart-bar-radius` | Corner radius of bar chart marks; defaults to `calc(var(--radius) + 0.125rem)` |
|
|
116
|
+
| `--border` | Color of grid lines |
|
|
117
|
+
| `--muted-foreground` | Color of axis tick labels |
|
|
118
|
+
| `--background` | Tooltip / legend background |
|
|
119
|
+
| `--foreground` | Tooltip / legend text |
|
|
120
|
+
| `--ring` | Focus ring on bars when navigating with the keyboard |
|
|
121
|
+
|
|
122
|
+
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`.
|
|
123
|
+
|
|
124
|
+
## Animation
|
|
125
|
+
|
|
126
|
+
Bar charts fade and scale in on mount via CSS `@starting-style`. No JS animation engine, no extra dependencies.
|
|
127
|
+
|
|
128
|
+
- Toggle with the `animated` prop on `<BarChart>` (defaults to `true`).
|
|
129
|
+
- Replay on demand by bumping the React `key`:
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
const [replayKey, setReplayKey] = useState(0);
|
|
133
|
+
|
|
134
|
+
<button onClick={() => setReplayKey((k) => k + 1)}>Replay</button>
|
|
135
|
+
<BarChart key={replayKey} data={data} />
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
- Users with `prefers-reduced-motion: reduce` get the instant render automatically — the animation rule is wrapped in a `@media` query that disables the transitions on their device.
|
|
139
|
+
|
|
140
|
+
## Accessibility
|
|
141
|
+
|
|
142
|
+
Each chart ships with sensible defaults:
|
|
143
|
+
|
|
144
|
+
- `role="img"` and an `aria-label` on the root `<svg>` (override with the `ariaLabel` prop when the chart needs more specific context).
|
|
145
|
+
- 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`.
|
|
146
|
+
- A visually-hidden `<table>` under the chart with the full dataset, so assistive tech users can navigate the data tabularly.
|
|
147
|
+
|
|
148
|
+
## Versioning & support
|
|
149
|
+
|
|
150
|
+
- `@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.
|
|
151
|
+
- Chart APIs are still in `0.x`: minor breaking changes may ship under new alpha versions. Pin the exact version in production apps.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ChartTooltipItem } from '../ChartTooltip';
|
|
2
|
+
import { Margin } from '../../types';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
export interface BarChartDataPoint {
|
|
5
|
+
/** Category label displayed on the category axis. */
|
|
6
|
+
category: string;
|
|
7
|
+
/** One or more numeric values keyed by series name (must match ChartConfig keys). */
|
|
8
|
+
[series: string]: string | number;
|
|
9
|
+
}
|
|
10
|
+
export type BarChartLayout = 'vertical' | 'horizontal';
|
|
11
|
+
export type BarChartVariant = 'grouped' | 'stacked';
|
|
12
|
+
export interface BarChartProps extends React.ComponentProps<'div'> {
|
|
13
|
+
data: BarChartDataPoint[];
|
|
14
|
+
/** Series keys to render (must match ChartConfig keys). Inferred from data if omitted. */
|
|
15
|
+
dataKeys?: string[];
|
|
16
|
+
layout?: BarChartLayout;
|
|
17
|
+
variant?: BarChartVariant;
|
|
18
|
+
margin?: Partial<Margin>;
|
|
19
|
+
/**
|
|
20
|
+
* Corner radius on bar extremities (px). Defaults to the
|
|
21
|
+
* `--chart-bar-radius` design token (which itself defaults to
|
|
22
|
+
* `--radius + 0.125rem`, i.e. 4 px out of the box) so bars stay in
|
|
23
|
+
* sync with the theme radius unless the chart needs a bespoke value.
|
|
24
|
+
*/
|
|
25
|
+
barRadius?: number;
|
|
26
|
+
/** Gap between grouped bars as a fraction of bandwidth (0..1). */
|
|
27
|
+
barGap?: number;
|
|
28
|
+
/** Show horizontal/vertical grid lines. */
|
|
29
|
+
showGrid?: boolean;
|
|
30
|
+
/** Show category-axis labels. */
|
|
31
|
+
showCategoryAxis?: boolean;
|
|
32
|
+
/** Show value-axis labels. */
|
|
33
|
+
showValueAxis?: boolean;
|
|
34
|
+
/** Format value-axis tick labels. */
|
|
35
|
+
valueTickFormatter?: (value: number) => string;
|
|
36
|
+
/**
|
|
37
|
+
* Human-readable summary of the chart for assistive tech. Defaults to a
|
|
38
|
+
* description derived from the data (e.g. "Bar chart with 6 categories and
|
|
39
|
+
* 2 series"). Override when the chart needs more specific context.
|
|
40
|
+
*/
|
|
41
|
+
ariaLabel?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Whether bars fade & scale in when the chart mounts. Defaults to `true`.
|
|
44
|
+
* Set to `false` to render bars instantly — useful for snapshot tests,
|
|
45
|
+
* motion-reduced preferences, or high-density dashboards where the
|
|
46
|
+
* animation becomes a distraction.
|
|
47
|
+
*
|
|
48
|
+
* The animation replays when the chart remounts. To replay it
|
|
49
|
+
* imperatively (e.g. via a "Replay" button), change the React `key`
|
|
50
|
+
* on `<BarChart>` so it remounts — the CSS `@starting-style` rule that
|
|
51
|
+
* drives the animation fires on every DOM insertion.
|
|
52
|
+
*/
|
|
53
|
+
animated?: boolean;
|
|
54
|
+
/** Escape-hatch hover callback. Prefer `<ChartTooltip>` for tooltips. */
|
|
55
|
+
onBarHover?: (items: ChartTooltipItem[], category: string, event: React.MouseEvent) => void;
|
|
56
|
+
onBarLeave?: () => void;
|
|
57
|
+
}
|
|
58
|
+
declare function BarChart(props: BarChartProps): import("react/jsx-runtime").JSX.Element;
|
|
59
|
+
export { BarChart };
|
|
60
|
+
//# sourceMapp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E,MAAM,CAAC;IACnB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yEAAyE;IACzE,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAC5F,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAmED,iBAAS,QAAQ,CAAC,KAAK,EAAE,aAAa,2CASrC;AAuVD,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/BarChart/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ChartConfig } from '../../types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
interface ChartContextValue {
|
|
4
|
+
config: ChartConfig;
|
|
5
|
+
id: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function useChartConfig(): ChartContextValue;
|
|
8
|
+
export interface ChartContainerProps extends React.ComponentProps<'div'> {
|
|
9
|
+
config: ChartConfig;
|
|
10
|
+
}
|
|
11
|
+
declare function ChartContainer({ id, config, className, children, style, ...props }: ChartContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
/**
|
|
13
|
+
* Injects CSS vars for each series in the form `--color-{seriesKey}`,
|
|
14
|
+
* scoped to a specific chart id and theme (light / dark).
|
|
15
|
+
*/
|
|
16
|
+
declare function ChartStyle({ id, config }: {
|
|
17
|
+
id: string;
|
|
18
|
+
config: ChartConfig;
|
|
19
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export { ChartContainer, ChartStyle };
|
|
21
|
+
//# sourceMappingURL=ChartContainer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartContainer.d.ts","sourceRoot":"","sources":["../../../src/components/ChartContainer/ChartContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAGnE,UAAU,iBAAiB;IACzB,MAAM,EAAE,WAAW,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;CACZ;AAID,wBAAgB,cAAc,sBAM7B;AAED,MAAM,WAAW,mBAAoB,SAAQ,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC;IACtE,MAAM,EAAE,WAAW,CAAC;CACrB;AA2BD,iBAAS,cAAc,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,mBAAmB,2CA8BhG;AAED;;;GAGG;AACH,iBAAS,UAAU,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAE,2CAgBtE;AAED,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ChartContainer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC9E,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface ChartLegendItem {
|
|
3
|
+
/** Data key used to resolve config (falls back to value). */
|
|
4
|
+
dataKey?: string;
|
|
5
|
+
/** Display value used to match a series in ChartConfig. */
|
|
6
|
+
value: string;
|
|
7
|
+
/** Optional color override; defaults to the series color from ChartConfig. */
|
|
8
|
+
color?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ChartLegendContentProps extends React.ComponentProps<'div'> {
|
|
11
|
+
/** Legend payload; injected by the parent chart. */
|
|
12
|
+
items?: ChartLegendItem[];
|
|
13
|
+
/** Hide the small color indicator next to each item. */
|
|
14
|
+
hideIcon?: boolean;
|
|
15
|
+
/** Override the ChartConfig key used to resolve each item's label. */
|
|
16
|
+
nameKey?: string;
|
|
17
|
+
/** Vertical alignment hint passed by the chart so content can self-position. */
|
|
18
|
+
verticalAlign?: 'top' | 'bottom';
|
|
19
|
+
}
|
|
20
|
+
declare function ChartLegendContent({ items, hideIcon, nameKey, verticalAlign, className, ...props }: ChartLegendContentProps): import("react/jsx-runtime").JSX.Element | null;
|
|
21
|
+
export interface ChartLegendProps {
|
|
22
|
+
content: React.ReactElement;
|
|
23
|
+
/** Where to render the legend relative to the chart body. Defaults to `'bottom'`. */
|
|
24
|
+
verticalAlign?: 'top' | 'bottom';
|
|
25
|
+
}
|
|
26
|
+
declare function ChartLegend({ content, verticalAlign }: ChartLegendProps): null;
|
|
27
|
+
export { ChartLegend, ChartLegendContent };
|
|
28
|
+
//# sourceMappingURL=ChartLegend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartLegend.d.ts","sourceRoot":"","sources":["../../../src/components/ChartLegend/ChartLegend.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,MAAM,WAAW,eAAe;IAC9B,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,uBAAwB,SAAQ,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC;IAC1E,oDAAoD;IACpD,KAAK,CAAC,EAAE,eAAe,EAAE,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gFAAgF;IAChF,aAAa,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;CAClC;AAED,iBAAS,kBAAkB,CAAC,EAC1B,KAAU,EACV,QAAgB,EAChB,OAAO,EACP,aAAwB,EACxB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,uBAAuB,kDAgCzB;AASD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC;IAC5B,qFAAqF;IACrF,aAAa,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;CAClC;AAED,iBAAS,WAAW,CAAC,EAAE,OAAO,EAAE,aAAwB,EAAE,EAAE,gBAAgB,QAY3E;AAED,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ChartLegend/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChE,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface ChartTooltipItem {
|
|
3
|
+
/** Key used to resolve series config (falls back to name). */
|
|
4
|
+
dataKey?: string;
|
|
5
|
+
name: string;
|
|
6
|
+
value: number | string;
|
|
7
|
+
/** Optional color override; defaults to the series color from ChartConfig. */
|
|
8
|
+
color?: string;
|
|
9
|
+
/** Optional raw payload for advanced labelFormatter use cases. */
|
|
10
|
+
payload?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
export interface ChartTooltipContentProps extends React.ComponentProps<'div'> {
|
|
13
|
+
/** The label shown at the top of the tooltip (usually the x-axis category). */
|
|
14
|
+
label?: string;
|
|
15
|
+
/** Payload of items, one per series. Injected by the parent chart. */
|
|
16
|
+
items?: ChartTooltipItem[];
|
|
17
|
+
/** Whether the tooltip is visible. Injected by the parent chart. */
|
|
18
|
+
active?: boolean;
|
|
19
|
+
/** Hide the top label row. */
|
|
20
|
+
hideLabel?: boolean;
|
|
21
|
+
/** Hide the color indicator next to each item. */
|
|
22
|
+
hideIndicator?: boolean;
|
|
23
|
+
/** Visual style of the indicator next to each item. */
|
|
24
|
+
indicator?: 'dot' | 'line' | 'dashed';
|
|
25
|
+
/** Override the ChartConfig key used to resolve the label. */
|
|
26
|
+
labelKey?: string;
|
|
27
|
+
/** Override the ChartConfig key used to resolve each item's name. */
|
|
28
|
+
nameKey?: string;
|
|
29
|
+
/** Format the top label. */
|
|
30
|
+
labelFormatter?: (label: string, items: ChartTooltipItem[]) => React.ReactNode;
|
|
31
|
+
/** Extra class for the label row. */
|
|
32
|
+
labelClassName?: string;
|
|
33
|
+
/** Format each item's value. Defaults to `.toLocaleString()` for numbers. */
|
|
34
|
+
valueFormatter?: (value: number | string, item: ChartTooltipItem, index: number) => React.ReactNode;
|
|
35
|
+
}
|
|
36
|
+
declare function ChartTooltipContent({ label, items, active, hideLabel, hideIndicator, indicator, labelKey, nameKey, labelFormatter, labelClassName, valueFormatter, className, ...props }: ChartTooltipContentProps): import("react/jsx-runtime").JSX.Element | null;
|
|
37
|
+
export interface ChartTooltipProps {
|
|
38
|
+
/** The tooltip content element. Receives `label`, `items`, `active` at render time. */
|
|
39
|
+
content: React.ReactElement;
|
|
40
|
+
}
|
|
41
|
+
declare function ChartTooltip({ content }: ChartTooltipProps): null;
|
|
42
|
+
export { ChartTooltipContent, ChartTooltip };
|
|
43
|
+
//# sourceMappingURL=ChartTooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartTooltip.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CAAC,SAAS,CAAC;CACrG;AAWD,iBAAS,mBAAmB,CAAC,EAC3B,KAAK,EACL,KAAU,EACV,MAAa,EACb,SAAiB,EACjB,aAAqB,EACrB,SAAiB,EACjB,QAAQ,EACR,OAAO,EACP,cAAc,EACd,cAAc,EACd,cAAsC,EACtC,SAAS,EACT,GAAG,KAAK,EACT,EAAE,wBAAwB,kDAyF1B;AASD,MAAM,WAAW,iBAAiB;IAChC,uFAAuF;IACvF,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC;CAC7B;AAED,iBAAS,YAAY,CAAC,EAAE,OAAO,EAAE,EAAE,iBAAiB,QAYnD;AAED,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ChartTooltip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnE,YAAY,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { cn } from './lib/utils';
|
|
2
|
+
export type { ChartConfig, ChartSeriesConfig, ChartThemeColors, Margin } from './types';
|
|
3
|
+
export { CHART_THEMES, DEFAULT_MARGIN } from './types';
|
|
4
|
+
export * from './components/ChartContainer';
|
|
5
|
+
export * from './components/ChartTooltip';
|
|
6
|
+
export * from './components/ChartLegend';
|
|
7
|
+
export * from './components/BarChart';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAGjC,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGvD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AAGzC,cAAc,uBAAuB,CAAC"}
|