Skip to content Skip to sidebar Skip to footer

Display Timeline/Linear Data In Flot

Does anyone know how to get flot to display a type of 'timeline'? E.g. Y: Person1| ----- ------- Person2| ------- ------- Person3| -- ----- ---- Person4| -------

Solution 1:

Finally found the answer. Use the configuration 'ticks'.

Answer :

//american dates
    var d1 = [[(new Date("01/01/2009")).getTime(), 1], [(new Date("01/10/2009")).getTime(), 1]];
    var d2 = [[(new Date("05/05/2009")).getTime(), 2], [(new Date("06/23/2009")).getTime(), 2]];
    var d3 = [[(new Date("03/10/2009")).getTime(), 3], [(new Date("03/15/2009")).getTime(), 3]];
    //var d1 = [[0, 5], [5, 5], null, [5, 10], [15, 10]];
    var placeholder = $("#placeholder");

    // plot it
    var plot = $.plot(placeholder, [d1,d2,d3], {
        xaxis:{mode:"time", timeformat:"%b.%y"},
        yaxis:{ticks:[[1, "Apple"], [2, "Microsoft"], [3, "Dell"]]}
    });

Solution 2:

View the source of http://people.iola.dk/olau/flot/examples/basic.html pay particular attention to the comment // a null signifies separate line segments I think that should get you where you want to be.


Post a Comment for "Display Timeline/Linear Data In Flot"