Scruffy Stacked Bar Chart

Hi-

Trying to do a stacked bar chart, but nothing is rendering when I add
more then 1 bar:

This works:
graph = Scruffy::Graph.new(:title => “My Chart”)
graph.add :stacked do |stack|
stack.add(:bar, ‘Stack1’, [10,10])
end

This doesn’t:
graph = Scruffy::Graph.new(:title => “My Chart”)
graph.add :stacked do |stack|
stack.add(:bar, ‘Stack1’, [10,10])
stack.add(:bar, ‘Stack2’, [15,10])
end

Anyone know what’s going wrong here?

Thanks!

pete wrote:

Hi-

Trying to do a stacked bar chart, but nothing is rendering when I add
more then 1 bar:

This works:
graph = Scruffy::Graph.new(:title => “My Chart”)
graph.add :stacked do |stack|
stack.add(:bar, ‘Stack1’, [10,10])
end

This doesn’t:
graph = Scruffy::Graph.new(:title => “My Chart”)
graph.add :stacked do |stack|
stack.add(:bar, ‘Stack1’, [10,10])
stack.add(:bar, ‘Stack2’, [15,10])
end

Anyone know what’s going wrong here?

There’s a small bug in an inject call inside the “points” method of the
Stacked layer class. You need to replace this line (71 in my copy of
the source)

longest = layer.points if (longest.nil? || longest.size <
layer.points.size)

with this one

layer.points if (longest.nil? || longest.size < layer.points.size)

At least, that worked for me. YMMV :-).