'Flot Charts with xasis Time

I am trying a flot charts with data
[[1645570986, 0.4624863055203449], [1645570987, 0.4624863055203449], [1645570988, 0.468952235505014],…]
therefore [timespamp, value], however, the time does not appear in the x axis. Anyone can give me some advice.

function CF_real_CPU(){

'use strict';
var cpu = $.plot('#flotRealtime1', [real[0].data], {
    colors: ['#ff5e5e'],
    series: {
        lines: {
            show: true,
            lineWidth: 1
        },
        shadowSize: 0 // Drawing is faster without shadows
    },
    grid: {
        borderColor: 'transparent',
        borderWidth: 1,
        labelMargin: 5
    },
    xaxis: {
        mode: "time",
    tickSize: [10, "second"],
    tickLength: 10,
    axisLabelUseCanvas: true,
    axisLabelPadding: 10,
        color: "transparent",
        font: {
            size: 10,
            color: "#fff"
        }
    },
    yaxis: {
        color: 'transparent',
        font: {
            size: 10,
            color: '#fff'
        }
    }
});

}

image charts

Thank you
alby696



Solution 1:[1]

Your timestamp are in seconds. When using Flot (and JavaScript in general) they need to be in milliseconds. 1645570987 needs to be 1645570987000 and so on.

With the timestamps as they are now, all your data spans less than one second, so the time on the axis is outside the vissible area.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Raidri