question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Linechart: NaN values are not skipped when type: 'logarithmic' is used

See original GitHub issue

Expected Behavior

NaN datapoint should be skipped (there should be gap).

chart js

Current Behavior

NaN datapoint is displayed as a zero value.

Steps to Reproduce (for bugs)

<html>
  <body>
    <div class="myChartDiv">
      <canvas id="myChart" width="600" height="400"></canvas>
    </div>
  </body>
</html>
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
    type: 'line',
    data: {
        labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
        datasets: [{
            label: '# of Votes',
            data: [12, 19, NaN, 5, 2, 3]
        }]
    },
    options: {
        scales: {
            yAxes: [{
                type: 'logarithmic',
                ticks: {
                    beginAtZero:true
                }
            }]
        }
    }
});

Using spanGaps has no effect. There is no bug when type: 'logarithmic', is removed:

image

Environment

  • Chart.js version: v2.9.3
  • Browser name and version: Google Chrome 79.0.3945.88 (Official Build) (64-bit)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
benmccanncommented, Feb 27, 2020
0reactions
kylemiller3commented, Oct 16, 2020

I am still experiencing this behavior in my code. I am setting blank values to NaN. Any ideas?

screenshot_20201016_030428

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chart js logarithmic line chart showing NaN values instead of ...
I've made a simple line chart to test the empty values. But in my test, the values are not shown in the graph....
Read more >
It's not possible to add data points with no value ('null') to a ...
[Charts] Support "missing value": It's not possible to add data points ... However it is not possible to use a LineChart for that...
Read more >
A Line chart may plot gaps in lines when the data range ...
Describes an issue where the lines of a Line chart may plot with gaps when the data ... Use the NA function in...
Read more >
Broken Y Axis in an Excel Chart - Peltier Tech
A better suggestion than either a log scale or a broken axis is to plot ... In this chart, the gradient at the...
Read more >
Line Chart - Google Developers
It is not supported by the Annotation Chart . Type: object. Default: null. axisTitlesPosition. Where to place the axis titles, compared to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found