Skip to content

feat: Add chart event for title change#2352

Merged
jnumainville merged 3 commits intodeephaven:mainfrom
jnumainville:18091_indicator
Feb 4, 2025
Merged

feat: Add chart event for title change#2352
jnumainville merged 3 commits intodeephaven:mainfrom
jnumainville:18091_indicator

Conversation

@jnumainville
Copy link
Copy Markdown
Contributor

@jnumainville jnumainville commented Jan 29, 2025

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.

Comment thread packages/chart/src/Chart.tsx Outdated
}
case ChartModel.EVENT_TITLE_CHANGE: {
const titleText = `${detail}`;
const oldTitle = this.state.layout.title;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const oldTitle = this.state.layout.title;
const { title: oldTitle } = this.state.layout;

Comment thread packages/chart/src/Chart.tsx Outdated
this.setState({ shownBlocker: null });
break;
}
case ChartModel.EVENT_TITLE_CHANGE: {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of an EVENT_TITLE_CHANGE, go with EVENT_LAYOUT_UPDATED and emit the new layout.
ChartModel already has the layout (.getLayout()) and that should contain the updated title.
Also see in ChartModel.initData how we use the chart layout on top of the state layout... so this would be something like:

case ChartModel.EVENT_LAYOUT_UPDATED: {
  const newLayout = detail as Partial<Layout>;
  this.setState(({ layout, revision }) => ({ layout: { ...layout, ...newLayout }, revision: revision + 1 }))
}

@mofojed
Copy link
Copy Markdown
Member

mofojed commented Jan 29, 2025

@jnumainville also if you could separate the decimal fix into a separate PR that would make cherry-picking changes if needed easier.

@jnumainville
Copy link
Copy Markdown
Contributor Author

format options added to #2353

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 29, 2025

Codecov Report

Attention: Patch coverage is 14.28571% with 6 lines in your changes missing coverage. Please review.

Project coverage is 46.09%. Comparing base (6a20d69) to head (1317187).

Files with missing lines Patch % Lines
packages/chart/src/Chart.tsx 0.00% 4 Missing ⚠️
packages/chart/src/ChartModel.ts 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2352      +/-   ##
==========================================
- Coverage   46.09%   46.09%   -0.01%     
==========================================
  Files         712      712              
  Lines       39674    39681       +7     
  Branches    10055     9870     -185     
==========================================
+ Hits        18288    18289       +1     
- Misses      21375    21381       +6     
  Partials       11       11              
Flag Coverage Δ
unit 46.09% <14.28%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jnumainville jnumainville requested a review from mofojed February 3, 2025 14:40
Copy link
Copy Markdown
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge the latest main into this branch

Comment thread packages/chart/src/Chart.tsx
@jnumainville jnumainville requested a review from mofojed February 4, 2025 15:14
@jnumainville jnumainville changed the title feat: Add chart event for title change and fix format options feat: Add chart event for title change Feb 4, 2025
@jnumainville jnumainville enabled auto-merge (squash) February 4, 2025 16:22
@jnumainville jnumainville merged commit 25563dc into deephaven:main Feb 4, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants