require 'daru/view'
true
require 'daru'
true
Daru::View.load_lib_in_iruby('Nyaplot')
Daru::View.plotting_library = :highcharts
:highcharts
df = Daru::DataFrame.new({a:['A', 'B', 'C', 'D', 'E'], b:[10,20,30,40,50]})
Daru::DataFrame(5x2) | ||
---|---|---|
a | b | |
0 | A | 10 |
1 | B | 20 |
2 | C | 30 |
3 | D | 40 |
4 | E | 50 |
plt = Daru::View::Plot.new df, type: :bar, x: :a, y: :b
#<Daru::View::Plot:0x007fc19a21b728 @adapter=Daru::View::Adapter::HighchartsAdapter, @chart=#<LazyHighCharts::HighChart:0x007fc199198838 @series_data=[{:type=>:bar, :name=>nil, :data=>[["A", 10], ["B", 20], ["C", 30], ["D", 40], ["E", 50]]}], @options={:title=>{:text=>nil}, :legend=>{:layout=>"vertical", :style=>{}}, :xAxis=>{}, :yAxis=>{:title=>{:text=>nil}, :labels=>{}}, :tooltip=>{:enabled=>true}, :credits=>{:enabled=>false}, :plotOptions=>{:areaspline=>{}}, :chart=>{:defaultSeriesType=>"line", :renderTo=>nil}, :subtitle=>{}}, @html_options={}, @placeholder="graph">>
plt.class
Daru::View::Plot
plt.div
" <script type=\"text/javascript\">\n $(function() {\n\n var options = { \"title\": { \"text\": null },\"legend\": { \"layout\": \"vertical\",\"style\": { } },\"xAxis\": { },\"yAxis\": { \"title\": { \"text\": null },\"labels\": { } },\"tooltip\": { \"enabled\": true },\"credits\": { \"enabled\": false },\"plotOptions\": { \"areaspline\": { } },\"chart\": { \"defaultSeriesType\": \"line\",\"renderTo\": \"cebvwfdmznl\" },\"subtitle\": { },\"series\": [{ \"type\": \"bar\",\"name\": null,\"data\": [ [ \"A\",10 ],[ \"B\",20 ],[ \"C\",30 ],[ \"D\",40 ],[ \"E\",50 ] ] }] };\n \n window.chart_cebvwfdmznl = new Highcharts.Chart(options);\n\n });\n </script>\n\n<div id=\"cebvwfdmznl\"></div>"
plt.init_iruby
plt.show_in_iruby
plt_gauge = Daru::View::Plot.new df, type: :gauge, x: :a, y: :b
#<Daru::View::Plot:0x007fc19aad07b0 @adapter=Daru::View::Adapter::HighchartsAdapter, @chart=#<LazyHighCharts::HighChart:0x007fc19a1716d8 @series_data=[{:type=>:gauge, :name=>nil, :data=>[["A", 10], ["B", 20], ["C", 30], ["D", 40], ["E", 50]]}], @options={:title=>{:text=>nil}, :legend=>{:layout=>"vertical", :style=>{}}, :xAxis=>{}, :yAxis=>{:title=>{:text=>nil}, :labels=>{}}, :tooltip=>{:enabled=>true}, :credits=>{:enabled=>false}, :plotOptions=>{:areaspline=>{}}, :chart=>{:defaultSeriesType=>"line", :renderTo=>nil}, :subtitle=>{}}, @html_options={}, @placeholder="graph">>
plt_gauge.show_in_iruby
dv = Daru::Vector.new [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
Daru::Vector(8) | |
---|---|
0 | 43934 |
1 | 52503 |
2 | 57177 |
3 | 69658 |
4 | 97031 |
5 | 119931 |
6 | 137133 |
7 | 154175 |
plt_line = Daru::View::Plot.new dv, type: :line
#<Daru::View::Plot:0x007fc19ab09830 @adapter=Daru::View::Adapter::HighchartsAdapter, @chart=#<LazyHighCharts::HighChart:0x007fc19ab09628 @series_data=[{:type=>:line, :name=>nil, :data=>[43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]}], @options={:title=>{:text=>nil}, :legend=>{:layout=>"vertical", :style=>{}}, :xAxis=>{}, :yAxis=>{:title=>{:text=>nil}, :labels=>{}}, :tooltip=>{:enabled=>true}, :credits=>{:enabled=>false}, :plotOptions=>{:areaspline=>{}}, :chart=>{:defaultSeriesType=>"line", :renderTo=>nil}, :subtitle=>{}}, @html_options={}, @placeholder="graph">>
Daru::View.plotting_library
:highcharts
plt_line = Daru::View::Plot.new dv, type: :spline
#<Daru::View::Plot:0x007fc199328c20 @adapter=Daru::View::Adapter::HighchartsAdapter, @chart=#<LazyHighCharts::HighChart:0x007fc1993286d0 @series_data=[{:type=>:spline, :name=>nil, :data=>[43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]}], @options={:title=>{:text=>nil}, :legend=>{:layout=>"vertical", :style=>{}}, :xAxis=>{}, :yAxis=>{:title=>{:text=>nil}, :labels=>{}}, :tooltip=>{:enabled=>true}, :credits=>{:enabled=>false}, :plotOptions=>{:areaspline=>{}}, :chart=>{:defaultSeriesType=>"line", :renderTo=>nil}, :subtitle=>{}}, @html_options={}, @placeholder="graph">>
plt_line.chart
#<LazyHighCharts::HighChart:0x007fc1993286d0 @series_data=[{:type=>:spline, :name=>nil, :data=>[43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]}], @options={:title=>{:text=>nil}, :legend=>{:layout=>"vertical", :style=>{}}, :xAxis=>{}, :yAxis=>{:title=>{:text=>nil}, :labels=>{}}, :tooltip=>{:enabled=>true}, :credits=>{:enabled=>false}, :plotOptions=>{:areaspline=>{}}, :chart=>{:defaultSeriesType=>"line", :renderTo=>nil}, :subtitle=>{}}, @html_options={}, @placeholder="graph">
plt_line.show_in_iruby