• Resolved Frieze Design

    (@friezedesign)


    Is there a quick and easy way to change/override the animation time (too fast)?

    I’m not an expert, but it appears the Chart.js Javascript options have been converted to PHP (Templates, filter arrays)? I don’t understand these. Is there a comprehensive example of these array options?

    I’ve managed to get the JS ‘deferred’ Chart.js plugin working, but ‘delay’and ‘duration’ are ignored (all in JS).

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

    (@methnen)

    Hello,

    Yes the gist of it is that the settings are in an array that gets converted into a Javascript object and then passed on to Chart.js at the last moment.

    This allows the Templates and WordPress style filter hooks to modify things.

    It’s relatively straightforward to modify. You simply translate from a javascript object to a PHP array.

    So for instance the animation stuff is all in options:

    options: {
        animations {
            duration: 1000
        }
    }

    Adding that to the chart arguments via the filter hook stuff:

    https://github.com/methnen/m-chart/wiki/Action-and-filter-hooks#m_chart_chart_args

    Would look like this:

    function filter_m_chart_chart_args( $chart_args, $post, $post_meta, $args ) {
    	$chart_args['options']['animation']['duration'] = 2000;
    
    	return $chart_args;
    }
    
    add_filter( 'm_chart_chart_args', 'filter_m_chart_chart_args', 10, 4 );
    Thread Starter Frieze Design

    (@friezedesign)

    Many thanks Methnen, working perfectly.

    Looks like ‘nested’ arrays as a means to drill down to equivalent JS stuff? Although I don’t think I’d ever got to that without your example.

    Thanks again for your help, and for your time/expertise in developing a great plugin.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adjust Animation default time’ is closed to new replies.