Class: Chart::Bar
Instance Attribute Summary
Attributes inherited from Base
#angle, #colors, #data, #extra_fields, #height, #inside, #label_format, #labels, #legend, #line_width, #margins, #multicolor, #object, #plot_area, #plot_top_margin, #position, #radius, #style, #symbols, #width
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Chart::Base
Instance Method Details
#generate ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/chart/bar.rb', line 8 def generate # set the plot area @object.setPlotArea(@margins[0], @margins[1], @plot_area[0], @plot_area[1], 0xe9e9e9, 0xf5f5f5) # set the legend position @object.addLegend(@margins[0], 0, false, "normal", 8).setBackground(ChartDirector::Transparent) # set the top margin @object.yAxis.setTopMargin(@plot_top_margin) # set the labels @object.xAxis.setLabels(@labels) # set extra fields add_extra_fields # add data to layer if @multicolor layer = @object.addBarLayer3(@data, @colors, @legend, 0) else layer = @object.addBarLayer(@data, @colors.first) end # set label over bars unless @label_format.nil? if @inside layer.setDataLabelFormat(@label_format) layer.setDataLabelStyle("normal", 8, 0x000000, @angle) else layer.setAggregateLabelFormat(@label_format) layer.setAggregateLabelStyle("normal", 8, 0x00000, @angle) end end end |
#instantiate ⇒ Object
3 4 5 6 |
# File 'lib/chart/bar.rb', line 3 def instantiate # instantiate a new chart @object = ChartDirector::XYChart.new(@width, @height) if @width && @height end |