Define some colors

$colors2020 = array (
'#34568B',
'#CD212A',
'#FFA500',
'#56C6A9',
'#4B5335',
'#798EA4',
'#FA7A35',
'#00758F',
'#EDD59E',
'#E8A798',
'#9C4722',
'#6B5876'
);

Define chart options

$chart_options = array();
$chart_options["title"] = array();
$chart_options["title"]["display"] = true;
$chart_options["title"]["text"] = "This text will appear above the chart"; 

This should produce the following after conversion through json_encode($chart_options)

{
    "title": {
        "display": true,
        "text": "This text will appear above the chart"
    }
}

Test above code.

<?php 
echo "The result of json_encode(\$chart_data, JSON_PRETTY_PRINT):<pre>".json_encode($chart_options, JSON_PRETTY_PRINT)."</pre>"; 
?>
        
<?php 
echo var_dump($chart_options); 
?>

<?php 
echo '<pre>'; print_r($chart_options); echo '</pre>'; 
?>

You should see tha following:

// var_dump($chart_options) output:

array (size=1)
  'title' => 
    array (size=2)
      'display' => boolean true
      'text' => string 'This text will appear above the chart' (length=55)

// print_r($chart_options) output:

Array
(
    [title] => Array
        (
            [display] => 1
            [text] => This text will appear above the chart
        )

)

Defina chart data

We must construct the following JSON using php:

{
    "datasets": [
        {
            "data": [
                "222",
                "999",
                "555"
            ],
            "backgroundColor": "#D9CE52",
            "label": "this month"
        },
        {
            "backgroundColor": "#FA7A35",
            "label": "last month",
            "data": [
                "777",
                "999",
                "666"
            ]
        }
    ],
    "labels": [
        "AAA",
        "BBB",
        "CCC"
    ]
}

Define HTML canvas

<canvas
    id="myChart"
    style="width:100%;max-width:600px" >
</canvas>

Define chart in JS

<script>
    myChart = new Chart
    (
        'myChart' ,
        {
        type: 'bar',
        data: <?php echo json_encode($chart_data); ?>,
        options: <?php echo json_encode($chart_options); ?>
        }
    );
</script>

How JSON looks like:

{
    "datasets": [
        {
            "data": [
                "724",
                "1043",
                "704"
            ],
            "backgroundColor": "#DC793E",
            "label": "this month"
        },
        {
            "backgroundColor": "#282D3C",
            "label": "last month",
            "data": [
                "740",
                "976",
                "685"
            ]
        }
    ],
    "labels": [
        "AAA",
        "BBB",
        "CCC"
    ]
}