Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do i set the correct height when using javascript google bar chart

i am using google bar chart and in the options there is a height property. depending on my dataset i need to set a different height as things either get squeezed together or there is tons of whitespace above and below the bar chart.

is there anyway to have the chart know how much height it needs based on the number of items in the datatable?

like image 957
leora Avatar asked Aug 12 '10 09:08

leora


People also ask

How do you change the width and height of a Google chart?

One very common option to set is the chart height and width. You can specify the chart size in two places: in the HTML of the container <div> element, or in the chart options. If you specify the size in both locations, the chart will generally defer to the size specified in the HTML.

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.


2 Answers

Have you run into issues dynamically resizing based on dataset size?

e.g., on the Code Playground:

line 31            width:600, height: data.getNumberOfRows() * 80,
like image 119
user194743 Avatar answered Oct 06 '22 00:10

user194743


no, at least not using the bar chart API but it wouldn't be too hard for you to make a method :D

like image 22
stevebot Avatar answered Oct 05 '22 22:10

stevebot