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]:
# dynamic-update/
    opts = {
        chart: {
            type: 'spline',
            animation: "Highcharts.svg".js_code, # don't animate in old IE
            marginRight: 10,
            events: {
                load: "function () {

                                    // set up the updating of the chart each second
                                    var series = this.series[0];
                                    setInterval(function () {
                                        var x = (new Date()).getTime(), // current time
                                            y = Math.random();
                                        series.addPoint([x, y], true, true);
                                    }, 1000);
                                }".js_code
            }
        },
        title: {
            text: 'Live random data'
        },
        xAxis: {
            type: 'datetime',
            tickPixelInterval: 150
        },
        yAxis: {
            title: {
                text: 'Value'
            },
            plotLines: [{
                value: 0,
                width: 1,
                color: '#808080'
            }]
        },
        tooltip: {
            formatter: "function () {
                            return '<b>' + this.series.name + '</b><br/>' +
                                Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) + '<br/>' +
                                Highcharts.numberFormat(this.y, 2);
                        }".js_code
        },
        legend: {
            enabled: false
        },
        exporting: {
            enabled: false
        },
    }

    series_dt = [
      {
            name: 'Random data',
            data: "(function () {
                            // generate an array of random data
                            var data = [],
                                time = (new Date()).getTime(),
                                i;

                            for (i = -19; i <= 0; i += 1) {
                                data.push({
                                    x: time + i * 1000,
                                    y: Math.random()
                                });
                            }
                            return data;
                        }())".js_code
        }
    ]

dyn_update = Daru::View::Plot.new
dyn_update.chart.options = opts;
dyn_update.chart.series_data = series_dt
dyn_update.show_in_iruby
Out[3]:
In [4]:
# dynamic-click-to-add/
    opts = {
      chart: {
          type: 'scatter',
          margin: [70, 50, 60, 80],
          events: {
              click: "function (e) {
                                // find the clicked values and the series
                                var x = Math.round(e.xAxis[0].value),
                                    y = Math.round(e.yAxis[0].value),
                                    series = this.series[0];

                                // Add it
                                series.addPoint([x, y]);

                            }".js_code
          }
      },
      title: {
          text: 'User supplied data'
      },
      subtitle: {
          text: 'Click the plot area to add a point. Click a point to remove it.'
      },
      xAxis: {
          gridLineWidth: 1,
          minPadding: 0.2,
          maxPadding: 0.2,
          maxZoom: 60
      },
      yAxis: {
          title: {
              text: 'Value'
          },
          minPadding: 0.2,
          maxPadding: 0.2,
          maxZoom: 60,
          plotLines: [{
              value: 0,
              width: 1,
              color: '#808080'
          }]
      },
      legend: {
          enabled: false
      },
      exporting: {
          enabled: false
      },
      plotOptions: {
          series: {
              lineWidth: 1,
              point: {
                  events: {
                      'click': "function () {
                                                if (this.series.data.length > 1) {
                                                    this.remove();
                                                }
                                            }".js_code
                  }
              }
          }
      },

    }

    series_dt = [
      {data: [[20, 20], [80, 80]]}
    ]

dyn_click_add = Daru::View::Plot.new
dyn_click_add.chart.options = opts;
dyn_click_add.chart.series_data = series_dt
dyn_click_add.show_in_iruby
Out[4]: