Thursday, June 23, 2005

Image expired trouble?

Problem
The following message is shown instead of the graphs:
"Image Expired
Please refresh the page
To view the image"


Lot of people have faced this problem, the reason is the timeout in the caching engine of the Coldfusion keeps the charts for any request only for a default value of 5 seconds.
We missed providing an interface to change this value in the CF Admin, but you can still change this value by:

1. Stop the CF server.
2. Open <cf install path>\lib\webcharts3d.xml
3. You can increase the timeout for keeping the graphs in the cache by editing the minTimeout and maxTimeout attributes:

<?xml version="1.0" encoding="UTF-8"?>
<server image="PNG" cache="Memory" minTimeout="5000" maxTimeout="30000"....

change this to whatever values you want.(Values of minTimeout and maxTimeout are in milliseconds.)

The minTimeout and maxTimeout are per each request, i.e. the graphing cache will keep the graphs for each request for minTimeout amount of time. So if there are 4 graphs in one page then request for the page arrives at lets say 1'o clock and the min timeout is 5 secs, then each graph for the request will be kept only in cache for 1'o clock + time to generate graph + minTimeout. So a problem could be if the last graph takes lets say 10 secs to generate, then by the time it is ready all the previous graphs will timeout and will be removed from the cached.

This can create a problem when:


  1. There are a large number of charts one page (> 200). In this case, some charts will be drawn but remaining charts will display the error message

  2. There are only a few charts on a page but some charts take more than minTimeOut amount of time to generate in this case the remaining charts will not be generated and the error message will be thrown.

Flash charts crashing Apache/IIS?

Yesterday an issue on flash charts generated via <cfchart> was reported on the forums - read here.
I will just surmise the discussion (thanks a lot to Tiamat74 for his solution).

Problem
Credit: Chris Brandt, sdowle & "is me"
Environment specs :


  1. XP pro, IIS

  2. win2k sp3 or winxp sp2 , apache, mdac2.8 , jre1.4.2_07

  3. Apache 2.0.53, WinXP


On creating flash charts in CF7, the following errors occurs:

Server Error
The server encountered an internal error and was unable to complete your request.
JRun closed connection.

Though jpeg and gif charts work fine.

Solution
Credit: Tiamat74
This issue is actually caused by a corrupted font in your systems font folder, which in turn produces an error in the jre. Please go here for additional information:

The work around I used to fix this issue on my server was to move all of my fonts from the window/font folder to a temporary folder. If you are using windows, it should install the basic fonts needed to run windows. After that cfchart worked fine.

Another option is to go through all of your fonts to see which one is corrupted.

Tuesday, June 21, 2005

Charting Technote Addendum

Macromedia came out with a fix for some issues in cfchart implementation, it can be accessed here - Charting Technote

This blog will try to elborate on this fix. You will need to download the supplied files in the technote to follow the instructions


NOTE: Please take backup of all files (take backup in a folder outside <cfinstall>\lib) that you change during installation, so that you can revert to your old configuration just in case you face some problems after this fix. While backing up wc50.jar please ensure that


  1. Shutdown CF server.

  2. Replace wc50.jar in <cfinstall-path>\lib directory, with supplied file.

  3. Replace webcharts3D.xml in <cfinstall-path>\lib directory, with supplied file.

  4. Copy supplied style files (in styles folder) to <cfinstall-path>\charting\styles directory. (overwrite existing files)

  5. Start CF server.

  6. You are ready to go.



This technote fixes the following bugs:

60028 – Scaling & gridlines problems have been resolved.

57581 – Line charts no longer display negative axis if any values are 0.

59943 – Users can format legend text in pie charts.

59466 – X axis titles are not rotated if too long ( advisory )

59162 – Barcharts with only one data series will be displayed


NOTE: To use most of these fixes/features, users will be required to create their own styles. Please take some time in experimenting with creating and applying your own styles to cfchart. A speed-up for the same is discussed here.


Description:


60028 – Scaling & gridlines problems have been resolved.

Issue

Users were unable to control the scaling of the graphs that were being generated. The scaleTo and scaleFrom attributes in <cfchart> were not being followed by the charting engine. In some cases the y-axis were scaled to many times the maximum range of the data.

old-5-gridlines
old-6-gridlines
old-7-gridlines



Solution

