Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Bar Chart.....Please Help....

Status
Not open for further replies.

mobsterz

Technical User
Feb 14, 2004
13
GB
Hi,

I am quite confused at the moment, as I have this simple code, which should display a bar graph, but instead I see nothing on the screen, just a blank white page!! Here's my code:

<cfquery name=&quot;countQ1agree&quot; datasource=&quot;dynamic&quot;>
SELECT COUNT(results.Question1) AS RESPONSES, results.Question1
FROM results
IN '#application.dblocation#'
GROUP BY results.Question1
</cfquery>

<cfchart
name=&quot;Question1&quot;
format=&quot;jpg&quot;
yAxisTitle=&quot;Total number of Hits&quot;
xAxisTitle=&quot;Response&quot;
font=&quot;Arial&quot;
gridlines=6
showXGridlines=&quot;yes&quot;
showYGridlines=&quot;yes&quot;
showborder=&quot;yes&quot;
show3d=&quot;yes&quot; >

<cfchartseries
type=&quot;bar&quot;
query=&quot;countQ1agree&quot;
valueColumn=&quot;RESPONSES&quot;
itemColumn=&quot;Question1&quot;
seriesColor=&quot;olive&quot;
paintStyle=&quot;plain&quot; />

</cfchart>

Is there any way I can get a bar chart to display the results for 3 different responses to a question? This doesn't seem to work.

Thanks alot
 
Not sure why the graph wouldn't be showing up, have you verified that your query is returning results?

Try this for your query:
Code:
<cfquery name=&quot;countQ1agree&quot; datasource=&quot;dynamic&quot;>
SELECT DISTINCT(results.Question1) AS Question1, COUNT(*) AS RESPONSES
FROM results
GROUP BY results.Question1
</cfquery>
I'm not exactly sure what you're trying to do with &quot;IN '#application.dblocation#'&quot;. Are you trying to compare against a list of values or are you wanting to use a sub-query?



Hope This Helps!

Ecobb

&quot;My work is a game, a very serious game.&quot; - M.C. Escher
 
Thanks for that, I'll look into the query.

Thanks again, take care
 
Mobsterz,

Take a look at this. I think your difficulty might be in the <cfchartserie>.


<cfquery name=&quot;myquery&quot; datasource=&quot;dsn&quot; dbtype=&quot;ODBC&quot;>
Select max(inv_no)as minv_no, max(cust)as mcust, max(style)as mstyle, SUM(units)as munits,
SUM(amount)as mamount, max(color)as mcolor, max(year)as myear, max(PERIOD)as MPERIOD
from SALES#YEAR#
WHERE STYLE = '#STYLE#' AND YEAR = '#YEAR#' AND COLOR = '#COLOR#'
GROUP BY PERIOD

</cfquery>

<cfgraph
type = &quot;bar&quot;
query = &quot;myquery&quot;
valueColumn = &quot;MAMOUNT&quot;
itemColumn = &quot;MPERIOD&quot;
itemLabelFont = &quot;Arial&quot;
itemLabelOrientation = &quot;horizontal&quot;
title = #COLOR#
titleFont = &quot;Arial&quot;
fileFormat = &quot;jpg&quot;>
</cfgraph>

This code works on Cold Fusion 5.0

I believe the <cfchartseries> is for MX. I could be wrong.


Best of luck.

jspellman
 
jspellman is right.
Code:
<cfgraph>
was for ColdFusion 5.0, and it was replaced with
Code:
<cfchart>
in ColdFusion MX. What version of CF are you running mobsterz?



Hope This Helps!

Ecobb

&quot;My work is a game, a very serious game.&quot; - M.C. Escher
 
Thanks guys, I'm running MX version.

I had an idea!! Basically, what I have done is used the <IMG SRC function to use a tiny .gif picture of a square, and what I am doing is changing it's width dynamically, and passing it as being equal to the percentage. Here's abit of the code:

<cfoutput query=&quot;countQ1disagree&quot;><img align=&quot;middle&quot; src=&quot;poll-graph.gif&quot; width=&quot;#PercentQ1disagree#&quot; height=&quot;5&quot;></cfoutput>

This varies the length of the .gif file, according to a couple of calculations for the percentage (done earlier in the page). I guess for the time being this does the job.

Thanks alot for all of your support and help on this. Take care
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top