We are new to angularjs v4. We have a requirement of drilldown charts in
google charts. We are using ng2-google-charts directives. We are able to
find the select event and updated the data. but chart is not reloading.
Could any one please help on this.
*view: index.html*
<google-chart #drillchart [data]='pieChartData' type="BarChart"
(chartSelect)='select($event)'>
</google-chart>
*Component.ts:*
pieChartData = {
chartType: 'BarChart',
dataTable: [
['Country', 'Poulation'],
['Ind', 25],
['Rus', 10],
['Chi', 30],
['USA', 15],
['UK', 12],
['Aus', 8]
],
options: {'title': 'Population'}
};
newDataIndia = [
['State', 'Poulation'],
['AndhraPradesh', 30],
['UttarPradesh', 40],
['MadyaPradesh', 10],
['Karnataka', 10],
['Tamilnadu', 10]
];
newDataUS = [
['State', 'Poulation'],
['Texas', 30],
['Florida', 40],
['Pennsylvania', 10],
['Lousiana', 15],
['Colorado', 10]
];
public changeData(data):void {
/*let dataTable = this.drillchart.wrapper.getDataTable();
for (let i = 0; i < 6; i++) {
dataTable.setValue(i, 1, Math.round(Math.random() * 1000));
dataTable.setValue(i, 2, Math.round(Math.random() * 1000));
}*/
let dataTable = this.drillchart.wrapper.getDataTable()
console.log(dataTable);
dataTable.Sf[0].label = data[0][0];
dataTable.Sf[0].type = "string";
dataTable.Sf[1].label = data[0][1];
dataTable.Sf[1].type = "number";
for (let i = 0; i < data.length-1; i++) {
dataTable.Tf[i].c[0].v = data[i+1][0];
dataTable.Tf[i].c[1].v = data[i+1][1];
}
if(dataTable.Tf.length < data.length-1)
{
for(var icount = data.length-1; icount != data.length-1; icount--) {
dataTable = dataTable.Tf.pop();
}
}
this.drillchart.redraw();
}
Thanks in advance.
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-visualization-api/d396731f-7341-41f8-b0a1-ac849455fade%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.