Baklap4 Baklap4 - 1 year ago 478
Javascript Question

Add Time Scaling to linechart (Chart.js)

Heey all,

I'm using chartjs to generate a view charts. The data is loaded correctly now but i'm having troubles with the x-axis labels.
As Chart.js does support a time scale i was wondering how it does work?
The timeline will should be dynamic. And should show values over time.

This is what i've tried so far but somehow i don't get time values at my x-axis.

I'm using the lastest Chart.js (2.1.2)

As you guys maybe see within the object there is a timestamp available. This is the timestamp to use for the data to be inserted in the graph.
The object i'm sending is as following:

var object = [

Answer Source
see below updated method from your jsFiddle code:
add below 2 lines:;;

$.each(data, function() {
    var tmp =[0].data;
    tmp.push(this['avg_c_p_u'][0]*100);[0].data = tmp;; //new line;//new line
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download