[Chartjs]-Chart.js How to make a sample math axis?

1👍

You can get a result close to your example image, but not exactly the same. You would probably need to create a custom axis to align the tick labels to the zero line.

let axisConfig = {
  drawBorder: false,
  gridLines: {
    lineWidth: 0,
    zeroLineWidth: 1
  },
  ticks: {
    max: 6,
    min: -6
  }
};
new Chart(document.getElementById("chart"), {
  type: "scatter",
  options: {
    scales: {
      xAxes: [axisConfig],
      yAxes: [axisConfig]
    }
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js"></script>
<canvas id="chart"></canvas>

Leave a comment