google / google-visualization-issues

288 stars 35 forks source link

ChartRangeFilter not showing custom colors #2685

Open FineTralfazz opened 5 years ago

FineTralfazz commented 5 years ago

I'm using Google Charts to render a line chart with custom line colors, and I'm using a ChartRangeFilter to allow users to zoom in and out easily. However, the filter shows the default Google Charts colors instead of the custom ones: screen shot 2018-11-13 at 4 17 40 pm I've tried supplying a color array in the ControlWrapper's options array like I do in the ChartWrapper, but that didn't help. I've also tried calling the draw() method on the Dashboard object again manually in case this was the result of some sort of race condition, which didn't work either.

Hecrer commented 5 years ago

You can change the color of the control line by adding ui.chartOptions to the options object of the control wrapper as below.

I stumbled onto this whilst struggling with the same issue and found the solution in the guides here.

Hope this helps!

let safetyControl = new google.visualization.ControlWrapper({
        controlType: 'ChartRangeFilter',
        containerId: 'control-div',
        options: {
            filterColumnIndex: 0,
            ui: {
                chartType: 'LineChart',
                'chartOptions': {
                    series: {
                        0: { color: '#ffc107' },
                    },
                },
            },
        }
    });