KoolReport's Forum

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

DrillDown does not load second level by pressing #3192

Closed TICGAL opened this topic on on Nov 21, 2023 - 9 comments

TICGAL commented on Nov 21, 2023

I added a Drilldown with a widget of type ColumnChart but when I click on a bar it doesn't load the next level. It doesn't show any error either

TICGAL commented on Nov 29, 2023

Any feedback on this? Support is not very good

KoolReport commented on Nov 30, 2023

Really sorry for the late reply, could you please provide us more information such as:

  1. Please turn on the error_reporting so that we can see what may go wrong. Also, please see if there is any javascript error on browser after you click the bar.
  2. Please show us your code as well.
TICGAL commented on Nov 30, 2023

Browser does not show any error when clicked.

This is the code I use

DrillDown::create([
    "name" => "Time",
    "title" => "Time",
    "levels" => [
				[
					"title" => __('By month'),
					"widget" => [
						ColumnChart::class, [
							"dataSource" => function($params, $scope) use ($DB, $query) {
								$query['SELECT'][] = new QueryExpression("FROM_UNIXTIME(UNIX_TIMESTAMP(" . $DB->quoteName(PluginActualtimeTask::getTable() . ".actual_begin") . "),'%Y-%m') AS period");

								$iterator = new DBmysqlIterator($DB);
								$iterator->buildQuery($query);
								$sql = $iterator->getSql();
								$this->src('glpi')->query($sql)
								->pipe(new \koolreport\cube\processes\Cube([
									'row' => 'period',
									'column' => 'users_id',
									'sum' => 'total'
								]))
								->pipe(new \koolreport\processes\Map([
									"{value}" => function($row) {
										$aux = $row;
										unset($aux['period']);
										foreach ($aux as $key => $value) {
											$row[$key] = round($value / HOUR_TIMESTAMP, 2);
										}
										return $row;
									},
									"{meta}" => function($meta) {
										$aux = $meta['columns'];
										unset($aux['period']);
										unset($aux['{{all}}']);
										foreach ($aux as $key => $value) {
											$meta['columns'][$key] = [
												'label' => getUserName($key)
											];
										}
										$meta['columns']['{{all}}'] = [
											'label' => __('Total')
										];
										return $meta;
									}
								]))
								->pipe($this->dataStore('actualTime'));
								return $this->dataStore('actualTime');
							}
						]
					]
				],
				[
					"title" => __('Each week'),
					"widget" => [
						ColumnChart::class, [
							"dataSource" => function($params, $scope) use ($DB, $query) {
								$query['SELECT'][] = new QueryExpression("WEEK(" . $DB->quoteName(PluginActualtimeTask::getTable() . ".actual_begin") . ") AS period");

								$query['WHERE'][] = [
									PluginActualtimeTask::getTable() . ".actual_begin" => ['>=', date("Y-m-01 00:00:00", $params['period'])],
									'AND' => [
										PluginActualtimeTask::getTable() . ".actual_begin" => ['<=', date("Y-m-t 23:59:59", $params['period'])]
									]
								];
								$iterator = new DBmysqlIterator($DB);
								$iterator->buildQuery($query);
								$sql = $iterator->getSql();
								$this->src('glpi')->query($sql)->pipe(new \koolreport\cube\processes\Cube([
									'row' => 'period',
									'column' => 'users_id',
									'sum' => 'total'
								]))
								->pipe(new \koolreport\processes\Map([
									"{value}" => function($row) {
										$aux = $row;
										unset($aux['period']);
										foreach ($aux as $key => $value) {
											$row[$key] = round($value / HOUR_TIMESTAMP, 2);
										}
										return $row;
									},
									"{meta}" => function($meta) {
										$aux = $meta['columns'];
										unset($aux['period']);
										unset($aux['{{all}}']);
										foreach ($aux as $key => $value) {
											$meta['columns'][$key] = [
												'label' => getUserName($key)
											];
										}
										$meta['columns']['{{all}}'] = [
											'label' => __('Total')
										];
										return $meta;
									}
								]))
								->pipe($this->dataStore('actualTime'));
								return $this->dataStore('actualTime');
							}
						]
					]
				],
			],
    'css' => [
        'panel' => 'background-color: #fff; border: 1px solid #ddd; border-radius: 5px; padding: 10px;',
]);

TICGAL commented on Dec 11, 2023

Hi, Is there any other way to get support? This method is very slow. Thanks

KoolReport commented on Dec 12, 2023

Really sorry for the late reply, despite of looking at the code, I have not been able to spot what may go wrong. There are something that you may try to further debug.

  1. Please define clearly the list of columns for ColumnChart in first level.
  2. In the second level, inside the dataSource anonymous function, please check whether $params is correct. You can just put var_dump($params) to make sure parameter is correct sent from first level. Since this will be ajax request, so you can see the var_dump text from the inspector tool in browser.

Please let me know.

TICGAL commented on Dec 12, 2023

Hi. The graph I am trying to generate is the total user hours per month. As the number of users is not fixed I use the Map package.

Anyway for testing purposes I tried to manually indicate the users.


"columns" => [
	"period" => [
		"type" => "string"
	],
	"{{all}}" => [
		"type" => "number"
	],
	"2" => [
		"type" => "number"
	],
	"7" => [
		"type" => "number"
	],
],

I also add var_dump() but it still does not show me anything.

I have the feeling that the drilldown is not adding the 'onclick' in the columns that is why it is not showing me any error.

Is it possible that I need to load some other package besides DrillDown?

KoolReport commented on Dec 12, 2023

That's mystery. So it does not show any single error, even javascript at client-side? Is it possible that you replicate this issue and make it online, send the link over to our support@koolreport.com, I will try to spot out the issue as soon as possible. Let leave the var_dump(params);exit; inside the "dataSource"

TICGAL commented on Dec 13, 2023

Hi. I have already sent an email with the instructions to access the site.

KoolReport commented on Dec 13, 2023

We have received your email, please try to temporarily use ColumnChart from chartjs or google charts which are supported by DrillDown package at this moment. We will make apexcharts work with drilldown in next version.

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

DrillDown