Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I rotate my HighCharts bar chart so its vertical, not horizontal?

enter image description here

$(document).ready(function() { chart1 = new Highcharts.Chart({     chart: {         renderTo: 'QueryResultsChart',         type: 'bar'     },     title: {         text: 'Production History'     },     xAxis: {         title: {             text: 'Production Day'         },         type: 'datetime'     },     yAxis: {         title: {             text: 'Gross Production'         }     },     series: [{         name: 'Data',         data: []     }] }); chart1.series[0].setData(". json_encode($aChartData) ."); }); 

The data is there an correct, it's just showing my xAxis on the yAxis for some reason...

like image 701
John Zumbrum Avatar asked Jun 27 '12 21:06

John Zumbrum


People also ask

Can bar charts be vertical?

A vertical bar graph is the most common type of bar chart and it is also referred to as a column graph. It represents the numerical value of research variables using vertical bars whose lengths are proportional to the quantities that they represent.

Can bar chart be horizontally or vertically oriented?

In a bar graph, bars can be drawn horizontally or vertically.


2 Answers

Vertical bar charts are called column's in Highchart.

Change this:

type: 'column' //was 'bar' previously` 

See example here: http://jsfiddle.net/aznBb/

like image 95
Moin Zaman Avatar answered Sep 21 '22 13:09

Moin Zaman


To expand on Moin Zaman's answer, I played with his jsfiddle http://jsfiddle.net/aznBb/ and found this.

This is horizontal.

chart: {     type: 'bar',     inverted: false // default } 

This is also horizontal.

chart: {     type: 'bar',     inverted: true } 

This is vertical.

chart: {     type: 'column',     inverted: false // default } 

This is horizontal and apparently identical to the bar charts.

chart: {     type: 'column',     inverted: true } 

Very odd. I can only guess that type: 'bar' aliases type: 'column' and forces inverted: true no matter what it's actually set at. It'd be nice if it just toggled the inverted boolean.

like image 36
StevenClontz Avatar answered Sep 20 '22 13:09

StevenClontz