Skip to content

Commit 90cfae5

Browse files
jnumainvillemofojed
authored andcommitted
feat: Add chart event for title change (#2352)
These are for deephaven/deephaven-plugins#1088 Currently the layout is only set once, but with indicator it may change, although specifically the title, so I added an event for that. Not sure if it's the best approach.
1 parent 912f1d6 commit 90cfae5

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

packages/chart/src/Chart.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,14 @@ class Chart extends Component<ChartProps, ChartState> {
525525
this.setState({ shownBlocker: null });
526526
break;
527527
}
528+
case ChartModel.EVENT_LAYOUT_UPDATED: {
529+
const newLayout = detail as Partial<Layout>;
530+
this.setState(({ layout, revision }) => ({
531+
layout: { ...layout, ...newLayout },
532+
revision: revision + 1,
533+
}));
534+
break;
535+
}
528536
default:
529537
log.debug('Unknown event type', type, event);
530538
}

packages/chart/src/ChartModel.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class ChartModel {
4141

4242
static EVENT_BLOCKER_CLEAR = 'ChartModel.EVENT_BLOCKER_CLEAR';
4343

44+
static EVENT_LAYOUT_UPDATED = 'ChartModel.EVENT_LAYOUT_UPDATED';
45+
4446
constructor(dh: typeof DhType) {
4547
this.dh = dh;
4648
this.listeners = [];
@@ -196,6 +198,12 @@ class ChartModel {
196198
fireBlockerClear(): void {
197199
this.fireEvent(new CustomEvent(ChartModel.EVENT_BLOCKER_CLEAR));
198200
}
201+
202+
fireLayoutUpdated(detail: Partial<Layout>): void {
203+
this.fireEvent(
204+
new CustomEvent(ChartModel.EVENT_LAYOUT_UPDATED, { detail })
205+
);
206+
}
199207
}
200208

201209
export default ChartModel;

0 commit comments

Comments
 (0)