How to make the position of shared tooltip be above the points? - highcharts

I found a lot of answers for this question, but no one fit mine.
So, we can see that regular tooltip is located above the point, like in this picture:
And when I change this example to use shared:true, the tooltip located in the left side:
Now I just want that shared tooltip will be located above the 2 points(in the example).
I know that I need to add code in the property positioner, but I cant figure out the math. more than that, if outside: true than I absolutely can't understand the math.
So, to conclude, how to make the position in shared tooltip to be above the points?
Thanks in advance.

Ok, it's really annoying task!
So I give a solution for shared tooltip and outside: true.
So first problem was to understand the coordinates system.
When outside: true we work relative to window, and when outside: false we work relative to chart.
Second, you can see if you put a log, that point values are always relative to chart, so what to do when we do outside: true?
Here the code which worked for me:
outside: true,
positioner: function(labelWidth, labelHeight, point) {
const chart = this.chart;
const chartPosition = chart.pointer.getChartPosition();
const hoverPoints = chart.hoverPoints;
const highestPoint = [...hoverPoints].sort((a, b) => a.plotY - b.plotY)[0];
const middlePoint = hoverPoints[Math.floor(hoverPoints.length / 2)];
return {
x:
chartPosition.left +
middlePoint.barX +
chart.plotLeft +
middlePoint.pointWidth / 2 -
labelWidth / 2,
y: chartPosition.top + highestPoint.plotY - labelHeight
};
},
I used a little the solutions from:
How to position highcharts tooltip above chart with outside:true
Highcharts custom tooltip positioner
To a little bit explain my solution, i share a picture:
Till now I'm not 100% understand what exactly each property say, but it's the way.
To investigate further, I suggest you to put a lot of console.logs on the properties, and also I used this code pasted to Console in devtools:
addEventListener('click', (event) => {
console.log(`x: ${event.clientX}, y: ${event.clientY}`);
})
It helped me to create a target, for example:
"The middle need to be in x:250 and y:300 because I clicked on the middle and got this values => let's play with the properties to get closer as I can!"

Related

How to properly align Font Awesome symbols on Highcharts scatter plots?

Using the Highcharts example posted here how can you ensure that the Font Awesome icons will be positioned exactly in the middle of the data point like the native symbols/markers are? It gets called like this in the data series and uses the "plugin" that is found in that same Fiddle:
marker: {
symbol: 'text:\uf183' // fa-male
}
Using that example, if you toggle the series on/off a couple of times or zoom in/out the icons are no longer visually accurate, often displaying above the actual coordinate. In the image below you'd believe that data point had a value >50 based on where the icon is.
Their SVGRenderer example here doesn't seem to be effected.
It looks like problem with re-rendering icons later - height of the marker isn't considered. I suggest to change a bit logic for rendering icon:
var text = symbol.split(':')[1],
svgElem = this.text(text, x, y)
.attr({
translateY: h, // translate marker
translateX: -1
})
.css({
fontFamily: 'FontAwesome',
fontSize: h * 2
});
See demo: http://jsfiddle.net/2A7Zf/29/
If you want to use the markers XL-sized (i.e larger radius) for a custom chart (e.g. a Yes/No prevalence chart using the x and check icons, circle empty for the less prevalent one and circle filled for the more prevalent one and data labels showing counts/%s), then I'd recommend this tweak to center the symbols:
translateX: -w/2 + options.radius/4 - 3

showing ranks on yaxis in highchart in a manner that 1 is best and 50 is worst

This a sample in highcharts for what exactly i need to create. The issue i am facing is the blue color should be in the area chart series, but highchart is applying the color at the top (outside the series). I apologize if i am not able to explain the issue correctly.
This happens when i use reversed: true, in yAxis.
Please help or let me know if you need me to explain the issue in different words.
When you reverse the axis, the data reverses as well, to match.
I would probably do this by using negative values as the axis min/max, and the data points.
Then, in the axis label formatter, return the absolute value (removing the '-').
labels: {
formatter: function() {
return Math.abs(this.value);
}
}
You can use the same formatting method to fix the tool tips, data labels, and anything else that might need it.
Example:
http://jsfiddle.net/jlbriggs/MybCM/27/

Highstock navigator padding issue

