【问题标题】:implementing threshold for bar graphs using flot api使用 flot api 实现条形图的阈值
【发布时间】:2013-05-08 20:01:29
【问题描述】:

我正在使用 flot 来绘制图表。我想实现该功能,以便能够突出显示图表中 10% 的增长,以不同于我现在使用的颜色显示。 我使用的代码是:

var options_blue = {
    series: {
        color: 'blue',
        threshold: { above: 5, color: 'green' },
        bars: { show: true, barWidth: 20 * 20 }
    },
    xaxis: { show: false, min: 1 },
    yaxis: { show: false, min: 1, max: max_value }
};

var options_red = {
    series: {
        color: '#ff0000',
        threshold: { above: 10, color:'green' },    
        bars: { show: true, barWidth: 20 * 20 }
    },
    threshold: { above: 5, color: "yellow" },
    xaxis: { show: false, min: 1 },
    yaxis: { show: false, min: 5, max: max_value }
};

我正在使用 jquery.flot.threshold.js,但是超过阈值的图表颜色没有变化。

【问题讨论】:

    标签: jquery graph flot threshold


    【解决方案1】:

    您使用的是“高于”,但阈值插件仅支持“低于”。所以你只需要交换你的系列和阈值颜色,并改用'below'。

    另请注意,在您的 options_red 中,您在系列选项之外还有第二个阈值选项。阈值插件仅在系列选项中查找选项,因此第二个将被忽略。

    【讨论】:

    • 我纠正了代码中的错误。但我仍然无法使用 jquery.flot.threshold.js 绘制条形图 当我使用 jquery.flot.threshold.min.js 时,我能够绘制两种不同的颜色,但图表显示为单线。对此提供任何可能的解决方案。
    • 您需要提供更多信息; '显示为单行'是什么意思?你用的是什么版本的 Flot? JS控制台有错误吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多