If I set a tooltip in the Configuration it is displayed fine.
However I want to set an individual Tooltip for every DataSeries:
private PlotOptionsLine getDefaultPlotOptionsLine(int decimalShown) {
PlotOptionsLine plotOptions = new PlotOptionsLine();
Tooltip tooltip = new Tooltip();
tooltip.setFormatter(getTooltipFormatter(decimalShown));
plotOptions.setTooltip(tooltip);
plotOptions.setMarker(new Marker(false));
...
Setting the Tooltip for a DataSerie by using the PlotOptions seem to be ignored. I checked this by changing the Marker to true, which is working, so the PlotOptions themselves are correctly set. Setting the same Tooltip with the Configuration however works.
Is this a bug or is there another way to set the Tooltip indivually for every DataSeries?
Is the way I tried to set an individual Tooltip for every DataSeries by the use of PlotOptions a valid way to do this?
Is there another way?
Or is it just not possible?
Or is it just not possible?
The plotoptions have the setToolTip () method. So if its there is must work …
I have an even more strange effect with tooltips and PlotOptionsScatter(): The tooltips from the basic chart config are ignored and just a 1,2,3, … categories series is displayed in the tooltip.
Consideration of PlotOptions ToolTips also for Series would be of real value for this excellent add-on.
Example: StackedBars of requires a tool tip which includes the total of the included series.
For further series of the same chart, the total mostly makes no sense.
For some reason I’ve completely missed this thread, sorry about that.
Unfortunately this seems to be missing from the API. I added this to the product backlog so that it gets added in a future version. Until then, you can fairly easily add the functionality yourself by extending the DataSeries class and adding a getter/setter for Tooltip like so:
public class DataSeriesWithTooltip extends DataSeries {
private Tooltip tooltip;
public Tooltip getTooltip() {
if (tooltip == null) {
tooltip = new Tooltip();
}
return tooltip;
}
public void setTooltip(Tooltip tooltip) {
this.tooltip = tooltip;
}
}
Use this class instead of the DataSeries class wherever you like to specify the tooltip options for a specific series.
I tested your code, and indeed it does not work. I did, however, manage to get it to work correctly by using the pointFormat property instead of the formatter property, i.e. specifying the contents of the tooltips using HTML templates instead of JS functions. Changing the two relevant lines as follows makes the tooltips display the correct information:
stackedBarTooltip.setPointFormat("<b>{point.x}</b> {series.name}: {point.y}, Total: {point.stackTotal}");
and