echarts icon indicating copy to clipboard operation
echarts copied to clipboard

feat(dataZoom): `valueRange` for `dataZoom` event

Open susiwen8 opened this issue 3 years ago • 8 comments

Brief Information

This pull request is in the type of:

  • [ ] bug fixing
  • [x] new feature
  • [ ] others

What does this PR do?

Expose startValue and endValue at dataZoom event

Fixed issues

  • Close #10700

Details

Before: What was the problem?

After: How does it behave after the fixing?

Document Info

One of the following should be checked.

  • [ ] This PR doesn't relate to document changes
  • [ ] The document should be updated later
  • [x] The document changes have been made in apache/echarts-doc#10700

Misc

ZRender Changes

  • [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

N.A.

Others

Merging options

  • [x] Please squash the commits into a single one when merging.

Other information

susiwen8 avatar Jun 23 '22 15:06 susiwen8

Thanks for your contribution! The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

The pull request is marked to be PR: author is committer because you are a committer of this project.

echarts-bot[bot] avatar Jun 23 '22 15:06 echarts-bot[bot]

Document changes are required in this PR. Please also make a PR to apache/echarts-doc for document changes and update the issue id in the PR description. When the doc PR is merged, the maintainers will remove the PR: awaiting doc label.

echarts-bot[bot] avatar Jun 24 '22 02:06 echarts-bot[bot]

The document should be updated by removing "only exists in zoom event of triggered by toolbar".

Ovilia avatar Jun 24 '22 02:06 Ovilia

The document should be updated by removing "only exists in zoom event of triggered by toolbar".

Created a PR for it.

susiwen8 avatar Jun 24 '22 11:06 susiwen8

Looks good. if (dataZoomModel.get('showDetail')) is not a mistake. It's just the old logic only used dataInterval to display the labels and didn't save it to_dataRange.

pissang avatar Jun 28 '22 03:06 pissang

Seems the valueRange is updated after the action being dispatched. I guess in the event startValue and endValue will not be the latest value? A test will be good to verify it

pissang avatar Jun 28 '22 04:06 pissang

Any update on this PR? This would be really helpful as there's merely no way to map start/end percentage to values in the same way as ECharts does accurately.

SevenOutman avatar Jul 18 '22 08:07 SevenOutman

Seems the valueRange is updated after the action being dispatched. I guess in the event startValue and endValue will not be the latest value? A test will be good to verify it

@pissang @Ovilia @plainheart The missing person has returned, Sorry I haven't checked this in time, had very busy two months.

The timing for calculating _valueRange has moved after the calculation of range. This might be the better way, cause dataZoom event rely on range as well as _valueRange, so this two variable could be calculated at same time

susiwen8 avatar Aug 10 '22 15:08 susiwen8

By the way, if an xAxis.type is set to time, a dataZoom.startValue and dataZoom.endValue properties will return formatted values, which makes it difficult to map them back to the original data. For example, if your dataset value is 1682850281010, the dataZoom.startValue will be 1682850281399.8394. Even if you use an ISO string format instead of a timestamp, the dataZoom object will still return a formatted value

ddubrava avatar Apr 30 '23 17:04 ddubrava