RC0 How to export Components and other features properly

for what its worth and for those interested, i got chart.js working by itself, this is what i did:

1: - install chart.js via npm:

npm install chart.js --save

2: - in your .ts file import chart.js, declare and import viewchild and elementref:

import 'chart.js/src/chart'; declare var Chart; import { Component, ViewChild, ElementRef } from '@angular/core';

3: - add the viewchild

export class YourChartsPage { @ViewChild('canvas') canvas:ElementRef;

4: - add your chart code:

ionViewDidEnter(){ let ctx = this.canvas.nativeElement new Chart(ctx, { type: 'bar', data: { labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], datasets: [{ label: '# of Votes', data: [12, 19, 3, 5, 2, 3], backgroundColor: [ 'rgba(255, 99, 132, 0.2)', 'rgba(54, 162, 235, 0.2)', 'rgba(255, 206, 86, 0.2)', 'rgba(75, 192, 192, 0.2)', 'rgba(153, 102, 255, 0.2)', 'rgba(255, 159, 64, 0.2)' ], borderColor: [ 'rgba(255,99,132,1)', 'rgba(54, 162, 235, 1)', 'rgba(255, 206, 86, 1)', 'rgba(75, 192, 192, 1)', 'rgba(153, 102, 255, 1)', 'rgba(255, 159, 64, 1)' ], borderWidth: 1 }] }, options: { scales: { yAxes: [{ ticks: { beginAtZero:true } }] } } });

5: add the chart to your html file:

<canvas #canvas></canvas>

you can style it with css

Works with serve and just built it for android and works too and no errors! So instead of looking for a solution or waiting for a fix… just do this and have chart.js working again :slight_smile:

7 Likes