Flotr2 - hover over a line in a line chart

I have a Barchart Flotr2 with line charts on them, when you hover a line chart, you should see the coordinates in the tooltip.

The problem is that tooltips are not displayed for the two minimum points in the line chart on top of the green bar chart.

See this jsfiddle: http://jsfiddle.net/P855Q/1/

This is javascript for charts:

(function basic_bars (container, horizontal) {

var NumberOfBars = 3;

var barcenters = [];
var barWidth = ( (1 / NumberOfBars) * 0.8 )
var barcenterAdjust =  (barWidth * (NumberOfBars/2)) - (barWidth/2.2);

for (i = 0; i < NumberOfBars; i++) {
    var barcenter = (i *(( 1 / NumberOfBars ) * 0.8));
    barcenter = barcenter - barcenterAdjust;
    barcenters.push(barcenter);
}


var dummyVar,
d0=[
    [barcenters[0] + 3, 5],
    [barcenters[0] + 3, 8.1333],
    [barcenters[0] + 3, 9]
],
d7=[
    [barcenters[1] + 3, 5],
    [barcenters[1] + 3, 8.1333],
    [barcenters[1] + 3, 9]
],
d14=[
    [barcenters[2] + 3, 5],
    [barcenters[2] + 3, 8.1333],
    [barcenters[2] + 3, 9]
];
var a =  [[3,8.303000]];
var b =  [[3,8.574500]];
var c =  [[3,8.222200]];


Flotr.draw(
    container,[
        { data : a, label : 'a' , bars: {show : true, horizontal : false, shadowSize : 0, barWidth : 0.8, grouped: true, mouse:{track:false}} },
        { data : b, label : 'b' , bars: {show : true, horizontal : false, shadowSize : 0, barWidth : 0.8, grouped: true, mouse:{track:false}} },
        { data : c, label : 'c' , bars: {show : true, horizontal : false, shadowSize : 0, barWidth : 0.8, grouped: true, mouse:{track:false}} },
        { data : d7 , lines : { show : true }, points : { show : true },mouse:{track:true,trackFormatter: function(obj){ return obj.y; },relative: true}, color: '#999999'},
        { data : d14 , lines : { show : true }, points : { show : true },mouse:{track:true,trackFormatter: function(obj){ return obj.y; },relative: true}, color: '#999999'},
        { data : d0 , lines : { show : true }, points : { show : true },mouse:{track:true,trackFormatter: function(obj){ return obj.y; },relative: true}, color: '#999999'},
    ],
        {
            yaxis : {min : 1,max: 10,noTicks: 10,tickDecimals: 0,autoscaleMargin : 1},
            xaxis : {min: 0,ticks: [["1", "1"],["2", "2"],["3", "3"],["4", "4"],["5", "5"],["6", "6"],["7", "7"],["8", "8"]]}       
        }
);
})(document.getElementById("example"));
+4
source share
1 answer

I analyzed its details and found out that the violin was in order!

Also the code looks great, (except for the barcenterspart of the code that seems to be causing some problem ..

event ,

<div class="flotr-mouse-value">

div , .

, .

, , - 3, .. ( ) B (8.1), , !! - B (5.0) .

, β†’ , , toolTip ( )

<div id="example"></div>, script, , floatr script , .

1: , , ; fiddle

, - , .

+1

Source: https://habr.com/ru/post/1547411/


All Articles