10 09/2014

flot.barnumbers add font color size control

最后更新: Wed Sep 10 2014 12:35:31 GMT+0800

The deafult jquery.flot.barnumbers.js can not modify the

  • font family
  • font size
  • text color

So i add some code between lines 47-48

/*by davidguoshuang at gmail.com -start*/
if(series.bars.numbers.color){
  ctx.fillStyle=series.bars.numbers.color;
}
if(series.bars.numbers.font){
  ctx.font=series.bars.numbers.font;
}
/*by davidguoshuang at gmail.com -end*/

Usage:

bars:{
show:true,
barWidth:0.65,
align:'center',
numbers:{
  color:'rgba(0,0,0,.5)',//text color
  font:'14px arial',//font size and family
  show:true,
  xAlign:50,//align center
  yAlign: function(y) { return y + 5; } //upside of bars
}

Download the .js file
Demo