Hi everyone,
I used ng2 chart for my Ionic project. It’s useful and cool. But I have 2 problem cannot resolve.
1 - set gradient fill color for area.
I read this solution but I cannot use it:
// in template
<canvas #myCanvas [colors]="lineChartColors" ...
// in component
export class Demo {
@ViewChild("myCanvas") canvas: ElementRef;
lineChartColors;
// in ngOnInit
let gradient = this.canvas.nativeElement.getContext('2d').createLinearGradient(0, 0, 0, 200);
gradient.addColorStop(0, 'green');
gradient.addColorStop(1, 'white');
this.lineChartColors = [
{
backgroundColor: gradient
}
];
2 - add an icon to last point (current point).
Same first problem,I did it but just one chart display and others is error ( I have many charts in my project)
ngOnInit() {
var specialPoint = new Image();
specialPoint.src= 'https://i.imgur.com/yDYW1I7.png';
Chart.pluginService.register({
afterUpdate: function(chart) {
chart.config.data.datasets[0]._meta[0].data[23]._model.pointStyle = specialPoint;
}
});
}
Please help me. I just a newbie in Ionic, so maybe I can not describe everything clearly. Thank you so much