Sha256: 43758169f8818872225970900bf212f3a5833a7bae735bd1445a0a22483106ea

Contents?: true

Size: 1.3 KB

Versions: 57

Compression:

Stored size: 1.3 KB

Contents

- resolution = 1
- data_id = "data-" << id
- Open.write(@step.file(data_id), plot_data.to_json)
- x_label = nil unless defined? x_label
- y_label = nil unless defined? y_label

- extra = "" unless defined? extra

- url = @uri

%svg(id=id)

:ruby
  setup ||=<<-EOF
    var graph = nv.models.discreteBarChart()
        .x(function(d) { return d.label })
        .y(function(d) { return d.value })
        .staggerLabels(true)
        .showValues(true)

        graph.tooltip.enabled(true)
  EOF

  setup += "\ngraph.xAxis.axisLabel('#{x_label}')" if x_label
  setup += "\ngraph.yAxis.axisLabel('#{y_label}')" if y_label

:javascript
  

  defer(function(){

    var id = '#{id}';
    var selector = "svg#" + id
    var uri = add_parameter(rbbt.url_add_script_name('#{url}'), '_file', '#{data_id}')

    var resolution = #{resolution}
    var svg = $(selector)
    var figure = svg.parent('.figure')
    var W = figure.innerWidth()
    var H = figure.innerHeight()

    nv.addGraph({
      generate: function(){
        #{setup}

        #{extra}

        $.get(uri, function(data){
          var json = JSON.parse(data)
          console.log(json)

          d3.select(selector)
            .datum(json)
            .call(graph);
        })

        nv.utils.windowResize(graph.update);

        return graph;
      },
    })
  })




Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
rbbt-rest-1.8.136 share/views/tools/nvd3/chart.haml
rbbt-rest-1.8.135 share/views/tools/nvd3/chart.haml
rbbt-rest-1.8.134 share/views/tools/nvd3/chart.haml
rbbt-rest-1.8.133 share/views/tools/nvd3/chart.haml
rbbt-rest-1.8.132 share/views/tools/nvd3/chart.haml
rbbt-rest-1.8.131 share/views/tools/nvd3/chart.haml
rbbt-rest-1.8.130 share/views/tools/nvd3/chart.haml
rbbt-rest-1.8.129 share/views/tools/nvd3/chart.haml
rbbt-rest-1.8.126 share/views/tools/nvd3/chart.haml
rbbt-rest-1.8.123 share/views/tools/nvd3/chart.haml
rbbt-rest-1.8.122 share/views/tools/nvd3/chart.haml
rbbt-rest-1.8.121 share/views/tools/nvd3/chart.haml
rbbt-rest-1.8.120 share/views/tools/nvd3/chart.haml
rbbt-rest-1.8.119 share/views/tools/nvd3/chart.haml
rbbt-rest-1.8.118 share/views/tools/nvd3/chart.haml
rbbt-rest-1.8.117 share/views/tools/nvd3/chart.haml
rbbt-rest-1.8.116 share/views/tools/nvd3/chart.haml
rbbt-rest-1.8.115 share/views/tools/nvd3/chart.haml
rbbt-rest-1.8.114 share/views/tools/nvd3/chart.haml
rbbt-rest-1.8.113 share/views/tools/nvd3/chart.haml