@openvizai/react 0.1.0

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.
Files changed (50) hide show
  1. package/README.md +17 -0
  2. package/dist/OpenVizDashboard.d.ts +7 -0
  3. package/dist/OpenVizDashboard.d.ts.map +1 -0
  4. package/dist/OpenVizDashboard.js +29 -0
  5. package/dist/OpenVizRenderer.d.ts +3 -0
  6. package/dist/OpenVizRenderer.d.ts.map +1 -0
  7. package/dist/OpenVizRenderer.js +22 -0
  8. package/dist/charts/BarChart.d.ts +3 -0
  9. package/dist/charts/BarChart.d.ts.map +1 -0
  10. package/dist/charts/BarChart.js +170 -0
  11. package/dist/charts/LineChart.d.ts +3 -0
  12. package/dist/charts/LineChart.d.ts.map +1 -0
  13. package/dist/charts/LineChart.js +98 -0
  14. package/dist/charts/PieChart.d.ts +3 -0
  15. package/dist/charts/PieChart.d.ts.map +1 -0
  16. package/dist/charts/PieChart.js +66 -0
  17. package/dist/charts/RadarChart.d.ts +3 -0
  18. package/dist/charts/RadarChart.d.ts.map +1 -0
  19. package/dist/charts/RadarChart.js +48 -0
  20. package/dist/charts/index.d.ts +5 -0
  21. package/dist/charts/index.d.ts.map +1 -0
  22. package/dist/charts/index.js +4 -0
  23. package/dist/charts/registry.d.ts +9 -0
  24. package/dist/charts/registry.d.ts.map +1 -0
  25. package/dist/charts/registry.js +25 -0
  26. package/dist/charts/types.d.ts +10 -0
  27. package/dist/charts/types.d.ts.map +1 -0
  28. package/dist/charts/types.js +1 -0
  29. package/dist/embedding/apexBaseOptions.d.ts +33 -0
  30. package/dist/embedding/apexBaseOptions.d.ts.map +1 -0
  31. package/dist/embedding/apexBaseOptions.js +25 -0
  32. package/dist/embedding/chartData.d.ts +9 -0
  33. package/dist/embedding/chartData.d.ts.map +1 -0
  34. package/dist/embedding/chartData.js +25 -0
  35. package/dist/embedding/seriesBuilder.d.ts +22 -0
  36. package/dist/embedding/seriesBuilder.d.ts.map +1 -0
  37. package/dist/embedding/seriesBuilder.js +52 -0
  38. package/dist/index.d.ts +9 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +10 -0
  41. package/dist/types/dashboard.d.ts +22 -0
  42. package/dist/types/dashboard.d.ts.map +1 -0
  43. package/dist/types/dashboard.js +1 -0
  44. package/dist/types/index.d.ts +3 -0
  45. package/dist/types/index.d.ts.map +1 -0
  46. package/dist/types/index.js +1 -0
  47. package/dist/types/renderer.d.ts +62 -0
  48. package/dist/types/renderer.d.ts.map +1 -0
  49. package/dist/types/renderer.js +1 -0
  50. package/package.json +43 -0
package/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # @openvizai/react
2
+
3
+ React renderer package for OpenVizAI chart output.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @openvizai/react
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```tsx
14
+ import { OpenVizRenderer } from "@openvizai/react";
15
+ ```
16
+
17
+ See the root repository README for complete examples and integration details.
@@ -0,0 +1,7 @@
1
+ import type { OpenVizDashboardProps } from "./types/dashboard";
2
+ /**
3
+ * Renders multiple charts in a responsive grid.
4
+ * Each chart is an independent OpenVizRenderer with its own embedding + meta.
5
+ */
6
+ export default function OpenVizDashboard({ data, charts, config, columns, className, }: OpenVizDashboardProps): import("react/jsx-runtime").JSX.Element;
7
+ //# sourceMappingURL=OpenVizDashboard.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import OpenVizRenderer from "./OpenVizRenderer";
3
+ /**
4
+ * Renders multiple charts in a responsive grid.
5
+ * Each chart is an independent OpenVizRenderer with its own embedding + meta.
6
+ */
7
+ export default function OpenVizDashboard({ data, charts, config, columns = 2, className, }) {
8
+ if (!charts || charts.length === 0) {
9
+ return (_jsx("div", { style: {
10
+ padding: "24px",
11
+ textAlign: "center",
12
+ color: "#6b7280",
13
+ border: "1px dashed #d1d5db",
14
+ borderRadius: "8px",
15
+ backgroundColor: "#f9fafb",
16
+ }, children: _jsx("p", { style: { margin: 0, fontSize: "14px" }, children: "No charts to display." }) }));
17
+ }
18
+ return (_jsx("div", { className: className, style: {
19
+ display: "grid",
20
+ gridTemplateColumns: `repeat(${columns}, 1fr)`,
21
+ gap: "16px",
22
+ width: "100%",
23
+ }, children: charts.map((chart, index) => (_jsxs("div", { style: {
24
+ border: "1px solid #e5e7eb",
25
+ borderRadius: "8px",
26
+ padding: "16px",
27
+ backgroundColor: "#ffffff",
28
+ }, children: [_jsxs("div", { style: { marginBottom: "8px" }, children: [_jsx("h4", { style: { margin: "0 0 4px 0", fontSize: "14px", fontWeight: 600 }, children: chart.meta.title }), chart.meta.query_explanation && (_jsx("p", { style: { margin: 0, fontSize: "12px", color: "#6b7280" }, children: chart.meta.query_explanation }))] }), _jsx(OpenVizRenderer, { data: data, chartType: chart.chart_type, embedding: chart.embedding, meta: chart.meta, config: config })] }, `${chart.chart_type}-${index}`))) }));
29
+ }
@@ -0,0 +1,3 @@
1
+ import type { OpenVizRendererProps } from "./types/renderer";
2
+ export default function OpenVizRenderer({ data, chartType, embedding, meta, config, className, }: OpenVizRendererProps): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=OpenVizRenderer.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { getChartComponent } from "./charts/registry";
3
+ function ChartError({ message }) {
4
+ return (_jsx("div", { style: {
5
+ padding: "24px",
6
+ textAlign: "center",
7
+ color: "#6b7280",
8
+ border: "1px dashed #d1d5db",
9
+ borderRadius: "8px",
10
+ backgroundColor: "#f9fafb",
11
+ }, children: _jsx("p", { style: { margin: 0, fontSize: "14px" }, children: message }) }));
12
+ }
13
+ export default function OpenVizRenderer({ data, chartType, embedding, meta, config, className, }) {
14
+ const ChartComponent = getChartComponent(chartType);
15
+ if (!ChartComponent) {
16
+ return (_jsx("div", { className: className, children: _jsx(ChartError, { message: `Unsupported chart type: "${chartType}"` }) }));
17
+ }
18
+ if (!data || data.length === 0) {
19
+ return (_jsx("div", { className: className, children: _jsx(ChartError, { message: "No data available to render the chart." }) }));
20
+ }
21
+ return (_jsx("div", { className: className, children: _jsx(ChartComponent, { data: data, chartType: chartType, embedding: embedding, meta: meta, config: config }) }));
22
+ }
@@ -0,0 +1,3 @@
1
+ import type { ChartComponentProps } from "./types";
2
+ export default function BarChart({ data, chartType, embedding, meta, config, }: ChartComponentProps): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=BarChart.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,170 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useId } from "react";
3
+ import Chart from "react-apexcharts";
4
+ import { buildApexBaseOptions } from "../embedding/apexBaseOptions";
5
+ import { buildCategorySeriesLabels, buildNumericSeries, buildRangeBarPoints, } from "../embedding/seriesBuilder";
6
+ // Normalize start/end which can be either a single EmbeddingField or EmbeddingField[]
7
+ function normalizeField(field) {
8
+ if (!field)
9
+ return undefined;
10
+ if (Array.isArray(field))
11
+ return field[0];
12
+ return field;
13
+ }
14
+ function isNumericLike(value) {
15
+ if (value === null || value === undefined || value === "")
16
+ return false;
17
+ if (typeof value === "number")
18
+ return Number.isFinite(value);
19
+ const parsed = Number(value);
20
+ return Number.isFinite(parsed);
21
+ }
22
+ function inferRangeFields(rows, xField, yFields, startField, endField) {
23
+ let resolvedX = xField;
24
+ let resolvedStart = startField;
25
+ let resolvedEnd = endField;
26
+ if ((!resolvedStart || !resolvedEnd) && yFields.length >= 2) {
27
+ resolvedStart = resolvedStart ?? {
28
+ field: yFields[0].field,
29
+ label: yFields[0].label,
30
+ };
31
+ resolvedEnd = resolvedEnd ?? {
32
+ field: yFields[1].field,
33
+ label: yFields[1].label,
34
+ };
35
+ }
36
+ if ((!resolvedStart || !resolvedEnd) && rows.length > 0) {
37
+ const sample = rows[0] ?? {};
38
+ const keys = Object.keys(sample);
39
+ const numericKeys = keys.filter((key) => key !== resolvedX && rows.some((row) => isNumericLike(row[key])));
40
+ if (!resolvedStart && numericKeys[0]) {
41
+ resolvedStart = { field: numericKeys[0], label: numericKeys[0] };
42
+ }
43
+ if (!resolvedEnd && numericKeys[1]) {
44
+ resolvedEnd = { field: numericKeys[1], label: numericKeys[1] };
45
+ }
46
+ }
47
+ if (!resolvedX && rows.length > 0) {
48
+ const sample = rows[0] ?? {};
49
+ const keys = Object.keys(sample);
50
+ const categoricalKey = keys.find((key) => key !== resolvedStart?.field &&
51
+ key !== resolvedEnd?.field &&
52
+ !rows.some((row) => isNumericLike(row[key])));
53
+ resolvedX = categoricalKey ?? keys[0];
54
+ }
55
+ return {
56
+ xField: resolvedX,
57
+ startField: resolvedStart,
58
+ endField: resolvedEnd,
59
+ };
60
+ }
61
+ export default function BarChart({ data, chartType, embedding, meta, config, }) {
62
+ const instanceId = useId();
63
+ const isRangeChart = chartType === "range_bar" || embedding.is_range;
64
+ const apexType = isRangeChart ? "rangeBar" : "bar";
65
+ const chartId = `${meta?.title || "bar-chart"}-${apexType}-${instanceId}`;
66
+ const xField = embedding.x?.[0]?.field;
67
+ const yFields = embedding.y ?? [];
68
+ const startField = normalizeField(embedding.start);
69
+ const endField = normalizeField(embedding.end);
70
+ const resolvedRangeFields = inferRangeFields(data, xField, yFields, startField, endField);
71
+ // Guard: bar/column needs either x+y or range fields
72
+ if (!xField &&
73
+ !resolvedRangeFields.xField &&
74
+ !startField &&
75
+ !resolvedRangeFields.startField) {
76
+ return (_jsx("div", { style: {
77
+ padding: "24px",
78
+ textAlign: "center",
79
+ color: "#6b7280",
80
+ border: "1px dashed #d1d5db",
81
+ borderRadius: "8px",
82
+ backgroundColor: "#f9fafb",
83
+ }, children: _jsx("p", { style: { margin: 0, fontSize: "14px" }, children: "Unable to render bar chart: missing required axis fields." }) }));
84
+ }
85
+ const baseOptions = buildApexBaseOptions({
86
+ chartId,
87
+ title: meta?.title,
88
+ subtitle: meta?.subtitle,
89
+ legendPosition: config?.legendPosition ?? "top",
90
+ dataLabelsEnabled: config?.dataLabelsEnabled ?? false,
91
+ toolbarVisible: config?.toolbarVisible,
92
+ });
93
+ let series;
94
+ if (isRangeChart &&
95
+ resolvedRangeFields.startField &&
96
+ resolvedRangeFields.endField &&
97
+ resolvedRangeFields.xField) {
98
+ // Range bar chart: data points as { x: category, y: [start, end] }
99
+ series = [
100
+ {
101
+ name: `${resolvedRangeFields.startField.label ?? "Start"} - ${resolvedRangeFields.endField.label ?? "End"}`,
102
+ data: buildRangeBarPoints(data, resolvedRangeFields.xField, resolvedRangeFields.startField.field, resolvedRangeFields.endField.field),
103
+ },
104
+ ];
105
+ if (!series[0].data || series[0].data.length === 0) {
106
+ return (_jsx("div", { style: {
107
+ padding: "24px",
108
+ textAlign: "center",
109
+ color: "#6b7280",
110
+ border: "1px dashed #d1d5db",
111
+ borderRadius: "8px",
112
+ backgroundColor: "#f9fafb",
113
+ }, children: _jsx("p", { style: { margin: 0, fontSize: "14px" }, children: "Unable to render range bar chart: no valid range points found." }) }));
114
+ }
115
+ }
116
+ else if (isRangeChart) {
117
+ return (_jsx("div", { style: {
118
+ padding: "24px",
119
+ textAlign: "center",
120
+ color: "#6b7280",
121
+ border: "1px dashed #d1d5db",
122
+ borderRadius: "8px",
123
+ backgroundColor: "#f9fafb",
124
+ }, children: _jsx("p", { style: { margin: 0, fontSize: "14px" }, children: "Unable to render range bar chart: missing start/end fields." }) }));
125
+ }
126
+ else {
127
+ // Standard bar/column chart (supports stacked, multi-series)
128
+ const categories = xField ? buildCategorySeriesLabels(data, xField) : [];
129
+ series = buildNumericSeries(data, yFields);
130
+ const options = {
131
+ ...baseOptions,
132
+ chart: {
133
+ ...baseOptions.chart,
134
+ stacked: embedding.is_stacked,
135
+ },
136
+ plotOptions: {
137
+ bar: {
138
+ horizontal: embedding.is_horizontal,
139
+ },
140
+ },
141
+ xaxis: {
142
+ categories,
143
+ title: {
144
+ text: embedding.x?.[0]?.label ?? undefined,
145
+ },
146
+ },
147
+ };
148
+ return (_jsx(Chart, { type: apexType, width: config?.width ?? "100%", height: config?.height ?? 350, options: options, series: series }, chartId));
149
+ }
150
+ // Options for range bar (x-axis usually category or datetime)
151
+ const rangeOptions = {
152
+ ...baseOptions,
153
+ chart: {
154
+ ...baseOptions.chart,
155
+ id: chartId,
156
+ },
157
+ plotOptions: {
158
+ bar: {
159
+ horizontal: embedding.is_horizontal,
160
+ },
161
+ },
162
+ xaxis: {
163
+ type: resolvedRangeFields.startField?.unit === "datetime" ||
164
+ resolvedRangeFields.endField?.unit === "datetime"
165
+ ? "datetime"
166
+ : "category",
167
+ },
168
+ };
169
+ return (_jsx(Chart, { type: apexType, width: config?.width ?? "100%", height: config?.height ?? 350, options: rangeOptions, series: series }, chartId));
170
+ }
@@ -0,0 +1,3 @@
1
+ import type { ChartComponentProps } from "./types";
2
+ export default function LineChart({ data, embedding, meta, config, }: ChartComponentProps): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=LineChart.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,98 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import Chart from "react-apexcharts";
3
+ import { buildApexBaseOptions } from "../embedding/apexBaseOptions";
4
+ import { buildCategorySeriesLabels, buildDatetimePoints, buildNumericDataByField, } from "../embedding/seriesBuilder";
5
+ export default function LineChart({ data, embedding, meta, config, }) {
6
+ const xField = embedding.x?.[0]?.field;
7
+ const isDatetime = embedding.x?.[0]?.unit === "datetime";
8
+ const yFields = embedding.y ?? [];
9
+ if (!xField || yFields.length === 0) {
10
+ return (_jsx("div", { style: {
11
+ padding: "24px",
12
+ textAlign: "center",
13
+ color: "#6b7280",
14
+ border: "1px dashed #d1d5db",
15
+ borderRadius: "8px",
16
+ backgroundColor: "#f9fafb",
17
+ }, children: _jsx("p", { style: { margin: 0, fontSize: "14px" }, children: "Unable to render line chart: missing required x-axis or y-axis fields." }) }));
18
+ }
19
+ const baseOptions = buildApexBaseOptions({
20
+ chartId: meta?.title || "line-chart",
21
+ title: meta?.title,
22
+ subtitle: meta?.subtitle,
23
+ legendPosition: config?.legendPosition ?? "top",
24
+ dataLabelsEnabled: config?.dataLabelsEnabled ?? false,
25
+ toolbarVisible: config?.toolbarVisible,
26
+ });
27
+ const categories = xField && !isDatetime ? buildCategorySeriesLabels(data, xField) : undefined;
28
+ // Build distinct units to drive multi-axis behavior
29
+ const unitKeys = Array.from(new Set(yFields.map((yField) => (yField.unit ? yField.unit : "default"))));
30
+ const series = yFields.map((yField) => {
31
+ const axisKey = yField.unit ? yField.unit : "default";
32
+ const yAxisIndex = unitKeys.indexOf(axisKey);
33
+ const base = {
34
+ name: yField.label || yField.field,
35
+ type: yField.type ?? "line",
36
+ yAxisIndex,
37
+ };
38
+ if (isDatetime && xField) {
39
+ return {
40
+ ...base,
41
+ data: buildDatetimePoints(data, xField, yField.field),
42
+ };
43
+ }
44
+ return {
45
+ ...base,
46
+ data: buildNumericDataByField(data, yField.field),
47
+ };
48
+ });
49
+ const yaxis = unitKeys.length > 1
50
+ ? unitKeys.map((unit, idx) => ({
51
+ title: {
52
+ text: unit === "default" ? undefined : unit,
53
+ },
54
+ opposite: idx % 2 === 1,
55
+ }))
56
+ : {
57
+ labels: {
58
+ formatter: (val) => `${val}`,
59
+ },
60
+ };
61
+ const options = {
62
+ ...baseOptions,
63
+ chart: {
64
+ ...baseOptions.chart,
65
+ stacked: embedding.is_stacked,
66
+ animations: {
67
+ enabled: config?.animations ?? true,
68
+ },
69
+ },
70
+ xaxis: {
71
+ ...(categories ? { categories } : {}),
72
+ type: isDatetime ? "datetime" : "category",
73
+ title: {
74
+ text: embedding.x?.[0]?.label ?? undefined,
75
+ },
76
+ },
77
+ yaxis,
78
+ tooltip: {
79
+ shared: true,
80
+ intersect: false,
81
+ },
82
+ stroke: {
83
+ curve: (embedding.line_curve ?? "smooth"),
84
+ width: 2,
85
+ },
86
+ markers: {
87
+ size: embedding.markers_size ?? 0,
88
+ },
89
+ ...(embedding.forecast_points
90
+ ? {
91
+ forecastDataPoints: {
92
+ count: embedding.forecast_points,
93
+ },
94
+ }
95
+ : {}),
96
+ };
97
+ return (_jsx(Chart, { type: "line", width: config?.width ?? "100%", height: config?.height ?? 350, options: options, series: series }));
98
+ }
@@ -0,0 +1,3 @@
1
+ import type { ChartComponentProps } from "./types";
2
+ export default function PieChart({ data, chartType, embedding, meta, config, }: ChartComponentProps): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=PieChart.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,66 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import Chart from "react-apexcharts";
3
+ import { buildApexBaseOptions } from "../embedding/apexBaseOptions";
4
+ import { buildCategorySeriesLabels, buildSingleValueSeries, } from "../embedding/seriesBuilder";
5
+ export default function PieChart({ data, chartType, embedding, meta, config, }) {
6
+ const categoryField = embedding.category?.[0]?.field;
7
+ const valueField = embedding.value?.[0]?.field;
8
+ if (!categoryField || !valueField) {
9
+ return (_jsx("div", { style: {
10
+ padding: "24px",
11
+ textAlign: "center",
12
+ color: "#6b7280",
13
+ border: "1px dashed #d1d5db",
14
+ borderRadius: "8px",
15
+ backgroundColor: "#f9fafb",
16
+ }, children: _jsx("p", { style: { margin: 0, fontSize: "14px" }, children: "Unable to render pie chart: missing required category or value fields." }) }));
17
+ }
18
+ const labels = buildCategorySeriesLabels(data, categoryField);
19
+ const series = buildSingleValueSeries(data, valueField);
20
+ const pieType = chartType === "donut" || embedding.is_donut
21
+ ? "donut"
22
+ : "pie";
23
+ const baseOptions = buildApexBaseOptions({
24
+ chartId: meta?.title || "pie-chart",
25
+ title: meta?.title,
26
+ subtitle: meta?.subtitle,
27
+ legendPosition: config?.legendPosition ?? "right",
28
+ dataLabelsEnabled: config?.dataLabelsEnabled ?? true,
29
+ toolbarVisible: config?.toolbarVisible,
30
+ });
31
+ const options = {
32
+ ...baseOptions,
33
+ labels,
34
+ dataLabels: {
35
+ ...baseOptions.dataLabels,
36
+ formatter: (val) => `${val.toFixed(1)}%`,
37
+ },
38
+ tooltip: {
39
+ y: {
40
+ formatter: (val) => val.toLocaleString(),
41
+ },
42
+ },
43
+ plotOptions: {
44
+ pie: {
45
+ expandOnClick: true,
46
+ donut: {
47
+ size: pieType === "donut" ? "60%" : "0%",
48
+ labels: {
49
+ show: pieType === "donut",
50
+ },
51
+ },
52
+ },
53
+ },
54
+ responsive: [
55
+ {
56
+ breakpoint: 768,
57
+ options: {
58
+ legend: {
59
+ position: "bottom",
60
+ },
61
+ },
62
+ },
63
+ ],
64
+ };
65
+ return (_jsx(Chart, { type: pieType, width: config?.width ?? "100%", height: config?.height ?? 350, options: options, series: series }));
66
+ }
@@ -0,0 +1,3 @@
1
+ import type { ChartComponentProps } from "./types";
2
+ export default function RadarChart({ data, embedding, meta, config, }: ChartComponentProps): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=RadarChart.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,48 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import Chart from "react-apexcharts";
3
+ import { buildApexBaseOptions } from "../embedding/apexBaseOptions";
4
+ import { buildCategorySeriesLabels, buildNumericSeries, } from "../embedding/seriesBuilder";
5
+ export default function RadarChart({ data, embedding, meta, config, }) {
6
+ const xField = embedding.x?.[0]?.field;
7
+ const yFields = embedding.y ?? [];
8
+ if (!xField) {
9
+ return (_jsx("div", { style: {
10
+ padding: "24px",
11
+ textAlign: "center",
12
+ color: "#6b7280",
13
+ border: "1px dashed #d1d5db",
14
+ borderRadius: "8px",
15
+ backgroundColor: "#f9fafb",
16
+ }, children: _jsx("p", { style: { margin: 0, fontSize: "14px" }, children: "Unable to render radar chart: missing required x-axis field." }) }));
17
+ }
18
+ const labels = buildCategorySeriesLabels(data, xField);
19
+ const series = buildNumericSeries(data, yFields);
20
+ const baseOptions = buildApexBaseOptions({
21
+ chartId: meta?.title || "radar-chart",
22
+ title: meta?.title,
23
+ subtitle: meta?.subtitle,
24
+ legendPosition: config?.legendPosition ?? "top",
25
+ dataLabelsEnabled: config?.dataLabelsEnabled ?? false,
26
+ toolbarVisible: config?.toolbarVisible,
27
+ });
28
+ const options = {
29
+ ...baseOptions,
30
+ labels,
31
+ xaxis: {
32
+ categories: labels,
33
+ title: {
34
+ text: embedding.x?.[0]?.label ?? undefined,
35
+ },
36
+ },
37
+ stroke: {
38
+ width: 2,
39
+ },
40
+ fill: {
41
+ opacity: 0.2,
42
+ },
43
+ markers: {
44
+ size: embedding.markers_size ?? 3,
45
+ },
46
+ };
47
+ return (_jsx(Chart, { type: "radar", width: config?.width ?? "100%", height: config?.height ?? 350, options: options, series: series }));
48
+ }
@@ -0,0 +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";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +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";
@@ -0,0 +1,9 @@
1
+ import type { ComponentType } from "react";
2
+ import type { ChartComponentProps } from "./types";
3
+ /** Register a custom chart component for a chart type */
4
+ export declare function registerChart(chartType: string, component: ComponentType<ChartComponentProps>): void;
5
+ /** Get the component for a chart type. Returns undefined if not registered. */
6
+ export declare function getChartComponent(chartType: string): ComponentType<ChartComponentProps> | undefined;
7
+ /** Reset registry to defaults (useful for testing) */
8
+ export declare function resetChartRegistry(): void;
9
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,25 @@
1
+ import LineChart from "./LineChart";
2
+ import BarChart from "./BarChart";
3
+ import PieChart from "./PieChart";
4
+ import RadarChart from "./RadarChart";
5
+ const defaultRegistry = {
6
+ line: LineChart,
7
+ bar: BarChart,
8
+ range_bar: BarChart,
9
+ pie: PieChart,
10
+ donut: PieChart,
11
+ radar: RadarChart,
12
+ };
13
+ let registry = { ...defaultRegistry };
14
+ /** Register a custom chart component for a chart type */
15
+ export function registerChart(chartType, component) {
16
+ registry[chartType] = component;
17
+ }
18
+ /** Get the component for a chart type. Returns undefined if not registered. */
19
+ export function getChartComponent(chartType) {
20
+ return registry[chartType];
21
+ }
22
+ /** Reset registry to defaults (useful for testing) */
23
+ export function resetChartRegistry() {
24
+ registry = { ...defaultRegistry };
25
+ }
@@ -0,0 +1,10 @@
1
+ import type { ChartType } from "@openvizai/shared-types";
2
+ import type { ChartEmbedding, ChartMeta, OpenVizConfig } from "../types";
3
+ export type ChartComponentProps = {
4
+ data: Record<string, unknown>[];
5
+ chartType: ChartType;
6
+ embedding: ChartEmbedding;
7
+ meta?: ChartMeta;
8
+ config?: OpenVizConfig;
9
+ };
10
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,33 @@
1
+ type LegendPosition = "top" | "bottom" | "left" | "right";
2
+ type BuildBaseOptionsParams = {
3
+ chartId: string;
4
+ title?: string;
5
+ subtitle?: string | null;
6
+ legendPosition?: LegendPosition;
7
+ dataLabelsEnabled?: boolean;
8
+ toolbarVisible?: boolean;
9
+ };
10
+ export declare function buildApexBaseOptions({ chartId, title, subtitle, legendPosition, dataLabelsEnabled, toolbarVisible, }: BuildBaseOptionsParams): {
11
+ chart: {
12
+ id: string;
13
+ toolbar: {
14
+ show: boolean;
15
+ };
16
+ };
17
+ title: {
18
+ text: string | undefined;
19
+ align: "left";
20
+ };
21
+ subtitle: {
22
+ text: string | undefined;
23
+ align: "left";
24
+ };
25
+ dataLabels: {
26
+ enabled: boolean;
27
+ };
28
+ legend: {
29
+ position: LegendPosition;
30
+ };
31
+ };
32
+ export {};
33
+ //# sourceMappingURL=apexBaseOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apexBaseOptions.d.ts","sourceRoot":"","sources":["../../src/embedding/apexBaseOptions.ts"],"names":[],"mappings":"AAAA,KAAK,cAAc,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAE1D,KAAK,sBAAsB,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAGF,wBAAgB,oBAAoB,CAAC,EACnC,OAAO,EACP,KAAK,EACL,QAAQ,EACR,cAAsB,EACtB,iBAAyB,EACzB,cAAqB,GACtB,EAAE,sBAAsB;;;;;;;;;;;;;;;;;;;;;EAuBxB"}
@@ -0,0 +1,25 @@
1
+ // Creates option blocks reused across chart types; components can extend/override chart-specific fields.
2
+ export function buildApexBaseOptions({ chartId, title, subtitle, legendPosition = "top", dataLabelsEnabled = false, toolbarVisible = true, }) {
3
+ return {
4
+ chart: {
5
+ id: chartId,
6
+ toolbar: {
7
+ show: toolbarVisible,
8
+ },
9
+ },
10
+ title: {
11
+ text: title,
12
+ align: "left",
13
+ },
14
+ subtitle: {
15
+ text: subtitle ?? undefined,
16
+ align: "left",
17
+ },
18
+ dataLabels: {
19
+ enabled: dataLabelsEnabled,
20
+ },
21
+ legend: {
22
+ position: legendPosition,
23
+ },
24
+ };
25
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Coerce a value to a finite number.
3
+ * Returns null for non-numeric/missing values so ApexCharts renders gaps
4
+ * instead of misleading zeros.
5
+ */
6
+ export declare function toFiniteNumber(value: unknown, fallback?: number | null): number | null;
7
+ export declare function toCategoryString(value: unknown): string;
8
+ export declare function toMilliseconds(value: unknown): number;
9
+ //# sourceMappingURL=chartData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chartData.d.ts","sourceRoot":"","sources":["../../src/embedding/chartData.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,EACd,QAAQ,GAAE,MAAM,GAAG,IAAW,GAC7B,MAAM,GAAG,IAAI,CAIf;AAGD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEvD;AAGD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAMrD"}
@@ -0,0 +1,25 @@
1
+ // Shared data coercion helpers used by chart components and series builders.
2
+ /**
3
+ * Coerce a value to a finite number.
4
+ * Returns null for non-numeric/missing values so ApexCharts renders gaps
5
+ * instead of misleading zeros.
6
+ */
7
+ export function toFiniteNumber(value, fallback = null) {
8
+ if (value === null || value === undefined || value === "")
9
+ return fallback;
10
+ const numeric = typeof value === "number" ? value : Number(value);
11
+ return Number.isFinite(numeric) ? numeric : fallback;
12
+ }
13
+ // Normalizes category labels so axis/legend text never receives null/undefined.
14
+ export function toCategoryString(value) {
15
+ return String(value ?? "");
16
+ }
17
+ // Converts number/date-like values into epoch milliseconds for datetime charts.
18
+ export function toMilliseconds(value) {
19
+ if (value === undefined || value === null)
20
+ return Number.NaN;
21
+ if (typeof value === "number")
22
+ return value;
23
+ const parsed = new Date(String(value)).getTime();
24
+ return Number.isFinite(parsed) ? parsed : Number.NaN;
25
+ }
@@ -0,0 +1,22 @@
1
+ type Row = Record<string, unknown>;
2
+ type YFieldLike = {
3
+ field: string;
4
+ label?: string | null;
5
+ };
6
+ export declare function buildCategorySeriesLabels(rows: Row[], xField: string): string[];
7
+ export declare function buildNumericSeries(rows: Row[], yFields: YFieldLike[]): {
8
+ name: string;
9
+ data: (number | null)[];
10
+ }[];
11
+ export declare function buildNumericDataByField(rows: Row[], yField: string): (number | null)[];
12
+ export declare function buildSingleValueSeries(rows: Row[], valueField: string): number[];
13
+ export declare function buildDatetimePoints(rows: Row[], xField: string, yField: string): Array<{
14
+ x: number;
15
+ y: number | null;
16
+ }>;
17
+ export declare function buildRangeBarPoints(rows: Row[], xField: string, startField: string, endField: string): Array<{
18
+ x: string;
19
+ y: [number, number];
20
+ }>;
21
+ export {};
22
+ //# sourceMappingURL=seriesBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seriesBuilder.d.ts","sourceRoot":"","sources":["../../src/embedding/seriesBuilder.ts"],"names":[],"mappings":"AAEA,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEnC,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAGF,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,GAAG,EAAE,EACX,MAAM,EAAE,MAAM,GACb,MAAM,EAAE,CAEV;AAID,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;;;IAKpE;AAGD,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,GAAG,EAAE,EACX,MAAM,EAAE,MAAM,GACb,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAEnB;AAID,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,GAAG,EAAE,EACX,UAAU,EAAE,MAAM,GACjB,MAAM,EAAE,CAEV;AAGD,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,GAAG,EAAE,EACX,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,KAAK,CAAC;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CAKxC;AAGD,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,GAAG,EAAE,EACX,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,KAAK,CAAC;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC,CAyB3C"}
@@ -0,0 +1,52 @@
1
+ import { toCategoryString, toFiniteNumber, toMilliseconds } from "./chartData";
2
+ // Builds x-axis categories for category-based charts (bar/line/category modes).
3
+ export function buildCategorySeriesLabels(rows, xField) {
4
+ return rows.map((row) => toCategoryString(row[xField]));
5
+ }
6
+ // Builds numeric series used by bar-like and category-line charts.
7
+ // Returns null for missing values so ApexCharts can render gaps.
8
+ export function buildNumericSeries(rows, yFields) {
9
+ return yFields.map((yField) => ({
10
+ name: yField.label || yField.field,
11
+ data: rows.map((row) => toFiniteNumber(row[yField.field])),
12
+ }));
13
+ }
14
+ // Builds numeric data for one field; null = gap in the chart.
15
+ export function buildNumericDataByField(rows, yField) {
16
+ return rows.map((row) => toFiniteNumber(row[yField]));
17
+ }
18
+ // Builds pie/donut numeric values from a single field.
19
+ // Pie charts cannot handle null, so fallback to 0.
20
+ export function buildSingleValueSeries(rows, valueField) {
21
+ return rows.map((row) => toFiniteNumber(row[valueField], 0) ?? 0);
22
+ }
23
+ // Builds datetime points for ApexCharts time-series format: { x: timestamp, y: number | null }.
24
+ export function buildDatetimePoints(rows, xField, yField) {
25
+ return rows.map((row) => ({
26
+ x: toMilliseconds(row[xField]),
27
+ y: toFiniteNumber(row[yField]),
28
+ }));
29
+ }
30
+ // Builds range-bar points for ApexCharts format: { x: category, y: [number, number] }.
31
+ export function buildRangeBarPoints(rows, xField, startField, endField) {
32
+ const toRangeValue = (value) => {
33
+ const numeric = toFiniteNumber(value);
34
+ if (numeric !== null)
35
+ return numeric;
36
+ return toMilliseconds(value);
37
+ };
38
+ return rows
39
+ .map((row) => {
40
+ const start = toRangeValue(row[startField]);
41
+ const end = toRangeValue(row[endField]);
42
+ const low = Math.min(start, end);
43
+ const high = Math.max(start, end);
44
+ return {
45
+ x: toCategoryString(row[xField]),
46
+ y: [low, high],
47
+ };
48
+ })
49
+ .filter((point) => Number.isFinite(point.y[0]) &&
50
+ Number.isFinite(point.y[1]) &&
51
+ point.x.length > 0);
52
+ }
@@ -0,0 +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";
7
+ export { SUPPORTED_CHART_TYPES } from "@openvizai/shared-types";
8
+ export type { ChartType } from "@openvizai/shared-types";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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"}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ // Main component
2
+ export { default as OpenVizRenderer } from "./OpenVizRenderer";
3
+ // Dashboard component
4
+ export { default as OpenVizDashboard } from "./OpenVizDashboard";
5
+ // Chart registry (for plugin system)
6
+ export { registerChart, getChartComponent, resetChartRegistry, } from "./charts/registry";
7
+ // Individual chart components (for advanced usage)
8
+ export { LineChart, BarChart, PieChart, RadarChart } from "./charts";
9
+ // Re-export chart type constants
10
+ export { SUPPORTED_CHART_TYPES } from "@openvizai/shared-types";
@@ -0,0 +1,22 @@
1
+ import type { ChartType } from "@openvizai/shared-types";
2
+ import type { ChartEmbedding, ChartMeta, OpenVizConfig } from "./renderer";
3
+ /** A single chart item for the dashboard */
4
+ export type DashboardChartItem = {
5
+ chart_type: ChartType;
6
+ embedding: ChartEmbedding;
7
+ meta: ChartMeta;
8
+ };
9
+ /** Props for the <OpenVizDashboard /> component */
10
+ export type OpenVizDashboardProps = {
11
+ /** The dataset rows — shared across all charts */
12
+ data: Record<string, unknown>[];
13
+ /** Array of chart configurations returned by analyzeDashboard */
14
+ charts: DashboardChartItem[];
15
+ /** Optional rendering config applied to all charts */
16
+ config?: OpenVizConfig;
17
+ /** Number of columns in the grid (default: 2) */
18
+ columns?: number;
19
+ /** Optional CSS class name for the wrapper */
20
+ className?: string;
21
+ };
22
+ //# sourceMappingURL=dashboard.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export type { EmbeddingField, ChartEmbedding, ChartMeta, OpenVizConfig, OpenVizRendererProps, } from "./renderer";
2
+ export type { DashboardChartItem, OpenVizDashboardProps, } from "./dashboard";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,62 @@
1
+ import type { ChartType } from "@openvizai/shared-types";
2
+ /** Field mapping from embedding metadata */
3
+ export type EmbeddingField = {
4
+ field: string;
5
+ label: string;
6
+ unit?: string | null;
7
+ type?: string | null;
8
+ };
9
+ /** Full embedding metadata describing how to visualize the data */
10
+ export type ChartEmbedding = {
11
+ x?: EmbeddingField[] | null;
12
+ y?: EmbeddingField[] | null;
13
+ group?: EmbeddingField[] | null;
14
+ category?: EmbeddingField[] | null;
15
+ value?: EmbeddingField[] | null;
16
+ source?: EmbeddingField[] | null;
17
+ target?: EmbeddingField[] | null;
18
+ start?: EmbeddingField | EmbeddingField[] | null;
19
+ end?: EmbeddingField | EmbeddingField[] | null;
20
+ series?: EmbeddingField[] | null;
21
+ path?: EmbeddingField[] | null;
22
+ is_stacked?: boolean;
23
+ is_horizontal?: boolean;
24
+ is_range?: boolean;
25
+ is_donut?: boolean;
26
+ isSemanticColors?: boolean;
27
+ colorSemantic?: string | null;
28
+ line_curve?: "smooth" | "straight" | "stepline";
29
+ markers_size?: number;
30
+ forecast_points?: number;
31
+ };
32
+ /** Chart metadata from the LLM response */
33
+ export type ChartMeta = {
34
+ title: string;
35
+ subtitle?: string | null;
36
+ query_explanation?: string | null;
37
+ };
38
+ /** Optional rendering configuration */
39
+ export type OpenVizConfig = {
40
+ height?: number;
41
+ width?: string | number;
42
+ legendPosition?: "top" | "bottom" | "left" | "right";
43
+ dataLabelsEnabled?: boolean;
44
+ toolbarVisible?: boolean;
45
+ animations?: boolean;
46
+ };
47
+ /** Props for the main <OpenVizRenderer /> component */
48
+ export type OpenVizRendererProps = {
49
+ /** The dataset rows to visualize */
50
+ data: Record<string, unknown>[];
51
+ /** Chart type to render */
52
+ chartType: ChartType;
53
+ /** Embedding metadata describing field mappings */
54
+ embedding: ChartEmbedding;
55
+ /** Optional chart metadata (title, subtitle) */
56
+ meta?: ChartMeta;
57
+ /** Optional rendering config overrides */
58
+ config?: OpenVizConfig;
59
+ /** Optional CSS class name for the wrapper */
60
+ className?: string;
61
+ };
62
+ //# sourceMappingURL=renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/types/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,4CAA4C;AAC5C,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAEF,mEAAmE;AACnE,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IAC5B,CAAC,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IAChC,MAAM,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IACjC,MAAM,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IACjC,KAAK,CAAC,EAAE,cAAc,GAAG,cAAc,EAAE,GAAG,IAAI,CAAC;IACjD,GAAG,CAAC,EAAE,cAAc,GAAG,cAAc,EAAE,GAAG,IAAI,CAAC;IAC/C,MAAM,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IACjC,IAAI,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,UAAU,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,2CAA2C;AAC3C,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC,CAAC;AAEF,uCAAuC;AACvC,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IACrD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,uDAAuD;AACvD,MAAM,MAAM,oBAAoB,GAAG;IACjC,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAChC,2BAA2B;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,mDAAmD;IACnD,SAAS,EAAE,cAAc,CAAC;IAC1B,gDAAgD;IAChD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@openvizai/react",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "README.md",
10
+ "package.json"
11
+ ],
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ }
20
+ },
21
+ "scripts": {
22
+ "build": "tsc -p tsconfig.build.json",
23
+ "prepublishOnly": "npm run build"
24
+ },
25
+ "dependencies": {
26
+ "@openvizai/shared-types": "^0.1.0"
27
+ },
28
+ "peerDependencies": {
29
+ "react": ">=18.0.0",
30
+ "react-dom": ">=18.0.0",
31
+ "apexcharts": ">=5.0.0",
32
+ "react-apexcharts": ">=2.0.0"
33
+ },
34
+ "devDependencies": {
35
+ "typescript": "^5.9.3",
36
+ "@types/react": "^19.2.7",
37
+ "@types/react-dom": "^19.2.3",
38
+ "react": "^19.2.0",
39
+ "react-dom": "^19.2.0",
40
+ "apexcharts": "^5.6.0",
41
+ "react-apexcharts": "^2.0.1"
42
+ }
43
+ }