Sha256: 775669cd3a75b3644829040bce6cc3805f97633bd5480d1057eb6bb7de8696d0

Contents?: true

Size: 969 Bytes

Versions: 5

Compression:

Stored size: 969 Bytes

Contents

ReportsKit.Chart = (function(options) {
  var self = this;

  self.initialize = function(options) {
    self.options = options;
    self.report = options.report;
    self.el = self.report.el;

    self.canvas = $('<canvas />').appendTo(self.el);
  };

  self.render = function() {
    var path = self.el.data('path') + 'reports_kit/reports';
    path += '?properties=' + JSON.stringify(self.report.properties());
    $.getJSON(path, function(response) {
      var data = response.data;
      var chart_data = data.chart_data;
      var options = chart_data.options;

      var args = {
        type: data.type,
        data: chart_data,
        options: options
      };

      if (self.chart) {
        self.chart.data.datasets = chart_data.datasets;
        self.chart.data.labels = chart_data.labels;
        self.chart.update();
      } else {
        self.chart = new Chart(self.canvas, args);
      }
    });
  };

  self.initialize(options);

  return self;
});

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
reports_kit-0.1.0 app/assets/javascripts/reports_kit/lib/chart.js
reports_kit-0.0.4 app/assets/javascripts/reports_kit/lib/chart.js
reports_kit-0.0.3 app/assets/javascripts/reports_kit/lib/chart.js
reports_kit-0.0.2 app/assets/javascripts/reports_kit/lib/chart.js
reports_kit-0.0.1 app/assets/javascripts/reports_kit/lib/chart.js