Zero values skipped on logarithmic scale line chart
See original GitHub issueExpected Behavior
A line chart should be able to display values of 0 along the bottom axis and the y axis should start at zero if the y scale is logarithmic.
Current Behavior
Values of 0 on a logarithmic scale line chart are not shown on the chart. min:0
and beginAtZero: true
both appear to have no effect on the issue that 0 does not appear on the line chart.
This functionality appears to be working in v2. In v3.0.2 it somewhat works by displaying the 0 points at the bottom of the chart, however the scale is still not set to 0.
Steps to Reproduce
https://codepen.io/flesher1/pen/WNORQoQ
Provide a dataset containing 0s. Use a line graph with logarithmic scale. Copying example below:
var ctx = document.getElementById("chart").getContext("2d");
var chart = new Chart(ctx, {
type: "line",
data: {
labels: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
datasets: [
{
backgroundColor: "rgb(75, 192, 192, 0.5)",
data: [2000, 400, 10, 1, 0, 0.001, 0.5],
}
]
},
options: {
scales: {
xAxes: [{
type: 'category'
}],
y: {
type: 'logarithmic',
beginAtZero: true
}
}
}
});
Context
In this case, I have Data that contains 10s, 20s, 0s, and numbers around 80,000.
Environment
- Chart.js version: 3.1.0 and newer
- Browser name and version: Chrome
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Highcharts: Displaying zero values in logarithmic scale
I know that log(0) doesn't exist but I need to draw 0 values, and I need a log scale. I read in other...
Read more >Logarithmic scale with zeros - Nevron Software
The behavior of zero values in log axes primarily targets charts with zero scale origin (like bar), which look "good" when zeros are...
Read more >Logarithmic Axis - Chart.js
The logarithmic scale is used to chart numerical data. ... logarithmic interpolation is used to determine where a value lies on the axis....
Read more >Problem with Log Scale type in Line chart
This problem is handled in line graph when Scale type is chosen as "Linear" and Start as "Auto". But the same "Auto" feature...
Read more >How do I set my axis values down to zero when changing my y ...
There is no zero on log scale. Add one line on the end of your code: Theme.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fake it: https://codepen.io/kurkle/pen/WNORmJr
For now, points at 0 are skipped