jorgenfb / ng2-google-charts

Angular2 Google Charts Module

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ng2-google-charts

Google Charts module for Angular 2

Please see this page for a live demo.

NPM Version Downloads

Install

npm i --save ng2-google-charts

Usage

Add the following inside the <head> element in your index.html:

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

Import the Ng2GoogleChartsModule in your app.module.ts:

import { Ng2GoogleChartsModule } from 'ng2-google-charts';

@NgModule({
  ...
  imports: [
    ...
    Ng2GoogleChartsModule,
  ],
})
export class AppModule { }

In your templates, use the google-chart component like this:

<google-chart [data]="pieChartOptions"></google-chart>

and in the corresponding .ts file:

pieChartOptions =  {
  chartType: 'PieChart',
  dataTable: [
    ['Task', 'Hours per Day'],
    ['Work',     11],
    ['Eat',      2],
    ['Commute',  2],
    ['Watch TV', 2],
    ['Sleep',    7]
  ],
  options: {'title': 'Tasks'},
};

Please see this page for a demo with more examples.

License

MIT

About

Angular2 Google Charts Module

License:MIT License


Languages

Language:TypeScript 59.6%Language:JavaScript 30.8%Language:HTML 8.8%Language:CSS 0.7%