-
Notifications
You must be signed in to change notification settings - Fork 320
How to: Store data to and display from database
and7ey edited this page Mar 5, 2016
·
3 revisions
The Dashing by default just displays the data just received. If you would like to store the data received and then send it to your widget, you may use Redis datastore.
The job should be modified to store and read the data, see below the example how to do it with simple Number
widget:
require 'redis' # https://github.com/redis/redis-rb
redis_uri = URI.parse(ENV["REDISTOGO_URL"])
redis = Redis.new(:host => redis_uri.host, :port => redis_uri.port, :password => redis_uri.password)
SCHEDULER.every '20s', :first_in => 0 do |job|
rand_value = rand(1000) # replace this line with the code to get your data
prev_value = redis.get("widget-id-prev-value") # read previous value from the Redis datastore
redis.set("widget-id-prev-value", rand_value) # store current value to the Redis datastore
send_event('karma', { current: rand_value, last: prev_value })
end
- Home
- Dashing Workshop
- Installation
- Widgets
- Configuration
- Security
- Troubleshooting
- Deploying dashboards
- How Tos
- How to: post data to your dashboard and widgets
- How to: Define a data model and store history data to database
- How to: Prevent a job from overlapping with itself
- How to: Send HTML data to your widgets
- How to: Send mysql data to your widgets
- How to: Setup a Graph
- How to: Store data to and display from database
- How to: Update a Dashboard using a spreadsheet
- How to: update dashboard in Django
- How to: Update font awesome fonts from version 3 to 4
- How to: Use New Relic with Dashing
- How to: precompile assets
- Development