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

Radar chart: allow missing data #5073

Closed
flaurida opened this issue Dec 22, 2017 · 6 comments · Fixed by #6289
Closed

Radar chart: allow missing data #5073

flaurida opened this issue Dec 22, 2017 · 6 comments · Fixed by #6289

Comments

@flaurida
Copy link
Contributor

flaurida commented Dec 22, 2017

Hi Chart.js,

I am trying to build a radar chart with a consistent set of point labels, but that handles the case where not all of the labels have data. Is there a way to only draw points for the labels that have data, and then connect just those points, while still showing the same set of labels consistently? Let me know!

Thanks,
Laura

@flaurida flaurida changed the title Cannot set lineArc: true for radar chart Remove tick labels on radar chart Dec 22, 2017
@flaurida flaurida changed the title Remove tick labels on radar chart Radar chart: allow missing data Dec 22, 2017
@etimberg
Copy link
Member

@flaurida supporting this should be relatively easy. We already have a spanGaps flag for line charts that skips over NaN data.

I think all that needs to happen is to set spanGaps in here in a similar way to https://github.com/chartjs/Chart.js/blob/master/src/controllers/controller.line.js#L71

Then you'd insert NaN for missing data and set spanGaps: true in the options and it should work

const chart = new Chart(ctx, {
  type: 'radar',
  data: {
    datasets: [{
      label: 'dataset',
      data: [10, 20, NaN, 15, 25],
      borderColor: 'red',
      fill: false,
      spanGaps: true
    }],
    labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding"]
  },
  options: {
  }
})

@flaurida
Copy link
Contributor Author

Hi @etimberg thanks for the prompt response! I just tried setting spanGaps: true in both the options object as well as in the dataset itself, and then setting the missing values to NaN. However, this does not connect the lines around the missing data point, rather just sets the missing point to zero. See screenshot. Am I missing something?

screen shot 2017-12-22 at 12 31 43 pm

@flaurida
Copy link
Contributor Author

flaurida commented Dec 22, 2017

If it is helpful, here is a jsfiddle of your suggestion to see the issue more clearly:
https://jsfiddle.net/hvenb74o/28/

@etimberg
Copy link
Member

Thanks for the fiddle! This still requires a small code change in src/controllers/controller.radar.js to work. If you're able to try out a custom build locally and see if it works that'd be great.

@flaurida
Copy link
Contributor Author

Oh awesome, just tried it locally and it works! How can we get this fixed for chart.js?

@flaurida
Copy link
Contributor Author

Just submitted a PR, hopefully we can merge the fix soon? Thanks again!

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

Successfully merging a pull request may close this issue.

4 participants