我在Chart.js中使用Angular,我需要添加一个趋势线。我已经添加了searchIn = 0;
this.dataSource.filterPredicate =
(data: Element, filter: string) => {
if(searchIn == 1)
return data['username'].trim().toLowerCase().indexOf(filter) != -1;
else{
const datasrc = data['username']+data['name']
return datasrc.trim().toLowerCase().indexOf(filter) != -1;
}
}
applyFilter(filterValue: string) {
console.log(filterValue);
this.searchIn=1;
this.dataSource.filter = filterValue.trim().toLowerCase();
}
searchFilter(filterValue: string) {
console.log(filterValue);
this.searchIn=0;
this.dataSource.filter = filterValue.trim().toLowerCase();
}
插件和以下代码,但未显示趋势线。
HTML代码:
chartjs-plugin-trendline.js
角度代码:
<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">
答案 0 :(得分:0)
您似乎正在指定折线图:
<canvas id="base" class="chart-bar" chart-labels="vm.ts_labels" class="chart chart-line" ...
-----------------------------------------------------------------------------^
readme for chartjs-plugin-trendline指出仅支持条形图图表。