[英]Coloring column series in django-graphos google Chart
如何在django-graphos Google柱形圖中為每個柱系列設置顏色?
為此,谷歌圖表在文檔中有此說明( https://developers.google.com/chart/interactive/docs/gallery/columnchart#coloring-columns )
var data = google.visualization.arrayToDataTable([
['Element', 'Density', { role: 'style' }],
['Copper', 8.94, '#b87333'], // RGB value
['Silver', 10.49, 'silver'], // English color name
['Gold', 19.30, 'gold'],
]);
但是當我在django-graphos的數據數組中使用它時
data = [
['Type', 'Amount', { role: 'style' }],
['Current Month', 2000, '#b87333'], // RGB value
['Previous Month', 3000, 'silver'], // English color name
]
我收到此錯誤:給定軸上的所有序列必須具有相同的數據類型。
如何在django-graphos中為Google柱形圖在每個柱形系列中設置不同的顏色?
謝謝
為此,我首先修改數組,如下所示:
data = [
['Type', 'Amount', 'Amount'],
['Current Month', 2000, None],
['Previous Month', None, 3000],
]
然后添加以下選項:
chart = ColumnChart(SimpleDataSource(data=data), options= {
'isStacked': True,
'legend': {
'position': 'none'
}, 'series': [
{'color': '#0084cgg'},
{'color': '#ef4036'}
]
})
通過這個選項,我設法為每個系列上色
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.