[charts] Add `VisibilityManager` logic to allow managing series/items
Split from https://github.com/mui/mui-x/pull/20404/
Code is the same, but removed the implementation part to decrease complexity.
This should be ready to review/merge as the plugin is not hooked into anything.
Docs on: https://deploy-preview-20404--material-ui-x.netlify.app/x/react-charts/legend/#toggle-visibility
Deploy preview: https://deploy-preview-20571--material-ui-x.netlify.app/
Updated pages:
Bundle size report
| Bundle | Parsed size | Gzip size |
|---|---|---|
| @mui/x-data-grid | 0B(0.00%) | 0B(0.00%) |
| @mui/x-data-grid-pro | 0B(0.00%) | 0B(0.00%) |
| @mui/x-data-grid-premium | 0B(0.00%) | 0B(0.00%) |
| @mui/x-charts | 🔺+2.23KB(+0.65%) | 🔺+628B(+0.61%) |
| @mui/x-charts-pro | 🔺+2.23KB(+0.50%) | 🔺+738B(+0.55%) |
| @mui/x-charts-premium | 🔺+1.22KB(+0.27%) | 🔺+389B(+0.29%) |
| @mui/x-date-pickers | 0B(0.00%) | 0B(0.00%) |
| @mui/x-date-pickers-pro | 0B(0.00%) | 0B(0.00%) |
| @mui/x-tree-view | 0B(0.00%) | 0B(0.00%) |
| @mui/x-tree-view-pro | 0B(0.00%) | 0B(0.00%) |
Generated by :no_entry_sign: dangerJS against 54ca8885063578dc13fc151c88be0fb35dd79780
CodSpeed Performance Report
Merging #20571 will not alter performance
Comparing JCQuintas:visibility-manager-code (54ca888) with master (46d77ce)[^unexpected-base]
[^unexpected-base]: No successful run was found on master (59c5050) during the generation of this report, so 46d77ce was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.
Summary
✅ 13 untouched
How should hidden series affect the domain when using filterMode: 'discard'? If it's supposed to be affected, I think we need to update extremums.ts to use visibleStackedData instead.
How should hidden series affect the domain when using
filterMode: 'discard'? If it's supposed to be affected, I think we need to updateextremums.tsto usevisibleStackedDatainstead.
It currently doesn't support that use-case.
@prakhargupta1 question https://github.com/mui/mui-x/pull/20404#issuecomment-3595762639
Issue tracking it https://github.com/mui/mui-x/issues/20517
It currently doesn't support that use-case.
@prakhargupta1 question #20404 (comment)
Issue tracking it #20517
Wouldn't it be a breaking change if we update filterMode: 'discard' to start discarding values according to hidden series?
If you set filterMode: 'discard' I think you're expecting that invisible items are removed from the domain calculations, so we'd end up with an inconsistent state where the domain is updated when an item is outside the view, but not when it's hidden by user action.
Nevertheless, I think this poses a greater question that we probably should think about now (even if we only implement it later): if we add a visibilityDomainMode: 'keep' | 'discard' to the axis types, how should that interact with zoom's filterMode? Should zoom's filterMode also apply to hidden series?
Nevertheless, I think this poses a greater question that we probably should think about now
IMO it's straightforward:
- filterMode: Indicates if you compute axis extremums based on the entire data range or if you consider the zoom and then only pick a sub-domain. For axample values only between 5 and 7.
- visibilityDomainMode: Indicates if you compute axis extremums based on all series or just the visible ones.
Let assume you have:
- series A: visible
- series B: hidden
- x-axis values from 0 to 10 with a zoom on 5 to 7
you can get
| filterMode | visibilityDomainMode | y-axis domain |
| keep | keep | The min/max of A and B from 0 to 10 |
| keep | discard | The min/max of A from 0 to 10 |
| discard | keep | The min/max of A and B from 5 to 7 |
| discard | discard | The min/max of A from 5 to 7 |
This pull request has conflicts, please resolve those before we can evaluate the pull request.
- visibilityDomainMode: Indicates if you compute axis extremums based on all series or just the visible ones.
Yeah, it will use a different prop as the mechanics are different