@openvizai/react 0.1.0 → 0.1.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 CHANGED
@@ -1,6 +1,25 @@
1
1
  # @openvizai/react
2
2
 
3
- React renderer package for OpenVizAI chart output.
3
+ React renderer components for OpenVizAI chart metadata.
4
+
5
+ `@openvizai/react` renders chart output produced by `@openvizai/core` using ApexCharts.
6
+
7
+ ## New to OpenVizAI?
8
+
9
+ `@openvizai/react` is the frontend rendering layer.
10
+
11
+ OpenVizAI works as an interlinked backend + frontend flow:
12
+
13
+ 1. Backend (`@openvizai/core`) analyzes prompt + sampled rows and returns chart metadata (`chart_type`, `embedding`, `meta`).
14
+ 2. Frontend (`@openvizai/react`) uses that metadata to render production-ready charts.
15
+
16
+ This separation is the core idea behind generative charts in OpenVizAI: LLM for decision-making, deterministic code for full-data rendering.
17
+
18
+ If you're new to the repo, start here:
19
+
20
+ - Root architecture + end-to-end explanation: https://github.com/OpenVizAI/OpenVizAI#readme
21
+ - Playground setup guide: https://github.com/OpenVizAI/OpenVizAI/blob/main/docs/PLAYGROUND.md
22
+ - Backend package docs (`@openvizai/core`): https://www.npmjs.com/package/@openvizai/core
4
23
 
5
24
  ## Install
6
25
 
@@ -8,10 +27,101 @@ React renderer package for OpenVizAI chart output.
8
27
  npm install @openvizai/react
9
28
  ```
10
29
 
11
- ## Usage
30
+ ## Peer Dependencies
31
+
32
+ ```bash
33
+ npm install react react-dom apexcharts react-apexcharts
34
+ ```
35
+
36
+ ## Full Example
37
+
38
+ ```jsx
39
+ import { OpenVizRenderer } from "@openvizai/react";
40
+
41
+ const data = [
42
+ { day: "Mon", kwh: 1480, peak_kw: 320, building: "HQ" },
43
+ { day: "Tue", kwh: 1525, peak_kw: 338, building: "HQ" },
44
+ { day: "Wed", kwh: 1410, peak_kw: 305, building: "HQ" },
45
+ { day: "Mon", kwh: 2350, peak_kw: 520, building: "Plant-A" },
46
+ { day: "Tue", kwh: 2415, peak_kw: 548, building: "Plant-A" },
47
+ { day: "Wed", kwh: 2290, peak_kw: 502, building: "Plant-A" },
48
+ ];
49
+
50
+ const embedding = {
51
+ x: [{ field: "day", label: "Day" }],
52
+ y: [
53
+ { type: "bar", unit: "kWh", field: "kwh", label: "Energy Usage" },
54
+ { type: "bar", unit: "kW", field: "peak_kw", label: "Peak Demand" },
55
+ ],
56
+ end: null,
57
+ start: null,
58
+ value: null,
59
+ category: null,
60
+ is_stacked: false,
61
+ colorSemantic: "neutral",
62
+ is_horizontal: false,
63
+ isSemanticColors: false,
64
+ };
65
+
66
+ const meta = {
67
+ title: "Daily Energy Usage vs. Peak Demand by Building",
68
+ subtitle: "Comparison of kWh and Peak kW",
69
+ query_explanation:
70
+ "This chart displays the daily energy consumption in kWh and the peak power demand in kW.",
71
+ };
72
+
73
+ function App() {
74
+ return (
75
+ <div className="App">
76
+ <OpenVizRenderer
77
+ data={data}
78
+ chartType="bar"
79
+ embedding={embedding}
80
+ meta={meta}
81
+ />
82
+ </div>
83
+ );
84
+ }
85
+
86
+ export default App;
87
+ ```
88
+
89
+ ## End-to-End with `@openvizai/core`
12
90
 
13
91
  ```tsx
92
+ import { analyzeChart } from "@openvizai/core";
14
93
  import { OpenVizRenderer } from "@openvizai/react";
