In [1]:
require 'daru/view'
Out[1]:
In [2]:
Daru::View.plotting_library = :googlecharts
Out[2]:
In [3]:
# Since we want to use more features of google chart using google data table. Here v and f (formatters) is used.
# These can't be used in dataframe/vectors and using data array .
# Hence directly generating the google data table from the options cols and rows.
opts = {
cols: [{id: 'Name', label: 'Name', type: 'string'},
{id: 'Manager', label: 'Manager', type: 'string'},
{id: 'ToolTip', label: 'ToolTip', type: 'string'},
],
rows: [
{c:[{v:'Mike', f:'Mike<div style="color:red; font-style:italic">President</div>'}, {v: ''}, {v: 'The President'}]},
{c:[{v:'Jim', f:'Jim<div style="color:red; font-style:italic">Vice President</div>'}, {v: 'Mike'}, {v: 'VP'}]},
{c:[{v: 'Alice'}, {v: 'Mike'}, {v: ''}]},
{c:[{v: 'Bob'}, {v: 'Jim'}, {v: 'Bob Sponge'}]},
{c:[{v: 'Carol'}, {v: 'Bob'}, {v: ''}]},
]
}
org_chart_table = Daru::View::Table.new(opts)
org_chart_table.show_in_iruby
Out[3]:
In [4]:
org_chart_options = {
type: :org, allowHtml:true
}
org_chart_chart = Daru::View::Plot.new(org_chart_table.table, org_chart_options)
org_chart_chart.show_in_iruby
Out[4]:
In [ ]: