Ionic 2 + Chartjs2 small chart

If you are looking for a way to implement chartjs in ionic2 here is the instruction that i followed
btw i don’t speak japanese either just follow the steps

here is the working code based on the example above

  private ngAfterViewInit() {
    
      let canvas: any = document.getElementById("myChart");
      let ctx = canvas.getContext("2d");
      ctx.canvas.width = 350;
      ctx.canvas.height = 300;

      var plot = new ChartJs(ctx, {
         type: 'line',
         data: {
             labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
             datasets: [{
                 label: 'Avg Km',
                 data: [4,5,8,4,5,2,4,5,4],
                 backgroundColor: [
                     'rgba(25,229,22,0.2)',
                 ],
                 borderColor: [
                     'rgba(25,229,22,1)',
                 ],
                 borderWidth: 1
             }

           ]
         },
         options: {
     responsive: false,
             scales: {
                 yAxes: [{
                     stacked: true
                 }]
             }
         }
       }); ///chartjs ends here
}
3 Likes