2016-04-09 8 views

Antwort

1

Sie 2 verschiedene Lösungen nutzen könnten. Zuerst zählen, wenn der Tooltip rechts oder links zeigen müssen:

positioner: function (labelWidth, labelHeight, point) { 
    var tooltipX, tooltipY; 
    if (point.plotX + labelWidth > chart.plotWidth) { 
     tooltipX = point.plotX + chart.plotLeft - labelWidth - 20; 
    } else { 
     tooltipX = point.plotX + chart.plotLeft + 20; 
    } 
    tooltipY = point.plotY + chart.plotTop - 20; 
    return { 
     x: tooltipX, 
     y: tooltipY 
    }; 
} 

Fiddle: http://jsfiddle.net/jugal/eSfy8/?utm_source=website&utm_medium=embed&utm_campaign=eSfy8

Oder mit einer festen Position des Tooltips:

positioner: function (labelWidth, labelHeight, point) { 
    var tooltipX, tooltipY; 
    if (point.plotX + chart.plotLeft < labelWidth && point.plotY + labelHeight > chart.plotHeight) { 
     tooltipX = chart.plotLeft; 
     tooltipY = chart.plotTop + chart.plotHeight - 2 * labelHeight - 10; 
    } else { 
     tooltipX = chart.plotLeft; 
     tooltipY = chart.plotTop + chart.plotHeight - labelHeight; 
    } 
    return { 
     x: tooltipX, 
     y: tooltipY 
    }; 
} 

Fiddle: http://jsfiddle.net/jugal/8cJD7/?utm_source=website&utm_medium=embed&utm_campaign=8cJD7

Mit Ihrem Diagrammtyp ist der Tooltip der gleiche, Sie müssen nur vorsichtig sein, wenn 'Diagramm' definiert ist (normalerweise).

Hoffe es hilft!

Verwandte Themen