Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TimeSeriesWidget: fix echarts props update, to keep state of control when clicking #865

Merged
merged 4 commits into from
Apr 22, 2024

Conversation

zbigg
Copy link
Contributor

@zbigg zbigg commented Apr 19, 2024

Description

Shortcut: https://app.shortcut.com/cartoteam/story/404593/builder-timeserieswidget-tooltip-disappears-when-clicking-on-series

In TimeseriesWidget, fix way we update props in echarts instance so

  • series are effectively removed
  • we don't lose state of control on props update

(note, data update still resets control animation/filter state)

Fixes regression from #863

Type of change

  • Fix

Acceptance

Please describe how to validate the feature or fix

  1. go to X
  2. test Y
  3. assert Z

If feature deals with theme / UI or internal elements used also in CARTO 3, please also add a note on how to do acceptance on that part.

Basic checklist

  • Good PR name
  • Shortcut link
  • Changelog entry
  • Just one issue per PR
  • GitHub labels
  • Proper status & reviewers
  • Tests
  • Documentation

@zbigg zbigg force-pushed the zbigg/fix-timeseries-reset-on-click branch from da2bf87 to 65826e7 Compare April 19, 2024 07:39
Copy link

github-actions bot commented Apr 19, 2024

Pull Request Test Coverage Report for Build 8753292311

Details

  • 7 of 13 (53.85%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 71.251%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/react-ui/src/custom-components/echarts-for-react/index.js 6 7 85.71%
packages/react-ui/src/widgets/TimeSeriesWidgetUI/hooks/useTimeSeriesInteractivity.js 1 6 16.67%
Totals Coverage Status
Change from base Build 8736848869: 0.02%
Covered Lines: 2804
Relevant Lines: 3625

💛 - Coveralls

Copy link

github-actions bot commented Apr 19, 2024

Visit the preview URL for this PR (updated for commit 612b93c):

https://cartodb-fb-storybook-react-dev--pr865-zbigg-fix-timese-mj6tc0du.web.app

(expires Fri, 26 Apr 2024 12:16:00 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 517cc4d31d7e09cf277774e034094b67c301cd4c

@zbigg zbigg force-pushed the zbigg/fix-timeseries-reset-on-click branch from 65826e7 to 2a735e2 Compare April 19, 2024 09:01
@zbigg zbigg force-pushed the zbigg/fix-timeseries-reset-on-click branch from 2a735e2 to 6f64967 Compare April 19, 2024 09:03
@@ -197,6 +197,7 @@ export default function TimeSeriesChart({
: theme.palette.action.disabledBackground;

return {
id: name,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This ensures that echarts keeps track of series when we update data.

const { option, lazyUpdate, showLoading, loadingOption = null } = this.props;
const echartInstance = this.getEchartsInstance();

echartInstance.setOption(option, { replaceMerge: ['series'], lazyUpdate });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This ensures that merges series objects as list identified by id

const updateTimelineByCoordinate = useCallback(
(params) => {
if (echartsInstance) {
const [x] = echartsInstance.convertFromPixel({ seriesIndex: 0 }, [
const [x] = echartsInstance.convertFromPixel(seriesFinder, [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we remove series from beginnning (by filtering sql by param), internal echarts array looks this: [undefined, undefined, something, something ]

So seriesIndex: 0 doesn't always work. Solution: find by category name

@zbigg zbigg merged commit 1a8d8e2 into master Apr 22, 2024
2 checks passed
zbigg added a commit that referenced this pull request Apr 22, 2024
@zbigg zbigg mentioned this pull request Apr 22, 2024
zbigg added a commit that referenced this pull request Apr 22, 2024
* TimeSeriesWidget: fix echarts props update, to keep state of control when clicking (#865)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants