Highcharts introduces shared tooltips for specific data series

I am seeking to implement specific behavior in highcharts regarding tooltips. The desired setup includes having two types of tooltips:

  1. the default shared tooltip
  2. a custom tooltip

For the custom tooltip, a simple formatter can be utilized. However, the challenge lies with the shared tooltip. Is it feasible to share the default tooltip among certain series while implementing a custom one for others?

Thank you.

Answer №1

Yes, it is possible but you will need to implement a formatter and prepare the necessary logic for it. Take a look at this very basic demonstration here

        customFormatter:function(){
            var content = '',
                currentX = this.x,
                allSeries = this.point.series.chart.series;

            if(this.series.options.shared) {
                $.each(allSeries,function(index,series){
                    if(series.options.shared) {
                        $.each(series.data,function(j, dataPoint){
                            if(dataPoint.x === currentX) {
                                content += '<span style="color:'+series.color+';font-weight:bold;">'+series.name+'</span> value: ' + dataPoint.y + '<br/>';
                            }
                        });
                    }
                });
            } else {
                content = 'not shared value: ' + this.y;
            }

            return content;
        }

Answer №2

If you're looking for a workaround in the API to achieve a specific functionality, one way is to track which series the mouse hovers over:

 var series1Selected=0;
 ...
 series: [{
        events: {
            mouseOver: function () {
                series1Selected = 1;
            },
            mouseOut: function () {
                series1Selected = 0;
            }
        },

This approach allows you to customize the tooltip based on whether the mouse is over series 1 or not.

 tooltip: {
        formatter: function () {
            if (series1Selected == 1) {
                var s = '<b>Series 1</b>';
            } else {
                var s = '<b>Shared</b>';
                $.each(this.points, function () {
                    s += '<br/>' + this.series.name + ': ' + this.y + 'm';
                });

            }
            return s;
        },
        shared: true
    },

http://jsfiddle.net/rjbfmob6/

While not perfect, this method can be used as a starting point for finding a solution.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exploring Express.js: Implementing multithreading and asynchronous techniques for handling simultaneous HTTP requests

Recently, I find myself exploring ways to manage large-scale HTTP requests using Express.js. While I'm aware that Node.js has introduced 'workers' from version 13 onwards for multithreading capabilities, I am curious about how to effectively ...

Can a browser still execute AJAX even if the window.location is altered right away?

Here is the situation I am facing: <script> jQuery.ajax{ url : 'some serverside bookkeeping handler', type : post, data : ajaxData }; window.location = 'Some new URL'; </script> Scenario: I n ...

Determine the number of rows in an Excel spreadsheet using JavaScript

Currently, I am working on a codeigniter project where I need to upload an Excel file. However, before uploading the file, I want to display the number of records it contains. To achieve this, I decided to create a function within my script and then call t ...

Executing a separate function after each iteration of an ajax call within a loop using Jquery

I am faced with a situation where an ajax function must be run inside a loop that depends on the array's size. How can I execute another function after the ajax call is completed and outside the loop? Is this achievable? Below is the function: funct ...

Is it possible to trigger the eventListener just once for every instance of my constructor?

I have a common property that is shared among all instances of my constructor: function Me() { } Me.prototype.window = {}; I want to update this property when the window is resized, but I only want it to happen once for each resize event, regardless of h ...

Splitting jQuery - discover and distribute all price categories

I am faced with a challenge on my page where I have a list of items each displaying prices in GBP. The price is enclosed within a span element with a class of "price". My goal is to change the value of all the prices by dividing them by 1.2. Here's an ...

Learn the steps to successfully rotate the custom icon in Material-Ui select without impacting its functionality and making sure it remains clickable

I've been trying to incorporate my own icon for the material UI select component. I successfully replaced the default icon using the "IconComponent" attribute in MU select. However, I'm facing issues with the new icon not rotating when the menu ...

Click on the link to see the jQuery effect in action

I'm trying to achieve a fade-out effect on the current page followed by fading in a new one. The fade-in effect is working fine, but when I click on the link, the new page loads without first fading out the existing content. The div that I want to app ...

Select dropdown in AngularJS for Date formatting

After retrieving json data from a web API, I found that it contains a series of datetimes. My goal is to select a specific datetime from a dropdown list. While I can populate the list without any issues, the formatting appears to be incorrect and I'm ...

Navigate to another HTML division using data-toggle

I have 2 HTML documents index.html and services.html In services.html, I have the following code: <a class="nav-link" data-bs-toggle="tab" href="#ds-tab">Data Science</a> <a class="nav-link" data-bs- ...

Following the same occurrence using varying mouse clicks

I am currently exploring the most effective method for tracking file downloads (specifically, pdf files) on my website using Google Analytics (UA). I understand that by utilizing <a href="book.pdf" onClick="ga('send','event','P ...

Replacing text using regex results in whitespace

How can I eliminate text and spaces? For instance: http://www.exampleweb.com/myprogram.rar http://www.examplebackup.com/mybackups.rar http://www.exampleweb.com/myprogram1.rar I have used something similar to remove the second line: http://www.exampleba ...

How to Shift Focus to a Component in Vue.js

Within a container, I have a form section enclosed by a component that remains hidden due to the use of v-if. Upon clicking a button, the boolean value is toggled, revealing the previously concealed component. At this point, I aim to shift focus to the ini ...

Choosing to maintain an open server connection instead of regularly requesting updates

Currently, I am in the process of developing an innovative online presentation tool. Let's dive into a hypothetical situation: Imagine one person is presenting while another connects to view this presentation. >> How can we ensure that the vie ...

Execute multiple events using jQuery's .trigger() method

As I develop a jQuery plugin, I am utilizing the .on and .trigger functions for my pub/sub system. One challenge I am facing is triggering multiple events in different scenarios with ease. My question is whether it is possible to trigger multiple events a ...

Is there a way to only refresh the div specifically for the calendar with an id of "

$(document).ready(function() { $("#client-list").on("change", function() { var selectedValue = $(this).val(); location.reload(); }); }); Is there a way to refresh only the div with id='calendar' without refreshing the entire pa ...

Issue with Basic jQuery Demonstration (Failure to Conceal Item)

Below is a jQuery example where an element should be hidden, but it's not working as expected: <html> <head> <script src="../lib/jquery-1.7.1.min.js" type="text/javascript"></script> <script type="text/javascript"> $ ...

Access basePath within the Next.js AppRouter

Is there a way to access the basePath in Next.js 13 when using AppRouter? To retrieve it, we can simply get router.basePath through the useRouter hook of PageRouter by importing `import { useRouter } from 'next/router' I am currently unable to ...

I am encountering difficulties while attempting to import Typescript files. Upon compiling them into Javascript, I am faced with errors in the web browser, specifically the issue of "exports is not defined"

When I run TodoAppUI.js:15, I get an error saying "Uncaught ReferenceError: exports is not defined" In all my classes, I use the export keyword. For example: export class mysclass { public constructor(){} } Even though I have the proper syntax for impo ...

What is the equivalent of jQuery's blur event in AngularJS?

I need to implement a functionality in AngularJS where any opened component is closed when clicking outside of it. Is there an existing Angular directive for handling blur events, or do I need to come up with a custom solution? ...