@opendata-ai/openchart-react 9.0.0-rc.2 → 9.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.
- package/dist/index.d.ts +26 -8
- package/dist/index.js +142 -39
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { BarListSpec, ThemeConfig, DarkMode, DataRow, ChartEventHandlers, ChartSpec, LayerSpec, ElementRef, GeoMapSpec, TableSpec, SortState, GeoReaderSelection, ReaderChangeMeta, GraphSpec, ChartLayout, SankeySpec, TileMapSpec, VizSpec } from '@opendata-ai/openchart-core';
|
|
1
|
+
import { BarListSpec, ThemeConfig, DarkMode, DataRow, ChartEventHandlers, ChartSpec, LayerSpec, ElementRef, GeoMapSpec, TableSpec, SortState, GeoReaderSelection, ReaderChangeMeta, GraphSpec, ChartLayout, RaceSpec, RaceFrame, SankeySpec, TileMapSpec, VizSpec } from '@opendata-ai/openchart-core';
|
|
2
2
|
export * from '@opendata-ai/openchart-core';
|
|
3
|
-
import { BarListInstance, InteractionMode, ChartReaderProps, ChartInstance, MountOptions, GeoReaderOptions, GeoMapMountOptions, GeoMapMarkEvent, Camera, GeoMapCameraChangeMeta, GeoMapInstance, CameraFlightOptions, GraphFlyTarget, GraphCamera, GraphHighlightTarget, GraphLegendData, GraphInstance, GraphTooltipFormatter, TableInstance, TableState, TableMountOptions, SankeyInstance, TileMapInstance } from '@opendata-ai/openchart-vanilla';
|
|
3
|
+
import { BarListInstance, InteractionMode, ChartReaderProps, ChartInstance, MountOptions, GeoReaderOptions, GeoMapMountOptions, GeoMapMarkEvent, Camera, GeoMapCameraChangeMeta, GeoMapInstance, CameraFlightOptions, GraphFlyTarget, GraphCamera, GraphHighlightTarget, GraphLegendData, GraphInstance, GraphTooltipFormatter, TableInstance, TableState, TableMountOptions, RaceMountOptions, RaceInstance, SankeyInstance, TileMapInstance } from '@opendata-ai/openchart-vanilla';
|
|
4
4
|
export { GeoMapCameraChangeMeta, InteractionMode, JPGExportOptions, PNGExportOptions, SVGExportOptions, SpecSequenceOptions, exportCSV, exportJPG, exportPNG, exportSVG, exportSVGWithFonts, exportSpecSequence } from '@opendata-ai/openchart-vanilla';
|
|
5
5
|
export { ChartRenderer, CompileResult, CompiledGraphEdge, CompiledGraphNode, GraphCompilation, NormalizedBarListSpec, NormalizedChartSpec, NormalizedChrome, NormalizedGeoMapSpec, NormalizedGraphSpec, NormalizedSankeySpec, NormalizedSpec, NormalizedTableSpec, NormalizedTileMapSpec, SimulationConfig, ValidationError, ValidationErrorCode, ValidationResult, clearRenderers, compile, compileBarList, compileChart, compileGeoMap, compileGraph, compileSankey, compileTable, compileTileMap, getChartRenderer, normalizeSpec, registerChartRenderer, validateSpec } from '@opendata-ai/openchart-engine';
|
|
6
6
|
import * as react from 'react';
|
|
7
7
|
import { CSSProperties, ReactNode, Ref } from 'react';
|
|
8
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
9
8
|
import { ChartStoryOptions, ChartStoryInstance } from '@opendata-ai/openchart-vanilla/story';
|
|
10
9
|
|
|
11
10
|
interface BarListProps {
|
|
@@ -145,7 +144,7 @@ interface ChartStoryProps<TData extends DataRow = DataRow> {
|
|
|
145
144
|
style?: CSSProperties;
|
|
146
145
|
ref?: Ref<ChartStoryHandle>;
|
|
147
146
|
}
|
|
148
|
-
declare function ChartStory<TData extends DataRow = DataRow>({ spec, steps, narrative, step, triggerPosition, cameraMode, mountOptions, className, style, ref, }: ChartStoryProps<TData>):
|
|
147
|
+
declare function ChartStory<TData extends DataRow = DataRow>({ spec, steps, narrative, step, triggerPosition, cameraMode, mountOptions, className, style, ref, }: ChartStoryProps<TData>): react.JSX.Element;
|
|
149
148
|
|
|
150
149
|
interface DataTableProps {
|
|
151
150
|
/** The table spec to render. */
|
|
@@ -179,7 +178,7 @@ interface DataTableProps {
|
|
|
179
178
|
* Uses the vanilla adapter internally. Supports controlled and uncontrolled
|
|
180
179
|
* modes for sort, search, and pagination state.
|
|
181
180
|
*/
|
|
182
|
-
declare function DataTable({ spec, theme: themeProp, darkMode, onRowClick, onSortChange, onSearchChange, onPageChange, className, style, sort, search, page, }: DataTableProps):
|
|
181
|
+
declare function DataTable({ spec, theme: themeProp, darkMode, onRowClick, onSortChange, onSearchChange, onPageChange, className, style, sort, search, page, }: DataTableProps): react.JSX.Element;
|
|
183
182
|
|
|
184
183
|
interface GeoMapProps {
|
|
185
184
|
reader?: false | GeoReaderOptions;
|
|
@@ -495,6 +494,25 @@ interface UseTableStateOptions {
|
|
|
495
494
|
*/
|
|
496
495
|
declare function useTableState(initialState?: UseTableStateOptions): UseTableStateReturn;
|
|
497
496
|
|
|
497
|
+
/** Options and callbacks for a mounted race chart. */
|
|
498
|
+
interface RaceProps {
|
|
499
|
+
spec: RaceSpec;
|
|
500
|
+
theme?: ThemeConfig;
|
|
501
|
+
darkMode?: DarkMode;
|
|
502
|
+
className?: string;
|
|
503
|
+
style?: CSSProperties;
|
|
504
|
+
autoResize?: boolean;
|
|
505
|
+
watermark?: boolean;
|
|
506
|
+
onWarn?: RaceMountOptions['onWarn'];
|
|
507
|
+
onPeriod?: (period: RaceFrame['period']) => void;
|
|
508
|
+
}
|
|
509
|
+
/** Ref handle for imperative race playback. */
|
|
510
|
+
interface RaceHandle {
|
|
511
|
+
readonly instance: RaceInstance | null;
|
|
512
|
+
}
|
|
513
|
+
/** Render an interactive race chart. */
|
|
514
|
+
declare const Race: react.ForwardRefExoticComponent<RaceProps & react.RefAttributes<RaceHandle>>;
|
|
515
|
+
|
|
498
516
|
interface SankeyProps {
|
|
499
517
|
/** The sankey spec to render. */
|
|
500
518
|
spec: SankeySpec;
|
|
@@ -540,7 +558,7 @@ interface VizThemeProviderProps {
|
|
|
540
558
|
children: ReactNode;
|
|
541
559
|
}
|
|
542
560
|
/** Provides a theme and dark mode preference to all nested Chart, DataTable, and Graph components. */
|
|
543
|
-
declare function VizThemeProvider({ theme, darkMode, children }: VizThemeProviderProps):
|
|
561
|
+
declare function VizThemeProvider({ theme, darkMode, children }: VizThemeProviderProps): react.JSX.Element;
|
|
544
562
|
|
|
545
563
|
interface TileMapProps {
|
|
546
564
|
/** The tilemap spec to render. */
|
|
@@ -599,6 +617,6 @@ interface VisualizationProps {
|
|
|
599
617
|
* Accepts any VizSpec and renders it with the correct component based on the
|
|
600
618
|
* spec's type field. For event handlers, use Chart, DataTable, or Graph directly.
|
|
601
619
|
*/
|
|
602
|
-
declare function Visualization({ spec, theme, darkMode, className, style }: VisualizationProps):
|
|
620
|
+
declare function Visualization({ spec, theme, darkMode, className, style }: VisualizationProps): react.JSX.Element;
|
|
603
621
|
|
|
604
|
-
export { BarList, type BarListHandle, type BarListProps, Chart, type ChartHandle, type ChartProps, ChartStory, type ChartStoryHandle, type ChartStoryProps, DataTable, type DataTableProps, GeoMap, type GeoMapHandle, type GeoMapProps, Graph, type GraphHandle, type GraphProps, type ObservationChartProps, Sankey, type SankeyHandle, type SankeyProps, type SliceChartProps, TileMap, type TileMapHandle, type TileMapProps, type UseChartOptions, type UseChartReturn, type UseGraphReturn, type UseTableReturn, type UseTableStateOptions, type UseTableStateReturn, Visualization, type VisualizationProps, VizThemeProvider, type VizThemeProviderProps, useChart, useDarkMode, useGraph, useTable, useTableState, useVizDarkMode, useVizTheme };
|
|
622
|
+
export { BarList, type BarListHandle, type BarListProps, Chart, type ChartHandle, type ChartProps, ChartStory, type ChartStoryHandle, type ChartStoryProps, DataTable, type DataTableProps, GeoMap, type GeoMapHandle, type GeoMapProps, Graph, type GraphHandle, type GraphProps, type ObservationChartProps, Race, type RaceHandle, type RaceProps, Sankey, type SankeyHandle, type SankeyProps, type SliceChartProps, TileMap, type TileMapHandle, type TileMapProps, type UseChartOptions, type UseChartReturn, type UseGraphReturn, type UseTableReturn, type UseTableStateOptions, type UseTableStateReturn, Visualization, type VisualizationProps, VizThemeProvider, type VizThemeProviderProps, useChart, useDarkMode, useGraph, useTable, useTableState, useVizDarkMode, useVizTheme };
|
package/dist/index.js
CHANGED
|
@@ -146,6 +146,7 @@ function ChartInner({
|
|
|
146
146
|
onEdit,
|
|
147
147
|
onMarkClick,
|
|
148
148
|
onMarkHover,
|
|
149
|
+
onMarkFocus,
|
|
149
150
|
onMarkLeave,
|
|
150
151
|
onLegendToggle,
|
|
151
152
|
onHighlightChange,
|
|
@@ -192,6 +193,7 @@ function ChartInner({
|
|
|
192
193
|
onEdit,
|
|
193
194
|
onMarkClick,
|
|
194
195
|
onMarkHover,
|
|
196
|
+
onMarkFocus,
|
|
195
197
|
onMarkLeave,
|
|
196
198
|
onLegendToggle,
|
|
197
199
|
onHighlightChange,
|
|
@@ -208,6 +210,10 @@ function ChartInner({
|
|
|
208
210
|
(event) => handlersRef.current.onMarkHover?.(event),
|
|
209
211
|
[]
|
|
210
212
|
);
|
|
213
|
+
const stableOnMarkFocus = useCallback2(
|
|
214
|
+
(event) => handlersRef.current.onMarkFocus?.(event),
|
|
215
|
+
[]
|
|
216
|
+
);
|
|
211
217
|
const stableOnMarkLeave = useCallback2(() => handlersRef.current.onMarkLeave?.(), []);
|
|
212
218
|
const stableOnLegendToggle = useCallback2(
|
|
213
219
|
(series, visible) => handlersRef.current.onLegendToggle?.(series, visible),
|
|
@@ -264,6 +270,7 @@ function ChartInner({
|
|
|
264
270
|
renderer,
|
|
265
271
|
onMarkClick: stableOnMarkClick,
|
|
266
272
|
onMarkHover: stableOnMarkHover,
|
|
273
|
+
onMarkFocus: stableOnMarkFocus,
|
|
267
274
|
onMarkLeave: stableOnMarkLeave,
|
|
268
275
|
onLegendToggle: stableOnLegendToggle,
|
|
269
276
|
onHighlightChange: stableOnHighlightChange,
|
|
@@ -305,6 +312,7 @@ function ChartInner({
|
|
|
305
312
|
stableOnHighlightChange,
|
|
306
313
|
stableOnMarkClick,
|
|
307
314
|
stableOnMarkHover,
|
|
315
|
+
stableOnMarkFocus,
|
|
308
316
|
stableOnMarkLeave,
|
|
309
317
|
stableOnSelect,
|
|
310
318
|
stableOnDeselect,
|
|
@@ -736,6 +744,7 @@ var Graph = forwardRef4(function Graph2({
|
|
|
736
744
|
const graphRef = useRef6(null);
|
|
737
745
|
const specRef = useRef6("");
|
|
738
746
|
const prevMountDepsRef = useRef6(null);
|
|
747
|
+
const prevEntrancePlayedRef = useRef6(false);
|
|
739
748
|
const handlersRef = useRef6({});
|
|
740
749
|
handlersRef.current = {
|
|
741
750
|
onNodeClick,
|
|
@@ -858,7 +867,7 @@ var Graph = forwardRef4(function Graph2({
|
|
|
858
867
|
const tooltipOption = tooltipOn ? { formatter: stableTooltipFormatter } : false;
|
|
859
868
|
const mountDeps = [theme, resolvedDarkMode, tooltipOn, legendKey, fitOnLoad];
|
|
860
869
|
const prevDeps = prevMountDepsRef.current;
|
|
861
|
-
const suppressEntrance = prevDeps !== null && mountDeps.some((d, i) => !Object.is(d, prevDeps[i]));
|
|
870
|
+
const suppressEntrance = prevDeps !== null && prevEntrancePlayedRef.current && mountDeps.some((d, i) => !Object.is(d, prevDeps[i]));
|
|
862
871
|
const options = {
|
|
863
872
|
theme,
|
|
864
873
|
darkMode: resolvedDarkMode,
|
|
@@ -883,6 +892,7 @@ var Graph = forwardRef4(function Graph2({
|
|
|
883
892
|
specRef.current = JSON.stringify(spec);
|
|
884
893
|
prevMountDepsRef.current = mountDeps;
|
|
885
894
|
return () => {
|
|
895
|
+
prevEntrancePlayedRef.current = graphRef.current?.entrancePlayed ?? false;
|
|
886
896
|
graphRef.current?.destroy();
|
|
887
897
|
graphRef.current = null;
|
|
888
898
|
};
|
|
@@ -1160,21 +1170,109 @@ function useTableState(initialState) {
|
|
|
1160
1170
|
};
|
|
1161
1171
|
}
|
|
1162
1172
|
|
|
1163
|
-
// src/
|
|
1173
|
+
// src/Race.tsx
|
|
1164
1174
|
import { mergeThemeConfig as mergeThemeConfig6 } from "@opendata-ai/openchart-core";
|
|
1165
1175
|
import {
|
|
1166
|
-
|
|
1176
|
+
createRace
|
|
1167
1177
|
} from "@opendata-ai/openchart-vanilla";
|
|
1168
1178
|
import {
|
|
1169
1179
|
forwardRef as forwardRef5,
|
|
1170
|
-
useCallback as useCallback9,
|
|
1171
1180
|
useEffect as useEffect9,
|
|
1172
1181
|
useImperativeHandle as useImperativeHandle6,
|
|
1173
1182
|
useMemo as useMemo6,
|
|
1174
1183
|
useRef as useRef10
|
|
1175
1184
|
} from "react";
|
|
1176
1185
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1177
|
-
var
|
|
1186
|
+
var Race = forwardRef5(function Race2({ spec, theme, darkMode, className, style, autoResize, watermark, onWarn, onPeriod }, ref) {
|
|
1187
|
+
const contextTheme = useVizTheme();
|
|
1188
|
+
const contextDarkMode = useVizDarkMode();
|
|
1189
|
+
const resolvedDarkMode = darkMode ?? contextDarkMode;
|
|
1190
|
+
const containerRef = useRef10(null);
|
|
1191
|
+
const mounted = useRef10(null);
|
|
1192
|
+
const warnRef = useRef10(onWarn);
|
|
1193
|
+
useEffect9(() => {
|
|
1194
|
+
warnRef.current = onWarn;
|
|
1195
|
+
}, [onWarn]);
|
|
1196
|
+
const options = useMemo6(
|
|
1197
|
+
() => ({
|
|
1198
|
+
theme: mergeThemeConfig6(contextTheme, theme),
|
|
1199
|
+
darkMode: resolvedDarkMode,
|
|
1200
|
+
autoResize,
|
|
1201
|
+
watermark,
|
|
1202
|
+
onWarn: (message) => (warnRef.current ?? console.warn)(message)
|
|
1203
|
+
}),
|
|
1204
|
+
[contextTheme, theme, resolvedDarkMode, autoResize, watermark]
|
|
1205
|
+
);
|
|
1206
|
+
const optionsKey = JSON.stringify({ autoResize, watermark });
|
|
1207
|
+
const themeKey = JSON.stringify({ theme: options.theme, darkMode: options.darkMode });
|
|
1208
|
+
useImperativeHandle6(
|
|
1209
|
+
ref,
|
|
1210
|
+
() => ({
|
|
1211
|
+
get instance() {
|
|
1212
|
+
return mounted.current?.instance ?? null;
|
|
1213
|
+
}
|
|
1214
|
+
}),
|
|
1215
|
+
[]
|
|
1216
|
+
);
|
|
1217
|
+
useEffect9(() => {
|
|
1218
|
+
const container = containerRef.current;
|
|
1219
|
+
if (!container) return;
|
|
1220
|
+
const current = mounted.current;
|
|
1221
|
+
const specKey = JSON.stringify(spec);
|
|
1222
|
+
if (current?.optionsKey === optionsKey) {
|
|
1223
|
+
if (specKey !== current.specKey) {
|
|
1224
|
+
current.instance.update(spec);
|
|
1225
|
+
current.specKey = specKey;
|
|
1226
|
+
}
|
|
1227
|
+
if (themeKey !== current.themeKey) {
|
|
1228
|
+
current.instance.setTheme(options);
|
|
1229
|
+
current.themeKey = themeKey;
|
|
1230
|
+
}
|
|
1231
|
+
return;
|
|
1232
|
+
}
|
|
1233
|
+
const state = current?.instance.getState();
|
|
1234
|
+
const instance = createRace(container, spec, { ...options, initialState: state });
|
|
1235
|
+
current?.instance.destroy();
|
|
1236
|
+
if (state) instance.resize();
|
|
1237
|
+
mounted.current = { instance, optionsKey, themeKey, specKey };
|
|
1238
|
+
}, [spec, options, optionsKey, themeKey]);
|
|
1239
|
+
useEffect9(() => {
|
|
1240
|
+
const current = mounted.current;
|
|
1241
|
+
if (current?.optionsKey === optionsKey && onPeriod)
|
|
1242
|
+
return current.instance.on("period", onPeriod);
|
|
1243
|
+
}, [optionsKey, onPeriod]);
|
|
1244
|
+
useEffect9(
|
|
1245
|
+
() => () => {
|
|
1246
|
+
mounted.current?.instance.destroy();
|
|
1247
|
+
mounted.current = null;
|
|
1248
|
+
},
|
|
1249
|
+
[]
|
|
1250
|
+
);
|
|
1251
|
+
return /* @__PURE__ */ jsx8(
|
|
1252
|
+
"div",
|
|
1253
|
+
{
|
|
1254
|
+
ref: containerRef,
|
|
1255
|
+
className: className ? `oc-root ${className}` : "oc-root",
|
|
1256
|
+
style
|
|
1257
|
+
}
|
|
1258
|
+
);
|
|
1259
|
+
});
|
|
1260
|
+
|
|
1261
|
+
// src/Sankey.tsx
|
|
1262
|
+
import { mergeThemeConfig as mergeThemeConfig7 } from "@opendata-ai/openchart-core";
|
|
1263
|
+
import {
|
|
1264
|
+
createSankey
|
|
1265
|
+
} from "@opendata-ai/openchart-vanilla";
|
|
1266
|
+
import {
|
|
1267
|
+
forwardRef as forwardRef6,
|
|
1268
|
+
useCallback as useCallback9,
|
|
1269
|
+
useEffect as useEffect10,
|
|
1270
|
+
useImperativeHandle as useImperativeHandle7,
|
|
1271
|
+
useMemo as useMemo7,
|
|
1272
|
+
useRef as useRef11
|
|
1273
|
+
} from "react";
|
|
1274
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
1275
|
+
var Sankey = forwardRef6(function Sankey2({
|
|
1178
1276
|
spec,
|
|
1179
1277
|
theme: themeProp,
|
|
1180
1278
|
darkMode,
|
|
@@ -1187,12 +1285,12 @@ var Sankey = forwardRef5(function Sankey2({
|
|
|
1187
1285
|
}, ref) {
|
|
1188
1286
|
const contextTheme = useVizTheme();
|
|
1189
1287
|
const contextDarkMode = useVizDarkMode();
|
|
1190
|
-
const theme =
|
|
1288
|
+
const theme = useMemo7(() => mergeThemeConfig7(contextTheme, themeProp), [contextTheme, themeProp]);
|
|
1191
1289
|
const resolvedDarkMode = darkMode ?? contextDarkMode;
|
|
1192
|
-
const containerRef =
|
|
1193
|
-
const instanceRef =
|
|
1194
|
-
const specRef =
|
|
1195
|
-
const handlersRef =
|
|
1290
|
+
const containerRef = useRef11(null);
|
|
1291
|
+
const instanceRef = useRef11(null);
|
|
1292
|
+
const specRef = useRef11("");
|
|
1293
|
+
const handlersRef = useRef11({});
|
|
1196
1294
|
handlersRef.current = {
|
|
1197
1295
|
onNodeClick,
|
|
1198
1296
|
onLinkClick,
|
|
@@ -1215,7 +1313,7 @@ var Sankey = forwardRef5(function Sankey2({
|
|
|
1215
1313
|
(link) => handlersRef.current.onLinkHover?.(link),
|
|
1216
1314
|
[]
|
|
1217
1315
|
);
|
|
1218
|
-
|
|
1316
|
+
useImperativeHandle7(
|
|
1219
1317
|
ref,
|
|
1220
1318
|
() => ({
|
|
1221
1319
|
get instance() {
|
|
@@ -1224,7 +1322,7 @@ var Sankey = forwardRef5(function Sankey2({
|
|
|
1224
1322
|
}),
|
|
1225
1323
|
[]
|
|
1226
1324
|
);
|
|
1227
|
-
|
|
1325
|
+
useEffect10(() => {
|
|
1228
1326
|
const container = containerRef.current;
|
|
1229
1327
|
if (!container) return;
|
|
1230
1328
|
const options = {
|
|
@@ -1250,7 +1348,7 @@ var Sankey = forwardRef5(function Sankey2({
|
|
|
1250
1348
|
stableOnNodeHover,
|
|
1251
1349
|
stableOnLinkHover
|
|
1252
1350
|
]);
|
|
1253
|
-
|
|
1351
|
+
useEffect10(() => {
|
|
1254
1352
|
const instance = instanceRef.current;
|
|
1255
1353
|
if (!instance) return;
|
|
1256
1354
|
const specString = JSON.stringify(spec);
|
|
@@ -1258,7 +1356,7 @@ var Sankey = forwardRef5(function Sankey2({
|
|
|
1258
1356
|
specRef.current = specString;
|
|
1259
1357
|
instance.update(spec);
|
|
1260
1358
|
}, [spec]);
|
|
1261
|
-
return /* @__PURE__ */
|
|
1359
|
+
return /* @__PURE__ */ jsx9(
|
|
1262
1360
|
"div",
|
|
1263
1361
|
{
|
|
1264
1362
|
ref: containerRef,
|
|
@@ -1269,28 +1367,28 @@ var Sankey = forwardRef5(function Sankey2({
|
|
|
1269
1367
|
});
|
|
1270
1368
|
|
|
1271
1369
|
// src/TileMap.tsx
|
|
1272
|
-
import { mergeThemeConfig as
|
|
1370
|
+
import { mergeThemeConfig as mergeThemeConfig8 } from "@opendata-ai/openchart-core";
|
|
1273
1371
|
import {
|
|
1274
1372
|
createTileMap
|
|
1275
1373
|
} from "@opendata-ai/openchart-vanilla";
|
|
1276
1374
|
import {
|
|
1277
|
-
forwardRef as
|
|
1375
|
+
forwardRef as forwardRef7,
|
|
1278
1376
|
useCallback as useCallback10,
|
|
1279
|
-
useEffect as
|
|
1280
|
-
useImperativeHandle as
|
|
1281
|
-
useMemo as
|
|
1282
|
-
useRef as
|
|
1377
|
+
useEffect as useEffect11,
|
|
1378
|
+
useImperativeHandle as useImperativeHandle8,
|
|
1379
|
+
useMemo as useMemo8,
|
|
1380
|
+
useRef as useRef12
|
|
1283
1381
|
} from "react";
|
|
1284
|
-
import { jsx as
|
|
1285
|
-
var TileMap =
|
|
1382
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1383
|
+
var TileMap = forwardRef7(function TileMap2({ spec, theme: themeProp, darkMode, onTileClick, onTileHover, className, style }, ref) {
|
|
1286
1384
|
const contextTheme = useVizTheme();
|
|
1287
1385
|
const contextDarkMode = useVizDarkMode();
|
|
1288
|
-
const theme =
|
|
1386
|
+
const theme = useMemo8(() => mergeThemeConfig8(contextTheme, themeProp), [contextTheme, themeProp]);
|
|
1289
1387
|
const resolvedDarkMode = darkMode ?? contextDarkMode;
|
|
1290
|
-
const containerRef =
|
|
1291
|
-
const instanceRef =
|
|
1292
|
-
const specRef =
|
|
1293
|
-
const handlersRef =
|
|
1388
|
+
const containerRef = useRef12(null);
|
|
1389
|
+
const instanceRef = useRef12(null);
|
|
1390
|
+
const specRef = useRef12("");
|
|
1391
|
+
const handlersRef = useRef12({});
|
|
1294
1392
|
handlersRef.current = {
|
|
1295
1393
|
onTileClick,
|
|
1296
1394
|
onTileHover
|
|
@@ -1303,7 +1401,7 @@ var TileMap = forwardRef6(function TileMap2({ spec, theme: themeProp, darkMode,
|
|
|
1303
1401
|
(tile) => handlersRef.current.onTileHover?.(tile),
|
|
1304
1402
|
[]
|
|
1305
1403
|
);
|
|
1306
|
-
|
|
1404
|
+
useImperativeHandle8(
|
|
1307
1405
|
ref,
|
|
1308
1406
|
() => ({
|
|
1309
1407
|
get instance() {
|
|
@@ -1312,7 +1410,7 @@ var TileMap = forwardRef6(function TileMap2({ spec, theme: themeProp, darkMode,
|
|
|
1312
1410
|
}),
|
|
1313
1411
|
[]
|
|
1314
1412
|
);
|
|
1315
|
-
|
|
1413
|
+
useEffect11(() => {
|
|
1316
1414
|
const container = containerRef.current;
|
|
1317
1415
|
if (!container) return;
|
|
1318
1416
|
const options = {
|
|
@@ -1329,7 +1427,7 @@ var TileMap = forwardRef6(function TileMap2({ spec, theme: themeProp, darkMode,
|
|
|
1329
1427
|
instanceRef.current = null;
|
|
1330
1428
|
};
|
|
1331
1429
|
}, [theme, resolvedDarkMode, stableOnTileClick, stableOnTileHover]);
|
|
1332
|
-
|
|
1430
|
+
useEffect11(() => {
|
|
1333
1431
|
const instance = instanceRef.current;
|
|
1334
1432
|
if (!instance) return;
|
|
1335
1433
|
const specString = JSON.stringify(spec);
|
|
@@ -1337,7 +1435,7 @@ var TileMap = forwardRef6(function TileMap2({ spec, theme: themeProp, darkMode,
|
|
|
1337
1435
|
specRef.current = specString;
|
|
1338
1436
|
instance.update(spec);
|
|
1339
1437
|
}, [spec]);
|
|
1340
|
-
return /* @__PURE__ */
|
|
1438
|
+
return /* @__PURE__ */ jsx10(
|
|
1341
1439
|
"div",
|
|
1342
1440
|
{
|
|
1343
1441
|
ref: containerRef,
|
|
@@ -1352,14 +1450,15 @@ import {
|
|
|
1352
1450
|
isBarListSpec,
|
|
1353
1451
|
isGeoMapSpec,
|
|
1354
1452
|
isGraphSpec,
|
|
1453
|
+
isRaceSpec,
|
|
1355
1454
|
isSankeySpec,
|
|
1356
1455
|
isTableSpec,
|
|
1357
1456
|
isTileMapSpec
|
|
1358
1457
|
} from "@opendata-ai/openchart-core";
|
|
1359
|
-
import { jsx as
|
|
1458
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
1360
1459
|
function Visualization({ spec, theme, darkMode, className, style }) {
|
|
1361
1460
|
if (isTableSpec(spec)) {
|
|
1362
|
-
return /* @__PURE__ */
|
|
1461
|
+
return /* @__PURE__ */ jsx11(
|
|
1363
1462
|
DataTable,
|
|
1364
1463
|
{
|
|
1365
1464
|
spec,
|
|
@@ -1371,21 +1470,24 @@ function Visualization({ spec, theme, darkMode, className, style }) {
|
|
|
1371
1470
|
);
|
|
1372
1471
|
}
|
|
1373
1472
|
if (isGraphSpec(spec)) {
|
|
1374
|
-
return /* @__PURE__ */
|
|
1473
|
+
return /* @__PURE__ */ jsx11(Graph, { spec, theme, darkMode, className, style });
|
|
1375
1474
|
}
|
|
1376
1475
|
if (isSankeySpec(spec)) {
|
|
1377
|
-
return /* @__PURE__ */
|
|
1476
|
+
return /* @__PURE__ */ jsx11(Sankey, { spec, theme, darkMode, className, style });
|
|
1378
1477
|
}
|
|
1379
1478
|
if (isTileMapSpec(spec)) {
|
|
1380
|
-
return /* @__PURE__ */
|
|
1479
|
+
return /* @__PURE__ */ jsx11(TileMap, { spec, theme, darkMode, className, style });
|
|
1381
1480
|
}
|
|
1382
1481
|
if (isBarListSpec(spec)) {
|
|
1383
|
-
return /* @__PURE__ */
|
|
1482
|
+
return /* @__PURE__ */ jsx11(BarList, { spec, theme, darkMode, className, style });
|
|
1384
1483
|
}
|
|
1385
1484
|
if (isGeoMapSpec(spec)) {
|
|
1386
|
-
return /* @__PURE__ */
|
|
1485
|
+
return /* @__PURE__ */ jsx11(GeoMap, { spec, theme, darkMode, className, style });
|
|
1486
|
+
}
|
|
1487
|
+
if (isRaceSpec(spec)) {
|
|
1488
|
+
return /* @__PURE__ */ jsx11(Race, { spec, theme, darkMode, className, style });
|
|
1387
1489
|
}
|
|
1388
|
-
return /* @__PURE__ */
|
|
1490
|
+
return /* @__PURE__ */ jsx11(Chart, { spec, theme, darkMode, className, style });
|
|
1389
1491
|
}
|
|
1390
1492
|
export {
|
|
1391
1493
|
BarList,
|
|
@@ -1394,6 +1496,7 @@ export {
|
|
|
1394
1496
|
DataTable,
|
|
1395
1497
|
GeoMap,
|
|
1396
1498
|
Graph,
|
|
1499
|
+
Race,
|
|
1397
1500
|
Sankey,
|
|
1398
1501
|
TileMap,
|
|
1399
1502
|
Visualization,
|