epochjs / epoch

A general purpose, real-time visualization library.
http://epochjs.github.io/epoch
MIT License
4.97k stars 278 forks source link

Error "Cannot read property 'x' of undefined" when attempting to push values to real time.line #200

Closed jonoabroad closed 9 years ago

jonoabroad commented 9 years ago

I have a real time graph defined as follows:

    var health = $('#area').epoch({
      type: 'time.line',
      data: data,
      axes: ['left', 'bottom', 'right']
    });

and data defined as:

    var data = [
    {
      label:"CPU Temperature",
      values:[]
    },
    {
      label:"CPU Voltage",
      values:[]
    }
    ];

retrieving data for the graph from a JSON source, I am formatting it, and pushing to the chart.

    $.getJSON( "data/health", function( data ) {
      _.map(sliced, function(element){
        var value = [];
        value.push({time: element.created, y: element.cpu.temperature});
        value.push({time: element.created, y: element.cpu.voltage});
        console.log("value",JSON.stringify(value));
        health.push(value);
      });
    });

I am pushing an array of objects to the chart, one object per series.

value [{"time":1443801648964,"y":47.099998474121094},{"time":1443801648964,"y":1.2000000476837158}]

The full stack trace is :

Uncaught TypeError: Cannot read property 'x' of undefined
Epoch.Time.Plot.a._updateTicks @ epoch.min.js:74
Epoch.Time.Plot.a._shift @ epoch.min.js:72
Epoch.Time.Plot.a._startTransition @ epoch.min.js:69
Epoch.Time.Plot.a.push @ epoch.min.js:71
(anonymous function) @ (index):46
m.map.m.collect @ underscore-min.js:5
(anonymous function) @ (index):41
n.Callbacks.j @ jquery-2.1.4.min.js:2
n.Callbacks.k.fireWith @ jquery-2.1.4.min.js:2
x @ jquery-2.1.4.min.js:4
n.ajaxTransport.k.cors.a.crossDomain.send.b @ jquery-2.1.4.min.js:4

Could it be that I'm using JQuery 2.x?

rsandor commented 9 years ago

Very well written bug report, I will look into this.

jonoabroad commented 9 years ago

Thank you, it was the end of a long day. I figured it was better to log a bug than complain about it. I worked around it by providing default values:

    var data = [
    {
      label:"CPU Temperature",
      values:[{time:0,y:0}]
    },
    {
      label:"CPU Voltage",
      values:[{time:0,y:0}]
    }
    ];
rsandor commented 9 years ago

@jonoabroad - Fixed in v0.8.1, sorry you had to deal with that :beers: