Od behaviors when there are undefined values #196

Open
jlopezpena opened this Issue Feb 9, 2013 · 1 comment

2 participants

@jlopezpena

When plotting several time series and some of them don't have values defined everywhere there are several odd behaviors. Consider for instance the following code (modified from the "formatter" example):

var graph = new Rickshaw.Graph( {
    element: document.getElementById("chart"),
    width: 960,
    height: 500,
    renderer: 'line',
    series: [
        {
            color: "#c05020",
            data: [{x:1, y:20}, {x:2, y:18}, {x:3, y:24}, {x:4, y:22}, {x:5, y:23}],
            name: 'New York'
        }, {
            color: "#30c020",
            data: [{x:1, y:21}, {x:2, y:21}, {x:3, y:22}, {x:4, y:23}, {x:5, y:21}],
            name: 'London'
        }, {
            color: "#6060c0",
            data: [ {x:4, y:24}, {x:5, y:23}],
            name: 'Tokyo'
        }
    ]
} );

graph.render();

var hoverDetail = new Rickshaw.Graph.HoverDetail( {
    graph: graph,
    formatter: function(series, x, y) {
        var date = '<span class="date">' + new Date(x * 1000).toUTCString() + '</span>';
        var swatch = '<span class="detail_swatch" style="background-color: ' + series.color + '"></span>';
        var content = swatch + series.name + ": " + parseInt(y) + '<br>' + date;
        return content;
    }
} );

The hover details only work in the x-interval [4,5], where all three series have defined values, but doesn't work in the interval [1,3] for the two series that are defined there.
Surprisingly enough, if the third series in only defined at the beginning (i.e. replace the x-values by 1 and 2 instead of 4 and 5) the hover works just fine over the whole graph.
On a similar line, if we add a range slider to this graph it will not allow the right hook to be dragged before the point x=4 where the third series start.

The hover problem disappears if the missing values are filled with null, but this is very inconvenient in some situations (eg with ajax graphs) with many series and many data points, since:
1. I have no way to know when I receive the data whether all series have started or not.
2. Populating all the missing values with null would result in a huge enlargement of my json data file.

Is there any way to tell rickshaw to automatically consider all the missing values as null?

@thirstyfish

@jlopezpena: did you manage to force Rickshaw to consider missing values as nulls ? I'have the exact same issue now. The time span is huge and sparsely populated with data, and it would be an overkill to manually fill in the nulls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment