Filippo Vitale
Filippo Vitale

Reputation: 8113

How to remove both axis from a Google Bar Chart (aka Chart API)

I can't find in the Chart API the way to remove any axis from a bar chart. For instance:

cht=bvg
chs=410x150
chd=s:StackOverflow

simple bar chart example

How to remove the gray x and y axis?

Upvotes: 3

Views: 2669

Answers (3)

rlovtang
rlovtang

Reputation: 5060

(based on Alexander Farber's answer, but with some minor improvements)

You can add

chxt=x,y
chxs=0,,0,0,_|1,,0,0,_

Explanation:

chxt=x,y

Which axis to show. Even though axis x and y are shown as default, we still need to specify those to be able to apply styling with chxs.

chxs=0,,0,0,_|1,,0,0,_

Styling for the two axis, separated by pipe. Separated by comma, we have:

  • Axis index. Reference to chxt. 0= first (x), 1= second (y)
  • Label color. Since we will hide the labels, we can leave this empty
  • Label font size. Setting this to 0 will hide the labels, and thus we don't need to set empty labels with chxl
  • Label alignment. Need to specify a valid value, although we don't display labels. 0 is fine.
  • Show axis and tick marks. _ will hide both

More info at https://developers.google.com/chart/image/docs/chart_params#axis_label_styles chart

Upvotes: 2

Filippo Vitale
Filippo Vitale

Reputation: 8113

All I found is this trick: cover them with a white line and it works

cht=bvg
chs=410x150
chd=s:StackOverflow
chm=r,FFFFFF,0,-0.01,0.01,1
    R,FFFFFF,0,-0.01,0.01,1

alt text

...but any "cleaner" way?

Upvotes: 3

Related Questions