<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0">
			<channel>
			<title>Rob Brooks-Bilson&apos;s Blog - cfchart</title>
			<link>http://www.brooks-bilson.com/blogs/rob/index.cfm</link>
			<description>A blog for ColdFusion and other topics by Rob Brooks-Bilson, author of the O&apos;Reilly book Programming ColdFusion MX</description>
			<language>en-us</language>
			<pubDate>Mon, 06 Sep 2010 21:21:51 -0400</pubDate>
			<lastBuildDate>Sat, 28 Sep 2002 20:28:00 -0400</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>rbils@amkor.com</managingEditor>
			<webMaster>rbils@amkor.com</webMaster>
			
			
			
			
			
			<item>
				<title>Working with Date Values on the Y-Axis in CFCHART</title>
				<link>http://www.brooks-bilson.com/blogs/rob/index.cfm/2002/9/28/Working-with-Date-Values-on-the-YAxis-in-CFCHART</link>
				<description>
				
				I&apos;ve seen a few posts from developers on the Macromedia Forums lately complaining that they can&apos;t get CFCHART to display dates on the y-axis.  Since I&apos;m finishing up the CFCHART chapter of my book right now, I decided to look into this.  It turns out, that this functionality is not at all documented in any of the Macromedia documentation, nor anywhere else that I can tell.  After spending a few hours trying to figure out what CFCHART could possibly want as it&apos;s date values, I finally figured it out.  For some reason, you can&apos;t pass dates in formats like mm/dd/yyyy.  My next thought was to try a numeric format, so I tried CF MX&apos;s new getNumericDate() funciton.  That didn&apos;t work.  Next, I thought of using Epoch seconds.  I tried a random Epoch time, but the date CF showed in the chart was about 32 years off!  After more messing around, I finally hit on the solution.  You need to take your date, convert it to Epoch seconds adjusted for your UTC offset, and multiply that number by 1000.  I&apos;m not sure why you have to multiply by 1000.  The only thing I can think of is that the 1000 represents milliseconds tacked on to the date.  Go figure.

So, here&apos;s some code that illustrates how to make it all work:
&lt;code&gt;
&lt;cfscript&gt;
/**
 * Returns the number of seconds since January 1, 1970, 00:00:00 (Epoch time).
 * 
 * @param DateTime 	 Date/time object you want converted to Epoch time. (Required)
 * @return Returns a numeric value. 
 * @author Rob Brooks-Bilson (rbils@amkor.com) 
 * @version 1, June 21, 2002 
 */
function GetEpochTimeFromLocal() {
  var datetime = 0;
  if (ArrayLen(Arguments) eq 0) {
    datetime = Now();
  }
  else {
    datetime = arguments[1];
  }
  return DateDiff(&quot;s&quot;, DateConvert(&quot;utc2Local&quot;, &quot;January 1 1970 00:00&quot;), datetime);
}

/**
 * Returns the number of seconds since January 1, 1970, 00:00:00
 * 
 * @param DateTime 	 Date/time object you want converted to Epoch time. 
 * @return Returns a numeric value. 
 * @author Chris Mellon (mellan@mnr.org) 
 * @version 1, February 21, 2002 
 */
function GetEpochTime() {
	var datetime = 0;
	if (ArrayLen(Arguments) is 0) {
		datetime = Now();

	}
	else {
		if (IsDate(Arguments[1])) {
			datetime = Arguments[1];
		} else {
			return NULL;
		}
	}
	return DateDiff(&quot;s&quot;, &quot;January 1 1970 00:00&quot;, datetime);
}
&lt;/cfscript&gt;

&lt;CFCHART FORMAT=&quot;flash&quot;
  CHARTHEIGHT=&quot;400&quot;
  CHARTWIDTH=&quot;400&quot;
  ROTATED=&quot;No&quot;
  SCALEFROM=&quot;0&quot;
  SCALETO=&quot;999999999&quot;
  GRIDLINES=&quot;11&quot;
  SHOWXGRIDLINES=&quot;yes&quot;
  SHOWYGRIDLINES=&quot;yes&quot;
  SERIESPLACEMENT=&quot;default&quot;
  FOREGROUNDCOLOR=&quot;##000000&quot;
  BACKGROUNDCOLOR=&quot;##C0C0C0&quot;
  DATABACKGROUNDCOLOR=&quot;##0000FF&quot;
  FONT=&quot;Arial&quot;
  FONTSIZE=&quot;12&quot;
  FONTBOLD=&quot;Yes&quot;
  FONTITALIC=&quot;Yes&quot;
  SHOWBORDER=&quot;yes&quot;
  LABELFORMAT=&quot;date&quot;
  LABELMASK=&quot;ignore_me_i_dont_work&quot;
  XAXISTITLE=&quot;What&quot;
  YAXISTITLE=&quot;When&quot;
  SORTXAXIS=&quot;No&quot;
  SHOW3D=&quot;yes&quot;
  XOFFSET=&quot;.1&quot;
  YOFFSET=&quot;.1&quot;
  SHOWLEGEND=&quot;no&quot;
  TIPSTYLE=&quot;mouseOver&quot;
  TIPBGCOLOR=&quot;##008000&quot;&gt;
  
  &lt;CFCHARTSERIES TYPE=&quot;bar&quot; SERIESLABEL=&quot;Time on the Y&quot; SERIESCOLOR=&quot;##0000FF&quot; PAINTSTYLE=&quot;plain&quot;&gt;
    &lt;CFCHARTDATA ITEM=&quot;Epoch             &quot;       VALUE=&quot;0&quot;&gt;
    &lt;CFCHARTDATA ITEM=&quot;Sep 28, 2002 00:00 UTC&quot;   VALUE=&quot;1033171200000&quot;&gt; &lt;!--- this will actually show as 9/27/02 because I&apos;m EST ---&gt;
    &lt;CFCHARTDATA ITEM=&quot;Sep 28, 2002 00:00 local&quot; VALUE=&quot;1033189200000&quot;&gt; &lt;!--- this is the correct value which takes into acct my UTC offset ---&gt;
    
  &lt;/CFCHARTSERIES&gt; 
  
&lt;/CFCHART&gt;
&lt;/code&gt;
				
				</description>
						
				
				<category>cfchart</category>				
				
				<category>ColdFusion</category>				
				
				<pubDate>Sat, 28 Sep 2002 20:28:00 -0400</pubDate>
				<guid>http://www.brooks-bilson.com/blogs/rob/index.cfm/2002/9/28/Working-with-Date-Values-on-the-YAxis-in-CFCHART</guid>
				
			</item>
			
		 	
			</channel></rss>