Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
Keep selection in highcharts even on page refresh

I am using highcharts for generating/showcasing graph on UI(HTML with JavaScript Page)

There are multiple elements in series section that one can select or unselect to display on graph. But after every refresh, user selected elements gets unselected and only the default selections appear. And user has to select the elements again.

Any solution to it?

One can relate the question from the picture: enter image description here

In this, By default A is selected. If user selects Ball or C then the point graph will appear for Ball and C as well but as soon as graph refreshes, graph will have point graph with A only.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can store your visible series states in local storage. Example:

const savedStates = localStorage.getItem('seriesStates');
const seriesStates = savedStates ?
    JSON.parse(savedStates) : {
        A: true,
        Ball: false,
        C: false,
        D: false
    };

Highcharts.chart('container', {
    series: [{
        name: 'A',
        data: [1, 2, 3],
        visible: seriesStates.A
    }, {
        name: 'Ball',
        data: [2, 2, 2],
        visible: seriesStates.Ball
    }, {
        name: 'C',
        data: [3, 3, 3],
        visible: seriesStates.C
    }, {
        name: 'D',
        data: [4, 4, 4],
        visible: seriesStates.D
    }],
    plotOptions: {
        series: {
            events: {
                legendItemClick: function() {
                    seriesStates[this.name] = !this.visible;
                    localStorage.setItem(
                        'seriesStates',
                        JSON.stringify(seriesStates)
                    );
                }
            }
        }
    }
});

Live demo: http://jsfiddle.net/BlackLabel/jkuc50Lf/

Docs: https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!