0
votes

How can I set a color for each column series in django-graphos google Column Chart?

To do this google chart has this in documentation (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'],
    ]);

but when I use that to in my data array in django-graphos

 data = [
             ['Type', 'Amount', { role: 'style' }],
             ['Current Month', 2000, '#b87333'],            // RGB value
             ['Previous Month', 3000, 'silver'],            // English color name
        ]

I got this error: All series on a given axis must be of the same data type.

What should I do to set a different color in each column series for a google column chart in django-graphos?

Thanks

1
use a column for each 'Element', instead of a row -- then use colors config option - WhiteHat

1 Answers

0
votes

To achieve this first I modify the array like this:

 data = [
         ['Type', 'Amount', 'Amount'],
         ['Current Month', 2000, None],
         ['Previous Month', None, 3000],
 ]

Then I add these options:

chart = ColumnChart(SimpleDataSource(data=data), options= {
                                             'isStacked': True,
                                             'legend': {
                                                 'position': 'none'
                                              }, 'series': [
                                                   {'color': '#0084cgg'},
                                                   {'color': '#ef4036'}                                                      
                                              ]
                                          })

With this options I managed to color each series