In [1]:
require 'daru/view'
Out[1]:
In [2]:
Daru::View.plotting_library = :highcharts
Out[2]:
In [3]:
graph = Daru::View::Plot.new
Out[3]:
In [4]:
graph.chart.class
Out[4]:
In [5]:
graph.chart.to_html
Out[5]:
In [7]:
graph.show_in_iruby
Out[7]:
In [8]:
g = Daru::View::Plot.new
graph = g.chart.tap do |f|
f.series(:name => 'John', :data => [3, 20])
f.series(:name => 'Jane', :data => [1, 3])
# without overriding
f.options[:chart][:defaultSeriesType] = "area"
f.options[:chart][:inverted] = true
f.options[:legend][:layout] = "horizontal"
f.options[:xAxis][:categories] = ["uno", "dos", "tres", "cuatro"]
end
Out[8]:
In [9]:
graph.series_data
Out[9]:
In [10]:
g.show_in_iruby
Out[10]:
In [11]:
graph.series_data.delete({type: nil, :name => nil, :data => []})
Out[11]:
In [12]:
graph.series_data
Out[12]:
In [13]:
graph.options[:xAxis][:categories]
Out[13]:
In [14]:
graph.options[:legend][:layout]
Out[14]:
In [15]:
df = Daru::DataFrame.new(
{
a: [1, 3, 5, 2, 5, 0],
b: [1, 5, 2, 5, 1, 0],
c: [1, 6, 7, 2, 6, 0]
}, index: 'a'..'f'
)
Out[15]:
In [16]:
df.class
Out[16]:
In [17]:
Daru::View::Plot.new(df, type: :bar)
Out[17]:
In [18]:
df = Daru::DataFrame.new(
{
a: [1, 2, 3, 4, 5, 6],
b: [1, 5, 2, 5, 1, 0],
c: [1, 6, 7, 2, 6, 0]
}, index: 'a'..'f'
)
Out[18]:
In [19]:
plt = Daru::View::Plot.new(df, type: :line, x: :a, y: :c)
Out[19]:
In [20]:
plt.show_in_iruby
Out[20]:
In [21]:
plt.div
Out[21]:
In [22]:
df.delete_vector :b
Out[22]:
In [23]:
plt = Daru::View::Plot.new(df, type: :line)
Out[23]:
In [24]:
plt.show_in_iruby
Out[24]:
In [ ]: