csv-charts-ai 1.10.0 → 1.11.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/README.md +23 -2
- package/dist/charts.d.ts +42 -2
- package/dist/charts.js +431 -293
- package/dist/charts.js.map +1 -1
- package/dist/index.js +39 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -5
package/README.md
CHANGED
|
@@ -343,13 +343,15 @@ useEffect(() => {
|
|
|
343
343
|
|
|
344
344
|
## React Components (`csv-charts-ai/charts`)
|
|
345
345
|
|
|
346
|
-
Chart components are available as a **separate entry point** so projects that only need AI/parsing don't pull in React
|
|
346
|
+
Chart components are available as a **separate entry point** so projects that only need AI/parsing don't pull in React or Recharts.
|
|
347
347
|
|
|
348
348
|
```bash
|
|
349
349
|
# Optional peer dependencies — only needed if you import from csv-charts-ai/charts
|
|
350
|
-
pnpm add react recharts
|
|
350
|
+
pnpm add react recharts
|
|
351
351
|
```
|
|
352
352
|
|
|
353
|
+
Icons are **built-in** (SVG, zero dependency). To use your own icon library, see [Custom Icons](#custom-icons) below.
|
|
354
|
+
|
|
353
355
|
### Display Charts
|
|
354
356
|
|
|
355
357
|
```tsx
|
|
@@ -409,6 +411,23 @@ You can also pass `className` to any component to add classes alongside the buil
|
|
|
409
411
|
<ChartDisplay data={data} charts={charts} className="my-extra-class" />
|
|
410
412
|
```
|
|
411
413
|
|
|
414
|
+
### Custom Icons
|
|
415
|
+
|
|
416
|
+
Chart toolbar icons are built-in as minimal SVGs (zero dependency). To use your own icon library (lucide-react, heroicons, phosphor, etc.), wrap your charts with `ChartIconProvider`:
|
|
417
|
+
|
|
418
|
+
```tsx
|
|
419
|
+
import { ChartDisplay, ChartIconProvider } from "csv-charts-ai/charts";
|
|
420
|
+
import { RefreshCw, Download, ArrowUp, ArrowDown, RotateCcw, TrendingUp, Filter, Image } from "lucide-react";
|
|
421
|
+
|
|
422
|
+
const icons = { RefreshCw, Download, SortAsc: ArrowUp, SortDesc: ArrowDown, RotateCcw, TrendingUp, Filter, ImageIcon: Image };
|
|
423
|
+
|
|
424
|
+
<ChartIconProvider icons={icons}>
|
|
425
|
+
<ChartDisplay data={data} charts={charts} />
|
|
426
|
+
</ChartIconProvider>
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
You only need to override the icons you want to change — the rest fall back to the built-in SVGs.
|
|
430
|
+
|
|
412
431
|
### Headless Usage (No React)
|
|
413
432
|
|
|
414
433
|
The core entry point (`csv-charts-ai`) works without React — use it in Node.js scripts, APIs, or CLI tools:
|
|
@@ -439,7 +458,9 @@ console.log(result.summary.keyInsights);
|
|
|
439
458
|
| `SingleChart` | Individual chart with toolbar (sort, zoom, trendline, CSV/PNG export) |
|
|
440
459
|
| `ChartToolbar` | Standalone toolbar component |
|
|
441
460
|
| `ChartThemeProvider` | React context for chart theming |
|
|
461
|
+
| `ChartIconProvider` | React context for pluggable icons (default: built-in SVGs) |
|
|
442
462
|
| `defaultDarkTheme` / `defaultLightTheme` | Built-in themes |
|
|
463
|
+
| `defaultIcons` | Built-in SVG icon set |
|
|
443
464
|
|
|
444
465
|
## AI Functions Reference
|
|
445
466
|
|
package/dist/charts.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ interface SingleChartProps {
|
|
|
36
36
|
/** When true, removes all built-in Tailwind classes from toolbar and metadata tags */
|
|
37
37
|
unstyled?: boolean;
|
|
38
38
|
}
|
|
39
|
-
declare function SingleChart({ data, chart, onRegenerate, className, unstyled }: SingleChartProps): react_jsx_runtime.JSX.Element;
|
|
39
|
+
declare function SingleChart({ data, chart, onRegenerate, className, unstyled, }: SingleChartProps): react_jsx_runtime.JSX.Element;
|
|
40
40
|
|
|
41
41
|
interface ChartToolbarProps {
|
|
42
42
|
chartType: ChartType;
|
|
@@ -66,4 +66,44 @@ declare function ChartThemeProvider({ theme, children, }: {
|
|
|
66
66
|
}): react_jsx_runtime.JSX.Element;
|
|
67
67
|
declare function useChartTheme(): ChartTheme;
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
/** Props accepted by every chart icon component. */
|
|
70
|
+
interface ChartIconProps {
|
|
71
|
+
className?: string;
|
|
72
|
+
}
|
|
73
|
+
/** A React component that renders an icon. */
|
|
74
|
+
type ChartIcon = React.ComponentType<ChartIconProps>;
|
|
75
|
+
/** The full set of icons used by chart components. */
|
|
76
|
+
interface ChartIconSet {
|
|
77
|
+
RefreshCw: ChartIcon;
|
|
78
|
+
Download: ChartIcon;
|
|
79
|
+
SortAsc: ChartIcon;
|
|
80
|
+
SortDesc: ChartIcon;
|
|
81
|
+
RotateCcw: ChartIcon;
|
|
82
|
+
TrendingUp: ChartIcon;
|
|
83
|
+
Filter: ChartIcon;
|
|
84
|
+
ImageIcon: ChartIcon;
|
|
85
|
+
}
|
|
86
|
+
declare const defaultIcons: ChartIconSet;
|
|
87
|
+
/**
|
|
88
|
+
* Provide a custom icon set to chart components.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```tsx
|
|
92
|
+
* import { ChartIconProvider } from "csv-charts-ai/charts";
|
|
93
|
+
* import { RefreshCw, Download, ... } from "lucide-react";
|
|
94
|
+
*
|
|
95
|
+
* const lucideIcons = { RefreshCw, Download, SortAsc, SortDesc, RotateCcw, TrendingUp, Filter, ImageIcon: Image };
|
|
96
|
+
*
|
|
97
|
+
* <ChartIconProvider icons={lucideIcons}>
|
|
98
|
+
* <ChartDisplay data={data} charts={charts} />
|
|
99
|
+
* </ChartIconProvider>
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
declare function ChartIconProvider({ icons, children, }: {
|
|
103
|
+
icons: Partial<ChartIconSet>;
|
|
104
|
+
children: React.ReactNode;
|
|
105
|
+
}): react_jsx_runtime.JSX.Element;
|
|
106
|
+
/** Get the current icon set from context. */
|
|
107
|
+
declare function useChartIcons(): ChartIconSet;
|
|
108
|
+
|
|
109
|
+
export { ChartConfig, ChartDisplay, type ChartDisplayProps, type ChartIcon, type ChartIconProps, ChartIconProvider, type ChartIconSet, ChartTheme, ChartThemeProvider, ChartToolbar, ChartType, SingleChart, type SingleChartProps, SortOrder, TabularData, defaultIcons, useChartIcons, useChartTheme };
|