New Release ZiYa gem 2.0.2

Posted by admin Sunday, August 24, 2008 13:26:00 GMT

ZiYa is now available as a gem. We've been hard at work getting the ZiYa framework converted over from a plugin to a gem. In the process a couple things happened. A new version of the xml/swf framework was released and we've also decided to incorporate xml/swf gauges as well. ZiYa gives your the ability to add some very cool, interactive, client side rendered charts and gauges to your rails applications.

To see a ZiYa application in action goto ZiYa Home

Installation

sudo gem install ziya

Setup

In your rails application directory issue the command ziyafy to copy the necessary ZiYa artifacts. Create an initializer in a ziya.rb file in your config/initializers directory ( Rails 2.0 ) ziya.rb:

# Pull in the ZiYa gem framework
gem "ziya", "~> 2.0.0"
require 'ziya'

# Initializes the ZiYa Framework
Ziya.initialize( :logger => RAILS_DEFAULT_LOGGER,
:helpers_dir => File.join( File.dirname(__FILE__), %w[.. .. app helpers ziya] ),
:themes_dir => File.join( File.dirname(__FILE__), %w[.. .. public charts themes]) )

This will initialize the gem. You can log the output to stdout as well using the ZiYa bundled logger or specify a file ie File.join( File.dirname(__FILE__), %w[.. log ziya.log]. If you choose to use the ZiYa logger, you can specify the :log_level option to either :warn :info :debug or :error.

You will need to indicate your themes directory typically located under public/charts/themes or any location you'll choose. Otherwise ZiYa will used the default themes from the gem ie default or commando. Lastly you can specify a custom helper directory :helpers_dir, so you can use helper methods within your ZiYa stylesheets.

Creating a chart

blee_controller.rb

class BleeController < ApplicationController
helper Ziya::Helper

# Callback from the flash movie to get the chart's data
def load_chart
chart = Ziya::Charts::Bar.new
chart.add( :axis_category_text, %w[2006 2007 2008] )
chart.add( :series, "Dogs", [10,20,30] )
chart.add( :series, "Cats", [5,15,25] )
respond_to do |fmt|
fmt.xml => { render :xml => chart.to_xml }
end end

blee/index.html.erb

<%= ziya_chart load_chart_url, :size => "300x200" -%>

config/route.rb

# Creates a named route for the chart.
map.load_chart '/blee/load_chart', :controller => 'blee', :action => 'load_chart'

Finally

You should now be able to reload your app and see the chart with the default styles. You can style your chart anyway you want by using the yml stylesheets in the public/chart/themes directory. There are many examples of this in the checked in galeria application:


svn checkout svn://rubyforge.org/var/svn/ziya/samples/galeria

If you have questions there is a Ziya google group set up at ZiYa Forum

We'll be working on documentation and more samples....Thanks for your support and feeback !