Chart.js : straight lines instead of curves

前端 未结 4 1314
不思量自难忘°
不思量自难忘° 2021-01-30 09:55

I\'m using Chart.JS to plot a dataset,

However I got a smooth effect !

Here is the curve I\'ve got :

Here is my code :



        
4条回答
  •  终归单人心
    2021-01-30 10:42

    I have used lineTension to set the smoothness of the curve.

    From the docs: lineTension receives a number, Bezier curve tension of the line. Set to 0 to draw straight lines. This option is ignored if monotone cubic interpolation is used.

    Just make sure to test with different values how smooth you want the line.

    For example:

    var data = {
      labels: ["Jan", "Feb", "Mar"],
      datasets: [{
          label: "Label 1",
          lineTension: 0.2
        }, {
          label: "Stock B",
          lineTension: 0.2
        }
    
      ]
    };
    

提交回复
热议问题