• Resolved gmagnenat

    (@gmagnenat)


    Hello,

    When using chartjs, can we customize our charts by passing chartJs options? (like colors, animations, etc ).

    Is there a render_start event for chartJs like the one documented in the wiki for highcharts?

    Thanks a lot!

Viewing 1 replies (of 1 total)
  • Plugin Author methnen

    (@methnen)

    There is. The same jQuery style events exist for Chart.js.

    Perhaps most useful for Chart.js though is there’s a m_chart_after_chart_args action hook that provides:

    $post_id, $args, $instance

    As arguments.

    This allows you throw some additional JS into the chart code before render.

    So you could set some Chart.js default values:

    
    Chart.defaults.font.size = 15;
    

    Or you could even call a custom Chart.js plugin:

    
    m_chart_chartjs_<?php echo absint( $post_id ); ?>_<?php echo absint( $instance ); ?>.chart_args.plugins = [plugin_name_here];
    

    I can’t remember if I’ve got documentation on those yet. I might not. I’ve been extremely busy with paying work and life in general this year and haven’t had a lot of time to spend writing docs.

    • This reply was modified 2 years, 8 months ago by methnen.
Viewing 1 replies (of 1 total)
  • The topic ‘Acces ChartJS custom options’ is closed to new replies.