Skip navigation
Currently Being Moderated

cfchart: 2 series, different series length

Nov 25, 2010 9:51 AM

I am plotting two lines on a cfchart:  1) a line with historical monthly averages (12 data points); 2) the actual data for the current year (which only has as many data points as there are "completed" months in the current year).

 

What I want to have happen is for all 12 months of (1) to be plotted as one line and then have a second line drawn that only shws the months of the current year for which data has ben collected (say the first three months).  For the remaining periods of the second line(e.g., 9 months) I want to show nothing (no line).  In other words the second line just stops after the first 3 data points are drawn.  Both series are arrays.

 

Here's what I've tried:

When the second array contains only 3 data points (i.e., arraylen = 3), cfchart draws the 4th through 12th data point as 0 and draws the line accordingly even though I am using chartdata within a loop that only loops 3 times.  If I create an empty array of 12 items (i.e. each item is empty) and then insert data for the first three, cfchart throws an error because item 4 through 12 are not values.

 

BTW I am using a custom xml style sheet that has "isInterpolated" set to "false".

 

Any suggestions as to how I might get the chart drawn correctly?

 
Replies
  • Currently Being Moderated
    Nov 25, 2010 10:34 AM   in reply to CFsolar

    BTW I am using a custom xml style sheet that has

    "isInterpolated" set to "false".

     

    Are you sure it is being applied? Because that should produce the desired results.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 25, 2010 3:15 PM   in reply to CFsolar

    Placing the file in the charting directory probably is not enough. Use cfchart's "style" attribute to point to your custom file (or pass in a variable containing the xml). Technically your file does not even have to be in the charting directory. It can be anywhere accessible to CF.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 25, 2010 3:41 PM   in reply to CFsolar

    style="default_non_interpolated"

     

    Almost. It should be an absolute path to the file

    ie c:\full\path\to\default_non_interpolated.xml

     

    Update:  This part did not show up in the first email

    Are you suggesting that I use the full path to the xml file?

    Yes

     

    Message was edited by: -==cfSearching==-

     

    Message was edited by: -==cfSearching==-

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 26, 2010 11:22 PM   in reply to CFsolar

    Weird. I tend to use variables. So I was about to say I could be wrong about the path. Maybe a url is expected. But it looks like you tried that already.

     

    Try these two examples. Both work fine for me with CF9 (and CF8). Everything except isInterpolated was excluded for brevity. So obviously most of the styling will be missing. But the lines should be correct.

     

    1. Use a variable

     

    <cfsavecontent variable="myStyle"><?xml version="1.0" encoding="UTF-8"?>
    <frameChart autoAdjust="false" is3D="false" isInterpolated="false">
    </frameChart>
    </cfsavecontent>

     

    <cfchart style="#myStyle#">
         <cfchartseries type="line">
             <cfloop from="1" to="12" index="x">
                 <cfchartdata item="#MonthAsString(x)#" value="#randRange(1, 100)#">
             </cfloop>
         </cfchartseries>
         <cfchartseries type="line">
             <cfloop from="1" to="4" index="x">
                 <cfchartdata item="#MonthAsString(x)#" value="#randRange(1, 100)#">
             </cfloop>
         </cfchartseries>
    </cfchart>

     


    2.  Save the contents of "myStyle" to a file in the same directory as your .cfm script.

     

    XML File: c:\coldfusion9\wwwrooot\testFolder\myStyle.xml

    CFM File:  c:\coldfusion9\wwwrooot\testFolder\myTestChart.cfm

     

    <cfchart style="myStyle.xml">
        <cfchartseries type="line">
            <cfloop from="1" to="12" index="x">
                <cfchartdata item="#MonthAsString(x)#" value="#randRange(1, 100)#">
            </cfloop>
        </cfchartseries>
        <cfchartseries type="line">
            <cfloop from="1" to="4" index="x">
                <cfchartdata item="#MonthAsString(x)#" value="#randRange(1, 100)#">
            </cfloop>
        </cfchartseries>
    </cfchart>

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 27, 2010 12:14 PM   in reply to CFsolar

    Yes, I did test it with CF8 and CF9 and the results were different from yours. That is why I am a bit puzzled. The image below was created using example #1 running under CF9.

     

    cfchart_isInterpolatedFalse.PNG

     

    Do you get the same results using the webcharts utility?  Open it up and select the first 2D line chart. The isInterpolated property should be unchecked. Click the xmlModel tab and paste in the modified data for the second line. After applying it does the green "Expense" line stop at 2001?

     

    <?xml version="1.0" encoding="UTF-8"?>
    <XML type="default">
    <COL>2000</COL>
    <COL>2001</COL>
    <COL>2002</COL>
    <COL>2003</COL>
    <COL>2004</COL>
    <COL>2005</COL>
    <ROW col0="100.0" col1="200.0" col2="100.0" col3="180.0" col4="200.0" col5="400.0">Income</ROW>
    <ROW col0="150.0" col1="300.0" col2="" col3="" col4="" col5="">Expense</ROW>
    </XML>

     

    cfchart_isInterpolatedFalse.PNG

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 27, 2010 1:50 PM   in reply to CFsolar

    Though it sounds like some of your previous steps would eliminate a caching problem, that would certainly be the obvious guess. Just for grins, have you tried clearing cache (both browser and server). Also, does a non-flash chart produce the same results?

     

    I admit I am grasping at straws a this point. But given that we both ran the exact same code, the difference in results is very weird. What is your full CF version number?

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 27, 2010 7:52 PM   in reply to CFsolar

    It is very odd. Especially as it does work within webcharts. So one would expect the same behavior when called from cfchart. I also cannot say I have ever heard of an issue with that setting (alone).

     

    For what it worth, I tested on an old XP test box (without updates 9,0,0,251028). When I get a chance, I will have to try it on another box running 9.0.1. See if it there is any difference.

     

    >> been fun troubleshooting with you.

     

    Yes, I enjoyed it too. Hope you are enjoying your (extended) Thanksgiving

     

    -Leigh

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 27, 2010 9:12 PM   in reply to CFsolar
    Full CF is:                  9,0,1,274 733

     

    I think we found the problem. I updated the test box to 9,0,1,274733 and now I am seeing the same results you are:

     

    cfchart_isInterpolatedFalse.PNG

     

    Update:  Well ... apparently, isInterpolated=false is respected if you use a query to populate the series and the query contains all twelve (12) months, even if the later months are empty/null. Sounds like a bug ...

     

            <!--- Sample query --->

    <cfset qry = queryNew("")>
    <cfset queryAddColumn(qry, "MonthName", listToArray("January,February,March,April,May,June,July,August,Septem ber,October,November,December"))>
    <cfset queryAddColumn(qry, "MonthValue", listToArray("85,50,65,100,,,,,,,,", ",", true))>
    <cfdump var="#qry#">

     

     


    <cfchart style="#myStyle#">
         <cfchartseries type="line">
             <cfloop from="1" to="12" index="x">
                 <cfchartdata item="#MonthAsString(x)#" value="#randRange(1, 100)#">
             </cfloop>
         </cfchartseries>
       
        <cfchartseries type="line" query="qry"
                        itemcolumn="MonthName"
                        valuecolumn="MonthValue" />   
    </cfchart>

     

    Message was edited by: -==cfSearching==-

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 28, 2010 2:57 PM   in reply to CFsolar
    I'll give it a try and make sure that it does indeed work in my situation as well

     

    Yes, give it a whirl. It should produce the correct results as long as you pad it with the empty months.

     

    I did not log the change in behavior in the public bug tracker yet. So feel free. Just post the bug number back here for reference. Anyway, glad we finally figured out the problem.  Nothing like a happy ending .. or at least a work around ;-)

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points