In [1]:
require 'daru/view'
Install the spreadsheet gem version ~>1.1.1 for using spreadsheet functions.

Install the mechanize gem version ~>2.7.5 for using mechanize functions.
Out[1]:
true
In [2]:
Daru::View.plotting_library = :highcharts
Out[2]:
:highcharts
In [3]:
# Reversed Y axis

    opts = {
        chart_class: 'STock',
        chart: {
            type: 'area'
        },

        rangeSelector: {
            selected: 1
        },

        title: {
            text: 'AAPL Stock Price'
        },

        yAxis: {
            reversed: true,
            showFirstLabel: false,
            showLastLabel: true
        },
        plotOptions: {
            series: {
                tooltip: {
                    valueDecimals: 2
                },
                fillColor: "{
                    linearGradient: {
                        x1: 0,
                        y1: 0,
                        x2: 0,
                        y2: 1
                    },
                    stops: [
                        [0, Highcharts.getOptions().colors[0]],
                        [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
                    ]
                }".js_code,
                threshold: nil
            }
        }
    }

    data = [
             [1147651200000,67.79],
             [1147737600000,64.98],
             [1147824000000,65.26],

             [1149120000000,62.17],
             [1149206400000,61.66],
             [1149465600000,60.00],
             [1149552000000,59.72],

             [1157932800000,72.50],
             [1158019200000,72.63],
             [1158105600000,74.20],
             [1158192000000,74.17],
             [1158278400000,74.10],
             [1158537600000,73.89],

             [1170288000000,84.74],
             [1170374400000,84.75],

             [1174953600000,95.46],
             [1175040000000,93.24],
             [1175126400000,93.75],
             [1175212800000,92.91],

             [1180051200000,113.62],
             [1180396800000,114.35],
             [1180483200000,118.77],
             [1180569600000,121.19],
          ]

    df = Daru::DataFrame.new(
      {
        data1: data.map {|row| row[0]},
        data2: data.map {|row| row[1]}
      }
    )

line_reversed_y_axis = Daru::View::Plot.new(df, opts)
line_reversed_y_axis.show_in_iruby
Out[3]:
In [4]:
# Styled scrollbar

    opts = {
        chart_class: 'Stock',
        rangeSelector: {
            selected: 1
        },

        title: {
            text: 'AAPL Stock Price'
        },

        scrollbar: {
            barBackgroundColor: 'gray',
            barBorderRadius: 7,
            barBorderWidth: 0,
            buttonBackgroundColor: 'gray',
            buttonBorderWidth: 0,
            buttonBorderRadius: 7,
            trackBackgroundColor: 'none',
            trackBorderWidth: 1,
            trackBorderRadius: 8,
            trackBorderColor: '#CCC'
        }
    }
    data = [
             [1147651200000,67.79],
             [1147737600000,64.98],
             [1147824000000,65.26],

             [1149120000000,62.17],
             [1149206400000,61.66],
             [1149465600000,60.00],
             [1149552000000,59.72],

             [1157932800000,72.50],
             [1158019200000,72.63],
             [1158105600000,74.20],
             [1158192000000,74.17],
             [1158278400000,74.10],
             [1158537600000,73.89],

             [1170288000000,84.74],
             [1170374400000,84.75],

             [1174953600000,95.46],
             [1175040000000,93.24],
             [1175126400000,93.75],
             [1175212800000,92.91],

             [1180051200000,113.62],
             [1180396800000,114.35],
             [1180483200000,118.77],
             [1180569600000,121.19],
          ]

    df = Daru::DataFrame.new(
          {
            data1: data.map {|row| row[0]},
            data2: data.map {|row| row[1]}
          }
        )

line_styled_scrollbar = Daru::View::Plot.new(df, opts)
line_styled_scrollbar.show_in_iruby
Out[4]:
In [5]:
# Disabled scrollbar

    opts = {
        chart_class: 'stock',
        rangeSelector: {
            selected: 1
        },

        title: {
            text: 'AAPL Stock Price'
        },

        scrollbar: {
            enabled: false
        }
    }

    data = [
             [1147651200000,67.79],
             [1147737600000,64.98],
             [1147824000000,65.26],

             [1149120000000,62.17],
             [1149206400000,61.66],
             [1149465600000,60.00],
             [1149552000000,59.72],

             [1157932800000,72.50],
             [1158019200000,72.63],
             [1158105600000,74.20],
             [1158192000000,74.17],
             [1158278400000,74.10],
             [1158537600000,73.89],

             [1170288000000,84.74],
             [1170374400000,84.75],

             [1174953600000,95.46],
             [1175040000000,93.24],
             [1175126400000,93.75],
             [1175212800000,92.91],

             [1180051200000,113.62],
             [1180396800000,114.35],
             [1180483200000,118.77],
             [1180569600000,121.19],
          ]
    
    df = Daru::DataFrame.new(
          {
            data1: data.map {|row| row[0]},
            data2: data.map {|row| row[1]}
          }
        )

line_disabled_scrollbar = Daru::View::Plot.new(df, opts)
line_disabled_scrollbar.show_in_iruby
Out[5]:
In [6]:
# Disabled navigator

    opts = {
        chart_class: 'sTock',
        rangeSelector: {
            selected: 1
        },

        title: {
            text: 'AAPL Stock Price'
        },

        navigator: {
            enabled: false
        }
    }

    data = [
             [1147651200000,67.79],
             [1147737600000,64.98],
             [1147824000000,65.26],

             [1149120000000,62.17],
             [1149206400000,61.66],
             [1149465600000,60.00],
             [1149552000000,59.72],

             [1157932800000,72.50],
             [1158019200000,72.63],
             [1158105600000,74.20],
             [1158192000000,74.17],
             [1158278400000,74.10],
             [1158537600000,73.89],

             [1170288000000,84.74],
             [1170374400000,84.75],

             [1174953600000,95.46],
             [1175040000000,93.24],
             [1175126400000,93.75],
             [1175212800000,92.91],

             [1180051200000,113.62],
             [1180396800000,114.35],
             [1180483200000,118.77],
             [1180569600000,121.19],
          ]

line_disabled_navigator = Daru::View::Plot.new(data, opts)
line_disabled_navigator.show_in_iruby
Out[6]:
In [ ]: