Skip to content

Instantly share code, notes, and snippets.

@watert
Created July 25, 2013 09:49
Show Gist options
  • Select an option

  • Save watert/6078340 to your computer and use it in GitHub Desktop.

Select an option

Save watert/6078340 to your computer and use it in GitHub Desktop.
带环比的sparkline视图。based on jquery.sparkline.min.js
$(".sparkline").each(function(idx){
var data = _.map(_.range(60*5),function(i){return 5*i+1000*0.5*Math.sin(i*0.1/Math.PI);});
var data2 = _.map(data,function(r){return r*(Math.random()+2);});
var allData = data.concat(data2);
var config = {chartRangeMin:_.min(allData),chartRangeMax:_.max(allData)};
console.log(config);
$(this).sparkline(data2,_.extend({width:"100%",height:80,lineColor:"hsla(30,100%,60%,0.6)",fillColor:"transparent"},config));
$(this).sparkline(data,_.extend({width:"100%",height:80,lineColor:"hsla(200,100%,60%,0.6)",fillColor:"hsla(200,100%,60%,0.2)",composite: true},config));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment