Sha256: 3bfd169b1600c99eab0fd9aebd190eea45d5a3e06f9765630220a8c0cf72b4e9

Contents?: true

Size: 1.89 KB

Versions: 8

Compression:

Stored size: 1.89 KB

Contents

L.provide('OML.pie_chart2', ["graph/js/abstract_nv_chart", "#OML.abstract_nv_chart"], function () {

  OML.pie_chart2 = OML.abstract_nv_chart.extend({
    decl_properties: [
      ['label', 'key', {property: 'label'}], 
      ['value', 'key', {property: 'value'}],
      ['color', 'color', 'category10()'],
      
    ],
        
    defaults: function() {
      return this.deep_defaults({
        tooltips: true,
        show_labels: true,
        donut: false,
        label_threshold: 0.02, //if slice percentage is under this, don't show label 
        show_legend: true,
        
        margin: {
          top: 20, right: 0, bottom: 100, left: 50 
        }    
      }, OML.pie_chart2.__super__.defaults.call(this));      
    },

    _create_model: function() {
      return  nv.models.pieChart();      
    },
    
    _configure_mapping: function(m, chart) {
      var label_f = m.label;
      var value_f = m.value;
      chart.x(function(d) {
        var v = label_f(d);        
        return v;
      })
      chart.y(function(d) {
        var v = value_f(d);
        return v;
      })
      chart.color(function(d, i) {
        // TODO: This is most likely broken. The color mapping
        // function should map from an element of 'd', not 'i'
        var v = m.color(i);
        return v;
      })
    },
    
    _configure_options: function(opts, chart) {
      OML.pie_chart2.__super__._configure_options.call(this, opts, chart);
      chart
        .tooltips(opts.tooltips)
        .showLabels(opts.show_labels)
        .donut(opts.donut)
        .labelThreshold(opts.label_threshold)
        .showLegend(opts.show_legend)  
        .margin(opts.margin)
        ;
    },
    
    _datum: function(data, chart) {
      return [{
                key: "???",
                values: data
              }];
    }
    
  })
})

/*
  Local Variables:
  mode: Javascript
  tab-width: 2
  indent-tabs-mode: nil
  End:
*/

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
omf_web-1.0.0 share/htdocs/graph/js/pie_chart2.js
omf_web-0.9.9 share/htdocs/graph/js/pie_chart2.js
omf_web-0.9.8 share/htdocs/graph/js/pie_chart2.js
omf_web-0.9.7 share/htdocs/graph/js/pie_chart2.js
omf_web-0.9.6 share/htdocs/graph/js/pie_chart2.js
omf_web-0.9.5 share/htdocs/graph/js/pie_chart2.js
omf_web-0.9.4 share/htdocs/graph/js/pie_chart2.js
omf_web-0.9.3 share/htdocs/graph/js/pie_chart2.js