Skip to content

Commit

Permalink
Resolve conflicts, merge with master
Browse files Browse the repository at this point in the history
  • Loading branch information
erebor committed Mar 4, 2009
2 parents 2e16e73 + 8aeb13b commit 2910b76
Show file tree
Hide file tree
Showing 8 changed files with 497 additions and 80 deletions.
7 changes: 6 additions & 1 deletion History.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
== 0.3.6

* Fixed manifest to list dot graph [theirishpenguin]
* Fixed color cycling error [Gunnar Wolf]

== 0.3.5

* ???
* Added dot graph from Erik Andrejko

== 0.3.4

Expand Down
2 changes: 2 additions & 0 deletions Manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ lib/gruff/bar_conversion.rb
lib/gruff/base.rb
lib/gruff/bullet.rb
lib/gruff/deprecated.rb
lib/gruff/dot.rb
lib/gruff/line.rb
lib/gruff/mini/bar.rb
lib/gruff/mini/legend.rb
Expand All @@ -63,6 +64,7 @@ test/test_area.rb
test/test_bar.rb
test/test_base.rb
test/test_bullet.rb
test/test_dot.rb
test/test_legend.rb
test/test_line.rb
test/test_mini_bar.rb
Expand Down
16 changes: 8 additions & 8 deletions gruff.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@ Gem::Specification.new do |s|

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Geoffrey Grosenbach"]
s.date = %q{2008-08-18}
s.date = %q{2009-01-14}
s.description = %q{Beautiful graphs for one or multiple datasets. Can be used on websites or in documents.}
s.email = %q{boss@topfunky.com}
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
s.files = ["History.txt", "MIT-LICENSE", "Manifest.txt", "README.txt", "Rakefile", "assets/bubble.png", "assets/city_scene/background/0000.png", "assets/city_scene/background/0600.png", "assets/city_scene/background/2000.png", "assets/city_scene/clouds/cloudy.png", "assets/city_scene/clouds/partly_cloudy.png", "assets/city_scene/clouds/stormy.png", "assets/city_scene/grass/default.png", "assets/city_scene/haze/true.png", "assets/city_scene/number_sample/1.png", "assets/city_scene/number_sample/2.png", "assets/city_scene/number_sample/default.png", "assets/city_scene/sky/0000.png", "assets/city_scene/sky/0200.png", "assets/city_scene/sky/0400.png", "assets/city_scene/sky/0600.png", "assets/city_scene/sky/0800.png", "assets/city_scene/sky/1000.png", "assets/city_scene/sky/1200.png", "assets/city_scene/sky/1400.png", "assets/city_scene/sky/1500.png", "assets/city_scene/sky/1700.png", "assets/city_scene/sky/2000.png", "assets/pc306715.jpg", "assets/plastik/blue.png", "assets/plastik/green.png", "assets/plastik/red.png", "init.rb", "lib/gruff.rb", "lib/gruff/accumulator_bar.rb", "lib/gruff/area.rb", "lib/gruff/bar.rb", "lib/gruff/bar_conversion.rb", "lib/gruff/base.rb", "lib/gruff/bullet.rb", "lib/gruff/deprecated.rb", "lib/gruff/line.rb", "lib/gruff/mini/bar.rb", "lib/gruff/mini/legend.rb", "lib/gruff/mini/pie.rb", "lib/gruff/mini/side_bar.rb", "lib/gruff/net.rb", "lib/gruff/photo_bar.rb", "lib/gruff/pie.rb", "lib/gruff/scene.rb", "lib/gruff/side_bar.rb", "lib/gruff/side_stacked_bar.rb", "lib/gruff/spider.rb", "lib/gruff/stacked_area.rb", "lib/gruff/stacked_bar.rb", "lib/gruff/stacked_mixin.rb", "rails_generators/gruff/gruff_generator.rb", "rails_generators/gruff/templates/controller.rb", "rails_generators/gruff/templates/functional_test.rb", "test/gruff_test_case.rb", "test/test_accumulator_bar.rb", "test/test_area.rb", "test/test_bar.rb", "test/test_base.rb", "test/test_bullet.rb", "test/test_legend.rb", "test/test_line.rb", "test/test_mini_bar.rb", "test/test_mini_pie.rb", "test/test_mini_side_bar.rb", "test/test_net.rb", "test/test_photo.rb", "test/test_pie.rb", "test/test_scene.rb", "test/test_side_bar.rb", "test/test_sidestacked_bar.rb", "test/test_spider.rb", "test/test_stacked_area.rb", "test/test_stacked_bar.rb"]
s.files = ["History.txt", "MIT-LICENSE", "Manifest.txt", "README.txt", "Rakefile", "assets/bubble.png", "assets/city_scene/background/0000.png", "assets/city_scene/background/0600.png", "assets/city_scene/background/2000.png", "assets/city_scene/clouds/cloudy.png", "assets/city_scene/clouds/partly_cloudy.png", "assets/city_scene/clouds/stormy.png", "assets/city_scene/grass/default.png", "assets/city_scene/haze/true.png", "assets/city_scene/number_sample/1.png", "assets/city_scene/number_sample/2.png", "assets/city_scene/number_sample/default.png", "assets/city_scene/sky/0000.png", "assets/city_scene/sky/0200.png", "assets/city_scene/sky/0400.png", "assets/city_scene/sky/0600.png", "assets/city_scene/sky/0800.png", "assets/city_scene/sky/1000.png", "assets/city_scene/sky/1200.png", "assets/city_scene/sky/1400.png", "assets/city_scene/sky/1500.png", "assets/city_scene/sky/1700.png", "assets/city_scene/sky/2000.png", "assets/pc306715.jpg", "assets/plastik/blue.png", "assets/plastik/green.png", "assets/plastik/red.png", "init.rb", "lib/gruff.rb", "lib/gruff/accumulator_bar.rb", "lib/gruff/area.rb", "lib/gruff/bar.rb", "lib/gruff/bar_conversion.rb", "lib/gruff/base.rb", "lib/gruff/bullet.rb", "lib/gruff/deprecated.rb", "lib/gruff/dot.rb", "lib/gruff/line.rb", "lib/gruff/mini/bar.rb", "lib/gruff/mini/legend.rb", "lib/gruff/mini/pie.rb", "lib/gruff/mini/side_bar.rb", "lib/gruff/net.rb", "lib/gruff/photo_bar.rb", "lib/gruff/pie.rb", "lib/gruff/scene.rb", "lib/gruff/side_bar.rb", "lib/gruff/side_stacked_bar.rb", "lib/gruff/spider.rb", "lib/gruff/stacked_area.rb", "lib/gruff/stacked_bar.rb", "lib/gruff/stacked_mixin.rb", "rails_generators/gruff/gruff_generator.rb", "rails_generators/gruff/templates/controller.rb", "rails_generators/gruff/templates/functional_test.rb", "test/gruff_test_case.rb", "test/test_accumulator_bar.rb", "test/test_area.rb", "test/test_bar.rb", "test/test_base.rb", "test/test_bullet.rb", "test/test_dot.rb", "test/test_legend.rb", "test/test_line.rb", "test/test_mini_bar.rb", "test/test_mini_pie.rb", "test/test_mini_side_bar.rb", "test/test_net.rb", "test/test_photo.rb", "test/test_pie.rb", "test/test_scene.rb", "test/test_side_bar.rb", "test/test_sidestacked_bar.rb", "test/test_spider.rb", "test/test_stacked_area.rb", "test/test_stacked_bar.rb"]
s.has_rdoc = true
s.homepage = %q{http://nubyonrails.com/pages/gruff}
s.rdoc_options = ["--main", "README.txt"]
s.require_paths = ["lib"]
s.rubyforge_project = %q{gruff}
s.rubygems_version = %q{1.2.0}
s.rubygems_version = %q{1.3.1}
s.summary = %q{Beautiful graphs for one or multiple datasets.}
s.test_files = ["test/test_accumulator_bar.rb", "test/test_area.rb", "test/test_bar.rb", "test/test_base.rb", "test/test_bullet.rb", "test/test_legend.rb", "test/test_line.rb", "test/test_mini_bar.rb", "test/test_mini_pie.rb", "test/test_mini_side_bar.rb", "test/test_net.rb", "test/test_photo.rb", "test/test_pie.rb", "test/test_scene.rb", "test/test_side_bar.rb", "test/test_sidestacked_bar.rb", "test/test_spider.rb", "test/test_stacked_area.rb", "test/test_stacked_bar.rb"]
s.test_files = ["test/test_accumulator_bar.rb", "test/test_area.rb", "test/test_bar.rb", "test/test_base.rb", "test/test_bullet.rb", "test/test_dot.rb", "test/test_legend.rb", "test/test_line.rb", "test/test_mini_bar.rb", "test/test_mini_pie.rb", "test/test_mini_side_bar.rb", "test/test_net.rb", "test/test_photo.rb", "test/test_pie.rb", "test/test_scene.rb", "test/test_side_bar.rb", "test/test_sidestacked_bar.rb", "test/test_spider.rb", "test/test_stacked_area.rb", "test/test_stacked_bar.rb"]

if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 2

if current_version >= 3 then
s.add_development_dependency(%q<hoe>, [">= 1.7.0"])
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
s.add_development_dependency(%q<hoe>, [">= 1.8.2"])
else
s.add_dependency(%q<hoe>, [">= 1.7.0"])
s.add_dependency(%q<hoe>, [">= 1.8.2"])
end
else
s.add_dependency(%q<hoe>, [">= 1.7.0"])
s.add_dependency(%q<hoe>, [">= 1.8.2"])
end
end
3 changes: 2 additions & 1 deletion lib/gruff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
area
bar
line
dot
pie
spider
net
Expand All @@ -24,4 +25,4 @@
require File.dirname(__FILE__) + "/gruff/#{filename}"
end

# TODO bullet
# TODO bullet
131 changes: 62 additions & 69 deletions lib/gruff/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
module Gruff

# This is the version of Gruff you are using.
VERSION = '0.3.5'
VERSION = '0.3.6'

class Base

Expand Down Expand Up @@ -390,14 +390,14 @@ def theme_odeo
def theme_pastel
# Colors
@colors = [
'#a9dada', # blue
'#aedaa9', # green
'#daaea9', # peach
'#dadaa9', # yellow
'#a9a9da', # dk purple
'#daaeda', # purple
'#dadada' # grey
]
'#a9dada', # blue
'#aedaa9', # green
'#daaea9', # peach
'#dadaa9', # yellow
'#a9a9da', # dk purple
'#daaeda', # purple
'#dadada' # grey
]

self.theme = {
:colors => @colors,
Expand All @@ -411,13 +411,13 @@ def theme_pastel
def theme_greyscale
# Colors
@colors = [
'#282828', #
'#383838', #
'#686868', #
'#989898', #
'#c8c8c8', #
'#e8e8e8', #
]
'#282828', #
'#383838', #
'#686868', #
'#989898', #
'#c8c8c8', #
'#e8e8e8', #
]

self.theme = {
:colors => @colors,
Expand Down Expand Up @@ -497,7 +497,7 @@ def draw
debug {
# Outer margin
@d.rectangle( @left_margin, @top_margin,
@raw_columns - @right_margin, @raw_rows - @bottom_margin)
@raw_columns - @right_margin, @raw_rows - @bottom_margin)
# Graph area box
@d.rectangle( @graph_left, @graph_top, @graph_right, @graph_bottom)
}
Expand Down Expand Up @@ -557,45 +557,45 @@ def calculate_spread # :nodoc:

def setup_graph_measurements
@marker_caps_height = @hide_line_markers ? 0 :
calculate_caps_height(@marker_font_size)
calculate_caps_height(@marker_font_size)
@title_caps_height = @hide_title ? 0 :
calculate_caps_height(@title_font_size)
calculate_caps_height(@title_font_size)
@legend_caps_height = @hide_legend ? 0 :
calculate_caps_height(@legend_font_size)
calculate_caps_height(@legend_font_size)

