Skip to content

Zero values skipped on logarithmic scale line chart #9629

Description

@flesher1

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions