jsoncoldfusioncfchart

Dynamic Y axis with Json in Coldfusion 11


I have many charts in my application Is there any way to make the y axis more dynamic with json . I am using coldfusion 11. Please see my code

 <cfchart  
         format="#format#"
           chartheight="320" chartwidth="690"  showborder="yes" 
        title="Trend in Subject Rents" style="20currency.js" name="TwntyQtrGraph1" tipstyle="mouseOver" 
        tooltip="#Deserializejson(stc_fields)#"  gridlines="#GraphInterval#">  
         <cfchartseries type="line" 
                 serieslabel="Gross"
                 seriescolor="navy"  markerStyle="diamond" paintStyle="plain" > 
                <cfloop query="qry_subproperty"> 
                     <cfset variables.Yearquarter=ObjPropDetails.JoinYearQuarter(qry_subproperty.Yearquarter)>            
                 <cfchartdata item="#variables.Yearquarter#" value="#round(qry_subproperty.Gross)#" >
                </cfloop>              
            </cfchartseries>

Solution

  • You can set the max-value and step interval through the yAxis property in cfchart. These values can be dynamic. You can also set an array of values if you want "values":[0,200,400,600,800,1000]. The scalefrom ,scaletop and the interval(eg values:100:500:10) technique doesn't appear to work. But like I said you can get the same result using max-value and step.

    <cfset yAxis = {"min-value":"0","max-value":"1000","step":"200"}>
    <cfchart  
         format="#format#" yAxis="#yAxis#" 
           chartheight="320" chartwidth="690"  showborder="yes" 
        title="Trend in Subject Rents" style="20currency.js" name="TwntyQtrGraph1" tipstyle="mouseOver" 
        tooltip="#Deserializejson(stc_fields)#"  gridlines="#GraphInterval#">  
         <cfchartseries type="line" 
                 serieslabel="Gross"
                 seriescolor="navy"  markerStyle="diamond" paintStyle="plain" > 
                <cfloop query="qry_subproperty"> 
                     <cfset variables.Yearquarter=ObjPropDetails.JoinYearQuarter(qry_subproperty.Yearquarter)>            
                 <cfchartdata item="#variables.Yearquarter#" value="#round(qry_subproperty.Gross)#" >
                </cfloop>              
            </cfchartseries>
    </cfchart>