if @hide_line_markers
(@graph_left,
@graph_right_margin,
@graph_bottom_margin) = [@left_margin, @right_margin, @bottom_margin]
@graph_right_margin,
@graph_bottom_margin) = [@left_margin, @right_margin, @bottom_margin]
else
longest_left_label_width = 0
if @has_left_labels
longest_left_label_width = calculate_width(@marker_font_size,
labels.values.inject('') { |value, memo| (value.to_s.length > memo.to_s.length) ? value : memo }) * 1.25
labels.values.inject('') { |value, memo| (value.to_s.length > memo.to_s.length) ? value : memo }) * 1.25
else
longest_left_label_width = calculate_width(@marker_font_size,
label(@maximum_value.to_f))
label(@maximum_value.to_f))
end

# Shift graph if left line numbers are hidden
line_number_width = @hide_line_numbers && !@has_left_labels ?
0.0 :
(longest_left_label_width + LABEL_MARGIN * 2)
(longest_left_label_width + LABEL_MARGIN * 2)

@graph_left = @left_margin +
line_number_width +
(@y_axis_label.nil? ? 0.0 : @marker_caps_height + LABEL_MARGIN * 2)
line_number_width +
(@y_axis_label.nil? ? 0.0 : @marker_caps_height + LABEL_MARGIN * 2)

