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

fix(dtatsample): fix rate infinity cause range error #16372

Merged
merged 2 commits into from
Jan 18, 2022

Conversation

Cuiyansong
Copy link
Contributor

@Cuiyansong Cuiyansong commented Jan 14, 2022

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Fixed issues

Details

Before: What was the problem?

After: How is it fixed in this PR?

Misc

  • The API has been changed (apache/echarts-doc#xxx).
  • This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

N.A.

Others

Merging options

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

Other information

@echarts-bot
Copy link

echarts-bot bot commented Jan 14, 2022

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.

@plainheart
Copy link
Member

Why is your chart width zero?

@Cuiyansong
Copy link
Contributor Author

Cuiyansong commented Jan 14, 2022

Why is your chart width zero?

In our application(datart), we set default container width to zero, and wait dataset back and debounce calculate the frame container width and height. For sure, we could set default is 1px or more, then the chart will reset width to 600px for example, the graph will be twinking.
For sure when the width set to 0, is it not make sense to draw any graph for ECharts, but sometime it is useful to init echart instance and resource, so it is much better to avoid Exception I think. In other word, it is seemed not friendly error message when width to zero.

@@ -94,7 +94,7 @@ export default function dataSample(seriesType: string): StageHandler {
const size = Math.abs(extent[1] - extent[0]) * (dpr || 1);
const rate = Math.round(count / size);

if (rate > 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Using isFinte(rate) may be better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using isFinte(rate) may be better

Sure, is it better for if (isFinite(rate) && rate > 1) ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes I think so

@pissang pissang added this to the 5.3.1 milestone Jan 18, 2022
@pissang
Copy link
Contributor

pissang commented Jan 18, 2022

Looks good.

We didn't suggest initializing a chart with zero width. But I think it's also not expected to have an expection that will break the following setOption or resize.

@pissang pissang merged commit 4fe9cb0 into apache:master Jan 18, 2022
@echarts-bot
Copy link

echarts-bot bot commented Jan 18, 2022

Congratulations! Your PR has been merged. Thanks for your contribution! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants