Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

A Closer Look at ZiYa – The Flash Chart Plugin For Rails

By Peter Cooper / January 17, 2007


Just a few weeks ago, a new Rails chart system called ZiYa was briefly mentioned on Ruby Inside. ZiYa is unique in that it can render graphically complex charts from data in your Rails application with a bare minimum of code. The layout and style of the charts is defined via special YAML stylesheets, sprinkled with a bare minimum of Ruby code.

Since ZiYa was first mentioned here, a lot has happened with it. ZiYa's official site is now full of comprehensive samples and documentation, and even a screencast is available demonstrating how to get a ZiYa chart working in just several minutes. Given all of these developments, I thought I'd ask lead developer Fernand Galiana a few questions about ZiYa.

Ruby Inside: What was the motivation behind developing ZiYa?

Fernand Galiana: I work for a company that deals with financial data where charts are worth a thousand words. We always get requests for various charts, and in the past we've used Gruff to produce them. Gruff is a great library and the results look good too! However, recently we've have more demanding requirements to provide more dynamic behavior on the charts. Users wanted to be able to interact with the charts in various ways and drill down to gather more information.

We looked at alternatives to Gruff, and decided to go with XML/SWF charts. This framework uses Flash rendering for charts and has great features, 24hr turnaround support and it's inexpensive. The other advantage is that we no longer had to deal with figuring out the various incantations to install RMagick on various servers. Moreover, we were able to delegate the actual chart rendering over to the client, which with dynamic graphs is key. All we had to do now on the server side is generate XML. This is what triggered the initial thoughts of leveraging Ruby to generate this XML.

The other motivation occurred when we wrote an internal reporting app that give us up to date information on what's going on in our database. My boss bought a nice 32" TFT flat panel. All day we cycle through various graphs representing critical data from our database. If something goes off in our internal processing, we all see it right there on the big screen! This is where the YAML style sheet idea came about as we wanted to create a special look and feel and since creating and customizing many different charts was a necessary feature, using style sheets makes it easy.

Where do you see ZiYa going in future?

We have a few clean-up and housekeeping items on the list. I was also thinking about adding more out of the box helpers for the YAML stylesheets. And, naturally, more docs and tutorials are always good.

Are there are any interesting uses of ZiYa you've seen elsewhere so far?

A couple. One was an internal app that had several graphs that were all kept in sync, that is the user clicks on something on one graph and changes update on all of the other automatically using AJAX. Very cool. The other was using a tiny column chart for both status information and navigation. I did not think it was a ZiYa chart to start with, but some JavaScript widget!


  1. Peter McMaster says:

    "...just several minutes..." I like it.

    "How many robbers were there ma'am?"
    "Just several."

  2. Peter Cooper says:

    Would you prefer it in exact number of seconds? :)

  3. Tony Buser says:

    This is really slick. I recently did a project involving a lot of graphs in reports and would have loved to use this, unfortunately one of the requirements was that the graphs be printable. Unfortunately, you can't print flash.

  4. Fernand says:

    Hi Tom,

    Thanks actually you could print the chart but not directly...
    Checkout this thread:


  5. MJ says:

    Wow a plugin!

    I was already using XML/SWF charts to graph lock type vs num bike stolen in Portland.

    And now there is a plugin to make it even easier!

  6. Sandro says:

    This is the kind of chart application I'm looking for !

  7. Henrik N says:

    There is a literal \n in the screenshot. ;) "Shipping date\n..."

  8. Sean Cribbs says:

    Looks really nice, but why bother with YAML? There's enough emit () tags in the source that I personally think one could more clearly just write something like

    chart :bar do
    component :chart_value do
    position :right

    rather than using ERb. Might be faster than ERb too!

  9. John says:

    Ziya was a great gateway drug that lead me to the XML/SWF Charts that underlies it:

    Emitting the XML myself has been fairly easy, and I find the documentation on the XML/SWF Charts site to be helpful.

    + I found the abstractions that Ziya implements, while concise to be confusing and poorly documented.
    + The themes that Ziya applies by default made some of my charts look worse than the plain XML/SWF charts.

    Maybe my needs aren't advanced enough to fully utilize the power and simplicity of Ziya.

    Quick Disclosure: I haven't tried to style my XML/SWF charts manually. Ziya's themes seems to be designed to alleviate that stress, but as I haven't explored deeply enough, my opinion isn't educated on the matter.

  10. Fernand says:

    Hi John,

    Thanks for voicing your feedback. Could you help us improve the documentation by
    begin more specific on where we could improve the docs.
    We gave it our best shot but our users input would help us improve..
    Could you post on our google page so we can track it

    Also you don't have to use the themes at all if you like the swf default look and feel.
    Currently you would have to del all the .yml in the default theme dir. We will make
    a note of that and provide the swf lnf by default.

  11. Fernand says:


    Thanks for your comment.

    The issue we were trying to avoid by adding yml is to have view specific information in the controller. By leveraging YAML and ERB we can keep a clean separation between the controller
    concerns and the view.

Other Posts to Enjoy

Twitter Mentions