Search code examples
javascriptjsonhtmlcanvasflot

Flot.js repetitive X axis values not showing


I am using flot.js to display a graph. The following JSON is used to display the graph attached below.

{
    "data": [
        ["02:56", 50],
        ["06:56", 120],
        ["10:56", 170],
        ["14:56", 210],
        ["18:56", 260],
        ["22:56", 300],
        ["02:56", 380],
        ["06:56", 420],
        ["10:56", 460],
        ["14:56", 500],
        ["18:56", 570],
        ["22:56", 700]
    ]
}

Above JSON is for only blue color line. Note that X-axis time values 02:26, 06:26... up to six values are repeated second time.

enter image description here

The graph is only plotted for first six values. And When these values are repeated second time, the graph is drawn again from backwards. Would any body please tell me how to display all 12 X-axis points consequtively.


Solution

  • Not a perfect solution. But Space is added at the end of repetitive time values. Here is the modified JSON. And it works fine.

    {
        "data": [
            ["02:56", 50],
            ["06:56", 120],
            ["10:56", 170],
            ["14:56", 210],
            ["18:56", 260],
            ["22:56", 300],
            ["02:56 ", 380],
            ["06:56 ", 420],
            ["10:56 ", 460],
            ["14:56 ", 500],
            ["18:56 ", 570],
            ["22:56 ", 700]
        ]
    }
    

    Since I've added space, both values are not same. But It'll display same in the graph