From: Sijo Kg Date: 2008-11-27T17:19:44+09:00 Subject: creating a dynamic hash Hi I am trying to draw a graph My question is not related to that In the below @tic_num_array is an array contains values like ["IN1","IN2","IN3".......] and @tic_elapsed_time_array contains values like [10,2,12,.......] They are dynamic arrays chart = Ziya::Charts::Mixed.new( 'licence', "status_chart" ) chart.add :chart_types, %w[column line line] chart.add :axis_category_text, @tic_num_array chart.add :series, "Ticket" , report( "ticket",@tic_elapsed_time_array ) chart.add :series, "Warning" , report( "warning",@tic_elapsed_time_array ) chart.add :theme , "them1" def report( charttype,elapsedtime ) case charttype when "ticket" elapsedtime.each { |etime| Hash.new("shadow" => 'high',:bevel => 'bevel1', :value => etime.to_i) } when "warning" [ { :bevel => 'bevel1', :value => 5 }, { :bevel => 'bevel1', :value => 5 }, { :bevel => 'bevel1', :value => 5 } ] end end The above works fine ..But it is clear the case when "warning" is dynamic So suppose some 20 values theer the above approch is wrong So for that I tried the "warning " like when "warning" (elapsedtime.length-1).times { Hash.new(:bevel => 'bevel1', :value => 5)} Here my I thought the above code for a value elapsedtime.length = 4 generate [ { :bevel => 'bevel1', :value => 5 }, { :bevel => 'bevel1', :value => 5 }, { :bevel => 'bevel1', :value => 5 } ] But this does not happen and also the graph now is not working? Please help me to solve this Thanks in advance sijo -- Posted via http://www.ruby-forum.com/.