KoolReport's Forum

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

Transform data for Google/Timeline #1698

Open Patryk opened this topic on on Nov 5, 2020 - 1 comments

Patryk commented on Nov 5, 2020

Hi, I'm trying to generate google/timeline chart. When I use datastore generated from db, I have array data like below

Dump => array(3) {
  [0] => array(3) {
    ["EVENT_TYPE"] => string(2) "BP"
    ["PROD_STARTTIME_DT"] => string(23) "2020-10-12 06:00:00.000"
    ["PROD_STOPTIME_DT"] => string(23) "2020-10-12 12:00:00.000"
  }
  [1] => array(3) {
    ["EVENT_TYPE"] => string(1) "P"
    ["PROD_STARTTIME_DT"] => string(23) "2020-10-12 12:00:00.000"
    ["PROD_STOPTIME_DT"] => string(23) "2020-10-12 17:45:00.000"
  }
  [2] => array(3) {
    ["EVENT_TYPE"] => string(1) "I"
    ["PROD_STARTTIME_DT"] => string(23) "2020-10-12 17:45:00.000"
    ["PROD_STOPTIME_DT"] => string(23) "2020-10-12 18:00:00.000"
  }
}

\koolreport\widgets\google\Timeline::create(array(
		"dataStore"=>$this->dataStore('PackagingLineTotal'),
		"columns"=>array(
			"EVENT_TYPE",
			"PROD_STARTTIME_DT"=>array(

				"type"=>"date",
			
			),
			"PROD_STOPTIME_DT"=>array(

				"type"=>"date",
			)
		),
		"withoutLoader"=>true
	));

When I try to create chart from those data I get error "Missing value in row 0." In the documentation/example there is a structure

[
        ['President','Start','End'],
        [ 'Gerald Ford',  "1974-01-20",  "1977-01-20" ],
        [ 'Jimmy Carter',  "1977-01-20",  "1981-01-20" ],
        [ 'Ronald Reagan',  "1981-01-20",  "1989-01-20" ],
        [ 'George H. W. Bush',  "1989-01-20",  "1993-01-20" ],
        [ 'Bill Clinton',  "1993-01-20",  "2001-01-20" ],
        [ 'George W. Bush',  "2001-01-20",  "2009-01-20" ],
        [ 'Barack Obama',  "2009-01-20",  "2017-01-20" ],
        [ 'Donald Trump',  "2017-01-20",  date("Y-m-d") ],
    ],

I don't have idea how to transform my data result to the structure accepted by timeline. Maybe I do something wrong? I would be appreciate for any suggestions.

Sebastian Morales commented on Nov 6, 2020

Patryk, please try using "dataSource" property instead of "dataStore" for chart widget:

    "dataSource"=>$this->dataStore('PackagingLineTotal')

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