require 'daru/view'
Daru::View.plotting_library = :highcharts
df = Daru::DataFrame.new({b: [11,12,13,14,15], a: [1,2,3,4,5],
c: [11,22,33,44,55]},
order: [:a, :b, :c],
index: [:one, :two, :three, :four, :five])
html_code = "
" + df.to_html_thead + df.to_html_tbody + "
"
IRuby.html html_code
opts = {
data: {
table: 'table_id1'
},
chart: {
type: 'column'
},
title: {
text: 'Data extracted from a HTML table in the page'
},
yAxis: {
allowDecimals: false,
title: {
text: 'Units'
}
},
tooltip: {
formatter: "function () {
return '' + this.series.name + '
' +
this.point.y + ' ' + this.point.name.toLowerCase();
}".js_code
},
adapter: :highcharts
}
line_1 = Daru::View::Plot.new
line_1.chart.options = opts
out = html_code + line_1.div
# must show chart as well. In IRuby notebook it is not working. Works well in web application
IRuby.html out