This problem has now been fixed. Users can set the minimum and maximum values that would be displayed in the charts. If no gridlines are specified then the default no. of lines that are drawn will be 11. Users have to be careful in selecting the values of scaleTo, scaleFrom and gridlines. If the difference of scaleTo and scaleFrom is not divisible by gridlines then labels with lot of decimal places will be displayed e.g.

5-gridlines
6-gridlines
7-gridlines

Users can overcome this by applying custom styles where the labels are formatted to be integers, and not fractional values.

57581 – Line charts no longer display negative axis if any values are 0

Issue

Users plotting any data with data points 0 or close to zero, observe that their charts display negative axes. This behavior is observed since the charting engine of CFMX tries to prevent any part of the graph from being clipped – this is known as the “AutoAdjust” feature. Hence in order to prevent clipping of markers the charting engine draws the negative axes.

line-graph-w-negative-axis


Solution

The AutoAdjust feature was “true” by default. The new style files, have been modified to turn off this feature by default. Users can deploy the new files to revert to the original charting behaviour as it was in CF 6.1. For those users who want to still use this feature, they are advised to deploy the provided style files and change the value of autoAdjust attribute to “true”.


line-graph-without-negative-axis


59943 – Users can format legend text in pie charts
Issue

Users were able to change the legend text for pie charts in CF 6.1. They are unable to do so in CFMX.


pie-graph-without-legend-control


Solution
Users should use the webcharts designer to create custom style xml which can be then applied, to modify the legend in pie charts and other graphs, e.g. the above pie chart was modified to the one below by applying a style file with the following attribute:


  <legend>
<![CDATA[ $(colLabel)-$(colPercent) ]]>
</legend>

pie-graph-with-detailed-legend


59466 – X axis titles are not rotated if too long (Advisory: change of behavior)

Issue

In CF 6.1, the X-axis titles were vertical by default. So any long titles like – “AAAAAAAAAAAAA” were displayed still by scaling the graph. However, in CFMX these titles are not being rotated.


long-axis-titles
long-axis-titles-2


Solution

Please note this is a change in default behavior – made on the recommendations of the eXperience Design team at Macromedia Inc. In CFMX, the titles have been made horizontal by default – thus any long title names get clipped (are not shown). Users can revert back to the old functionality in two ways:

Method 1: Modify all default style files.

(This is not the recommended method since all graphs will be affected by this change)



  1. The default style files are in the folder - <cfinstall dir>\charting\styles

  2. Users need to edit the files which do not have the *_pie.xml ending

  3. The following lines need to be changed:



<xAxis>
<labelStyle isHideOverlapped="true" orientation="Horizontal"/>
<titleStyle font="Arial-12-bold" isMultiline="false"/>
</xAxis>

To the following:
Here, isHideOverLapped attribute is set to false so those titles which overlap will also be displayed.



<xAxis>
<labelStyle isHideOverlapped="false" orientation="Horizontal"/>
<titleStyle font="Arial-12-bold" isMultiline="false"/>
</xAxis>

long-axis-titles-with-isHideoverlapped-false
long-axis-titles-2-with-isHideoverlapped-false
The following will make label orientation vertical



<xAxis>
<labelStyle isHideOverlapped="false" orientation="Vertical"/>
<titleStyle font="Arial-12-bold" isMultiline="false"/>
</xAxis>

long-axis-titles-vertical
long-axis-titles-2-vertical
Users will need to make similar changes to the <yAxis> section for changing the behavior for horizontal bar graphs.


Method 2: Using custom style files


  1. Read the section on creating custom style files.

  2. And apply step 3 in Method 1 to change the required attributes.



59162 – Barcharts with only one data series will be displayed
Issue

CFMX charting engine does not display charts properly if a single data series is defined and the seriesplacement attribute in <cfchart> is set to “stacked”.


single-bar-graph


Solution
These graphs are now rendered properly.


single-bar-graph-displayed


How to create your own styles for charts?

Applying custom styles to cfchart tag


  1. Create a custom style by using the webcharts designer. (<cfinstall>\charting\webcharts.bat)

  2. The custom style is in the style tab of the webcharts GUI.

  3. Save this xml in a file to your web root/ directory where you have the cfm to create the graph. (e.g. you save the file by name "myStyle.xml" in wwwroot\charts directory.

  4. Use the "style" attribute to import these settings in the <cfchart> tag. e.g. you have cfm in wwwroot folder then you can say –


<cfchart style="charts\myStyle.xml" .... other attributes>