Highcharts automatically hide series that are not active from the legend when capturing a screenshot

Is there a way to only display active series in the legend when capturing a screenshot?

Imagine having a chart like the following:

https://i.sstatic.net/9enrC.jpg

But I would like the screenshot to show only the active series, like this: https://i.sstatic.net/Wofmn.jpg

Answer №1

Here is a suggestion:

seriesData: [{
            displayLegend: true,
            title: 'My Series',
            values: data                
        }]

Answer №2

To customize the visibility of series in a Highcharts chart, you can modify the exportChart method by toggling the showInLegend property:

var H = Highcharts;

H.wrap(H.Chart.prototype, 'exportChart', function(proceed, exportingOptions) {
    var series = this.series;

    Highcharts.each(series, function(s) {
        if (s.visible) {
            s.update({
                showInLegend: true
            }, false);
        } else {
            s.update({
                showInLegend: false
            }, false);
        }
    });

    proceed.apply(this, Array.prototype.slice.call(arguments, 1));

    Highcharts.each(series, function(s) {
        s.update({
            showInLegend: true
        }, false);
    });

    this.redraw();
});

Check out this live demo showcasing the functionality: http://jsfiddle.net/BlackLabel/cgj9vwas/

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

Encountering an Issue when Registering New Users in Database using Next.js, Prisma, and Heroku

Currently, I am immersed in my inaugural full-stack app development project, which is aligning with an online course. Unfortunately, I have encountered a major stumbling block that has persisted despite hours of troubleshooting. The issue arises when I try ...

Analyzing input from the user for string comparison

I am trying to create a code that activates when the user inputs a specific symbol or string. The issue is that it seems to be disregarding the if statements I have implemented. Here is the challenge at hand: Develop a program that can determine the colo ...

The Canvas drawn using JavaScript is not being resized and painted correctly on Safari mobile and Firefox mobile browsers

I created an HTML page that features a canvas element where I am drawing a roulette using JavaScript After checking the CanIuse website, I learned that canvas functionality is supported in Firefox 68 and Safari 4 to 13 <!DOCTYPE html> <html> ...

Why do I keep receiving the error message "Cannot set property of undefined"?

In the midst of a small project that involves utilizing nuxt, js, and axios, I encountered an issue when attempting to assign the response data to my formFields object. Despite having declared formFields within the data section, I kept receiving an error m ...

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"> $ ...

Combining react-draggable and material-ui animations through react-transition group: a comprehensive guide

Trying to incorporate react-draggable with material-UI animations. One approach is as follows: <Draggable> <Grow in={checked}> <Card className={clsx(classes.abs, classes.paper)}> <svg classN ...

Output JSON data using Javascript

Here is some JSON data I am working with: { "lang": [ { "SECTION_NAME": { "english": "My title" }, "SECTION_NAME_2": { "english": "My title" } } ] } I ...

Repositioning a variable number of divs as the cursor hovers over the target area

Can anyone show me how to generate div elements in a loop using jQuery and change their position with the "mouseover" function? I've tried some code, but the positioning isn't changing correctly. Any suggestions on what needs fixing? var r, g, ...

Output from function in Angular expression

I am curious to find out if the following scenario is achievable: <div ng-repeat='article in articles | filter:search'> ... <div> {{marked(article.body)}} </div> ... </div> My goal is to run the "marked" ...

"Troubleshooting Issue: JavaScript and jQuery onClick Event Not Functioning Properly

Whenever I try to click on the "php1" div, nothing happens. The location.reload() function is only a placeholder used for testing if the onClick event is functioning properly. <div class="php-task"> <h1>PHP</h1> ...

What is preventing this from functioning properly? (html/javascript)

I need help checking if this code is correct, as I am not very knowledgeable about HTML. I would appreciate it if someone could explain it to me in simple terms so I can understand. Here is the code: <input type="text" id="user" value=""> <inpu ...

Using Typescript with Momentjs: 'String type cannot be assigned to Date type'

Up until now, my approach to utilizing the momentjs library was as follows: import * as moment from 'moment'; // import moment. @Component({..}); export class TestClass { lastUpdated = Date constructor(private myService: MyService){ this ...

disable the react .hover behavior once clicked

Can someone help me figure out why my attempt to cancel the .hover on function using .off is not working? $("document").ready(function(){ $("button").hover(function(){ $("h1").hide(); }, function(){ ...

A guide on dynamically sending data to a PHP script when an input is changed and displaying the results in a

I am trying to implement a feature where the data inputted into a text field is sent to posttothis.php and then the result is displayed in a content div. However, I am encountering difficulties in making it work. testscript.html <html> <head> ...

Change all instances of the subtraction symbol to parentheses using jQuery

--html-- <table> <tr> <th>a</th> <th>b<th> </tr> <tbody class = "tabledata"> <tr>a</tr> <tr>b</tr> </tbody> </table> --jquery-- $('.tabledata').empty(); for ( ...

The use of callbacks in Model.findById() is now deprecated due to a MongooseError

Hello there! I've run into an issue and could use some assistance, thank you in advance! Running MONGOOSE VERSION: "mongoose": "^7.0.3" Error Message: MongooseError: Model.findById() no longer accepts a callback at Function.findB ...

Positioning CSS for a Responsive Button

Currently, I am working on making my modal responsive. However, I am encountering an issue with the positioning of the "SAVE" button. The button is not staying in the desired position but instead disappears. Below is the snippet of my HTML and CSS: .dele ...

Struggling with setting up a search bar for infinite scrolling content

After dedicating a significant amount of time to solving the puzzle of integrating infinite scroll with a search bar in Angular, I encountered an issue. I am currently using Angular 9 and ngx-infinite-scroll for achieving infinity scrolling functionality. ...

The Jquery .each() method is causing the return value to be undefined

Why is the getColorOptionSelect() function returning an undefined value, even though it has a value when checked with the debugger? I am certain that this issue is related to scope - my apologies for my lack of knowledge in JavaScript. jQuery(document).r ...

Which is better: JQuery, YUI, or another option for JavaScript and CSS frameworks?

It's been about 6 years since I last dipped my toes into web development. Attempting to re-enter the field, I find myself overwhelmed by all the new technologies and trends. For my upcoming project, I've decided to go with Perl and Catalyst. The ...