Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Google charts

Questions related to nuBuilder Forte Reports and the Report Builder.
Post Reply
GlenMcCabe
Posts: 114
Joined: Sun Sep 29, 2019 12:40 pm

Google charts

Unread post 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
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Google charts

Unread post by kev1n »

Hi,

With PHP you can prepare the data and pass it to a JavaScript variable:
https://forums.nubuilder.cloud/viewtopic. ... ata#p16492
GlenMcCabe
Posts: 114
Joined: Sun Sep 29, 2019 12:40 pm

Re: Google charts

Unread post 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
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Google charts

Unread post 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) . ";";
GlenMcCabe
Posts: 114
Joined: Sun Sep 29, 2019 12:40 pm

Re: Google charts

Unread post 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
GlenMcCabe
Posts: 114
Joined: Sun Sep 29, 2019 12:40 pm

Re: Google charts

Unread post by GlenMcCabe »

Kevin

I replaced the d1 and d2 with absolute dates and it made no difference.
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Google charts

Unread post by kev1n »

Add

Code: Select all

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