Search code examples
javascriptjqueryflotgraphing

Graphing this with Jquery.Flot or similar


I'm trying to draw this chart with Flot. There's a flat line from 0 to 10 (at y=1). and points at x=2, x=3, x=7 all also at y=1.

________O____O_______________O_____________

0   1   2    3   4   5   6   7   8   9   10

I'm also open to anything else other than Flot, if there's a clear example how to do what I'm trying to do, that I can almost copy/paste.


Solution

  • Pretty easy using flot:

    <div id="placeholder" style="width:600px;height:300px;"></div>
    <script type="text/javascript">
    $(function () {
    
        var someLine = [[0, 1], [10, 1]];
        var somePoints = [[2,1],[3,1],[7,1]];
    
        $.plot($("#placeholder"),[
        {
            data: someLine,
            lines: { show: true}
        },
        {
            data: somePoints,
            points: { show: true}
        }
        ]);
    });
    </script>
    

    enter image description here