Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author methnen

    (@methnen)

    Hey @ocmpixvd

    I’d start by checking out the docs:

    https://github.com/methnen/m-chart/wiki

    There’s a variety of filters and action hooks you can plug into to tweak things.

    If there’s something you’d like me to add in the customization sense let me know via a Github issue and I’ll be sure to take a look.

    Thread Starter compixvd

    (@compixvd)

    Hi methnem.. thanks for the response,
    I was looking in m-chart wiki but sorry i can’t figure how do
    something like this:

    https://jsfiddle.net/philfreo/Nkeep/85/

    Can you help me plis

    Thanks in advance

    Plugin Author methnen

    (@methnen)

    So you want only the first series to be shown by default and then yo want subsequent ones to be toggled on click. Like in the jsfiddle?

    You’d need to use the m_chart_chart_args filter hook. Then you’d loop through the series and set all but the first to be visible: false then you’d need to add the event to the chart args.

    The value passed by m_chart_chart_args matches up with the Highcharts chart args objects only it’s a PHP array which then gets converted to a JSON string after the fact.

    You’ll see the series in there. You could add the visible false value to them with something like this:

    foreach ( $chart_args['series'] as $key => $set ) {
    	if ( 0 == $key ) {
    		continue;
    	}
    
    	$chart_args['series'][ $key ]['display'] = false;
    }

    Then you would add the event stuff with something that looks like this:

    $chart_args['series']['events']['legendItemClick'] = 'function(event) {
        var selected = this.index;
        var allSeries = this.chart.series;
    
        $.each(allSeries, function(index, series) {
            selected == index ? series.show() : series.hide();
        });
    
        return false;
    }';

    Hopefully I’m making sense.

    Keep in mind I haven’t tested any of that code so I might have made a typo or syntax error in there or something. Or I might be remembering the array structure a bit wrong. But that should point you in the right direction.

    Plugin Author methnen

    (@methnen)

    Also, it’s certainly possible you could build a UI around that so this was all done via something a normal user could do. But I’m not sure if that’s something in your comfort zone. If that’s a feature you’d like to see make a feature request on Github and I’ll definitely take it under advisement. ??

    Or maybe someone else will build it in.

    Plugin Author methnen

    (@methnen)

    Closing this since there’s been no feedback from the OP for some time.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Extra plotOptions’ is closed to new replies.