lib/prawn/graph/extension.rb in prawn-graph-0.9.10 vs lib/prawn/graph/extension.rb in prawn-graph-1.0.0.pre1

- old
+ new

@@ -1,64 +1,33 @@ module Prawn module Graph module Extension - # @deprecated bar_graph and bar_chart are deprecated and will be removed in a future version. Use the new graph / chart methods instead. - # Draws a bar graph into the PDF using the legacy graph stuff. Please avoid. + # Draws a bar graph into the PDF # # Example: # # bar_graph [ ["A", 1], ["B", 2], ["C", 3] ], at: [10,10] # def bar_graph(data, options = {}, &block) - deprecate :bar_graph - draw_graph(Prawn::Graph::Charts::Bar, data, options, &block) + graph = Prawn::Graph::Charts::Bar.new(data, self, options, &block) + graph.draw + {warnings: [], width: graph.prawn.bounds.width, height: graph.prawn.bounds.height} end alias bar_chart bar_graph - # @deprecated line_graph and line_chart are deprecated and will be removed in a future version. Use the new graph / chart methods instead. - # Draws a line graph into the PDF using the legacy graph stuff. Please avoid. + # Draws a line graph into the PDF # # Example: # # line_graph [ ["A", 1], ["B", 2], ["C", 3] ], at: [10,10] # def line_graph(data, options = {}, &block) - deprecate :line_graph - draw_graph(Prawn::Graph::Charts::Line, data, options, &block) + graph = Prawn::Graph::Charts::Line.new(data, self, options, &block) + graph.draw + {warnings: [], width: graph.prawn.bounds.width, height: graph.prawn.bounds.height} end alias line_chart line_graph - - # Plots one or more Prawn::Graph::Series on a chart. Expects an array-like object of - # Prawn::Graph::Series objects and some options for positioning the sizing the - # rendered graph - # - # @param series [Array] of Prawn::Graph::Series objects - # @param options [Hash] of options, which can be: - # `:width` - The overall width of the graph to be drawn. `<Integer>` - # `:height` - The overall height of the graph to be drawn. `<Integer>` - # `:at` - The point from where the graph will be drawn. `[<Integer>x, <Integer>y]` - # `:title` - The title for this chart. Must be a string. `<String>` - # `:series_key` - Should we render the key to series in this chart? `<Boolean>` - # - def graph(series, options = {}, &block) - canvas = Prawn::Graph::ChartComponents::Canvas.new(series, self, options, &block) - canvas.draw - {warnings: [], width: self.bounds.width, height: self.bounds.height} - end - alias chart graph - - private - - def draw_graph(klass, data, options, &block) - graph = klass.new(data, self, options, &block) - graph.draw - {warnings: [], width: self.bounds.width, height: self.bounds.height} - end - - def deprecate(method) - warn "[DEPRECATION] #{method} is deprecated and will be removed in future versions of prawn-graph. Use chart or graph instead." - end end end end \ No newline at end of file