module ChartJS
Chart
JS is a simple yet flexible JavaScript charting library. This gem is a Ruby Domain Specific Language which allows you to easily build charts without touching a single line of JavaScript or HTML. @author Kent 'picat' Gruber
Constants
- VERSION
Public Class Methods
A bar chart provides a way of showing data values represented as vertical bars. It is sometimes used to show trend data, and the comparison of multiple data sets side by side.
# File lib/chart_js.rb, line 64 def self.bar(type = :vertical, &block) chart = Chart.new case type when :vertical chart.type('bar') when :horizontal chart.type('horizontalBar') end chart.build(&block) end
Build a chart, do some stuff!
# File lib/chart_js.rb, line 19 def self.build(&block) Chart.new(&block) end
Need to send some server-side event data? You found your method. Optionally, it'll even call the “to_json” on the object your sending ( if it accepts that method call ); otherwise you should really only send JSON that is already formatted. Otherwise it'll just send the plaintext.
Live life the way you want to.
# File lib/chart_js.rb, line 81 def self.data(json: false, &block) if json "data: #{block.call} \r\n\n" else "data: #{block.call.to_json} \r\n\n" end end
Doughnut charts are probably one of the most commonly used charts. They are divided into segments, the arc of each segment shows the proportional value of each piece of data. They are excellent at showing the relational proportions between data but with a big'O hole in the middle.
# File lib/chart_js.rb, line 55 def self.doughnut(&block) chart = Chart.new chart.type('doughnut') chart.build(&block) end
A line chart is a way of plotting data points on a line. Often, it is used to show trend data, or the comparison of two data sets.
# File lib/chart_js.rb, line 25 def self.line(&block) chart = Chart.new chart.type('line') chart.build(&block) end
Pie charts are probably one of the most commonly used charts. They are divided into segments, the arc of each segment shows the proportional value of each piece of data. They are excellent at showing the relational proportions between data.
# File lib/chart_js.rb, line 44 def self.pie(&block) chart = Chart.new chart.type('pie') chart.build(&block) end
A radar chart is a way of showing multiple data points and the variation between them. They are often useful for comparing the points of two or more different data sets.
# File lib/chart_js.rb, line 34 def self.radar(&block) chart = Chart.new chart.type('radar') chart.build(&block) end