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(line): 过滤空节点, 避免阶梯线条变为斜线 #16435

Merged
merged 4 commits into from
Feb 18, 2022

Conversation

Gyyi
Copy link
Contributor

@Gyyi Gyyi commented Jan 26, 2022

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

fix that connectNulls with stepLine fails when after a long number of null entries occur

Fixed issues

#16424

Details

option:

option={
          title: {
            text: 'Step Line',
          },
          tooltip: {
            trigger: 'axis',
          },
          legend: {
            data: ['Step Start', 'Step Middle', 'Step End'],
          },
          grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true,
          },
          toolbox: {
            feature: {
              saveAsImage: {},
            },
          },
          xAxis: {
            type: 'category',
            data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
          },
          yAxis: {
            type: 'value',
          },
          series: [
            {
              name: 'Step Start',
              type: 'line',
              step: 'start',
              connectNulls: true,
              data: [120, 132, 101, 134, 90, 230, 210],
            },
            {
              name: 'Step Middle',
              type: 'line',
              step: 'middle',
              connectNulls: true,
              data: [220, 282, null, 234, null, 430, 410],
            },
            {
              name: 'Step End',
              type: 'line',
              step: 'end',
              connectNulls: true,
              data: [450, 432, null, null, 590, 530, 510],
            },
          ],
        }

Before: What was the problem?

image

After: How is it fixed in this PR?

image

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 26, 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.

@pissang
Copy link
Contributor

pissang commented Feb 15, 2022

The code looks good to me now. Could you add a test case line-step with npm run mktest command?

pt[1] = points[i + 1];
stepPoints.push(pt[0], pt[1]);
}
if (!isNaN(points[i + 2]) && !isNaN(points[i + 3])) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems it may not work when there are multiple consecutive NaN values. And handling these consecutive NaN values may be too complex and easy to bring bugs.

Perhaps the original filter logic is simpler and more robust. Sorry for the wrong suggestion.

But still the variable name points_ should be renamed to some others without underline, like newPoints.

Copy link
Contributor Author

@Gyyi Gyyi Feb 15, 2022

Choose a reason for hiding this comment

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

Haha, OK, I have fixed this problem. And I also make it filter null points only when using connectNull: true.
Please review the code again,Thanks~

@pissang pissang added this to the 5.3.1 milestone Feb 18, 2022
@pissang pissang merged commit f4e1864 into apache:master Feb 18, 2022
@echarts-bot
Copy link

echarts-bot bot commented Feb 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.

2 participants