javascript - flot dynamic bar width -
this code used use bars
bars: {                    show: true,                    barwidth: 12 * 24 * 60 * 60 * 300, that width works me when min , max value of x axis 2014-2-2.gettime() , 2014-9-9 respectively (i trying give idea not exact syntax).
but bar seems wide when data june july
is there way make flot make width , make not large , not small ?
to knowledge, flot won't auto-scale bars.  default barwidth: 1, // in units of x axis, of course, isn't going cut large-scale time plots.  here's attempt simple algorithm leaves equal sized bars , white space in between bars:
calcbarwidth = function(numbars, mintime, maxtime){    // assuming distribution    var totwidth = maxtime - mintime;    // totalwidth = (numbars * barsize) + ((1 + numbars) * barsize), solved barsize    return (totwidth / ((2 * numbars) + 1)); } untested code...
Comments
Post a Comment