Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling visibility toggler (legend) for errorbar series using linkedTo:null has severe issue #4245

Closed
paulflakstad opened this issue May 29, 2015 · 5 comments

Comments

@paulflakstad
Copy link

See http://highcharts.uservoice.com/forums/55896-highcharts-javascript-api/suggestions/4321475-add-an-ability-to-show-error-bar-in-legend

Nulling the error bar series means detaching it from its parent series. While this approach will certainly work sometimes, it is not a viable solution.

See, for example, what happens when multiple series are presented as columns:
http://jsfiddle.net/158nvhe3/

A different solution is needed; preferably one that keeps the parent link intact. How about adding an enableLegend (or equivalent) option in plotOptions.errorbar?

@pawelfus
Copy link
Contributor

It also can be achieved by using built-in options, like legendItemClick. Example: http://jsfiddle.net/158nvhe3/3/

In short, created three extra series, and manage visibility by using custom option connectTo.

Series example:

   {
        type: 'errorbar',
        name: 'D error',
        linkedTo: null,
        visible: false,
        connectTo: "D" // bar series should have id: "D".
    }

And legendItemClick function:

    plotOptions: {
        series: {
            events: {
                legendItemClick: function() {
                    if(this.options.connectTo) {
                         this.chart.get(this.options.connectTo).setVisible(!this.visible);   
                    }
                }
            }
        }
    },

@paulflakstad
Copy link
Author

Thank you for this, Paweł. I see what you did here, and it is pretty much exactly the workaround I had envisioned, but thought I'd have to spend days nailing it down. You just spared me a lot of work. Thanks again :)

Nevertheless, I'm still keeping my fingers crossed for something along the lines of my initial proposal. Hope you agree.

@pawelfus
Copy link
Contributor

pawelfus commented Jun 1, 2015

Yes, it would be nice to have it, but probably priority will be low, since workaround is quite straightforward.

@TorsteinHonsi
Copy link
Collaborator

I think the issue actually comes down to the position of the first series' error bar. Consider this jsFiddle. Enable the "A error" series by clicking the legend item. The error bars have the wrong position . However, on "B error" the position is correct.

Now in this jsFiddle, both error bars are visible from the start, and the same positioning issue appears.

@TorsteinHonsi
Copy link
Collaborator

Sorry, there was an error in the demo - turns out there is no bug at all. See http://jsfiddle.net/highcharts/158nvhe3/8/.

In the initial demo, instead of setting linkedTo: null, just set showInLegend: true and everything works: http://jsfiddle.net/highcharts/158nvhe3/9/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants