Charting output calculations?

Discussion in 'Programming' started by garrettdr, Nov 15, 2007.

  1. #1
    Hi all,
    I’m using a Coldfusion form to calculate and output variables in a form. Most of the forms values come from a database. In the code I apply various conversion factors , the user chooses their values and the form calculates the results upon submission.
    Currently I am simply outputting the results using the <cfoutput tag to a table however I would really like to output the results to a chart however so far all my research shows that the only way to chart data is if the user queries the database which this is not what I am doing.

    I have the example forms here if anyone would care to take a look (no design has been applied to them yet)
    http://www.carbonacs.com/fcalc/eocalc.cfm

    Any input is gratefully received,
    Thanks, Garrett
     
    garrettdr, Nov 15, 2007 IP
  2. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can create charts without using a query. Though its often easier. You could also put your calculations/values into a manual query. Then use the manual query in your chart.

    HTH

    
    <!--- option 1 --->
    <cfset form.numberOfApples = 35>
    <cfset form.numberOfOranges = 28>
    <cfset form.numberOfPears = 30>
    
    <cfchart show3D="yes">
    	<cfchartseries type="bar">
    		<cfchartdata item="Apples" value="#form.numberOfApples#">
    		<cfchartdata item="Oranges" value="#form.numberOfOranges#">
    		<cfchartdata item="Pears" value="#form.numberOfPears#">
    	</cfchartseries>
    </cfchart>
    
    <!--- option 2 --->
    <cfset yourManualQuery = QueryNew("Item,Value")>
    <cfset queryAddRow(yourManualQuery, 3)>
    <cfset yourManualQuery["Item"][1] = "Apples">
    <cfset yourManualQuery["Value"][1] = form.numberOfApples>
    <cfset yourManualQuery["Item"][2] = "Oranges">
    <cfset yourManualQuery["Value"][2] = form.numberOfOranges>
    <cfset yourManualQuery["Item"][3] = "Pears">
    <cfset yourManualQuery["Value"][3] = form.numberOfPears>
    
    <cfchart show3D="yes">
    	<cfchartseries type="bar" 
    		query="yourManualQuery"
    	    itemcolumn="Item"
    		valuecolumn="Value" />
    </cfchart>
    
    Code (markup):
     
    cfStarlight, Nov 15, 2007 IP
  3. garrettdr

    garrettdr Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank so much for that. Your solution worked perfectly. After hours of fruitless research last night I have never been so happy to see a chart work.

    Thanks again, Garrett
     
    garrettdr, Nov 16, 2007 IP
  4. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You're welcome
     
    cfStarlight, Nov 16, 2007 IP