epochjs / epoch

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

Creating time.bar from example causes TypeError #160

Closed jme783 closed 9 years ago

jme783 commented 9 years ago

Hi there, I'm trying to create a basic real-time bar graph from the library. I installed the package from bower and loaded jQuery and d3 before epoch. However, I am getting an error when trying to run the following simple code from the example:

Ember.$('#event-bar-chart').epoch({
    type: 'time.bar',
    data: [
    // First series
    {
      label: "Series 1",
      values: [{time: 1370044800, y: 100}, {time: 1370044801, y: 1000}]
    },
    // The second series
    {
      label: "Series 2",
      values: [{time: 1370044800, y: 78}, {time: 1370044801, y: 98}]
    }
   ]
});

I receive the following error:

Uncaught TypeError: Cannot read property 'length' of undefined
  Epoch.Time.Plot.a.setData
  Epoch.Time.Stack.a.setData
  ...

It's hard for me to debug this as the JS file is minified. Any ideas on what may be going wrong? Thanks in advance! This seems to happen with any real-time chart I try to use time.area, time.line, etc.

jme783 commented 9 years ago

It seems like the error is being triggered here in time.coffee:

 _annotateLayers: (prepared) ->
    data = []
    for own i, layer of prepared
      copy = Epoch.Util.copy(layer)
      start = Math.max(0, layer.values.length - @options.historySize)
      copy.values = layer.values.slice(start)
      classes = ['layer']
      classes.push "category#{(i|0)+1}"
      classes.push(Epoch.Util.dasherize layer.label) if layer.label?
      copy.className = classes.join(' ')
      copy.visible = true
      data.push copy
    return data

Specifically on this line: start = Math.max(0, layer.values.length - @options.historySize)

jme783 commented 9 years ago

This seems to be an issue with the minified version as if I run cake build on the repo then use the unminified version of the library, this issue goes away.

ryanlitalien commented 9 years ago

+1

jme783 commented 9 years ago

@ryanlitalien sadly it doesn't seem like Fastly is maintaining this repo anymore. It's a nice tool but without active maintainers I'm not sure I would recommend continuing to use it

ryanlitalien commented 9 years ago

Thanks @jme783, I figured as much. I switched to NVD3.js.

rsandor commented 9 years ago

Fastly did fail to maintain this project, and after some prodding they were gracious enough to let me back in to work on it. Thanks for digging into the problem some, I will take a look and let you know if I can see what is happening here.

rsandor commented 9 years ago

This no longer seems to be an issue after using the new build scripts. I was able to get the chart to correctly render with both the regular and minified versions of the library.