cfchart and cfimage - useless experiment

This post is more than 2 years old.

So after my last post on embedding cfchart in email, I've been playing with cfchart and image functions. The ability to create an image out of cfchart isn't new, and we've got a butt load of new image functions in ColdFusion 8, so we should be able to mix the two up right? I whipped up a quick demo using imageUtils from RIAForge and a simple chart:

<cfset imageutils = createObject("component","imageutils.imageUtils")>

<cfchart format="png" name="mychart" chartheight="200" chartwidth="200" showlegend="false"> <cfchartseries type="pie"> <cfchartdata item="1Q Sales" value="500" /> <cfchartdata item="2Q Sales" value="400" /> <cfchartdata item="3Q Sales" value="700" /> <cfchartdata item="4Q Sales" value="200" /> </cfchartseries> </cfchart>

<cfset mychart = imageNew(mychart)> <cfset myfancychart = imageutils.reflectImage(mychart,"Bottom") />

<cfimage action="writetobrowser" source="#myfancychart#" />

Nothing too crazy here. I save the image binary into a variable and then 'load' it as an Image object using imageNew. I then use the reflectImage function to create...

I then got artsy:

So yeah, this was a complete waste of time. I can't think of anything I'd use CF8's image functions for that I can't do natively with cfchart itself, but maybe something intelligent will come to me later.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by todd sharp posted on 1/16/2009 at 7:56 AM

I could see _maybe_ overlaying some text - like perhaps a watermark?

Comment 2 by Raymond Camden posted on 1/16/2009 at 8:08 AM

You can do text, a header, with cfchart, but a watermark would be useful perhaps.

Comment 3 by existdissolve posted on 1/16/2009 at 6:10 PM

I know this post isn't exclusively about cfimage, but I have to say that I think it the image functionality built into CF8 is one of the best features.

One area I've really been able to utilize cfimage is with dynamic image cropping and resizing. I have a web design gallery (css-imagine.com) that provides thumbnails and full-size images for featured site designs. Most people who have similar sites have to go through the work of taking screenshots, manually cropping and resizing, and finally uploading them to their website.

Not so with mine. CF8's image utils allow me to grab images taken with a free online screenshot service, re-size and crop them on the fly, and plop them into the right places in seconds. Where most of these similar sites have a lot of manual work to add a single entry, I literally only have to push a button (thanks to how easy cfc's make remote processing!), and it's done. CF8 seriously rocks, and I'm looking forward to see what 9 has to offer.

Comment 4 by todd sharp posted on 1/16/2009 at 6:50 PM

@existdissolve -- rather then rely on the external service you could take the screenshot yourself using CF 8 if you wanted to.

Ray blogged about it: http://www.coldfusionjedi.c...

Comment 5 by existdissolve posted on 1/16/2009 at 6:59 PM

@todd -

I tried that method, but was not happy with the results it produced. It's pretty good for thumbnails (e.g., something < 200px), but for the full-scale images the result was too inconsistent to be a feasible option. Thanks for the link, though!

Comment 6 by Raymond Camden posted on 1/16/2009 at 7:36 PM

@Existdissolve - when ya gonna reskin my blog and make it sexier? ;)

Comment 7 by Chris posted on 1/18/2009 at 8:16 AM

"expirement"? hehe sorry..had to point that out :)

Comment 8 by Raymond Camden posted on 1/18/2009 at 8:31 PM

Fixed. Spelling is for nerds! ;)

Comment 9 by ryanTJ posted on 1/18/2009 at 9:18 PM

Heck yeah, I can see lots of uses. Custom legends, headers and a fancy data table even though you can get that with a style. Great idea, keep the juices flowing.

Comment 10 by Fred Anderson posted on 1/23/2009 at 10:35 AM

" I can't think of anything I'd use CF8's image functions for that I can't do natively with cfchart itself, but maybe something intelligent will come to me later."

Hi Ray, I have just finished adding Bullet Graphs to my SparklineCFC project. That's somethign you cant do with CFChart.
Have a look.
http://www.dashcapper.com/2...

Comment 11 by Raymond Camden posted on 1/23/2009 at 8:59 PM

That is dang sweet Fred, thanks for sharing it.

Comment 12 by existdissolve posted on 1/28/2009 at 8:28 AM

@ray--

March-ish? Seriously, I'll do it (I owe you for all the code, advice and interesting stuff you post all the time) :)

Comment 13 by Raymond Camden posted on 1/28/2009 at 9:25 PM

Just ping me and we will talk. Thanks. :)

Comment 14 by Humberto Fujitani posted on 9/26/2012 at 11:39 PM

This experience may have been useless, but the use of tag <cfimage action="writetobrowser"> to display <cfchart> graph saved me from the annoying message "Expired Image. Please refresh the page to view the image." Thank you Raymond.

Comment 15 by Raymond Camden posted on 9/26/2012 at 11:41 PM

You are most welcome. :)