Link to home
Start Free TrialLog in
Avatar of Fusionite
Fusionite

asked on

CFCHART or CFGRAPH

Hello,

I need to use either CFGRAPH or CFCHART  to do the following.

I have a form that a user places a value from 0 - 10 depending on how they feel about the subject matter for 20 specific questions.  What I need to plot is the question numbers across the horizontal axis and their ratings on the vertical axis.  The values of the 20 individual questions have their own individual columns in the database.  Most of the graph or charting explained in books is average based and not so much pulling 20 individual columns to populate a bar chart; although you can select an individual column there is no way to select all 20 columns across 1 individual row.  I figure this may be an easy task and I am over thinking the solution.

Database Table is as follows (SQL Server):

ID  = "int"  (PK)
Name = "nvarchar"  (FK)
[1] THROUGH [24] = "numeric"

I'd give a 500 Bonus Points total for help.

Thanks for your help....
Fusionite...
Avatar of nickj224
nickj224

I am not 100% sure what you are asking, but I think what you are trying to accomplish can be done with the cfchartdata tag.  CFGRAPH is depreciated after CF5, so I would use CFCHART depending on what version of CF you are using.

<cfchart *attributes*>

   <cfchartseries type="bar">

        <cfloop index="x" from="1" to="20">

              <cfchartdata item="#x#" value="#myquery.mycolumn#">

        </cfloop>

   </cfchartseries>

</cfchart>

Hope this helps
Avatar of Fusionite

ASKER

Hi Nick

Thanks for answering.  Here is the only problem I am having with your code, now it appears that  the limited selection of myquery.mycolumn only displays the value of one of the columns across 24 rows.  Meaning that now instead of the values being 8 for 1, 9 for 2, it is coming up 8 for 1, 8 for 2 all the way to 24 the value is 8.  So it appears that if I specify a single value I only get that value result in all 24 plots.  I tried adding an additional line with a different column number, but it took the value of the second column as well and looped right past.  Here is the code, we are very close, your help is greatly appreciated!  I think if you could tweak the value column in the chartdata segment we should be golden!


<cfchart>

   <cfchartseries type="bar">

        <cfloop index="x" from="#1#" to="#24#">
           
         <cfchartdata item="#x#" value="#plot.1#">
         </cfloop>

   </cfchartseries>

</cfchart>

Thanks for all your help!
Fusionite
Just so I understand better, you are looking for 1 chart per person?  I assume this since each record in your DB has 1 column per answer for 20 answers and you want to show 20 bars across.
this should do you:

<cfquery name="getAnswers">
      SELECT *
      FROM Answers
      WHERE Name = 'PersonName'
</cfquery>

<cfchart>
      <cfchartseries type="bar">
            <cfloop index="i" from="1" to="20">
                  <cfchartdata item="#i#" value="#Evaluate("getAnswers.#i#")#">
            </cfloop>
      </cfchartseries>
</cfchart>
mmc98dl1 this works fine, but now all my y-axis data is showing up as decimal places.  I wanted the Y-axis to go from 0 - 10 (integers not decimals).  The x-axis is perfect, now if I can get the y right I am all set.  Thanks for your help!

I want the y to show like the following

0 , 1, 2 , 3

my data is coming up

0, 1.1111, 2.2222, 3.3333  etc up to 10.  0 and 10 are the only values appearing as integers everything else is a whole number plus decimal point and 4 places to the right.

Thanks again!

Fusionite.....
ASKER CERTIFIED SOLUTION
Avatar of mmc98dl1
mmc98dl1
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am pretty sure my answer is correct from what I understand, but we never had any feedback.