Kenny Wyland
Kenny Wyland

Reputation: 21880

Google BarChart set width of bars?

I'm generating a BarChart with Google's javascript visualization libraries. I would like to make the bars in the chart to be wider than they currently are, but I can't find anything in the documentation which shows how to configure the width of the bars of each data set.

Any help?

Upvotes: 21

Views: 48292

Answers (2)

Manohar Reddy Poreddy
Manohar Reddy Poreddy

Reputation: 27505

Try below format so the graph will have decently look, its not fixed but this solved our issue.

options: {
  titlePosition: "none",
  bar: { groupWidth: "50%" }
  // ...
}

data.push([" ", "t1","t2","t3","t4"]); // headings
data.push([" ", 0, 0, 0, 0]); // dummy bar so graph will display good
// push you actual data here
data.push([" ", 0, 0, 0, 0]); // dummy bar so graph will display good

Upvotes: 1

Josh Rumbut
Josh Rumbut

Reputation: 2710

Had this same question, figured I'd post for posterity. The bar.groupWidth appears to be the way to set this.

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

For example:

 var options = {
        title: "Density of Precious Metals, in g/cm^3",
        width: 600,
        height: 400,
        bar: {groupWidth: "95%"},
        legend: { position: "none" },
      };
 var chart = new google.visualization.BarChart(document.getElementById("barchart_values"));
 chart.draw(view, options);

Upvotes: 26

Related Questions