~bac/charmworld/bug-1257878

« back to all changes in this revision

Viewing changes to charmworld/static/sparklines.js

  • Committer: Tarmac
  • Author(s): j.c.sackett
  • Date: 2013-11-20 15:59:59 UTC
  • mfrom: (464.1.2 better-sparklines)
  • Revision ID: tarmac-20131120155959-1q1bkgiy9vbshrz6
Remove buggy jspark and create better sparklines.

Approved by Juju Gui Bot, Aaron Bentley.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
$(window).load(function() {
 
2
  $.map($('.sparkline'), function(item) {
 
3
    var data = $.parseJSON(item.getAttribute('data-values'));
 
4
    var graph = d3.select(item).append("svg:svg");
 
5
 
 
6
    var xlimit = data.length - 1;
 
7
    var ylimit = Math.max.apply(Math, data);
 
8
 
 
9
    var x = d3.scale.linear().domain([0, xlimit]).range([0, 20]);
 
10
    var y = d3.scale.linear().domain([0, ylimit]).range([0, 10]);
 
11
 
 
12
    var line = d3.svg.line().x(function(d,i) { 
 
13
      return x(i); 
 
14
    }).y(function(d) { 
 
15
      return y(d); 
 
16
    });
 
17
    graph.append("svg:path").attr("d", line(data));
 
18
  });
 
19
});