Я использую Angular с Chart.js и мне нужно добавить линию тренда.Я добавил плагин и код chartjs-plugin-trendline.js
, как показано ниже, но он не показывает линию тренда.
HTML-код:
<canvas id="base" class="chart-bar" chart-labels="vm.ts_labels" class="chart chart-line" chart-data="vm.generalSatisfactionLine" chart-dataset-override="vm.overallGraphDataOveride" chart-options="vm.overallGraphOptions">
Угловой код:
vm.overallGraphOptions = {
elements:
{
point:
{
radius: 9,
hoverRadius: 7.5
}
},
trendlineLinear: {
style: "rgba(255,105,180, .8)",
width: 2
}
layout: {
padding: {
left: 5000,
right: 0,
top: 0,
bottom: 0
}
},
scales: {
xAxes: [{
gridLines: {
display: true
},
ticks: {
display: true
}
}],
yAxes: [{
type: "linear",
position: "left",
id: 'satisfaction',
gridLines: {
display: true
},
ticks: {
display: true,
min: 0,
max: 10,
callback: function (label, index, labels) {
return label * 10;
},
},
labels: {
show: true,
}
},
{
type: "linear",
position: "right",
id: 'responses',
gridLines: {
display: false
},
ticks: {
display: false
},
labels: {
show: true,
}
}],
}
}