我尝试了多种应用方法,但似乎都无法改变我的图表。我正在通过文件上传数组,一切似乎都有效,甚至更改了默认颜色,但 colorAxis 似乎不起作用。你们(和女孩)能帮助我吗,我将不胜感激。谢谢
/* CSV handling - START */
var processedData = [];
var continent = $('select[name="continents"] option:selected').val();
$.get('example.csv', function(data) {
processedData = $.csv.toArrays(data);
}, 'text');
/* CSV handling - END */
/* Google Charts */
google.charts.load('current', {
'packages':['geochart'],
// Note: you will need to get a mapsApiKey for your project.
// See: https://developers.google.com/chart/interactive/docs/basic_load_libs#load-settings
'mapsApiKey': //doesn't matter
});
google.charts.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable(processedData, false);
var options = {
sizeAxis: { minValue: 0, maxValue: 100 },
colorAxis: {colors: ['#e7711c', '#4374e0']},
region: continent,
width: '100%',
height: '100%',
backgroundColor: 'none'
};
var chart = new google.visualization.GeoChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
/* Google Charts - End */
最佳答案
请参阅 Google 开发者引用
https://developers.google.com/chart/interactive/docs/gallery/geochart#important
var 选项 = { 地区: '002',//非洲 colorAxis: {颜色: ['#00853f', '黑色', '#e31b23']}, 背景颜色: '#81d4fa', datalessRegionColor: '#f8bbd0', 默认颜色:'#f5f5f5', };
https://developers.google.com/chart/interactive/docs/gallery/geochart#coloring-your-chart
var 选项 = { 地区:“IT”, 显示模式:'标记', colorAxis: {颜色: ['绿色', '蓝色']} };
var chart = new google.visualization.GeoChart(document.getElementById('chart_div'));
chart.draw(data, options);
关于javascript - Google GeoCharts 颜色不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44641467/