0

I am using react-chart-2.
I would like to set the minimum value of the y-axis to 0 and the maximum value to 100.
Now, the y-axis is determined according to the data value.
How can I customize the value of the y-axis?

code

import "./styles.css";
import { Line } from "react-chartjs-2";

const App = () => {
  const data = {
    labels: ["January", "February", "March", "April", "May", "June", "July"],
    datasets: [
      {
        label: "a",
        data: [30, 10, 10, 40, 20, 10, 30],
        fill: false
      }
    ]
  };

  const options = {
    responsive: true,
    scales: {
      xAxes: [
        {
          ticks: {
            beginAtZero: true,
            max: 1000,
            min: 0
          }
        }
      ]
    }
  };

  return (
    <div className="App">
      <Line data={data} options={options} />
    </div>
  );
};

export default App;

aahhuhuhu
  • 413
  • 1
  • 9
  • 26

0 Answers0