Open jefhu opened 7 years ago
This helped me a lot. Just going to clean up some of what you wrote for others to see...
npm install angular2-google-chart
<script src="https://www.gstatic.com/charts/loader.js"></script> <script> var googleLoaded = false; </script>
import {GoogleChart} from 'angular2-google-chart/directives/angular2-google-chart.directive';
@NgModule({ declarations: [ AppComponent, GoogleChart ],
<div id="pie_chart" [chartData]="pie_ChartData" [chartOptions]="pie_ChartOptions" chartType="PieChart" GoogleChart></div>
public pie_ChartData = [ ['Task', 'Hours per Day'], ['Work', 11], ['Eat', 2], ['Commute', 2], ['Watch TV', 2], ['Sleep', 7] ];
public pie_ChartOptions = { title: 'My Daily Activities', width: 400, height: 400 };
Thank you. Could someone post this to the overview page?
I have followed the same steps in my application, but getting error like
I'm using barChart, I need to wrap the text from the x-axis, which options should I use to overcome this? here is the screenshot of it : https://prnt.sc/gq6wuq
Thank you for creating this wonderful NPM module. I am sharing my experience to benefit others.
Use angular2-google-chart
@NgModule({ declarations: [ AppComponent, GoogleChart ],
Includes Timeline chart in app.component.html, I have
Timeline Charts
<div sytle="width:100%, height:600px" id="timeline_chart" [chartData]="timeline_ChartData" [chartOptions]= "timeline_ChartOptions" chartType="Timeline" GoogleChart>
in app.component.ts , I have public timeline_ChartData ={ cols: [ {type: 'string', id: 'Executor'}, {type: 'string', id: 'Name'}, {type: 'string', id: 'Tooltip', role: 'tooltip', p: {html: true}}, {type: 'date', id: 'start_date'}, {type: 'date', id: 'finish_date'}, ], rows: [
{c:[{v: 'A'}, {v: 'John'}, {v: 'John Doe'}, {v: new Date(2016, 7, 31)}, {v: new Date(2016, 8, 1)}]}, {c:[{v: 'A'}, {v: 'Jane'}, {v: 'Jane Doe'}, {v: new Date(2016, 7, 27)}, {v: new Date(2016, 7, 31)}]}, {c:[{v: 'B'}, {v: 'John'}, {v: 'John Doe'}, {v: new Date(2016, 7, 30)}, {v: new Date(2016, 8, 1)}]}, {c:[{v: 'B'}, {v: 'Jane'}, {v: 'Jane Doe'}, {v: new Date(2016, 7, 29)}, {v: new Date(2016, 8, 5)}]}, {c:[{v: 'C'}, {v: 'John'}, {v: 'John Doe'}, {v: new Date(2016, 7, 25)}, {v: new Date(2016, 7, 29)}]}, {c:[{v: 'C'}, {v: 'Jane'}, {v: 'Jane Doe'}, {v: new Date(2016, 7, 27)}, {v: new Date(2016, 8, 1)}]}, {c:[{v: 'C'}, {v: 'Fred'}, {v: 'Fred Doe'}, {v: new Date(2016, 7, 21)}, {v: new Date(2016, 7, 26)}]} ] };
public timeline_ChartOption={ timeline: { colorByRowLabel: true }, backgroundColor: '#ffd', tooltip: {isHtml: true}, width: '100%', height: '600px', chartArea: { width: '80%', height: '80%' }, colors: ['red', 'blue', 'green'], avoidOverlappingGridLines: true };