94
+
95
+ const { result } = await analyzeChart({
96
+ prompt: "show revenue trends over time",
97
+ data: rows,
98
+ config: { provider: "google", apiKey: GEMINI_API_KEY },
99
+ });
100
+
101
+ <OpenVizRenderer
102
+ data={rows}
103
+ chartType={result.chart.chart_type}
104
+ embedding={result.chart.embedding}
105
+ meta={result.meta}
106
+ />;
15
107
  ```
16
108
 
17
- See the root repository README for complete examples and integration details.
109
+ ## Exports
110
+
111
+ | Export | Description |
112
+ | ------------------------------------------------- | ------------------------------------------------------- |
113
+ | `OpenVizRenderer` | Renders a single chart from embedding metadata |
114
+ | `OpenVizDashboard` | Renders a grid of charts from `analyzeDashboard` output |
115
+ | `registerChart` | Register a custom chart component for a chart type |
116
+ | `getChartComponent` | Get the registered component for a chart type |
117
+ | `resetChartRegistry` | Reset the chart registry to built-in defaults |
118
+ | `LineChart`, `BarChart`, `PieChart`, `RadarChart` | Individual chart components (for advanced usage) |
119
+
120
+ ## Notes
121
+
122
+ - Use this package in the frontend/UI layer.
123
+ - Pair with `@openvizai/core` for end-to-end prompt-to-chart flow.
124
+ - The `embedding` and `meta` objects come directly from the `analyzeChart()` / `analyzeDashboard()` response.
125
+
126
+ For full docs, see the root project README:
127
+ https://github.com/OpenVizAI/OpenVizAI
@@ -1,7 +1,22 @@
1
- import type { OpenVizDashboardProps } from "./types/dashboard";
1
+ import type { OpenVizDashboardProps } from "./types/dashboard.js";
2
2
  /**
3
- * Renders multiple charts in a responsive grid.
4
- * Each chart is an independent OpenVizRenderer with its own embedding + meta.
3
+ * Renders multiple charts in a responsive grid layout.
4
+ *
5
+ * Accepts the output of `analyzeDashboard()` and renders each chart
6
+ * as an independent `<OpenVizRenderer />` with its own embedding + meta.
7
+ *
8
+ * @param props - Data, chart configs, and optional grid/layout settings.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * import { OpenVizDashboard } from "@openvizai/react";
13
+ *
14
+ * <OpenVizDashboard
15
+ * data={rows}
16
+ * charts={result.charts}
17
+ * columns={2}
18
+ * />
19
+ * ```
5
20
  */
6
21
  export default function OpenVizDashboard({ data, charts, config, columns, className, }: OpenVizDashboardProps): import("react/jsx-runtime").JSX.Element;
7
22
  //# sourceMappingURL=OpenVizDashboard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"OpenVizDashboard.d.ts","sourceRoot":"","sources":["../src/OpenVizDashboard.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE/D;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,IAAI,EACJ,MAAM,EACN,MAAM,EACN,OAAW,EACX,SAAS,GACV,EAAE,qBAAqB,2CA6DvB"}
