OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Trigger a tooltip in a google chart from external Url

  • Thread starter Thread starter Björn
  • Start date Start date
B

Björn

Guest
I tried to trigger the tooltip for a specific entry in a google chart when coming from a link from an external URL.

The tooltip should show with the following URL: https://example.com/page?showTooltip=Identifier

The data point in the chart is selected, but the tooltip doesn't show. The trigger for the tooltip is set to "both". Any ideas on how to fix this?

Code:
const urlParams = new URLSearchParams(window.location.search);
const showTooltip = urlParams.get('showTooltip');
if (showTooltip) {
  google.visualization.events.addListener(scatterChart, 'ready', function() {
    setTimeout(() => {
      showTooltipForEntry(showTooltip);
    }, 1000);
  });
}

function showTooltipForEntry(entryName) {
  const rowIndex = data.getFilteredRows([{
    column: 1,
    value: entryName
  }])[0];
  if (rowIndex === undefined) return; // If no matching row, exit

  scatterChart.getChart().setSelection([{
    row: rowIndex,
    column: null
  }]);
}

<p>I tried to trigger the tooltip for a specific entry in a google chart when coming from a link from an external URL.</p>
<p>The tooltip should show with the following URL: <code>https://example.com/page?showTooltip=Identifier</code></p>
<p>The data point in the chart is selected, but the tooltip doesn't show. The trigger for the tooltip is set to "both". Any ideas on how to fix this?</p>
<pre class="lang-js prettyprint-override"><code>const urlParams = new URLSearchParams(window.location.search);
const showTooltip = urlParams.get('showTooltip');
if (showTooltip) {
google.visualization.events.addListener(scatterChart, 'ready', function() {
setTimeout(() => {
showTooltipForEntry(showTooltip);
}, 1000);
});
}

function showTooltipForEntry(entryName) {
const rowIndex = data.getFilteredRows([{
column: 1,
value: entryName
}])[0];
if (rowIndex === undefined) return; // If no matching row, exit

scatterChart.getChart().setSelection([{
row: rowIndex,
column: null
}]);
}
</code></pre>
 

Latest posts

Online statistics

Members online
0
Guests online
4
Total visitors
4
Top