require 'daru/view' Daru::View.plotting_library = :highcharts data = [[0, 15], [10, -50], [20, -56.5], [30, -46.5], [40, -22.1], [50, -2.5], [60, -27.7], [70, -55.7], [80, -76.5]] opts = { chart: { type: 'spline', inverted: true }, title: { text: 'Atmosphere Temperature by Altitude' }, subtitle: { text: 'According to the Standard Atmosphere Model' }, xAxis: { reversed: false, title: { enabled: true, text: 'Altitude' }, labels: { formatter: "function () { return this.value + 'km'; }".js_code }, maxPadding: 0.05, showLastLabel: true }, yAxis:{ title: { text: 'Temperature' }, labels: { formatter: "function () { return this.value + '°'; }".js_code }, lineWidth: 2 }, legend:{ enabled: false }, tooltip:{ headerFormat: '{series.name}
', pointFormat: '{point.x} km: {point.y}°C' }, plotOptions:{ spline: { marker: { enable: false } } }, } chart1 = Daru::View::Plot.new data, opts chart1.show_in_iruby # add another chart chart1.add_series({ :data => [[10, 15], [20, -50], [30, -56.5], [40, -46.5], [50, -22.1], [55, -2.5], [65, -27.7], [80, -55.7], [90, -76.5]]}) # add another chart opts = { :type=> 'pie',:name=> 'Total consumption', :data=> [ {:name=> 'Jane', :y=> 13, :color=> 'red'}, {:name=> 'John', :y=> 23,:color=> 'green'}, {:name=> 'Joe', :y=> 19,:color=> 'blue'} ], :center=> [100, 150], :size=> 100, :showInLegend=> false } chart1.add_series(opts) chart1.show_in_iruby chart1.chart.class chart1.chart.series_data chart1.chart.series_data[2] # all te series options can be updated # removing last pie chart, that was added chart1.chart.series_data[2] = {} chart1.show_in_iruby chart1.chart.options # all the `options` can be set or updated chart1.chart.options[:chart][:inverted] = false chart1.div chart1.show_in_iruby # or do chart1.chart (but it will show chart when notebook is saved) # can be updated chart1.chart.placeholder # can be updated chart1.chart.html_options chart1.chart.html_options[:style] = "opacity: 0.5; height: 720px; width: 1020px" chart1.show_in_iruby