Page 1 of 1

Google charts

Posted: Tue Mar 23, 2021 12:19 am
by GlenMcCabe
I have a set of reports where the user can input a date range. I want to produce charts for some of them.

1) what is the format of the call to google charts?
2) can I use a drop down to choose the type of chart or do I need a button to run each type?

Any examples / videos available.

Thanks in advance

Re: Google charts

Posted: Tue Mar 23, 2021 9:07 am
by kev1n
Hi,

With PHP you can prepare the data and pass it to a JavaScript variable:
https://forums.nubuilder.cloud/viewtopic. ... ata#p16492

Re: Google charts

Posted: Tue Mar 23, 2021 10:12 pm
by GlenMcCabe
Kevin thanks - tried to emulate this

I entered the following in the before edit

$a[] = ['Owner', 'Number of referrals'];
$s = SELECT
practitioners.name,
COUNT(referral.ownerID)
FROM
referral
LEFT JOIN practitioners ON ownerID=practitioners.id
WHERE
((referral.referralDate BETWEEN '#d1#' AND '#d2')) ( d1 and d2 are dates input on the form. They work fine for PDF report listing)
GROUP BY referral.ownerId
$t = nuRunQuery($s);

while($r = db_fetch_row($t)){
$a[] = [$r[0], ($r[1]))];
}

$j = "refbyown.data = " . json_encode($a) . ";";

When I try to enter the form I get an error and cant enter the form. see attachment

Re: Google charts

Posted: Tue Mar 23, 2021 10:17 pm
by kev1n
I corrected some syntax errors:

Code: Select all

$a[] = ['Owner', 'Number of referrals'];

$s = "
	SELECT
	practitioners.name,
	COUNT(referral.ownerID)
	FROM
	referral
	LEFT JOIN practitioners ON ownerID=practitioners.id
	WHERE
	(referral.referralDate BETWEEN '#d1#' AND '#d2') 
	GROUP BY referral.ownerId
";

$t = nuRunQuery($s);

while($r = db_fetch_row($t)){
	$a[] = [$r[0], $r[1]];
}

$j = "refbyown.data = " . json_encode($a) . ";";

Re: Google charts

Posted: Tue Mar 23, 2021 11:04 pm
by GlenMcCabe
Thanks Kevin

That has got rid of the error message. However only the label of the HTML chart appears.

Can I check what is held in refbyown.data.?

Can the edit before be aware of #d1# and #d2# which are only input on the form when it opens?

Can I put the chart on a subform so that #d1# and #d2# are declared before I open the subform?

Glen

Re: Google charts

Posted: Tue Mar 23, 2021 11:33 pm
by GlenMcCabe
Kevin

I replaced the d1 and d2 with absolute dates and it made no difference.

Re: Google charts

Posted: Wed Mar 24, 2021 7:05 am
by kev1n
Add

Code: Select all

nuDebug($s);
before running the query and view the nuDebug Results.