I am using Highstock charts with single series having flags on it where x-axis is 'datetime' type and y-axis is any numerical value. Now initially when chart loads I provide bit of padding on x-axis using attribute "max" so that end point doesn't touch the edge (which is working fine) but as I drag the navigator, the padding gets lost and the point touches the edge.
Is there any way of maintaining that padding on graph line even after I drag the navigator?
Any help would be greatly appreciated...
Unfortnately maxPadding works only for first time, as you ddescribed, but you can catch adterSetExtremes and then (setExtremes](http://api.highcharts.com/highstock#xAxis.events.setExtremes) to modify range on chart.
Thanks a lot Sebastian Bochan.....It worked for me!!!!. Just in case if anyone needs it. Here is what I have done
events: {
setExtremes: function(e) {
if (e.trigger === "navigator") {
var max=e.max+padding_value;
var x=this;
setTimeout(function(){
x.setExtremes(e.min,max);
}, 4);
}
}
},
Padding_value is a variable proving padding every time navigator is triggered

Updating spline chart two lines on top of eachother

I am showing two lines in a single graph updating them each second with a value that is saved into a global variable (both have different global variables). An example of the code can be found here: jsFiddle example.
As you can see the two lines are on top of each other, even though they have different values when the ymin and ymax are added to the lines (you can see this in the console).
The cause appears to be in the first addPoint call (line 118). If the first boolean is set to true (like the second addPoint call) the lines are shown correctly but the animation is wrong: jsFiddle example.
Does anyone know why the lines are on top of each other while their values are obviously different? And more importantly: how can I fix this while keeping the smooth animation?
Previous (possibly related) question: Chart not moving fluently when adding value to two lines on interval.
The problem is with using the same variable emptyarray for both series. This is known issue with Highcharts (roported on github) that Highcharts overwrites some of options passed to the chart. Possible solution is to use function which will return that empty array, for example:
function generateArray(){
var emptyarray = [],
time = (new Date()).getTime(),
i;
for (i = -50; i <= 0; i++) {
emptyarray.push({
x: time + i * 1000,
y: 230
});
}
return emptyarray;
}
chartinfo.series = [{
name: 'Minimum Voltage',
data: generateArray(),
color: '#FFFFDD'
}, {
name: 'Maximum Voltage',
data: generateArray(),
color: '#B72E8D'
}];
Working jsFiddle: http://jsfiddle.net/XAHa4/2/
It looks like strange with your setInerval functions, because minified example http://jsfiddle.net/DxqUj/ works properly.

Highcharts tooltips not accessible for certain data points

Sometimes it is very difficult to get the Highcharts Javascript charting library to show a tool tip for certain data points. For example, try to show the tooltip of the data point at 50,50 on the below link. It is very difficult to get it to show, and it flickers a lot. Does anyone know about some workaround?
http://highcharts.com/jsbin/ogixaz/2/edit
I tried it with an update-to-date Chrome and Firefox.
have you tried:
//...
plotOptions:{
series:{
stickyTracking:true;
}
}
UPDATE:
I have to say that i looked at your embeded example and understood exactly what you meant,
but after moveing your code into the jsFiddle and setting the property shared:true (in the tooltip object), it works fine. check it... http://jsfiddle.net/yoav_barnea/LFvVy/2/
the important part is the property shared:true :
tooltip: {
formatter: function() {
return '<b style="font-size:18px;font-weight:bold;">Some very long title</b><br/>' + this.x + ":" + this.y + " <br/>and some<br/> extra stuff<br/>line<br/>line";
},
useHTML: true,
shared:true
},
UPDATE 2:
as for your other problem on getting the costom c property (that you mentioned in the comment...), the solution for that is to fix your code inside the formatter function into somthing like this: return ... this.points[0].point.c
(again, this was a new issue, not related to the first one of flickering tooltip...)
The reason the tooltip at 50,50 flickers is because the tooltip is being drawn over the point. The points to the left and right allow room for the tooltip to be drawn to the side. The reason the middle one can't be drawn to the side is that the chart is small, and the toolip is big.
Some ideas to help this situation:
1. Making the tooltip smaller.
2. Make the chart bigger (try making the right hand side bigger in your example).
3. Use the highcharts tooltip.positioner function to place the tooltip somewhere else.

Resources