Skip to content

Latest commit

 

History

History
35 lines (29 loc) · 1.24 KB

README.md

File metadata and controls

35 lines (29 loc) · 1.24 KB

Dashing-Graph

A class for preparing Rickshaw graphs for Dashing.

The following example uses the Graph class along with the Sequel gem to count the number of users and orders per day, then plot them as separate series on the graph.

graph = DashingGraph.new 'Users' => '#ff0000',
                         'Orders' => '#00ff00'
db[:users]
  .select(:created_at)
  .each do |row|
    # Group by day
    time = Time.at(row[:created_at]).to_datetime.at_beginning_of_day.to_i,
    # Add to the graph
    graph.add_point 'Users', time, 1
  end

db[:orders]
  .select(:created_at)
  .each do |row|
    # Group by day
    time = Time.at(row[:created_at]).to_datetime.at_beginning_of_day.to_i,
    # Add to the graph
    graph.add_point 'Orders', time, 1
  end

send_event('users-and-orders-per-day', graph)

To do

  • Allow for more rendering properties, such as graph type (e.g., 'line', 'area'), interpolation type (e.g., 'linear', 'cardinal'), etc.
  • Provide more usage examples in the README.
  • Add better/more code documentation.

Thanks to Tim Macdonald for writing all the original graph-data-massaging code that made this class possible.