KoolReport's Forum

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

Dashboard - Widget - Google Chart - LineChart #2988

Open Katherine Wong opened this topic on on Feb 15, 2023 - 3 comments

Katherine Wong commented on Feb 15, 2023

Can you guide me how to display the value in the Line chart rather than need to mouse rollover on it?

Dashboard package :

<?php

namespace App\Dashboard\SI;

use koolreport\dashboard\widgets\google\LineChart; use \koolreport\dashboard\fields\Text; use \koolreport\dashboard\fields\Currency; use \koolreport\dashboard\ColorList;

use App\Dashboard\AutoMaker;

class ARLSI extends LineChart {

protected function onInit()
{
  $this->title("ARL")
    ->colorScheme(ColorList::random()); 
}

protected function dataSource()
{
            $range = $this->sibling("SIDateRange")->value();
	
	$datefrom = $range[0];
	$dateto = $range[1];
	 
	return AutoMaker::rawSQL("
                    Select SIDate ,  total
		from SI_HDR 
		where SIDate between '$datefrom' and '$dateto'
			");
}

protected function fields()
{
    return [
        Text::create("SIDate "),
        Currency::create("total")
                ->MYR()
                ->symbol()
                ->decimals(0)
    ];
}

} ?>

Sebastian Morales commented on Feb 15, 2023

For Google Chart to show all values pls check for a solution using annotation posted previously here:

Google-ColumnChart: Showing values on the chart

Katherine Wong commented on Feb 15, 2023

I have read this posted, but I don't know how to apply

"columns"=>array(

			"Monat",
			"{{all}}"=>array(
				"type"=>"number",
				"prefix"=>"",
				"suffix"=>"",
				"decimals"=>2,
				"thousandSeparator"=>".",
				"decimalPoint"=>",",
				"annotation"=>function($row)
				{
					//return "$".number_format($row["{{all}}"]);
					return $row["{{all}}"];
				},
			)
		),

in my code whereby

protected function onInit() { $this->title("ARL")

->colorScheme(ColorList::random()); 

}

protected function dataSource() {

        $range = $this->sibling("SIDateRange")->value();

$datefrom = $range[0];
$dateto = $range[1];
 
return AutoMaker::rawSQL("
                Select SIDate ,  total
	from SI_HDR 
	where SIDate between '$datefrom' and '$dateto'
		");

}

protected function fields() {

return [
    Text::create("SIDate "),
    Currency::create("total")
            ->MYR()
            ->symbol()
            ->decimals(0)
];

}

Can you guide me along?

Katherine Wong commented on Feb 16, 2023

I got it done. Thanks.

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