我如何给 google 图表上色
How can i give colors to google charts
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Invites', 'Count'],
['No', parseInt(response['JobInvitationstatus']['no'])],
['Maybe', parseInt(response['JobInvitationstatus']['noresponse'])],
['Yes', parseInt(response['JobInvitationstatus']['yes'])]
]);
var options = {
title: 'Job ID '+response['jobData']['id_job']+' Invitation Status'
};
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}
这是 google 图表代码,我想给出特定的颜色,例如
没有是红色的
也许是黄色
是的,绿色,我该怎么做..?
做出这样的选择:
var options = {
colors: ['red','yellow', 'green'],
title: 'Job ID '+response['jobData']['id_job']+' Invitation Status'
};
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Invites', 'Count'],
['No', parseInt(response['JobInvitationstatus']['no'])],
['Maybe', parseInt(response['JobInvitationstatus']['noresponse'])],
['Yes', parseInt(response['JobInvitationstatus']['yes'])]
]);
var options = {
title: 'Job ID '+response['jobData']['id_job']+' Invitation Status'
};
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}
这是 google 图表代码,我想给出特定的颜色,例如
没有是红色的
也许是黄色
是的,绿色,我该怎么做..?
做出这样的选择:
var options = {
colors: ['red','yellow', 'green'],
title: 'Job ID '+response['jobData']['id_job']+' Invitation Status'
};