Created
November 2, 2012 13:13
-
-
Save thepleb/4001311 to your computer and use it in GitHub Desktop.
highcharts stacked bar graph
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## use lazy_high_charts to make a horizontal stacked bar chart | |
# in the controller | |
@h = LazyHighCharts::HighChart.new('graph') do |f| | |
f.options[:chart][:defaultSeriesType] = "bar" | |
f.options[:title][:text] = "Sample Title Text" | |
f.legend(:reversed => 'true') | |
f.xAxis(:categories=>['Cat1', | |
'Cat2', | |
'Cat3', | |
'Cat4', | |
'Cat5', | |
'Cat6', | |
'Cat7']) | |
f.plotOptions(:series=> {:stacking => 'normal'}) | |
f.series(:name=>'Type1', color: '#ba7fb3', :data=>[0, 1, 0, 0, 0, 0, 0]) | |
f.series(:name=>'Type2', color: '#AA4643', :data=> [1, 2, 2, 0, 1, 4, 2]) | |
f.series(:name=>'Type3', color: '#ffe963', :data=> [1, 3, 0, 2, 0, 1, 1]) | |
f.series(:name=>'Type4', color: '#95BBD7', :data=> [1, 1, 4, 1, 3, 1, 1]) | |
end | |
# in the view creates a div with id='divID' | |
<%= high_chart("divID", @h) %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment