Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rickshaw: HoverDetail at incorrect position when using line renderer plus RangeSlider.Preview

I have a Rickshaw Graph with two lines.

I need Rickshaw.Graph.RangeSlider.Preview and Rickshaw.Graph.HoverDetail:

var graph = new Rickshaw.Graph( {
    element: document.getElementById('chart'),
    renderer: 'line',
    width: 400,
    height: 300,
    offset: 'value',
    series: [
        {
            name: 'foo',
            data: seriesData.shift(),
            color: 'rgba(255, 0, 0, 0.4)'
        }, {
            name: 'bar',
            data: seriesData.shift(),
            color: 'rgba(255, 127, 0, 0.4)'
        }
    ]
} );

var slider = new Rickshaw.Graph.RangeSlider.Preview({
    graph: graph,
    element: document.getElementById('preview')
});

var detail = new Rickshaw.Graph.HoverDetail({
    graph: graph
});

graph.render();

http://jsfiddle.net/nsams/1jfswzp5/3/

My Issue

My issue is now that the Hover is shown at an invalid position:

Screenshot

What I have found out so far:

  • Removing the RangeSlider.Preview fixes the problem
  • Changing the renderer to 'stack' fixes the problem (Seems like the Hover is at the stack position even when using line renderer)
like image 979
Niko Sams Avatar asked Jul 10 '15 12:07

Niko Sams


1 Answers

Set stack:false in the Rickshaw.Graph constructor:

var graph = new Rickshaw.Graph( {
    element: document.getElementById('chart'),
    renderer: 'line',
    width: 400,
    height: 300,
    offset: 'value',
    stack: false,
    series: [
        {
            name: 'foo',
            data: seriesData.shift(),
            color: 'rgba(255, 0, 0, 0.4)'
        }, {
            name: 'bar',
            data: seriesData.shift(),
            color: 'rgba(255, 127, 0, 0.4)'
        }
    ]
} );

var slider = new Rickshaw.Graph.RangeSlider.Preview({
    graph: graph,
    element: document.getElementById('preview')
});

var detail = new Rickshaw.Graph.HoverDetail({
    graph: graph
});

graph.render();
like image 115
Bartłomiej T. Listwon Avatar answered Nov 08 '22 10:11

Bartłomiej T. Listwon