clicking the legend to show/hide series

clicking the legend to show/hide series

  

By default HighCharts allows clicking the legend to show/hide series. The Outsystems charts don't allow that out of the box. There must be some setting, but I can't find it! Does anyone know what setting allows this?

Add the following in the AdvancedFormat_Init action inside HighchartsJSON propertie:

SyntaxEditor Code Snippet

        series: {
            point: {
                events: {
                    legendItemClick: function () {
                        return true; // <== returning false will cancel the default action
                    }
                }
            }
        }

Tiago Flor wrote:

Add the following in the AdvancedFormat_Init action inside HighchartsJSON propertie:

SyntaxEditor Code Snippet

        series: {
            point: {
                events: {
                    legendItemClick: function () {
                        return true; // <== returning false will cancel the default action
                    }
                }
            }
        }

Thanks a lot for the reply. 

But when I added the codes below. The chart disappeared.




There was some code missing, try this:

SyntaxEditor Code Snippet

"plotOptions: {
    series: {
        point: {
            events: {
                legendItemClick: function () {
                    return true; // <== returning false will cancel the default action
                }
            }
        }
    }
}"


This should work now, sorry.

Tiago Flor wrote:

There was some code missing, try this:

SyntaxEditor Code Snippet

"plotOptions: {
    series: {
        point: {
            events: {
                legendItemClick: function () {
                    return true; // <== returning false will cancel the default action
                }
            }
        }
    }
}"


This should work now, sorry.

Sorry to bother you again, after changing the codes. It`s still not working. After clicking the
 legend, the series still didn`t  hide.


Have you associated the AdvancedFormat_Init action output to the chart?

If not you have to do it, click on the chart and, in the AdvancedFormat propertie, select the action.

Tiago Flor wrote:

Have you associated the AdvancedFormat_Init action output to the chart?

If not you have to do it, click on the chart and, in the AdvancedFormat propertie, select the action.

I think I`ve associated them. Please see the pic which I`ve uploaded. Thank you.


Try to put the action in the preparation and the code i mentioned before in that action, then associate the action to the chart.


If you can please attach the oml so that i can take a look.

@eric: If the chart is disappearing, it means there's something wrong with the JSON. Note that I solved this problem by calling AdvancedFormat_Init with a HighChartsJSON saying:

plotOptions: {
    series: {
        events: {
            legendItemClick: function() {" +
                If(a_EnableShowHide, "", "return false;") + "
            }
        }
    }
}

It's not necessary to return true, as long as the return isn't false you're fine.

Tiago Flor wrote:

Try to put the action in the preparation and the code i mentioned before in that action, then associate the action to the chart.


If you can please attach the oml so that i can take a look.

Here is my oml, thanks a lot.


Hi Eric,

Unfortunately, that looks ok :). I'd remove the point level (cf. my example above) and retest, but if that doesn't work either, you should try to debug using the Dev Tools in your browser, see if any error comes up.

As Kilian says, it seams fine.

You can try to use "AdvancedFormat_Init.AdvancedFormat" in the chart propertie, see if doing that solves the problem.

Tiago Flor wrote:

As Kilian says, it seams fine.

You can try to use "AdvancedFormat_Init.AdvancedFormat" in the chart propertie, see if doing that solves the problem.

It`s still not work, and I`ve attach the oml again. I don`t know if I make it right.


Change you action json to return true:

@Tiago: Note that it isn't needed to actually return True; as long as False isn't returned it's fine (see also here).

Tiago Flor wrote:

Change you action json to return true:

I have tried both true and false, but both of them didn`t work.


That works for me in Outsystems 9.1.

Hi eric,

The only thing that I can advise you to do is look at the page source and locate the JSON that makes up the chart. Copy the JSON, and click here and recplace the JSON with the copied JSON. You can play around to see why it doesn't work.