问题描述:

I can't create flot bars with reverse y asix.

From the point of this helps:

transform: function (v) {return -v; },

inverseTransform: function (v) { return -v; }

Вut the graphics just flips,

example: http://jsbin.com/eloven/2/edit

Help please!

网友答案:

If this is what you mean by reverse y axis (11, 10 , 9 ... 1),

xaxis: {
    transform: function(v) {
        return -v;
    },
    inverseTransform: function(v) {
        return -v;
    }
},
yaxis: {
    show: true,
    tickSize: 200

}
网友答案:

solution: 0 - (currentValue - maxValue)

#graph-bars .bar-wrap {
    height: 45px;
    display: block;
    margin: 0 0 10px;
    border-bottom: 1px solid #9D9D9C;
    position: relative;
}

#graph-bars .bar {
    background: #808080;
    color: #808080;
    width: 50px;
    min-height: 5px;
    max-height: 100%;
    position: absolute;
    bottom: 0;
    left: 20%;
}

Array.max = function( array ) {
    return Math.max.apply( Math, array );
};

for(...) {// i -counter
    var max = Array.max(years[lastYear]);
    var height = 0 - (years[lastYear][i] - max); // 0 - (currentValue - maxValue)

    $('#graph-bars').append("<span class='bar-wrap'><span class='bar' style='height:"+ height +"%'></span>");
}
相关阅读:
Top