KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Isssue on chartjs chart #3169

Open Komuraiah A opened this topic on on Oct 10, 2023 - 1 comments

Komuraiah A commented on Oct 10, 2023

Hi Team, am using chartjs chart for my report and am trying to add visible the values without hover the chart. so am using chartjs plugin then the values are coming but i needed the values showing top of the chart example when i use column chart i need to show the value in the top not in the middle and also am trying to add number format to my values example i have a value 172000 then i need to show 1.72 M and done adding code below like this but the value format changing when i hover the chart below am sharing screenshot.

protected function onCreated()

{
    $this
    ->use(\koolreport\chartjs\PolarChart::class)
    ->settings([
        "title"=>"PolarChart",
        "colorScheme"=>ColorList::random(),
        "columns"=>array(
            "branchname"=>[
                "label"=>"Branch Name"
            ],
			"cheqbouncestopamt"=>[
                "label"=>"Cheque S/B",
                "prefix"=>"₹",
				'formatValue'=>function($value) {
                    return number_format($value/100000, 2). 'M';
                }
            ],
			"refundamt"=>[
                "label"=>"Refund",
                "prefix"=>"₹",
				'formatValue'=>function($value) {
                    return number_format($value/100000, 2). 'M';
                }
            ]
        ),
		"plugins"=>array("datalabels")
    ]);
}

Sebastian Morales commented on Oct 10, 2023

If you use Chartjs' datalabels plugin, the formatter option is not in "columns" but in "options" like this:

ColumnChart::create(array(
    ...
    'options' => [
        'plugins' => [
            'datalabels' => [
                'formatter' => 'function(value, context) {
                    // return  formatted value here;
                }'
            ]
        ]
    ] 
));

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None