Chart.js : straight lines instead of curves
Solution for Version 1 (old charts version)
According to documentation on chartjs.org
you can set the 'bezierCurve' in options and pass it in when you create the chart.
bezierCurve: false
eg:
var options = {
//Boolean - Whether the line is curved between points
bezierCurve : false
};
var myLine = new Chart(document.getElementById("canvas").getContext("2d")).Line(lineChartData, options);
Update for version 2
According to updated documentation for Line Configuration in global options
Name Type Default Description
tension Number 0.4 Default bezier curve tension. Set to 0 for no bezier curves.
eg:
var options = {
elements: {
line: {
tension: 0
}
}
};
And also directly in the Dataset Structure by setting lineTension
to 0 (zero).
Property Type Usage
lineTension Number Bezier curve tension of the line. Set to 0 to draw straightlines.
This option is ignored if monotone cubic interpolation is used.
Note This was renamed from 'tension' but the old name still works.
An example data object using these attributes is shown below.
var lineChartData = {
labels: labels,
datasets: [
{
label: "My First dataset",
lineTension: 0,
data: data,
}
]
};
You can use lineTension option to set the desired curve. Set 0 for straight lines. You can give a number between 0-1
data: {
datasets: [{
lineTension: 0
}]
}