almende / chap-links-library

a web based visualization library for displaying graphs, networks, and timelines
http://almende.github.com/chap-links-library
Apache License 2.0
599 stars 167 forks source link

Initializing the timeline with options in the constructor is bugged. Step and scale not working #349

Closed kevinpirola closed 9 years ago

kevinpirola commented 9 years ago

Hello everybody, I found few minutes ago this bug in the timeline. The situation is this: I call the constructor, giving options directly in that method with:

var options = {
                    width : "100%",
                    height : "auto",
                    minHeight:300,
                    editable : false,
                    zoomMin:7200000,
                    scale:links.Timeline.StepDate.SCALE.HOUR,
                    step:5,
                    "min" : minData, // lower limit of visible range
                    "max" : maxData,
                    layout : "box",
                    cluster: true,
                    clusterMaxItems: 5,
                    eventMargin:5
                };
                // Instantiate our timeline object.
                timeline = new links.Timeline(document.getElementById('mytimeline'), options);

This go to an error due to the fact that it can't set the property "scale" and "step".

The problem is that the constructor in timeline.js on line 116 is calling the

setOption()

method (line 237) prior to initialize the var "this.step" (line 249).

SetOption is indeed calling this.step.setScale, but this.step is still undefined.

Using the constructor alone and then settings the options directly with "setOption" is fine because this.step is now initialized.

The easy fix is to move line 237 after line 249 in timeline.js

bye!

josdejong commented 9 years ago

Thanks, this should be fixed now in the master branch.

kevinpirola commented 9 years ago

You are very welcome ;) Thanks to you for your work