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
Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Google charts
-
- nuBuilder Team
- Posts: 4562
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 528 times
- Contact:
Re: Google charts
Hi,
With PHP you can prepare the data and pass it to a JavaScript variable:
https://forums.nubuilder.cloud/viewtopic. ... ata#p16492
With PHP you can prepare the data and pass it to a JavaScript variable:
https://forums.nubuilder.cloud/viewtopic. ... ata#p16492
-
- Posts: 114
- Joined: Sun Sep 29, 2019 12:40 pm
Re: Google charts
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
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.
-
- nuBuilder Team
- Posts: 4562
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 528 times
- Contact:
Re: Google charts
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) . ";";
-
- Posts: 114
- Joined: Sun Sep 29, 2019 12:40 pm
Re: Google charts
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
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
-
- Posts: 114
- Joined: Sun Sep 29, 2019 12:40 pm
-
- nuBuilder Team
- Posts: 4562
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 528 times
- Contact:
Re: Google charts
Add
before running the query and view the nuDebug Results.
Code: Select all
nuDebug($s);