require 'daru/view' Daru::View.dependent_scripts(['nyaplot', 'highcharts', 'googlecharts']) # line chart : inverted axis opts = { chart: { type: 'spline', inverted: true }, title: { text: 'Atmosphere Temperature by Altitude' }, subtitle: { text: 'According to the Standard Atmosphere Model' }, adapter: :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]] line_6 = Daru::View::Plot.new(data, opts) line_6.show_in_iruby line_basic_options = { title: 'Atmosphere Temperature by Altitude', curveType: 'function', legend: { position: 'bottom' }, adapter: :googlecharts } # We can pass dataframe/vector/data array/ google datatable or Daru-view Table as data source line_basic_chart = Daru::View::Plot.new(data, line_basic_options) line_basic_chart.show_in_iruby dv = Daru::Vector.new [:a, :a, :a, :b, :b, :c], type: :category bar_graph2_frac = Daru::View::Plot.new(dv, type: :bar, method: :fraction, adapter: :nyaplot) bar_graph2_frac.chart.y_label 'Fraction' bar_graph2_frac.show_in_iruby