?
Solved

CFChart Problem

Posted on 2010-04-07
2
Medium Priority
?
439 Views
Last Modified: 2012-06-27
This may be a silly question, but I would like an answer!
If have a chart which shows the number of hours worked per week (see image attached).  The green line is last year's data and you can ignore the red line.  Our year starts in week 14 and so there is only one line returned by the query for this year so far showing 6315 hours (the orange line).  My code is below.  

My question is, why do I have an orange line that stays at the same level for the whole year as the current week.  (Should it not have the rest of the year showing at the bottom of the graph (point 0))?
<cfchart format = "flash" chartHeight = "500" chartWidth = "1000" showXGridlines = "yes" showYGridlines = "yes" showLegend="no" yAxisTitle = "Hours" sortXAxis = "no" showmarkers="no">

<cfchartseries query="QoQ_Qty" type="line" itemColumn="WkNo" valueColumn="TotQty" serieslabel=""> 
</cfchartseries>

<cfchartseries query="QoQ_Qty#MYear#" type="line" itemColumn="WkNo" valueColumn="TotQty" serieslabel=""> 
</cfchartseries>

<cfchartseries type="line" seriescolor="red">
 <cfchartdata value=8000>
</cfchartseries>
</cfchart>

Open in new window

Graph.jpg
0
Comment
Question by:jdthedj
2 Comments
 
LVL 27

Accepted Solution

by:
azadisaryev earned 2000 total points
ID: 30117171
cf interpolates any missing data points in the chart by default - that's why it 'inserts' same value 6315 for each data point that does not have actual data.
unfortunately, and silly enough, there is no setting to change this in cfchart tag - there is no attribute that controls this.

so you have 2 options depending on how you want to present the data:
1) add 0 as value for each missing data point. do this if you would rather have the line dip to 0 when there is no data. you will need to edit your query that gets the data to set the value to 0 when it is null. the syntax is db-specific, so let me know what db you are using and post your query as it is now if you need help with this.

2) turn of this default data interpolation by providing a custom xml stulesheet for your chart. do this if you rather want to have no line drawn at all for missing data points (i.e. the line will not dip to 0 - there will just be no line for a missing data point). attached is an example of how to set a custom style for your chart that switches the data interpolation off. note that i have changed showmarkers="no" to "yes" so that the single point of your orange line is visible on the chart (otherwise no line will be visible at all, since the whole line is just one data point).

Azadi
<!--- create a custom xml chart style as myChartStyle var using cfsavecontent tag --->
<cfsavecontent variable="myChartStyle">
<?xml version="1.0" encoding="UTF-8"?>
<frameChart autoAdjust="false" is3D="false">
  <frame xdepth="1" ydepth="1" outline="black" />
  <elements place="Default" shape="Line" drawOutline="false" drawShadow="false" />
  <paint paint="Plain"/>
  <insets left="5" top="5" right="5" bottom="5"/>
</frameChart>
</cfsavecontent>

<!--- use our custom style in the chart by setting <cfchart>'s STYLE attribute --->
<cfchart format="flash" chartHeight="500" chartWidth="1000" showXGridlines="yes" showYGridlines="yes" showLegend="no" yAxisTitle="Hours" sortXAxis="no" showmarkers="yes" STYLE="#myChartStyle#">

<cfchartseries query="QoQ_Qty" type="line" itemColumn="WkNo" valueColumn="TotQty" serieslabel=""></cfchartseries>

<cfchartseries query="QoQ_Qty#MYear#" type="line" itemColumn="WkNo" valueColumn="TotQty" serieslabel=""></cfchartseries>

<cfchartseries type="line" seriescolor="red">
 <cfchartdata value=8000>
</cfchartseries>
</cfchart>

Open in new window

0
 
LVL 3

Author Closing Comment

by:jdthedj
ID: 31712097
Thanks Azadi - that's amazing!  I have gone with the XML solution.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
If you are looking for an automated solution for backup single or multiple Office 365 user mailboxes to Outlook data file, then you can use Kernel Office 365 Backup & Restore tool. Go through the video to check out the steps to backup single or mult…

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question