Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google charts y-axis color

I'm using google charts api (line chart) and I want to change y-axis color from black to grey.
(the same color as the grid lines)

enter image description here

my code:

google.load("visualization", "1", { packages: ["corechart"] });
        google.setOnLoadCallback(drawChart);

        var baseLineColor = '#a3d06e';
        var lineColor = '#717171';

        function drawChart() {
            var dataTable = new google.visualization.DataTable();
            dataTable.addColumn('number', 'date'); 
            dataTable.addColumn('number', 'sale'); 
            dataTable.addRows([
            [1, 2],
            [2, 3],
            [3, 3],
            [4, 4],
            [5, 5]
        ]);

            var options = {
                enableInteractivity: false,
                tooltip: {trigger: 'none'},
                pointSize: 0,
                legend: 'none',
                chartArea:{width:'94%',height:'70%'},
                backgroundColor: '#6AB5D1',
                series: { 0: { color: lineColor, pointSize: 5, lineWidth: 4 }}, 
                hAxis: { textPosition: 'none', gridlines: {color:"#CCCCCC"} },
                vAxis: { textPosition: 'none', baseline: 3, baselineColor: baseLineColor, gridlines: {color:"#CCCCCC"}}

            };

            var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
            chart.draw(dataTable, options); 

How can I do that?

like image 336
NickF Avatar asked Oct 17 '13 07:10

NickF


People also ask

How do you change the color of a chart on Google?

Set series colors To change the colors assigned to data series in a specific chart: Select that chart, then on the right, open the STYLE tab. In the Color by section, select Series order, Bar order, or Slice order, depending on the type of chart. Click a color box to set the color for each series.

How do you change the color of a line in a Google graph?

You can change the color of the lines that connect data points in Google Charts in two subtly different ways: with the colors option to change the chart palette, or with the series option to specify the color for particular series. In the following chart, we set the color of each series explicitly.

How do I customize my Google bar graph?

Customize a bar chartChoose an option: Chart style: Change how the chart looks. Chart & axis titles: Edit or format title text. Series: Change bar colors, axis location, or add error bars, data labels, or trendline.


1 Answers

Set the hAxis.baselineColor option:

hAxis: {
    textPosition: 'none',
    gridlines: {
        color: "#CCCCCC"
    },
    baselineColor: '#CCCCCC'
}
like image 194
asgallant Avatar answered Sep 19 '22 08:09

asgallant