# Make space for half the width of the rightmost column label.
# Might be greater than the number of columns if between-style bar markers are used.
last_label = @labels.keys.sort.last.to_i
extra_room_for_long_label = (last_label >= (@column_count-1) && @center_labels_over_point) ?
calculate_width(@marker_font_size, @labels[last_label]) / 2.0 :
0
0
@graph_right_margin = @right_margin + extra_room_for_long_label

@graph_bottom_margin = @bottom_margin +
@marker_caps_height + LABEL_MARGIN
@marker_caps_height + LABEL_MARGIN
end

@graph_right = @raw_columns - @graph_right_margin
Expand All @@ -604,11 +604,11 @@ def setup_graph_measurements
# When @hide title, leave a TITLE_MARGIN space for aesthetics.
# Same with @hide_legend
@graph_top = @top_margin +
(@hide_title ? TITLE_MARGIN : @title_caps_height + TITLE_MARGIN * 2) +
(@hide_legend ? LEGEND_MARGIN : @legend_caps_height + LEGEND_MARGIN * 2)
(@hide_title ? TITLE_MARGIN : @title_caps_height + TITLE_MARGIN * 2) +
(@hide_legend ? LEGEND_MARGIN : @legend_caps_height + LEGEND_MARGIN * 2)

x_axis_label_height = @x_axis_label.nil? ? 0.0 :
@marker_caps_height + LABEL_MARGIN
@marker_caps_height + LABEL_MARGIN
@graph_bottom = @raw_rows - @graph_bottom_margin - x_axis_label_height
@graph_height = @graph_bottom - @graph_top
end
Expand All @@ -628,9 +628,9 @@ def draw_axis_labels
@d.pointsize = scale_fontsize(@marker_font_size)
@d.gravity = NorthGravity
@d = @d.annotate_scaled( @base_image,
@raw_columns, 1.0,
0.0, x_axis_label_y_coordinate,
@x_axis_label, @scale)
@raw_columns, 1.0,
0.0, x_axis_label_y_coordinate,
@x_axis_label, @scale)
debug { @d.line 0.0, x_axis_label_y_coordinate, @raw_columns, x_axis_label_y_coordinate }
end

Expand All @@ -639,9 +639,9 @@ def draw_axis_labels
@d.rotation = 90.0
@d.gravity = CenterGravity
@d = @d.annotate_scaled( @base_image,
1.0, @raw_rows,
@left_margin + @marker_caps_height / 2.0, 0.0,
@y_axis_label, @scale)
1.0, @raw_rows,
@left_margin + @marker_caps_height / 2.0, 0.0,
@y_axis_label, @scale)
@d.rotation = -90.0
end
end
Expand Down Expand Up @@ -696,9 +696,9 @@ def draw_line_markers

# Vertically center with 1.0 for the height
@d = @d.annotate_scaled( @base_image,
@graph_left - LABEL_MARGIN, 1.0,
0.0, y,
label(marker_label), @scale)
@graph_left - LABEL_MARGIN, 1.0,
0.0, y,
label(marker_label), @scale)
end
end

