积算面积图结合基于面积图的折线图阈值着色

时间:2019-10-22 13:43:53

标签: javascript jquery charts flot

在Flot图表中,如何根据阈值为不同颜色的单线着色。

在下面的图表中,我要在横断面图时将线条颜色设为红色(在2和4之间的尖峰需要设为红色)     Fiddle  enter image description here

代码示例:

$(function() {

    var d3 = [];
    var d5 = [];
    for (var i = 0; i < 14; i += 0.5) {
        var v1 = -5 - Math.cos(i);
        var v2 = -8 - Math.sin(i);
        var v3 = (v1+v2)/2;
        if(i==3){
        v3=v3+4;
        }
        d3.push([i, v1,  v2]);
        d5.push([i, v3 ]);
    }


    $.plot("#placeholder", [{
            label: "Fill between",
            data: d3,
            lines: { show: true,  lineWidth: 0, fill: true, zero: false }
        },
        d5]
    );

    // Add the Flot version string to the footer

    $("#footer").prepend("Flot " + $.plot.version + " &ndash; ");
});

0 个答案:

没有答案