Jquery Flot Chart timeseries option in reverse chronological

Does anybody know how to use the Flot timeseries in a reverse chronological way, to show the latest dates first? I've been ting to search for an option but couldn't find one in the API. Here is my code

var plot = $.plot("#placeholder1", [data], {
        series: {
                lines: { 
                    show: true, 
                    fill: 0.1
                },
                points: { show: true, 
                    fill: 0.05 }
        },
        xaxis: 
        {    
            mode: "time",
            minTickSize: [1, "day"],
            ticks:7 
        },
        grid: {             
            backgroundColor: { colors: [ "#fff", "#fff" ] },
            borderColor: "#ccc",
            borderWidth: {
                top: 1,
                right: 1,
                bottom: 1,
                left: 1
            },
            hoverable: true,
            clickable: true,
            markings: weekendAreas
        },
        legend: {
            labelBoxBorderColor: "#fff",
            position: "ne",
            margin: [0, 0]              
        }
    });

Answers


You can do this with an xaxis transform function:

    xaxis: {    
        mode: "time",
        minTickSize: [1, "day"],
        ticks: 7,
        transform: function (v) { return -v; }, // run it backwards
        inverseTransform: function (v) { return -v; }
    },

Here's a fiddle.

Running code:

var data = [
    [1384436902000, Math.random() * 100],
    [1384523302000, Math.random() * 100],
    [1384609702000, Math.random() * 100],
    [1384696102000, Math.random() * 100],
    [1384782502000, Math.random() * 100],
    [1384868902000, Math.random() * 100],
    [1384955302000, Math.random() * 100]
    ];


var plot = $.plot("#placeholder1", [data], {
        series: {
                lines: { 
                    show: true, 
                    fill: 0.1
                },
                points: { show: true, 
                    fill: 0.05 }
        },
        xaxis: 
        {    
            mode: "time",
            minTickSize: [1, "day"],
            ticks: 7,
            transform: function (v) { return -v; },
            inverseTransform: function (v) { return -v; }
        },
        grid: {             
            backgroundColor: { colors: [ "#fff", "#fff" ] },
            borderColor: "#ccc",
            borderWidth: {
                top: 1,
                right: 1,
                bottom: 1,
                left: 1
            },
            hoverable: true,
            clickable: true
        },
        legend: {
            labelBoxBorderColor: "#fff",
            position: "ne",
            margin: [0, 0]              
        }
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://www.flotcharts.org/flot/jquery.flot.js"></script>
<script src="https://www.flotcharts.org/flot/jquery.flot.time.js"></script>
<div id="placeholder1" style="width:600px; height:300px"></div>

Need Your Help

How can I learn CSS easily?

css django

I am using the Django framework and am pretty comfortable with the backend logic using Python, but what's bothering me is the front-end bit where I have to work with CSS. How can I learn easily the

holding constructed static arrays in memory for multiple files c++

c++ arrays dll linker

I have a few arrays that I need to hold in memory for the duration of my program. The arrays are used as look up references by different files so I thought I should make a DLL to hold them in.