Databox
Ruby Gem for Databox - Mobile Executive Dashboard.
- By Oto Brglez
Installation
Add this line to your application's Gemfile:
gem 'databox'
And then execute:
$ bundle
Or install it yourself as:
$ gem install databox
Usage
Before using Databox gem you have to initialize it with key and token. There are 3 ways how you can do initialization.
- Within simple initializer
Databox.configure do |c|
c.token = "YOUR_TOKEN"
c.key = "YOUR_KEY"
end
By setting system
ENV
variablesDATABOX_KEY
andDATABOX_TOKEN
If your are using custom integration with different key please use
id
.
chart = Databox::LineChart.new "my_line", id: "OTHER_KEY"
Databox gem support following widgets
Widget | Implemented | Example | Databox Documentation |
---|---|---|---|
Big Number | Yes | Example | Basic Widgets / Big Number |
Compare | Yes | Example | Basic Widgets / Compare |
Internal | Yes | Example | Basic Widgets / Interval Values |
Line Chart | Yes | Example | Basic Widgets / Line Chart |
Bar Chart | Yes | Example | Basic Widgets / Bar Chart |
Pipeline | Yes | Example | Pipeline |
Funnel | Yes | Example | Funnel |
Pie | Yes | Example | Pie |
Progress | Yes | Example | Progress |
Table | No | ||
Messages | Yes | Example | Messages |
Big Number
number = Databox::BigNumber.new "just_number"
number.set 5000
number.save
# You can set date on initialize
number_dated = Databox::BigNumber.new "just_number", date: "2014-02-03"
# Or when setting number
number_dated.set 10_000, "2014-02-03"
number_dated.save
Line Chart
chart = Databox::LineChart.new "my_line"
chart.add 40, "2014-01-29"
chart.add 100, "2014-02-01"
chart.add 500, "2014-02-02"
chart.add 20, "2014-02-03"
chart.save
Bar Chart
chart = Databox::BarChart.new "my_bar"
chart.add 40, "2014-01-29"
chart.add 100, "2014-02-01"
chart.add 500, "2014-02-02"
chart.add 20, "2014-02-03"
chart.save
Compare
compare = Databox::BarChart.new "my_compare"
compare.add 40, "2014-01-29"
compare.add 100, "2014-02-01"
compare.add 500, "2014-02-02"
compare.add 20, "2014-02-03"
compare.save
Interval
interval = Databox::BarChart.new "my_interval"
interval.add 40, "2014-01-29"
interval.add 100, "2014-02-01"
interval.add 500, "2014-02-02"
interval.add 20, "2014-02-03"
interval.save
Pipeline
pipeline = Databox::Pipeline.new "pipe_visits"
pipeline.add "Negotiation", 1_121_603
pipeline.add "Proposal", 3_245_927
pipeline.add "Solution", 10_726_397
pipeline.save
Funnel
funnel = Databox::Funnel.new "funnel_simple"
funnel.add "Requests sent", 33_342
funnel.add "New Accounts", 25_350
funnel.add "Viewed results", 8_930
funnel.add "Return Visits", 3_580
funnel.save
Pie
pie = Databox::Pie.new "my_pie"
pie.add "A", 3_014
pie.add "B", 29_496
pie.add "C", 9_121
pie.add "D", 20_390
pie.add "E", 7_423
pie.save
Progress
progress = Databox::Progress.new "my_progress"
progress.set "33% done", 100, 33
pie.save
Messages
= Databox::Messages.new "just_messages"
.add "I was here"
.add "Second message"
.save
Using client directly
You can also use Databox::Client directly to insert raw KPIs. This is done by invoking Databox::Client and pushing Hash or Array of Hashes to it.
client = Databox.client
client.push([{
key: "name",
date: "2014-01-22T12:00:00",
value: 1
}])
puts client.logs
Versions
Databox is tested on following Ruby versions
- MRI 1.9.3
- MRI 2.0.0