Closed oleh-hastov closed 4 years ago
Hello @gasta-java,
what do you mean the same selected segment of the chart
?
@ihnatmoisieiev
So I am attaching a screenshot. You can see the first rect is tooltip and the second is same selected segment
@gasta-java please try to add the following configuration to your HIOptions
obejct:
let chart = HIChart()
chart.events = HIEvents()
chart.events.load = HIFunction(jsFunction: "function () { var chart = this, series = chart.series, addEvent = Highcharts.addEvent; series.forEach(function (serie) { serie.data.forEach(function(point) { addEvent(point.graphic.element, 'touchstart', function(){ if (!point.series.chart.tooltip.isHidden) { point.series.chart.tooltip.hide(); } else { point.series.chart.tooltip.refresh(point, {}, true); } }); }); }); }")
options.chart = chart
@ihnatmoisieiev thank you a lot! It works for tapping on selected segment
.
But it does not work for tapping on the tooltip by itself. The tooltip looks like does not catch touch events. Can you help with this, please?
For example:
If I tap on the zone I marked on the img it does not close tooltip but opens tooltip for the segment which is under the tooltip at tapped point:
@gasta-java unfortunately, there is no any default implementation for this. As a workaround, you can try the following:
let plotOptions = HIPlotOptions()
plotOptions.series = HISeries()
plotOptions.series.point = HIPoint()
plotOptions.series.point.events = HIEvents()
plotOptions.series.point.events.click = HIFunction(jsFunction: "function() { var chart = this.series.chart, addEvent = Highcharts.addEvent; if (chart.tooltip && !chart.tooltip.addedEvent) { addEvent(chart.tooltip.label.element, 'touchstart', function() { if (!point.series.chart.tooltip.isHidden) { point.series.chart.tooltip.hide(); } else { point.series.chart.tooltip.refresh(point, {}, true); } chart.tooltip.addedEvent = true; }); } }")
options.plotOptions = plotOptions
@ihnatmoisieiev thanks! But for some reason, it does not work. Can't we just catch a click on tooltip somehow and close it?
@gasta-java unfortunately, it's impossible as I know.
@ihnatmoisieiev thanks, got it. So do you have any thoughts why your example does nto close tooltip when I try it?
plotOptions.series.point.events.click = HIFunction(jsFunction: "function() { var chart = this.series.chart, addEvent = Highcharts.addEvent; if (chart.tooltip && !chart.tooltip.addedEvent) { addEvent(chart.tooltip.label.element, 'touchstart', function() { if (!point.series.chart.tooltip.isHidden) { point.series.chart.tooltip.hide(); } else { point.series.chart.tooltip.refresh(point, {}, true); } chart.tooltip.addedEvent = true; }); } }")
@gasta-java it works for me:
@ihnatmoisieiev okay, it looks like it's 'cause you're using default tooltip. So okay, I will investigate this;
Closing due to inactivity.
How to hide tooltip tapping on it or the same selected segment of the chart in iOS? Can you provide SWIFT example, please?