KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.

Datastore return number like text #1358

Closed pargibay opened this topic on on Mar 24 - 6 comments

pargibay commented on Mar 24

Hi, I need help with this:

i try to use datastore()->toArray(); but this function returns an array with numbers with quotes.

I understand it shouldn't be like this

Thanks

Regards

KoolReport commented on Mar 24

Can you share details the output and what you need?

pargibay commented on Mar 24

Hi, I try to pass data from mysql to gauge chart but in the script represent numbers with quote. This is a problem because the gauge chart is not recognized I just saw that the array is exactly the same at hand as a result of the datastore but still doesn't recognize

 KoolReport.widget.init({"js":["\/assets\/koolreport_assets\/1072229211\/jquery.min.js",["\/assets\/koolreport_assets\/754407801\/googlechart.js"]],"css":[]},function(){
        gchart5e7a6b0c0fb101 = new KoolReport.google.chart("Gauge","gchart5e7a6b0c0fb101",["machinery","temperature"],[["machinery","temperature"],["Plaquero 2",{"v":__"14.355"__,"f":"14.355\u00baC"}],["Plaquero 1",{"v":__"-20.550"__,"f":"-20.550\u00baC"}]],{"redFrom":-18,"redTo":0,"max":15,"min":-50,"yellowFrom":-25,"yellowTo":-18,"minorTicks":5},{"package":"gauge","stability":"current","mapsApiKey":""});
 

pargibay commented on Mar 24

This is the view code:

<?php
    use \koolreport\widgets\google\Gauge;
    use \koolreport\widgets\koolphp\Table
?>
<div class="report-content">
    <div class="text-center">
        <h1>Temperatura de congeladores</h1>
    </div>
        
    <?php

if($this->dataStore("temperaturedata")->countData()>0){
	$data=array(array("machinery"=>"Plaquero 1","temperature"=>-20.438),array("machinery"=>"Plaquero 2","temperature"=>13.938));
    Gauge::create(array(
        "dataSource"=>$this->dataStore("temperaturedata")->toArray(),
        "columns"=>array(
            "machinery",
            "temperature"=>array(
                "suffix"=>"ºC",
            )
        ),
        "options"=>array(
	        "redFrom"=> -18, 
	        "redTo"=> 0,
	        "max"=> 15, 
	        "min"=> -50,
	        "yellowFrom"=>-25, 
	        "yellowTo"=> -18,
	        "minorTicks"=> 5
	    ),
    ));

    Gauge::create(array(
        "dataSource"=>$data,
        "columns"=>array(
            "machinery",
            "temperature"=>array(
                "suffix"=>"ºC",
            )
        ),
        "options"=>array(
	        "redFrom"=> -18, 
	        "redTo"=> 0,
	        "max"=> 15, 
	        "min"=> -50,
	        "yellowFrom"=>-25, 
	        "yellowTo"=> -18,
	        "minorTicks"=> 5
	    ),
    ));
echo "<br/>Array:";
print_r($data);
echo "<br/>Datastore:";
print_r($this->dataStore("temperaturedata")->toArray());
Table::create(array(
    "dataSource"=>$this->dataStore('temperaturedata')
));
}else{
	echo "No hay datos";
}

    ?>
    
</div>
KoolReport commented on Mar 24

Make it like this:

"dataSource"=>$this->dataStore("temperaturedata"), //You do not need toArray()

Also specify the type for temperature:

            "temperature"=>array(
                "type"=>"number",
                "suffix"=>"ºC",
            )
pargibay commented on Mar 24

I think quarantine is damaging my brain.

Thank you very much for your help!!

KoolReport commented on Mar 24

You are welcome :), stay safe!

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
help needed
solved

None