comparison lib/SVG/Graph/TimeSeries.rb @ 1115:433d4f72a19b redmine-2.2

Update to Redmine SVN revision 11137 on 2.2-stable branch
author Chris Cannam
date Mon, 07 Jan 2013 12:01:42 +0000
parents 513646585e45
children 3e4c3460b6ca
comparison
equal deleted inserted replaced
929:5f33065ddc4b 1115:433d4f72a19b
1 require 'SVG/Graph/Plot' 1 require 'SVG/Graph/Plot'
2 require 'parsedate'
3 2
4 module SVG 3 module SVG
5 module Graph 4 module Graph
6 # === For creating SVG plots of scalar temporal data 5 # === For creating SVG plots of scalar temporal data
7 # 6 #
155 154
156 x = [] 155 x = []
157 y = [] 156 y = []
158 data[:data].each_index {|i| 157 data[:data].each_index {|i|
159 if i%2 == 0 158 if i%2 == 0
160 arr = ParseDate.parsedate( data[:data][i] ) 159 t = DateTime.parse( data[:data][i] ).to_time
161 t = Time.local( *arr[0,6].compact )
162 x << t.to_i 160 x << t.to_i
163 else 161 else
164 y << data[:data][i] 162 y << data[:data][i]
165 end 163 end
166 } 164 }
171 169
172 170
173 protected 171 protected
174 172
175 def min_x_value=(value) 173 def min_x_value=(value)
176 arr = ParseDate.parsedate( value ) 174 @min_x_value = DateTime.parse( value ).to_time
177 @min_x_value = Time.local( *arr[0,6].compact ).to_i
178 end 175 end
179 176
180 177
181 def format x, y 178 def format x, y
182 Time.at( x ).strftime( popup_format ) 179 Time.at( x ).strftime( popup_format )