coldfusioncfchartcoldfusion-11

set width of cfchartseries in Coldfusion 11


I have upgraded my cf site from cf 7 to cf 11 recently. But I am not able to set the width of cfchartseries. I have found in Adobe documentation to set the background as "fit: Defines the width/height to fit area of background." How can I set the width of Cfchartseries in coldfusion 11 using JSON? Please help.

Thanks.


Solution

  • You need to set the plotarea margin values to dynamic. This dynamically includes the scale values when determining the position of the chart. You can set the height and width of the plot area as well but this doesn't include the scales. I have found the best results is to include all styles through a JS file and calling it through the style attribute in cfchart.

    Below is a basic example:

    Create a JS file called test.js

    {
    "graphset":[
        {
        "border-width":1, 
        "background-color":"transparent",
        "plotarea":{"margin":"dynamic"}
        }
      ]
    }
    

    Add this chart code to a cfm page in the same directory as the test.js file (for example only)

    <cfchart format="html" showlegend="no" height="200" width="250" title="" show3d="no" style="test.js">
       <cfchartseries type="bar" paintstyle="light" color="red">
           <cfchartdata item="2005" value="1000"/>
           <cfchartdata item="2006" value="3000"/>
           <cfchartdata item="2007" value="1000"/>
           <cfchartdata item="2008" value="4000"/>
           <cfchartdata item="2009" value="2000"/>
       </cfchartseries> 
    </cfchart>