require 'daru/view'
require 'daru'
Install the spreadsheet gem version ~>1.1.1 for using spreadsheet functions. Install the mechanize gem version ~>2.7.5 for using mechanize functions.
false
Daru::View.plotting_library = :highcharts
:highcharts
data = [
['Firefox', 45.0],
['IE', 26.8],
{
:name=> 'Chrome',
:y=> 12.8,
:sliced=> true,
:selected=> true
},
['Safari', 8.5],
['Opera', 6.2],
['Others', 0.7]
]
plt_pie = Daru::View::Plot.new data, type: :pie
#<Daru::View::Plot:0x000000030d2520 @data=[["Firefox", 45.0], ["IE", 26.8], {:name=>"Chrome", :y=>12.8, :sliced=>true, :selected=>true}, ["Safari", 8.5], ["Opera", 6.2], ["Others", 0.7]], @options={:type=>:pie}, @adapter=Daru::View::Adapter::HighchartsAdapter, @chart=#<LazyHighCharts::HighChart:0x000000030d24a8 @series_data=[{:type=>:pie, :name=>nil, :data=>[["Firefox", 45.0], ["IE", 26.8], {:name=>"Chrome", :y=>12.8, :sliced=>true, :selected=>true}, ["Safari", 8.5], ["Opera", 6.2], ["Others", 0.7]]}], @options={:type=>:pie}, @html_options={}, @placeholder="ziurdomevwk">>
# this is done automatically when `Daru::View.plotting_library = :highcharts` is done.
# Daru::View.load_lib_in_iruby 'Highcharts'
plt_pie.show_in_iruby
plt_pie.div
" <script type=\"text/javascript\">\n (function() {\n\n var onload = window.onload;\n window.onload = function(){\n if (typeof onload == \"function\") onload();\n var options = { \"type\": \"pie\",\"chart\": { \"renderTo\": \"nrmficlhbax\" },\"series\": [{ \"type\": \"pie\",\"name\": null,\"data\": [ [ \"Firefox\",45.0 ],[ \"IE\",26.8 ],{ \"name\": \"Chrome\",\"y\": 12.8,\"sliced\": true,\"selected\": true },[ \"Safari\",8.5 ],[ \"Opera\",6.2 ],[ \"Others\",0.7 ] ] }] };\n \n window.chart_nrmficlhbax = new Highcharts.Chart(options);\n\n };\n })()\n </script>\n\n<div id=\"nrmficlhbax\"></div>"
chart_options = {:defaultSeriesType=>"pie" , :margin=> [50, 200, 60, 170], options3d: {
enabled: true,
alpha: 15,
beta: 15,
depth: 50,
viewDistance: 25}}
series = [
['Firefox', 45.0],
['IE', 26.8],
{
:name=> 'Chrome',
:y=> 12.8,
:sliced=> true,
:selected=> true
},
['Safari', 8.5],
['Opera', 6.2],
['Others', 0.7]
]
plot_options = {
pie: {
allowPointSelect: true,
cursor: 'pointer',
depth: 40,
dataLabels: {
enabled: true,
format: '{point.name}'
}
}
}
plt_pie_3d = Daru::View::Plot.new series, type: :pie, name: 'Browser share', chart: chart_options, plotOptions: plot_options
#<Daru::View::Plot:0x000000032d1240 @data=[["Firefox", 45.0], ["IE", 26.8], {:name=>"Chrome", :y=>12.8, :sliced=>true, :selected=>true}, ["Safari", 8.5], ["Opera", 6.2], ["Others", 0.7]], @options={:type=>:pie, :name=>"Browser share", :chart=>{:defaultSeriesType=>"pie", :margin=>[50, 200, 60, 170], :options3d=>{:enabled=>true, :alpha=>15, :beta=>15, :depth=>50, :viewDistance=>25}}, :plotOptions=>{:pie=>{:allowPointSelect=>true, :cursor=>"pointer", :depth=>40, :dataLabels=>{:enabled=>true, :format=>"{point.name}"}}}}, @adapter=Daru::View::Adapter::HighchartsAdapter, @chart=#<LazyHighCharts::HighChart:0x000000032d1218 @series_data=[{:type=>:pie, :name=>"Browser share", :data=>[["Firefox", 45.0], ["IE", 26.8], {:name=>"Chrome", :y=>12.8, :sliced=>true, :selected=>true}, ["Safari", 8.5], ["Opera", 6.2], ["Others", 0.7]]}], @options={:type=>:pie, :name=>"Browser share", :chart=>{:defaultSeriesType=>"pie", :margin=>[50, 200, 60, 170], :options3d=>{:enabled=>true, :alpha=>15, :beta=>15, :depth=>50, :viewDistance=>25}}, :plotOptions=>{:pie=>{:allowPointSelect=>true, :cursor=>"pointer", :depth=>40, :dataLabels=>{:enabled=>true, :format=>"{point.name}"}}}}, @html_options={}, @placeholder="pscmxqrjvzf">>
plt_pie_3d.show_in_iruby