Sha256: 74e43c1faddb8bc05244fe2b4846d151bcb281eb9a989aea3910737661cf6ffc
Contents?: true
Size: 735 Bytes
Versions: 2
Compression:
Stored size: 735 Bytes
Contents
# path setting magic for example directory only $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require "chart_js" require "willow_run" require "sinatra" set :bind, '0.0.0.0' set :port, 3141 get "/update_source", provides: 'text/event-stream' do stream(:keep_open) do |out| loop do out << ChartJS.data do { label: Time.now.strftime("%r"), value: WillowRun::Status.new.getinfo.agrctlrssi } end sleep 2 end end end get "/" do chart = ChartJS.bar do data do labels Array.new dataset WillowRun::Status.new.getinfo.ssid do color :random data Array.new end end event_stream "/update_source" do push end end chart.to_html end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
chart_js-1.1.1 | examples/bar_chart_event_stream.rb |
chart_js-1.1.0 | examples/bar_chart_event_stream.rb |