选择/突出显示 - 需要具有简单的价值,而不是范围

时间:2015-03-07 10:03:53

标签: selection flot highlight

我有一个flot图表,需要选择/突出显示一个值。选择需要设置“从 - 到”范围,静态数据是否容易,但是当数据集从0..0.1更改为0..100000时,我必须计算此范围以设置范围以显示为线。我根本不需要选择范围,我想通过简单的线条选择!有可能吗?

        var hoursPerTmpForSelection = hoursPer + 1;
        if (hoursPer > 300)
            hoursPerTmpForSelection = hoursPer + 10;
        else if (hoursPer > 100)
            hoursPerTmpForSelection = hoursPer + 6;
        else if (hoursPer > 50)
            hoursPerTmpForSelection = hoursPer + 4;
        else if (hoursPer > 10)
            hoursPerTmpForSelection = hoursPer + 1;
    else if (hoursPer > 1)
            hoursPerTmpForSelection = hoursPer + 0.5;
        else if (hour <=1)
            hoursPerTmpForSelection = hoursPer + 0.2;

        $.plot("#daytimeChart", [daytimeData], {
            series: {
                bars: {
                    show: true,
                    barWidth: 0.8,
                    align: "center",
                    lineWidth: 0,
                    fillColor: "rgba(153, 153, 255, 0.6)"
                }
            },
            yaxes: [{
                axisLabel: 'Hours per week'
            }],
            xaxis: {
                mode: "categories",
                tickLength: 0,
                font: {
                    lineheight: 0,
                    size: 0
                }
            },
            selection: { mode: "y" }
        }).setSelection({ yaxis: { from: hoursPer, to: hoursPerTmpForSelection } });

如果我设置了一点“hoursPerTmpForSelection”值 - 根本没有显示行,如果我设置太多 - 行很厚

我在图像上绘制了我想要做的事情

http://magicscreenshot.blob.core.windows.net/screenshots/giFYyhXdz0A.jpg

1 个答案:

答案 0 :(得分:3)

您所描述的内容听起来更像是标记而不是选择(请参阅此exampledocumentation)。扩展您的选项以包含以下内容:

grid: { markings: [
    { color: #888, lineWidth: 1, yaxis: { from: 320, to: 320 } }
] }