## Adobe Support Community

• cfchart: 2 series, different series length

# cfchart: 2 series, different series length

Community Beginner ,
Nov 25, 2010 Nov 25, 2010

Copy link to clipboard

Copied

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?

Views

4.8K

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
17 Replies 17
Valorous Hero ,
Nov 25, 2010 Nov 25, 2010

Copy link to clipboard

Copied

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.

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 25, 2010 Nov 25, 2010

Copy link to clipboard

Copied

Thanks for your response...

That's a good question.  I've verified that the template is in the charting directory and that style is set to "default_not_interpolated" (same name as the .xml file in the charging directory).  Is there another way to verify if it is being applied?

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Valorous Hero ,
Nov 25, 2010 Nov 25, 2010

Copy link to clipboard

Copied

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.

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 25, 2010 Nov 25, 2010

Copy link to clipboard

Copied

Thanks again...

If I understand you correctly, you are saying that the filename needs to be in the value of the Style attribute for the cfchart right?  If your answer is yes then that's already been done...it's what I meant by "style is set to "default_not_interpolated" (same name as the .xml file in the charging directory)".   For clarity, here's my code:

<cfchart format="flash" style="default_non_interpolated" yaxistitle="Cumulative \$" chartheight="300"
chartwidth="450" fontsize="10" showmarkers="no" showlegend="yes" show3d="no">

<cfchartseries type="line" serieslabel="3Yr Average"
seriescolor="##AAAAAA" >
<cfloop index="c" from="1" to="12">
<cfchartdata item="#xlabels#" value="#histAvg#">
</cfloop>
</cfchartseries>

<cfchartseries type="line" serieslabel="Current Year"
seriescolor="##018505" >
<cfloop index="c" from="1" to="#arraylen(currYrCumGraph)#">
<cfchartdata item="#xlabels#" value="#currYrCumGraph#">
</cfloop>
</cfchartseries>

</cfchart>

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

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Valorous Hero ,
Nov 25, 2010 Nov 25, 2010

Copy link to clipboard

Copied

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==-

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 26, 2010 Nov 26, 2010

Copy link to clipboard

Copied

Thanks again for working through this with me!  Really appreciate it!

So I tried a few things to get <cfchart> styles attribute to use the default_non_interpolated.xml file. I tried referencing the file as:

• c:/[cfroot]/charting/styles/[filename.xml] (original location)
• //c:/[cfroot]/charting/styles/[filename.xml]
• //[cfroot]/charting/styles/[filename.xml]
• c:\[cfroot]\charting\styles\[filename.xml]
• \[cfroot]\charting\styles\[filename.xml]

And I copied the xml to the same directory as the *.cfm file which references it and tried:

• c:/[path to site root]/[subfolder]/[filename.xml]
• //c:/[path to site root]/[subfolder]/[filename.xml]
• //[path to site root]/[subfolder]/[filename.xml]
• c:\[path to site root]\[subfolder]\[filename.xml]
• \\c:\[path to site root]\[subfolder]\[filename.xml]

None of the above worked...all threw an error "Could not find the style file....".  So I thought I'd go at it from the other end. And tried:

• [filename.xml]
• /[subfolder]/[filename.xml]
• /[sitefolder]/[subfolder]/[filename.xml]

And all of these succeeded in rendering the template (no errors) except that the graph was drawn as described in my first post.

When I tried

• /htdocs/[sitefolder]/[subfolder]/[filename.xml]

I got the error message again.

So it seems that it's not liking the full path scenario NOR is it applying the template when it is "found" (or at least not throwing an error to that effect).

Frustrating...

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Valorous Hero ,
Nov 26, 2010 Nov 26, 2010

Copy link to clipboard

Copied

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>

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 27, 2010 Nov 27, 2010

Copy link to clipboard

Copied

@cfSearching - thanks for the suggestions and apologies for the delay in getting back to this...

I tried both of your methods and they both successfully created a chart.  Alas they both  still show the second series going to zero for points 5 thru 12.

I even modified the 'autoadjust' and 'is3D' variables to ensure that cfchart was "reading" the style information correctly.  Sure enough, the chart changed when those two variables changed, but "isInterpolated" seems to have no effect on the outcome.

Just curious...did you try your code on your your machine and have it work?   If so, that means there is some setting somewhere on my machine that is fettering my attempts to get this to work!

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Valorous Hero ,
Nov 27, 2010 Nov 27, 2010

Copy link to clipboard

Copied

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.

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>

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 27, 2010 Nov 27, 2010

Copy link to clipboard

Copied

Yes...it works just fine in WebCharts.

So I've taken several other steps...

I went back to the original default.xml and started over by copying it wholesale to a new_non_interpolated.xml.  I then changed the "isInterpolated" attribute and still got the same extended line.  I've copied the new_non_interpolated to every possible directory I can think of (direct directory of the template, directory of a the calling template, root of the site, and in the original charting/styles directory of CF9.   All to no avail.  I even looked in CF Administrator to see if there was an obvious setting that I might have changed, but nothing of the sort exists.

This is truly baffling...

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Valorous Hero ,
Nov 27, 2010 Nov 27, 2010

Copy link to clipboard

Copied

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?

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 27, 2010 Nov 27, 2010

Copy link to clipboard

Copied

Yeah, I've kinda reached the end of the road for now too.

Full CF is:                  9,0,1,274733

I've cleared the browser cache and the server cache. No luck.

It also occurred to me that I've solely been testing this in Firefox 3.6.12.  So I tried it in IE as well.   No luck.

One other thought: are you on a Win7 box?  Could be that that's the only diff between our systems?  It would only be something about the interaction between WebCharts and CF9 though since WebCharts by itself seems fine.

Ah well, when I get some more time I might try reinstalling CF9 on this box or maybe on an old Win XP box just for giggles.

Thanks again for all of your responses...been fun troubleshooting with you.  I don't know where in the world you might be, but from this Californian a Happy (belated) ThanksGiving!!   And if that's not a holiday where you are, then be well and go out and enjoy life!

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Valorous Hero ,
Nov 27, 2010 Nov 27, 2010

Copy link to clipboard

Copied

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

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Valorous Hero ,
Nov 27, 2010 Nov 27, 2010

Copy link to clipboard

Copied

 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:

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,September,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==-

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 28, 2010 Nov 28, 2010

Copy link to clipboard

Copied

Awesome!  Thanks for discovering this apparent bug.  If you haven't already logged it with Adobe, I'd be happy to.

I can certainly build a quick query (pain in the butt, but if it gets the job done...).  I'll give it a try and make sure that it does indeed work in my situation as well.

Thanks again for nailing this one.

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Valorous Hero ,
Nov 28, 2010 Nov 28, 2010

Copy link to clipboard

Copied

 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 😉

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 28, 2010 Nov 28, 2010

Copy link to clipboard

Copied

LATEST

Converting the array to a query worked like a champ.

Bug posted as #85200.

On to the next challenge!

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more