Skip to content

A graph class for use with Shopify's Dashing and the Rickshaw JavaScript library

Notifications You must be signed in to change notification settings

jessepinho/dashing-graph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

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.

About

A graph class for use with Shopify's Dashing and the Rickshaw JavaScript library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages