11import { createClassFromSpec } from "react-vega" ;
22
33import { type PlotState } from "@/lib/types/state/component" ;
4- // import { type PropertyChangeHandler } from "@/lib/types/model/event";
4+ import { type PropertyChangeHandler } from "@/lib/types/model/event" ;
55import type { CSSProperties } from "react" ;
66
77export interface DashiPlotProps extends Omit < PlotState , "type" > {
8- // onPropertyChange: PropertyChangeHandler;
8+ onPropertyChange : PropertyChangeHandler ;
99}
1010
1111interface VegaChartWrapperProps {
@@ -17,15 +17,30 @@ export function DashiPlot({
1717 id,
1818 style,
1919 figure,
20- // onPropertyChange,
20+ onPropertyChange,
2121} : DashiPlotProps ) {
22+ if ( ! figure ) {
23+ console . error (
24+ "Rendering DashiPlot failed:" ,
25+ "Expected figure, got" ,
26+ figure ,
27+ ) ;
28+ return null ;
29+ }
2230 const { datasets, ...spec } = figure ;
2331 const Plot = createClassFromSpec ( {
2432 mode : "vega-lite" ,
2533 spec : spec ,
2634 } ) ;
27- const handleSignal = ( signalName : string , value : unknown ) => {
28- console . log ( "signalName" , signalName , value ) ;
35+ const handleSignal = ( _signalName : string , value : unknown ) => {
36+ if ( id ) {
37+ return onPropertyChange ( {
38+ componentType : "Plot" ,
39+ componentId : id ,
40+ propertyName : "points" ,
41+ propertyValue : value ,
42+ } ) ;
43+ }
2944 } ;
3045 const VegaChartWrapper = ( { id, style } : VegaChartWrapperProps ) => {
3146 return (
0 commit comments