Using Cfchart for charts and graphs in Coldfusion

Coldfusion makes it really simple to create and insert any kind of charts and other displays with the CFChart tag. While this is really an old feature(Available way back in ColdFusion 5), and little has been added to it in later versions, what many people don’t know is that it has now become much more efficient and actually holds its own against using client side JFQuery, CSS and other flash techniques. Cfchart is highly customizable and hence requires no need to involve designers or other javascript expert friends/colleagues whom you might need if you go for other methods. Below are some sample charts generated using CFChart with little styling options applied.

Now lets have a look at the code required to generate the above CFCharts.

<cfchart format=”png” name=”mychart” title=”Fruits Harvest” showlegend=”true”>
<cfchartseries type=”pie”>
<cfchartdata item=”Mangoes Harvest” value=”5000″/>
<cfchartdata item=”Oranges Harvest” value=”4000″/>
<cfchartdata item=”Apples Harvest” value=”3000″/>
<cfchartdata item=”Grapes Harvest” value=”2000”/>
</cfchartseries>
</cfchart>

The result of a query may directly be converted to a chart by using the code below. Coldfusion will generate the chart data items on its own from the query

<cfchartseries type=”bar” query=”data” itemcolumn=”name” valuecolumn=”sales”/>

Cfchart and Cfchartseries have a large number of attributes which maybe used to customize chart. You can check the complete list on Adobe Livedocs at http://bit.ly/cjiRPs and http://bit.ly/b3pioP

The type attribute of Cfchartseries is the most important among the list. It lets you choose from a wide array of chart types such as bar, line, pyramid, area, horizontalbar, cone, curve, cylinder, step, scatter and pie.

But what really takes the pie is the amount of styling options Coldfusion gives to the developers. Instead of setting each of the attributes, I found an easy way of doing this by modifying the built in style files in the folder cf_root\charting\styles and saving them under a new name to access. The style files are simple XML files and modifying them is really easy. One of the coolest attributes was the “show3D” attribute, which gives the chart a 3D effect. The appearance maybe modified to such extents that people will have a hard time figuring out it is custom generated and not designed by a web designer specifically.

Comparing Mate and Cairngorm

I just started learning Mate for my latest project (An AIR-based price comparison application) about three weeks ago. Having been introduced to Cairngorm at the same time as Flex itself, I was slightly apprehensive about the move as I was totally at home with Cairngorm. But now, three weeks later, and a project 80% finished, I am not only glad that I made the switch, but also regret not having tried it before. After all, Mate has been around for some while and it’s definitely here to stay.
An application framework is a standard structure for a specific development environment that makes development & maintenance easy for individual & teams of developers alike. No doubt, both Cairngorm and Mate serve the purpose, but with varying degrees of success. Here’s a quick, random list of pro’s and con’s of Mate compared with Cairngorm that I’ve noticed over the last three weeks.

The Pros

  • The event-map approach of Mate makes complete sense since Flex itself is event driven. The command based approach of Cairngorm seems like a big stretch and increases complexity.
  • Again, the command approach adds many more classes and lines of codes in Cairngorm which are considerably lessened when using Mate.
  • The application code is much more tightly bound with framework code in Cairngorm, such as the use of Cairngorm events. This is not the case with Mate.
  • Event bubbling can be caught/listened without having to write any excess code.
  • Easy learning curve. I remember Cairngorm gave me a hard time as a beginner. Compared with that, learning Mate was a breeze. The documentation is excellent. Furthermore, the tag based of Mate approach is always easier to learn.

The Cons

  • Cairngorm has a much more modular structure, more suited to the Flex MVC architecture that adheres to basic OOP concepts. This offers great advantages in larger enterprise level application development scenarios. Projects are more readable and work can easily be split into various parts and assigned to different teams.
  • The use of delegates makes use of dummy data simple to replicate server side behaviour. Client side development is not hindered by server side development issues.
  • And lastly, the thing that bugs me the most. While tag based approach is simpler and easier to learn, it is also hard to debug. Small errors are hard to find and more than a few times, problems are detected only during runtime and not during compiling. Simple mistakes such as a spelling here or there can lose you a lot of time.

While it may seem to some that the balance is tipped in Mate’s favour, it would be a rather harsh judgement. A closer look would show us that depending on the scenario, there is room for both. In fact, there is a NEED for both. The advantages of Cairngorm makes it much more suited for larger, enterprise level applications that are robust while Mate is more suited for smaller applications which needed to be executed swiftly.

My conclusion – it is important that a good Flex developer be able to easily switch between both the frameworks if he wants to deliver his clients the best that Flex has to offer.

Welcome to Toobler

It’s been an eventful and fruitful period the past couple of months for Toobler. Toobler got many new clients and projects, which led to hiring more employees and improving infrastructure which in turn led to us needing more space and finally forcing us to shift into a new better, swankier and larger office. I’m more than eager to post some photos of it but with all the work going on, time limits me now. But be sure, they will be here soon.

Apart from the office itself, the clients and projects too are becoming larger, challenging and interesting. I see this as a validation of my belief that a business grows only as and when it’s clients grow. Almost all our clients not just come back to us, whether for new projects or modifications of the old, but also give testimonials to our professionalism and recommend us to others. That is exactly how we bagged some of our new projects. And this is the fact that gives me the greatest pleasure of my professional life, as it means the old client is completely satisfied.

Also, this post will be the first on our revamped website, www.toobler.com. A decision was taken during this period to revamp the website as with the growth, it was felt that the old website did not represent Toobler accurately anymore. We also wanted to showcase more of our recent clients, projects and successes. Hope you like the look and feel(and most importantly, the content) of the new website.

Speaking about www.toobler.com, it is always a pleasure to work on your own company website, but there are many pitfalls associated with it which you can easily fall for as well. This is something I have learned from experience. Hopefully, in my next post I’ll share some of them with you. Until then, enjoy life and do please do visit this page again.