KoolReport's Forum

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

Can I create Google Charts > ComboChart in Dashboard Framework v.4.2.0 ? #3078

Open Katherine Wong opened this topic on on Jun 14, 2023 - 5 comments

Katherine Wong commented on Jun 14, 2023

Hi, I am try to create a combo chart (bar & line), but it still remain bar only, may I know what I have did wrong on this code?

protected function fields()
    {
        return [
            Text::create("month"),
            Currency::create("ARL")
                    ->MYR()
                    ->symbol()
                    ->decimals(0)
		    ->chartType("line"), 
	    Currency::create("Target")
                    ->MYR()
                    ->symbol()
                    ->decimals(0)
		    ->chartType("line"),
	    Currency::create("Actual")
                    ->MYR()
                    ->symbol()
                    ->decimals(0)
		    ->style(function($row){
				    return "opacity:0.5;";
				})
				
        ];
    }
KoolReport commented on Jun 19, 2023

I suspect that it could be a bug so I have forwarded your case to dev.team to further investigate. I beg your patience.

Katherine Wong commented on Jun 21, 2023

Thanks, Looking forward to your reply.

Katherine Wong commented on Jun 27, 2023

Hello, any updates?

Sebastian Morales commented on Jul 3, 2023

We will fix this issue with Dashboard's Google ComboChart in the next release. Meanwhile you can apply the following fix to solve it right at once if needed:

1 . Open the file .../koolreport/dashboard/widgets/google/ComboChart.php and add the following "beforeOnRendering" method to the class:

<?php

namespace koolreport\dashboard\widgets\google;

class ComboChart extends GoogleChart
{
    ...

    /**
     * Happens before the Google Chart rendering,
     * we try to finalize the settings by combine
     * other properties into settings properties.
     */
    protected function beforeOnRendering() // add this method
    {
        parent::beforeOnRendering();

        $settings = $this->_settings();
        $options = $settings["options"];
        $options["seriesType"] = "bars";
        $options["series"] = [];
        $dataView = $this->dataView();
        foreach ($dataView->fields() as $i => $field) {
            $seriesChartType = $field->getProp("chartType");
            if ($seriesChartType) $options["series"][$i - 1] = ["type" => $seriesChartType];
        }
        $settings["options"] = $options;
        $this->settings($settings);
        return true;
    }
} 

Let us know if this helps. Rgds,

Katherine Wong commented on Jul 3, 2023

Great! 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
bug
solved

Dashboard