Expand Down Expand Up @@ -773,7 +773,7 @@ def draw_legend
current_x_offset = center(sum(label_widths.first))
current_y_offset = @hide_title ?
@top_margin + LEGEND_MARGIN :
@top_margin + TITLE_MARGIN + @title_caps_height + LEGEND_MARGIN
@top_margin + TITLE_MARGIN + @title_caps_height + LEGEND_MARGIN

@legend_labels.each_with_index do |legend_label, index|

Expand All @@ -785,17 +785,17 @@ def draw_legend
@d.font_weight = NormalWeight
@d.gravity = WestGravity
@d = @d.annotate_scaled( @base_image,
@raw_columns, 1.0,
current_x_offset + (legend_square_width * 1.7), current_y_offset,
legend_label.to_s, @scale)
@raw_columns, 1.0,
current_x_offset + (legend_square_width * 1.7), current_y_offset,
legend_label.to_s, @scale)

# Now draw box with color of this dataset
@d = @d.stroke('transparent')
@d = @d.fill @data[index][DATA_COLOR_INDEX]
@d = @d.rectangle(current_x_offset,
current_y_offset - legend_square_width / 2.0,
current_x_offset + legend_square_width,
current_y_offset + legend_square_width / 2.0)
current_y_offset - legend_square_width / 2.0,
current_x_offset + legend_square_width,
current_y_offset + legend_square_width / 2.0)

@d.pointsize = @legend_font_size
metrics = @d.get_type_metrics(@base_image, legend_label.to_s)
Expand Down Expand Up @@ -833,9 +833,9 @@ def draw_title
@d.font_weight = BoldWeight
@d.gravity = NorthGravity
@d = @d.annotate_scaled( @base_image,
@raw_columns, 1.0,
0, @top_margin,
@title, @scale)
@raw_columns, 1.0,
0, @top_margin,
@title, @scale)
end

# Draws column labels below graph, centered over x_offset
Expand All @@ -854,9 +854,9 @@ def draw_label(x_offset, index)
@d.pointsize = scale_fontsize(@marker_font_size)
@d.gravity = NorthGravity
@d = @d.annotate_scaled(@base_image,
1.0, 1.0,
x_offset, y_offset,
@labels[index], @scale)
1.0, 1.0,
x_offset, y_offset,
@labels[index], @scale)
@labels_seen[index] = 1
debug { @d.line 0.0, y_offset, @raw_columns, y_offset }
end
Expand All @@ -871,9 +871,9 @@ def draw_no_data
@d.pointsize = scale_fontsize(80)
@d.gravity = CenterGravity
@d = @d.annotate_scaled( @base_image,
@raw_columns, @raw_rows/2.0,
0, 10,
@no_data_message, @scale)
@raw_columns, @raw_rows/2.0,
0, 10,
@no_data_message, @scale)
end

# Finds the best background to render based on the provided theme options.
Expand All @@ -900,7 +900,7 @@ def render_solid_background(color)
# Use with a theme definition method to draw a gradiated background.
def render_gradiated_background(top_color, bottom_color)
Image.new(@columns, @rows,
GradientFill.new(0, 0, 100, 0, top_color, bottom_color))
GradientFill.new(0, 0, 100, 0, top_color, bottom_color))
end

# Use with a theme to use an image (800x600 original) background.
Expand Down Expand Up @@ -1043,14 +1043,7 @@ def debug

# Returns the next color in your color list.
def increment_color
if @color_index < @colors.length
@color_index += 1
else
# Start over
@color_index = 0
end
# Return pre-incremented index element.
# If @color_index is 0, -1 yields last element in @colors.
@color_index = (@color_index + 1) % @colors.length
return @colors[@color_index - 1]
end

Expand Down Expand Up @@ -1105,9 +1098,9 @@ def annotate_scaled(img, width, height, x, y, text, scale)
scaled_height = (height * scale) >= 1 ? (height * scale) : 1

self.annotate( img,
scaled_width, scaled_height,
x * scale, y * scale,
text)
scaled_width, scaled_height,
x * scale, y * scale,
text)
end

end
Expand Down
Loading

0 comments on commit 2910b76

Please sign in to comment.