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

    (@methnen)

    If you’re comfortable playing with WP hooks yes.

    This is the one you’d want:

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

    It lets you play with everything the charting library will receive RIGHT before it gets printed out to the Javascript.

    Note that it’s in the form of a PHP Array which then get’s written out as a JSON object for the JS charting library to use.

    Thread Starter datverse

    (@datverse)

    Hi,
    Thank for your reply. With your help I did it successfully.

    The code snippet is:

    function filter_m_chart_chart_args( $chart_args, $post, $post_meta, $args ) {
    	$chart_args['options']['plugins']['title'] = [
    		'display' => false
    	];
    
    	return $chart_args;
    }
    
    add_filter( 'm_chart_chart_args', 'filter_m_chart_chart_args', 10, 4 );

    The config from the chartjs(.org)
    https://www.chartjs.org/docs/latest/configuration/title.html

    const chart = new Chart(ctx, {
        type: 'line',
        data: data,
        options: {
            plugins: {
                title: {
                    display: true,
                    text: 'Custom Chart Title',
                    padding: {
                        top: 10,
                        bottom: 30
                    }
                }
            }
        }
    });

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide Chart Title’ is closed to new replies.