How do you remove the x-axis from a bar chart produced by Google's Visualization API?

54,399

Solution 1

You can set hAxis.textPosition to the value of 'none'

For example:

var options = {

                hAxis: { textPosition: 'none' },
            };

chart.draw(data, options);

See https://developers.google.com/chart/interactive/docs/gallery/barchart#Configuration_Options

Solution 2

let options = {legend: { position: 'none' }};

Solution 3

Their API has no function for this indeed, but:

chart.draw( data, 
    {
        width: 400, 
        height: 240, 
        is3D: true, 
        legend :'none',
        axisFontSize : 0
    });

Setting axisFontSize to 0 will remove your x-axis data. :)

Solution 4

I was able to remove the label in the material version of the chart by removing the string in my datatable.

Before:

data.addColumn('string', 'Date');

After:

data.addColumn('string', '');

Solution 5

Google changes the API so fast, this is what works today:

chart.draw(daily, {
    hAxis : {textColor: '#ffffff'},
    [... your other options here ...]
});
Share:
54,399
Admin
Author by

Admin

Updated on December 05, 2020

Comments