giovedì 11 dicembre 2008

Radar chart lines

First attempt to offer something to my referring to the excellent tutorial by pullmonkey.com and harryseldon
here is the ruby in transposition of the third example of radar chart
radar chart lines

test_it_controller.rb

class TestItController < ApplicationController
def index
@graph1 = open_flash_chart_object(600,300,"/test_it/graph1_code")
end

def graph_code
chart = OpenFlashChart.new
chart.set_title(Title.new('Radar Chart'))

values = [30,50,60,70,80,90,100,115,130,115,100,90,80,70,60,50]
spokes = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p']
vals = []

values.each_with_index do |value, i|
tmp = DotValue.new( value, '#D41E47' )
tmp.set_tooltip("#val#&ltbr%rtSpoke: #{spokes[i]}")
vals.push(tmp)
end

line = LineHollow.new()
line.set_values( vals )
line.set_halo_size( 0 )
line.set_width( 2 )
line.set_dot_size( 6 )
line.set_colour( '#FBB829' )
line.set_key( 'Hearts', 10 )
line.loop()


# add the area object to the chart:
chart.add_element(line)

r = RadarAxis.new( 150 )
r.set_steps(10)
r.set_colour( '#DAD5E0' )
r.set_grid_colour( '#EFEFEF' )
chart.set_radar_axis( r )

tooltip = Tooltip.new()
tooltip.set_proximity()
chart.set_tooltip( tooltip )

chart.set_bg_colour( '#ffffff' )

render :text => chart.to_s
end
end

6 commenti:

  1. Questo commento è stato eliminato dall'autore.

    RispondiElimina
  2. Thanks Giovanni for these nice posts.

    Would you want to add your examples to the OFC test app ?
    The OFC test app is explained here: http://harryseldon.thinkosphere.com/2008/11/07/a-test-and-example-app-for-open-flash-chart-rails-plugin

    How to use GIT to contribute is explained here:
    http://harryseldon.thinkosphere.com/2008/11/08/grand-gardening-with-git

    Let me know if you are interested. Else I might add your examples myself in the app.

    Also I suggest you to write your posts in English ! Like the rails community majority, unfortunately, I do not speak italian.

    RispondiElimina
  3. Hi Harry!

    Sorry for the delay, but I am quite busy

    Add both examples without any problem

    Short version in English, I promise!

    Gio

    RispondiElimina
  4. Hi gio,thanks. Next time I am using the app I'll add your examples. But if you have yourself this opportunity I do encourage you to do it and blog about it ;-)

    RispondiElimina
  5. Hi Gio, I have added your examples to the test app. You can see this post : http://harryseldon.thinkosphere.com/2009/03/09/open-flash-charts-examples-with-rails

    RispondiElimina
  6. Hi Harry, thanks for reporting, I'm sorry I didn't spent the addition, but I'm preparing the report for half time scholarship suck almost all my energy.
    good coding
    Gio

    RispondiElimina