I'm looking to incorporate a new feature from this library on GitHub into my Angular project, which will enhance my ChartJS graph.
@ViewChild('myChart') myChart: ElementRef;
myChartBis: Chart;
....
....
const ctx = this.myChart.nativeElement.getContext('2d');
this.myChartBis = new Chart(ctx, {
type: 'bar',
data: {
labels: this.labels,
datasets: [{
label: 'test',
showLine: true,
lineTension: 0,
data: this.data,
fill: false,
pointBorderColor: '#cd0037',
pointBackgroundColor: '#ffffff',
borderColor: [
'#747678',
],
borderWidth: 0
}
],
},
options: {
showLines: true,
legend: {
display: false,
},
responsive: true,
maintainAspectRatio: true,
cornerRadius: 20,
...
}
});
So far, here are the steps I've taken:
I added the JS file to
angular.json
underbuild
:scripts": [ "src/assets/scripts/Chart.roundedBarCharts.js" ]
I included
cornerRadius: 20
in the graph options.- I restarted the app.
However, I encountered an error stating that it doesn't recognize the new option:
Type '{ showLines: true; legend: { display: false; }; responsive: true; maintainAspectRatio: true; corn...' is not assignable to type 'ChartOptions'.
I suspect that I may have imported the JS file incorrectly into my Angular app.