Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 477
  • Last Modified:

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...
0
Fusionite
Asked:
Fusionite
  • 3
  • 2
  • 2
1 Solution
 
nickj224Commented:
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
0
 
FusioniteAuthor Commented:
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
0
 
nickj224Commented:
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.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
mmc98dl1Commented:
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>
0
 
FusioniteAuthor Commented:
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.....
0
 
mmc98dl1Commented:
try

<cfchart>
     <cfchartseries type="bar">
          <cfloop index="i" from="1" to="20">
               <cfchartdata item="#i#" value="#NumberFormat(Evaluate("getAnswers.#i#"),"99")#">
          </cfloop>
     </cfchartseries>
</cfchart>

or

<cfchart>
     <cfchartseries type="bar">
          <cfloop index="i" from="1" to="20">
               <cfchartdata item="#i#" value="#listFirst(Evaluate("getAnswers.#i#"),".")#">
          </cfloop>
     </cfchartseries>
</cfchart>
0
 
mmc98dl1Commented:
I am pretty sure my answer is correct from what I understand, but we never had any feedback.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now