chartjs / chartjs/Chart.js

Zero values skipped on logarithmic scale line chart

Open
#9,629 11 comments 6 reactions 0 assignees View on GitHub
type: bug
Dominant language
JavaScript
Stars
67.7k
Forks
11.9k
Avg merge
7h 39m
Merged PRs (30d)
5

Description

## Expected 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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.