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

[BUG] Lines go back and forth when they are left to ticks.min #3502

Closed
robertwhitebit opened this issue Oct 23, 2016 · 5 comments
Closed

[BUG] Lines go back and forth when they are left to ticks.min #3502

robertwhitebit opened this issue Oct 23, 2016 · 5 comments

Comments

@robertwhitebit
Copy link

robertwhitebit commented Oct 23, 2016

Lines less than xAxes.ticks.min behave weird and maybe shouldn't be rendered at all. Or if rendered, they should be rendered correctly. As you can see in the image, they go back and forth.

image

used dataset is random

for (var i = -100; i < 100; i++) {
    data.push({x: i, y: Math.random()});
}

You can inspect the behavior live at http://codepen.io/anon/pen/wzNrGq

If you change the added points to data.push({x: i, y: Math.abs(i)});(linear, straight line), it will look like:

image

However, the left side should mirror the right side. (or not displayed at all)

@robertwhitebit robertwhitebit changed the title [BUG] Lines go back and forth when the are at the left of ticks.min [BUG] Lines go back and forth when they are left to ticks.min Oct 23, 2016
@etimberg
Copy link
Member

We used to clip the drawing of these points, but that caused other issues. I think the oscillating nature comes from how the bezier control points are calculated which are by default confined to the chart area.

One option would be to filter out all points < min or > max but I don't know how users expect this to work. Do they expect the line to be drawn to the very edge or not ... if so, we'd need to keep at least 1 point on the sides. What would you like to see in this case? Would the line stop at the last visible point or would it continue to the edge of the chart?

@robertwhitebit
Copy link
Author

robertwhitebit commented Oct 23, 2016

Thank you for your quick response!

I've created a sample page. http://robertwhitebit.github.io/chartjs-line-bug.html
On this page there is a slider to change the min/max values of the x axis. So you can zoom in on specific ranges. And also a checkbox to enable if points outside the chart are filtered.

The min/max only solution works better when changing the min value (e.g. from 0 to 30). During moving the slider, the chart is updated. It really looks like zooming in because the line is stretched.

On the filtered version however, the whole line jumps up and down (wobbles). I guess it's completely reconstructed when zooming in.

Even though there is a difference when changing the max value as well, it looks good enough to me 😉

Oh, and special thanks to all Chart.js members and contributors. It's an awesome project! 😽

@etimberg
Copy link
Member

Thanks for the test page :) I'm adding this to the v2.5 milestone. We're currently working on v2.4, but most of the issues we wanted to get fixed have been fixed so I'm hoping to get started on v2.5 soon.

@etimberg etimberg added this to the Version 2.5 milestone Oct 23, 2016
@etimberg
Copy link
Member

etimberg commented Dec 4, 2016

Resolved in #3658

@etimberg etimberg closed this as completed Dec 4, 2016
@robertwhitebit
Copy link
Author

LGTM! 👍
Thanks!

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

No branches or pull requests

2 participants