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

Resolve issues with sparse datasets #435

Merged
merged 12 commits into from
Aug 17, 2014
Merged

Resolve issues with sparse datasets #435

merged 12 commits into from
Aug 17, 2014

Conversation

nnnick
Copy link
Member

@nnnick nnnick commented Jul 8, 2014

Pass null as a value for Bar/Line/Radar chart values to not render that particular point.

Started as a solution to #426 but investigating there were some issues with sparse datasets in general.

Todo before merging:

  • Fix problems with bezier curve splining between points with no value

@nnnick nnnick mentioned this pull request Jul 8, 2014
@alexanderwiebe
Copy link

Hey Nnnick,
I was looking at the changes you made for this and tested them out at http://codepen.io/alexanderwiebe/debug/dighu to walk through the code and debug the issue you're having with the splining. It works for me!

I am curious if you would be able to elaborate on what you mean when you say fix problems with bezier's splining between points with no value?

I was wondering what would be the best behaviour when you have a dataset with a null value in a form [1,2,null,3,...10]. I would guess that you would still want a connection between ? Looking at how a tool like Excel handles this is by having 1 scale on the x but still connecting the dots. http://peltiertech.com/WordPress/plot-two-time-series-with-different-dates/

Again, thanks for your time!

@alexanderwiebe
Copy link

Actually, I think I found the issue when I expanded the size of the graph seen below,
image
It seems similar to:

#424

@alexanderwiebe
Copy link

I tried doing a smooth graph from excel to see how they handle this. When they have a chart with a null/blank value the chart looks like:
image
So I tried adding the value 40 for april and noticed the following:
image
It's visible that between march and april series 1 drops below 40 due to splining the curves.

aside from having an option for line graphs to not be smooth I can't really think of a viable alternative?

@alexanderwiebe
Copy link

I found an issue when the datasets are of different lengths the dialog doesn't show up and the following error is thrown,
Uncaught TypeError: Cannot read property 'highlightFill' of undefined
line 1972 chart.js

sample http://jsfiddle.net/alexanderjwiebe/xdpE7/

this can be resolved by making both datasets the same length with null values.

@nnnick
Copy link
Member Author

nnnick commented Jul 13, 2014

Yeah this PR should fix that issue.

As you can see in the line chart image you posted, the bezier handles are in the wrong place - a mathematical example of how they should be you can find here: http://scaledinnovation.com/analytics/splines/aboutSplines.html

When calculating the handles, we need to determine the next point without a null value, and using that to calculate the location of the bezier handle, rather than just getting the next point along.

I'd hoped to finish this up this weekend but I've had some other stuff on, so I'll try get this wrapped up one evening next week.

nnnick added a commit that referenced this pull request Aug 17, 2014
Resolve issues with sparse datasets & solve bezier capping to scale bounds
@nnnick nnnick merged commit 7eec283 into master Aug 17, 2014
@fulldecent fulldecent deleted the fix/sparse-datasets branch December 29, 2014 21:33
@Jasguerrero
Copy link

I got a question if I want to connect the lines between a null value, how can I achieve that for example [1, 2, null, 4] I want to connect the 2 with the 4 but right now it breaks the line

@etimberg
Copy link
Member

@Jasguerrero in v2 use the spanGaps option

@t202wes
Copy link

t202wes commented Jul 19, 2016

@etimberg what spanGaps option?

http://www.chartjs.org/docs/#line-chart-introduction

I don't see anything that refers to that.

Found it here, #2803

Although it's buggy, doesn't seem to plot the lines between the null points correctly.

@etimberg
Copy link
Member

@t202wes there is a known issue with bezier curves. Setting the tension to 0 is a possible work around

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

Successfully merging this pull request may close these issues.

None yet

5 participants