Dan
Dan

Reputation:

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

Referring to the kind of chart shown here: http://code.google.com/apis/visualization/documentation/gallery/barchart.html

There doesn't seem to be a simple switch, and changing the axis color to white (on a white background) didn't seem to do anything. I even tried jquery to hide the selectors produced by the api output but no dice.

Upvotes: 32

Views: 61078

Answers (8)

Divyesh Bhalani
Divyesh Bhalani

Reputation: 66

Use this to remove axis from chart

hAxis: { textPosition: "none", gridlines: { count: 0 } },
  vAxis: { textPosition: "none", gridlines: { count: 0 } },
  baselineColor:"transparent",

Upvotes: 0

AtyulyaKadam
AtyulyaKadam

Reputation: 61

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

Upvotes: 4

Tony Schmidt
Tony Schmidt

Reputation: 170

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', '');

Upvotes: 4

Dan Diplo
Dan Diplo

Reputation: 25369

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

Upvotes: 87

KKovacs
KKovacs

Reputation: 100

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

chart.draw(daily, {
    hAxis : {textColor: '#ffffff'},
    [... your other options here ...]
});

Upvotes: 2

John Erck
John Erck

Reputation: 9538

Check out http://code.google.com/apis/chart/docs/gallery/bar_charts.html#axis_label_styles

Axis Label Styles chxs "axis_or_tick"

You'll notice this documentation: "_ - (Underscore) Draw neither axis line nor tick marks. If you want to hide an axis line, use this value."

Example: 'chxs=0,,0,0,_'

Upvotes: 0

Denny
Denny

Reputation: 11

axisFontSize : 0 will remove x-axis and y-axis data

Upvotes: 1

Elzo Valugi
Elzo Valugi

Reputation: 27886

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. :)

Upvotes: 3

Related Questions