samhendley-scruffy 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ module Scruffy
|
|
8
8
|
attr_accessor :markers
|
9
9
|
|
10
10
|
def draw(svg, bounds, options={})
|
11
|
-
if (options[:point_markers].nil? || options[:point_markers].empty?)
|
11
|
+
if options[:calculate_markers] && (options[:point_markers].nil? || options[:point_markers].empty?)
|
12
12
|
markers = (options[:markers] || self.markers) || 5
|
13
13
|
options[:point_markers] = []
|
14
14
|
each_marker(markers, options[:min_key], options[:max_key], bounds[:width], options, :key_formatter) do |label, x|
|
data/lib/scruffy/formatters.rb
CHANGED
@@ -209,5 +209,22 @@ module Scruffy::Formatters
|
|
209
209
|
end
|
210
210
|
end
|
211
211
|
end
|
212
|
+
|
213
|
+
|
214
|
+
class Date < Base
|
215
|
+
|
216
|
+
def initialize(format_string, options = {})
|
217
|
+
@format_string = format_string
|
218
|
+
end
|
219
|
+
|
220
|
+
# Formats percentages.
|
221
|
+
def format(target, idx, options)
|
222
|
+
begin
|
223
|
+
target.strftime(@format_string)
|
224
|
+
rescue
|
225
|
+
target
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
212
229
|
|
213
230
|
end
|
data/lib/scruffy/graph.rb
CHANGED
@@ -116,7 +116,7 @@ module Scruffy
|
|
116
116
|
self.value_formatter = Scruffy::Formatters::Number.new
|
117
117
|
self.key_formatter = Scruffy::Formatters::Number.new
|
118
118
|
|
119
|
-
%w(title theme layers default_type value_formatter point_markers rasterizer).each do |arg|
|
119
|
+
%w(title theme layers default_type value_formatter point_markers rasterizer key_formatter).each do |arg|
|
120
120
|
self.send("#{arg}=".to_sym, options.delete(arg.to_sym)) unless options[arg.to_sym].nil?
|
121
121
|
end
|
122
122
|
|
data/lib/scruffy/layers/base.rb
CHANGED
@@ -162,8 +162,8 @@ module Scruffy::Layers
|
|
162
162
|
ret = []
|
163
163
|
points.each_point do |x, y|
|
164
164
|
if y
|
165
|
-
x_coord = dx * (x
|
166
|
-
y_coord = dy * (y
|
165
|
+
x_coord = dx * (x - options[:min_key])
|
166
|
+
y_coord = dy * (y - options[:min_value])
|
167
167
|
|
168
168
|
ret << [x_coord, height - y_coord]
|
169
169
|
end
|
data/lib/scruffy/version.rb
CHANGED
data/test/graph_creation_test.rb
CHANGED
@@ -117,4 +117,18 @@ class GraphCreationTest < Test::Unit::TestCase
|
|
117
117
|
graph.render :to => "#{WEBSITE_DIR}/scatter_test.svg"
|
118
118
|
graph.render :width => 500, :to => "#{WEBSITE_DIR}/scatter_test.png", :as => 'png' if $make_png
|
119
119
|
end
|
120
|
+
|
121
|
+
def test_scatter_by_date
|
122
|
+
graph = Scruffy::Graph.new
|
123
|
+
graph.title = "Some Kind of Information"
|
124
|
+
graph.renderer = Scruffy::Renderers::Standard.new
|
125
|
+
graph.key_formatter = Scruffy::Formatters::Date.new("%H:%M")
|
126
|
+
h = {}
|
127
|
+
start = Time.local(2009, 1, 20, 12, 0, 0)
|
128
|
+
30.times{|i| h[start + 60*i] = i*i}
|
129
|
+
|
130
|
+
graph.add :scatter, 'DNI', h
|
131
|
+
graph.render :to => "#{WEBSITE_DIR}/scatter_date_test.svg", :calculate_markers => true
|
132
|
+
graph.render :width => 500, :to => "#{WEBSITE_DIR}/scatter_date_test.png", :as => 'png' if $make_png
|
133
|
+
end
|
120
134
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: samhendley-scruffy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brasten Sager
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date:
|
14
|
+
date: 2009-01-22 21:00:00 -08:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|