Skip to content

Commit 3721a15

Browse files
jnumainvillebmingles
authored andcommitted
fix: DH-18279: fix one click titles (#2381)
Example from [DH-18279](https://deephaven.atlassian.net/browse/DH-18279) ``` import deephaven.plot.express as dx from deephaven.plot.figure import Figure from deephaven.plot.selectable_dataset import one_click stocks = dx.data.stocks() one_click = Figure().plot_xy(series_name="Stock Prices", t=one_click(stocks, ["Sym"]), x="Timestamp", y="Price").show() ``` Title now updates as the input filter is updated [DH-18279]: https://deephaven.atlassian.net/browse/DH-18279?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: Brian Ingles <github@emeraldwalk.com>
1 parent 91eacee commit 3721a15

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

packages/chart/src/FigureChartModel.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,22 @@ it('handles colors on bar charts properly', () => {
140140
]);
141141
});
142142

143+
it('updates the title correctly', () => {
144+
const figure = chartTestUtils.makeFigure();
145+
const model = new FigureChartModel(dh, figure);
146+
const mockSubscribe = jest.fn();
147+
model.subscribe(mockSubscribe);
148+
149+
model.setTitle('New Title');
150+
expect(mockSubscribe).toHaveBeenCalledTimes(1);
151+
expect(mockSubscribe).toHaveBeenCalledWith(
152+
expect.objectContaining({
153+
type: FigureChartModel.EVENT_LAYOUT_UPDATED,
154+
detail: { title: { text: 'New Title', pad: { t: 8 } } },
155+
})
156+
);
157+
});
158+
143159
describe('axis transform tests', () => {
144160
it('handles log x-axis properly', () => {
145161
const xAxis = chartTestUtils.makeAxis({

packages/chart/src/FigureChartModel.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,8 @@ class FigureChartModel extends ChartModel {
616616
ChartUtils.DEFAULT_TITLE_PADDING.t +
617617
subtitleCount * ChartUtils.SUBTITLE_LINE_HEIGHT * 0.5;
618618
}
619+
620+
this.fireLayoutUpdated({ title: this.layout.title });
619621
}
620622

621623
getPlotWidth(): number {

0 commit comments

Comments
 (0)