gruffy 1.0.4 → 1.1.0
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.
- checksums.yaml +4 -4
- data/lib/gruffy/base.rb +2 -0
- data/lib/gruffy/side_stacked_bar.rb +7 -15
- data/lib/gruffy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63f477231d82e41b3c6c22d654d880329ed45e21
|
4
|
+
data.tar.gz: e548d23c404fb6a1b273b3f59d17c54424dcbaed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d656ffbce7aefbe43fd307619182047a64a492da1902e8e32a849a7db44c5c2a847b622be5d2698640167d97bf11c12dbd9b69381948ff07a2dee4953a94b83
|
7
|
+
data.tar.gz: df1cec0423bd25b4952cf0abd7d47a8509957c731085dc9f13bebaf5f31ab9bedec4e7379d06a5f4f22a44c8e36495700226d9d3911d6155db23fb882009486c
|
data/lib/gruffy/base.rb
CHANGED
@@ -2,18 +2,12 @@ require File.dirname(__FILE__) + '/base'
|
|
2
2
|
require File.dirname(__FILE__) + '/side_bar'
|
3
3
|
require File.dirname(__FILE__) + '/stacked_mixin'
|
4
4
|
|
5
|
-
##
|
6
|
-
# New gruffy graph type added to enable sideways stacking bar charts
|
7
|
-
# (basically looks like a x/y flip of a standard stacking bar chart)
|
8
|
-
#
|
9
|
-
# alun.eyre@googlemail.com
|
10
|
-
|
11
5
|
class Gruffy::SideStackedBar < Gruffy::SideBar
|
12
6
|
include StackedMixin
|
13
7
|
|
14
8
|
# Spacing factor applied between bars
|
15
9
|
attr_accessor :bar_spacing
|
16
|
-
|
10
|
+
|
17
11
|
def draw
|
18
12
|
@has_left_labels = true
|
19
13
|
get_maximum_by_stack
|
@@ -42,10 +36,8 @@ class Gruffy::SideStackedBar < Gruffy::SideBar
|
|
42
36
|
|
43
37
|
## using the original calcs from the stacked bar chart to get the difference between
|
44
38
|
## part of the bart chart we wish to stack.
|
45
|
-
temp1 = @graph_left + (@graph_width -
|
46
|
-
|
47
|
-
height[point_index]) + 1
|
48
|
-
temp2 = @graph_left + @graph_width - height[point_index] - 1
|
39
|
+
temp1 = @graph_left + (@graph_width - data_point * @graph_width - height[point_index])
|
40
|
+
temp2 = @graph_left + @graph_width - height[point_index]
|
49
41
|
difference = temp2 - temp1
|
50
42
|
|
51
43
|
@d = @d.fill data_row[DATA_COLOR_INDEX]
|
@@ -56,12 +48,12 @@ class Gruffy::SideStackedBar < Gruffy::SideBar
|
|
56
48
|
right_y = left_y + @bar_width * @bar_spacing
|
57
49
|
length[point_index] += difference
|
58
50
|
height[point_index] += (data_point * @graph_width - 2)
|
59
|
-
|
51
|
+
|
60
52
|
if @show_labels_for_bar_values
|
61
53
|
label_values[point_index][:value] += @norm_data[row_index][3][point_index]
|
62
54
|
label_values[point_index][:right_x] = right_x
|
63
55
|
end
|
64
|
-
|
56
|
+
|
65
57
|
# if a data point is 0 it can result in weird really thing lines
|
66
58
|
# that shouldn't even be there being drawn on top of the existing
|
67
59
|
# bar - this is bad
|
@@ -82,8 +74,8 @@ class Gruffy::SideStackedBar < Gruffy::SideBar
|
|
82
74
|
draw_value_label(data[:right_x]+40, (@graph_top + (((i+1) * @bar_width) - (@bar_width / 2)))-12, val.commify, true)
|
83
75
|
end
|
84
76
|
end
|
85
|
-
|
86
|
-
@d.draw(@base_image)
|
77
|
+
|
78
|
+
@d.draw(@base_image)
|
87
79
|
end
|
88
80
|
|
89
81
|
def larger_than_max?(data_point, index=0)
|
data/lib/gruffy/version.rb
CHANGED