1
+ {"version":3,"file":"OpenVizDashboard.d.ts","sourceRoot":"","sources":["../src/OpenVizDashboard.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAElE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,IAAI,EACJ,MAAM,EACN,MAAM,EACN,OAAW,EACX,SAAS,GACV,EAAE,qBAAqB,2CA6DvB"}
@@ -1,8 +1,23 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import OpenVizRenderer from "./OpenVizRenderer";
2
+ import OpenVizRenderer from "./OpenVizRenderer.js";
3
3
  /**
4
- * Renders multiple charts in a responsive grid.
5
- * Each chart is an independent OpenVizRenderer with its own embedding + meta.
4
+ * Renders multiple charts in a responsive grid layout.
5
+ *
6
+ * Accepts the output of `analyzeDashboard()` and renders each chart
7
+ * as an independent `<OpenVizRenderer />` with its own embedding + meta.
8
+ *
9
+ * @param props - Data, chart configs, and optional grid/layout settings.
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * import { OpenVizDashboard } from "@openvizai/react";
14
+ *
15
+ * <OpenVizDashboard
16
+ * data={rows}
17
+ * charts={result.charts}
18
+ * columns={2}
19
+ * />
20
+ * ```
6
21
  */
7
22
  export default function OpenVizDashboard({ data, charts, config, columns = 2, className, }) {
8
23
  if (!charts || charts.length === 0) {
@@ -1,3 +1,23 @@
1
- import type { OpenVizRendererProps } from "./types/renderer";
1
+ import type { OpenVizRendererProps } from "./types/renderer.js";
2
+ /**
3
+ * Renders a single chart from OpenVizAI embedding metadata.
4
+ *
5
+ * Accepts the output of `analyzeChart()` and visualizes it using ApexCharts.
6
+ * Supports bar, line, pie, donut, radar, and range bar charts out of the box.
7
+ *
8
+ * @param props - Chart data, type, embedding, and optional config.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * import { OpenVizRenderer } from "@openvizai/react";
13
+ *
14
+ * <OpenVizRenderer
15
+ * data={rows}
16
+ * chartType={result.chart.chart_type}
17
+ * embedding={result.chart.embedding}
18
+ * meta={result.meta}
19
+ * />
20
+ * ```
21
+ */
2
22
  export default function OpenVizRenderer({ data, chartType, embedding, meta, config, className, }: OpenVizRendererProps): import("react/jsx-runtime").JSX.Element;
3
23
  //# sourceMappingURL=OpenVizRenderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"OpenVizRenderer.d.ts","sourceRoot":"","sources":["../src/OpenVizRenderer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAmB7D,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,IAAI,EACJ,SAAS,EACT,SAAS,EACT,IAAI,EACJ,MAAM,EACN,SAAS,GACV,EAAE,oBAAoB,2CA8BtB"}
1
+ {"version":3,"file":"OpenVizRenderer.d.ts","sourceRoot":"","sources":["../src/OpenVizRenderer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAmBhE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,IAAI,EACJ,SAAS,EACT,SAAS,EACT,IAAI,EACJ,MAAM,EACN,SAAS,GACV,EAAE,oBAAoB,2CA8BtB"}
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { getChartComponent } from "./charts/registry";
2
+ import { getChartComponent } from "./charts/registry.js";
3
3
  function ChartError({ message }) {
4
4
  return (_jsx("div", { style: {
5
5
  padding: "24px",
@@ -10,6 +10,26 @@ function ChartError({ message }) {
10
10
  backgroundColor: "#f9fafb",
11
11
  }, children: _jsx("p", { style: { margin: 0, fontSize: "14px" }, children: message }) }));
12
12
  }
13
+ /**
14
+ * Renders a single chart from OpenVizAI embedding metadata.
15
+ *
16
+ * Accepts the output of `analyzeChart()` and visualizes it using ApexCharts.
17
+ * Supports bar, line, pie, donut, radar, and range bar charts out of the box.
18
+ *
19
+ * @param props - Chart data, type, embedding, and optional config.
20
+ *
21
+ * @example
22
+ * ```tsx
23
+ * import { OpenVizRenderer } from "@openvizai/react";
24
+ *
25
+ * <OpenVizRenderer
26
+ * data={rows}
27
+ * chartType={result.chart.chart_type}
28
+ * embedding={result.chart.embedding}
29
+ * meta={result.meta}
30
+ * />
31
+ * ```
32
+ */
13
33
  export default function OpenVizRenderer({ data, chartType, embedding, meta, config, className, }) {
14
34
  const ChartComponent = getChartComponent(chartType);
15
35
  if (!ChartComponent) {
@@ -1,3 +1,3 @@
1
- import type { ChartComponentProps } from "./types";
1
+ import type { ChartComponentProps } from "./types.js";
2
2
  export default function BarChart({ data, chartType, embedding, meta, config, }: ChartComponentProps): import("react/jsx-runtime").JSX.Element;
3
3
  //# sourceMappingURL=BarChart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BarChart.d.ts","sourceRoot":"","sources":["../../src/charts/BarChart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAsFnD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,IAAI,EACJ,SAAS,EACT,SAAS,EACT,IAAI,EACJ,MAAM,GACP,EAAE,mBAAmB,2CAkLrB"}
1
+ {"version":3,"file":"BarChart.d.ts","sourceRoot":"","sources":["../../src/charts/BarChart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAsFtD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,IAAI,EACJ,SAAS,EACT,SAAS,EACT,IAAI,EACJ,MAAM,GACP,EAAE,mBAAmB,2CAkLrB"}
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useId } from "react";
3
3
  import Chart from "react-apexcharts";
4
- import { buildApexBaseOptions } from "../embedding/apexBaseOptions";
5
- import { buildCategorySeriesLabels, buildNumericSeries, buildRangeBarPoints, } from "../embedding/seriesBuilder";
4
+ import { buildApexBaseOptions } from "../embedding/apexBaseOptions.js";
5
+ import { buildCategorySeriesLabels, buildNumericSeries, buildRangeBarPoints, } from "../embedding/seriesBuilder.js";
6
6
  // Normalize start/end which can be either a single EmbeddingField or EmbeddingField[]
7
7
  function normalizeField(field) {
8
8
  if (!field)
@@ -1,3 +1,3 @@
1
- import type { ChartComponentProps } from "./types";
1
+ import type { ChartComponentProps } from "./types.js";
2
2
  export default function LineChart({ data, embedding, meta, config, }: ChartComponentProps): import("react/jsx-runtime").JSX.Element;
3
3
  //# sourceMappingURL=LineChart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../src/charts/LineChart.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAQnD,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,MAAM,GACP,EAAE,mBAAmB,2CA+HrB"}
1
+ {"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../src/charts/LineChart.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAQtD,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,MAAM,GACP,EAAE,mBAAmB,2CA+HrB"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import Chart from "react-apexcharts";
3
- import { buildApexBaseOptions } from "../embedding/apexBaseOptions";
4
- import { buildCategorySeriesLabels, buildDatetimePoints, buildNumericDataByField, } from "../embedding/seriesBuilder";
3
+ import { buildApexBaseOptions } from "../embedding/apexBaseOptions.js";
4
+ import { buildCategorySeriesLabels, buildDatetimePoints, buildNumericDataByField, } from "../embedding/seriesBuilder.js";
5
5
  export default function LineChart({ data, embedding, meta, config, }) {
6
6
  const xField = embedding.x?.[0]?.field;
7
7
  const isDatetime = embedding.x?.[0]?.unit === "datetime";
@@ -1,3 +1,3 @@
1
- import type { ChartComponentProps } from "./types";
1
+ import type { ChartComponentProps } from "./types.js";
2
2
  export default function PieChart({ data, chartType, embedding, meta, config, }: ChartComponentProps): import("react/jsx-runtime").JSX.Element;
3
3
  //# sourceMappingURL=PieChart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PieChart.d.ts","sourceRoot":"","sources":["../../src/charts/PieChart.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAOnD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,IAAI,EACJ,SAAS,EACT,SAAS,EACT,IAAI,EACJ,MAAM,GACP,EAAE,mBAAmB,2CAoFrB"}
1
+ {"version":3,"file":"PieChart.d.ts","sourceRoot":"","sources":["../../src/charts/PieChart.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAOtD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,IAAI,EACJ,SAAS,EACT,SAAS,EACT,IAAI,EACJ,MAAM,GACP,EAAE,mBAAmB,2CAoFrB"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import Chart from "react-apexcharts";
3
- import { buildApexBaseOptions } from "../embedding/apexBaseOptions";
4
- import { buildCategorySeriesLabels, buildSingleValueSeries, } from "../embedding/seriesBuilder";
3
+ import { buildApexBaseOptions } from "../embedding/apexBaseOptions.js";
4
+ import { buildCategorySeriesLabels, buildSingleValueSeries, } from "../embedding/seriesBuilder.js";
5
5
  export default function PieChart({ data, chartType, embedding, meta, config, }) {
6
6
  const categoryField = embedding.category?.[0]?.field;
7
7
  const valueField = embedding.value?.[0]?.field;
@@ -1,3 +1,3 @@
1
- import type { ChartComponentProps } from "./types";
1
+ import type { ChartComponentProps } from "./types.js";
2
2
  export default function RadarChart({ data, embedding, meta, config, }: ChartComponentProps): import("react/jsx-runtime").JSX.Element;
3
3
  //# sourceMappingURL=RadarChart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RadarChart.d.ts","sourceRoot":"","sources":["../../src/charts/RadarChart.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAOnD,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,MAAM,GACP,EAAE,mBAAmB,2CAgErB"}
1
+ {"version":3,"file":"RadarChart.d.ts","sourceRoot":"","sources":["../../src/charts/RadarChart.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAOtD,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,MAAM,GACP,EAAE,mBAAmB,2CAgErB"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import Chart from "react-apexcharts";
3
- import { buildApexBaseOptions } from "../embedding/apexBaseOptions";
4
- import { buildCategorySeriesLabels, buildNumericSeries, } from "../embedding/seriesBuilder";
3
+ import { buildApexBaseOptions } from "../embedding/apexBaseOptions.js";
4
+ import { buildCategorySeriesLabels, buildNumericSeries, } from "../embedding/seriesBuilder.js";
5
5
  export default function RadarChart({ data, embedding, meta, config, }) {
6
6
  const xField = embedding.x?.[0]?.field;
7
7
  const yFields = embedding.y ?? [];
@@ -1,5 +1,5 @@
1
- export { default as LineChart } from "./LineChart";
2
- export { default as BarChart } from "./BarChart";
3
- export { default as PieChart } from "./PieChart";
4
- export { default as RadarChart } from "./RadarChart";
1
+ export { default as LineChart } from "./LineChart.js";
2
+ export { default as BarChart } from "./BarChart.js";
3
+ export { default as PieChart } from "./PieChart.js";
4
+ export { default as RadarChart } from "./RadarChart.js";
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/charts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/charts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,4 +1,4 @@
1
- export { default as LineChart } from "./LineChart";
2
- export { default as BarChart } from "./BarChart";
3
- export { default as PieChart } from "./PieChart";
4
- export { default as RadarChart } from "./RadarChart";
1
+ export { default as LineChart } from "./LineChart.js";
2
+ export { default as BarChart } from "./BarChart.js";
3
+ export { default as PieChart } from "./PieChart.js";
4
+ export { default as RadarChart } from "./RadarChart.js";
@@ -1,9 +1,36 @@
1
1
  import type { ComponentType } from "react";
2
- import type { ChartComponentProps } from "./types";
3
- /** Register a custom chart component for a chart type */
2
+ import type { ChartComponentProps } from "./types.js";
3
+ /**
4
+ * Register a custom chart component for a given chart type.
5
+ *
6
+ * Use this to extend the built-in chart registry with your own
7
+ * chart components (e.g. a custom heatmap or treemap).
8
+ *
9
+ * @param chartType - The chart type key (e.g. `"heatmap"`).
10
+ * @param component - The React component to render for that type.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * import { registerChart } from "@openvizai/react";
15
+ * import MyHeatmap from "./MyHeatmap";
16
+ *
17
+ * registerChart("heatmap", MyHeatmap);
18
+ * ```
19
+ */
4
20
  export declare function registerChart(chartType: string, component: ComponentType<ChartComponentProps>): void;
5
- /** Get the component for a chart type. Returns undefined if not registered. */
21
+ /**
22
+ * Get the registered React component for a chart type.
23
+ *
24
+ * Returns `undefined` if no component is registered for the given type.
25
+ *
26
+ * @param chartType - The chart type key to look up.
27
+ * @returns The registered component, or `undefined`.
28
+ */
6
29
  export declare function getChartComponent(chartType: string): ComponentType<ChartComponentProps> | undefined;
7
- /** Reset registry to defaults (useful for testing) */
30
+ /**
31
+ * Reset the chart registry to the built-in defaults.
32
+ *
33
+ * Useful in tests to restore the original registry after custom registrations.
34
+ */
8
35
  export declare function resetChartRegistry(): void;
9
36
  //# sourceMappingURL=registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/charts/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAoBnD,yDAAyD;AACzD,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,aAAa,CAAC,mBAAmB,CAAC,GAC5C,IAAI,CAEN;AAED,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,GAChB,aAAa,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAEhD;AAED,sDAAsD;AACtD,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC"}
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/charts/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAoBtD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,aAAa,CAAC,mBAAmB,CAAC,GAC5C,IAAI,CAEN;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,GAChB,aAAa,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAEhD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC"}
@@ -1,7 +1,7 @@
1
- import LineChart from "./LineChart";
2
- import BarChart from "./BarChart";
3
- import PieChart from "./PieChart";
4
- import RadarChart from "./RadarChart";
1
+ import LineChart from "./LineChart.js";
2
+ import BarChart from "./BarChart.js";
3
+ import PieChart from "./PieChart.js";
4
+ import RadarChart from "./RadarChart.js";
5
5
  const defaultRegistry = {
6
6
  line: LineChart,
7
7
  bar: BarChart,
@@ -11,15 +11,42 @@ const defaultRegistry = {
11
11
  radar: RadarChart,
12
12
  };
13
13
  let registry = { ...defaultRegistry };
14
- /** Register a custom chart component for a chart type */
14
+ /**
15
+ * Register a custom chart component for a given chart type.
16
+ *
17
+ * Use this to extend the built-in chart registry with your own
18
+ * chart components (e.g. a custom heatmap or treemap).
19
+ *
20
+ * @param chartType - The chart type key (e.g. `"heatmap"`).
21
+ * @param component - The React component to render for that type.
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * import { registerChart } from "@openvizai/react";
26
+ * import MyHeatmap from "./MyHeatmap";
27
+ *
28
+ * registerChart("heatmap", MyHeatmap);
29
+ * ```
30
+ */
15
31
  export function registerChart(chartType, component) {
16
32
  registry[chartType] = component;
17
33
  }
18
- /** Get the component for a chart type. Returns undefined if not registered. */
34
+ /**
35
+ * Get the registered React component for a chart type.
36
+ *
37
+ * Returns `undefined` if no component is registered for the given type.
38
+ *
39
+ * @param chartType - The chart type key to look up.
40
+ * @returns The registered component, or `undefined`.
41
+ */
19
42
  export function getChartComponent(chartType) {
20
43
  return registry[chartType];
21
44
  }
22
- /** Reset registry to defaults (useful for testing) */
45
+ /**
46
+ * Reset the chart registry to the built-in defaults.
47
+ *
48
+ * Useful in tests to restore the original registry after custom registrations.
49
+ */
23
50
  export function resetChartRegistry() {
24
51
  registry = { ...defaultRegistry };
25
52
  }
@@ -1,5 +1,5 @@
1
1
  import type { ChartType } from "@openvizai/shared-types";
2
- import type { ChartEmbedding, ChartMeta, OpenVizConfig } from "../types";
2
+ import type { ChartEmbedding, ChartMeta, OpenVizConfig } from "../types/index.js";
3
3
  export type ChartComponentProps = {
4
4
  data: Record<string, unknown>[];
5
5
  chartType: ChartType;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/charts/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzE,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAChC,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,cAAc,CAAC;IAC1B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/charts/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,aAAa,EACd,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC,MAAM,EA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 +1,4 @@
1
- import { toCategoryString, toFiniteNumber, toMilliseconds } from "./chartData";
1
+ import { toCategoryString, toFiniteNumber, toMilliseconds, } from "./chartData.js";
2
2
  // Builds x-axis categories for category-based charts (bar/line/category modes).
3
3
  export function buildCategorySeriesLabels(rows, xField) {
4
4
  return rows.map((row) => toCategoryString(row[xField]));
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export { default as OpenVizRenderer } from "./OpenVizRenderer";
2
- export { default as OpenVizDashboard } from "./OpenVizDashboard";
3
- export { registerChart, getChartComponent, resetChartRegistry, } from "./charts/registry";
4
- export { LineChart, BarChart, PieChart, RadarChart } from "./charts";
5
- export type { EmbeddingField, ChartEmbedding, ChartMeta, OpenVizConfig, OpenVizRendererProps, DashboardChartItem, OpenVizDashboardProps, } from "./types";
6
- export type { ChartComponentProps } from "./charts/types";
1
+ export { default as OpenVizRenderer } from "./OpenVizRenderer.js";
2
+ export { default as OpenVizDashboard } from "./OpenVizDashboard.js";
3
+ export { registerChart, getChartComponent, resetChartRegistry, } from "./charts/registry.js";
4
+ export { LineChart, BarChart, PieChart, RadarChart } from "./charts/index.js";
5
+ export type { EmbeddingField, ChartEmbedding, ChartMeta, OpenVizConfig, OpenVizRendererProps, DashboardChartItem, OpenVizDashboardProps, } from "./types/index.js";
6
+ export type { ChartComponentProps } from "./charts/types.js";
7
7
  export { SUPPORTED_CHART_TYPES } from "@openvizai/shared-types";
8
8
  export type { ChartType } from "@openvizai/shared-types";
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAG/D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGjE,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGrE,YAAY,EACV,cAAc,EACd,cAAc,EACd,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,SAAS,CAAC;AAGjB,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAG1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,YAAY,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGlE,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGpE,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG9E,YAAY,EACV,cAAc,EACd,cAAc,EACd,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,YAAY,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  // Main component
2
- export { default as OpenVizRenderer } from "./OpenVizRenderer";
2
+ export { default as OpenVizRenderer } from "./OpenVizRenderer.js";
3
3
  // Dashboard component
4
- export { default as OpenVizDashboard } from "./OpenVizDashboard";
4
+ export { default as OpenVizDashboard } from "./OpenVizDashboard.js";
5
5
  // Chart registry (for plugin system)
6
- export { registerChart, getChartComponent, resetChartRegistry, } from "./charts/registry";
6
+ export { registerChart, getChartComponent, resetChartRegistry, } from "./charts/registry.js";
7
7
  // Individual chart components (for advanced usage)
8
- export { LineChart, BarChart, PieChart, RadarChart } from "./charts";
8
+ export { LineChart, BarChart, PieChart, RadarChart } from "./charts/index.js";
9
9
  // Re-export chart type constants
10
10
  export { SUPPORTED_CHART_TYPES } from "@openvizai/shared-types";
@@ -1,5 +1,5 @@
1
1
  import type { ChartType } from "@openvizai/shared-types";
2
- import type { ChartEmbedding, ChartMeta, OpenVizConfig } from "./renderer";
2
+ import type { ChartEmbedding, ChartMeta, OpenVizConfig } from "./renderer.js";
3
3
  /** A single chart item for the dashboard */
4
4
  export type DashboardChartItem = {
5
5
  chart_type: ChartType;
@@ -1 +1 @@
1
- {"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../../src/types/dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3E,4CAA4C;AAC5C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,SAAS,CAAC;IACtB,SAAS,EAAE,cAAc,CAAC;IAC1B,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,mDAAmD;AACnD,MAAM,MAAM,qBAAqB,GAAG;IAClC,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAChC,iEAAiE;IACjE,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,sDAAsD;IACtD,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC"}
1
+ {"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../../src/types/dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9E,4CAA4C;AAC5C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,SAAS,CAAC;IACtB,SAAS,EAAE,cAAc,CAAC;IAC1B,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,mDAAmD;AACnD,MAAM,MAAM,qBAAqB,GAAG;IAClC,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAChC,iEAAiE;IACjE,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,sDAAsD;IACtD,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC"}
@@ -1,3 +1,3 @@
1
- export type { EmbeddingField, ChartEmbedding, ChartMeta, OpenVizConfig, OpenVizRendererProps, } from "./renderer";
2
- export type { DashboardChartItem, OpenVizDashboardProps, } from "./dashboard";
1
+ export type { EmbeddingField, ChartEmbedding, ChartMeta, OpenVizConfig, OpenVizRendererProps, } from "./renderer.js";
2
+ export type { DashboardChartItem, OpenVizDashboardProps } from "./dashboard.js";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,cAAc,EACd,SAAS,EACT,aAAa,EACb,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,cAAc,EACd,SAAS,EACT,aAAa,EACb,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,29 @@
1
1
  {
2
2
  "name": "@openvizai/react",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
+ "description": "React renderer components for OpenVizAI chart metadata powered by ApexCharts.",
5
+ "license": "MIT",
6
+ "author": "Jay Gajera",
7
+ "homepage": "https://github.com/OpenVizAI/OpenVizAI#readme",
8
+ "bugs": {
9
+ "url": "https://github.com/OpenVizAI/OpenVizAI/issues"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/OpenVizAI/OpenVizAI.git",
14
+ "directory": "packages/react"
15
+ },
16
+ "keywords": [
17
+ "openvizai",
18
+ "react",
19
+ "charts",
20
+ "visualization",
21
+ "apexcharts",
22
+ "dashboard",
23
+ "typescript",
24
+ "gen-ai-charts",
25
+ "generative-charts"
26
+ ],
4
27
  "type": "module",
5
28
  "main": "./dist/index.js",
6
29
  "types": "./dist/index.d.ts",
@@ -23,7 +46,7 @@
23
46
  "prepublishOnly": "npm run build"
24
47
  },
25
48
  "dependencies": {
26
- "@openvizai/shared-types": "^0.1.0"
49
+ "@openvizai/shared-types": "^0.1.1"
27
50
  },
28
51
  "peerDependencies": {
29
52
  "react": ">=18.0.0",