lib/ctioga2/graphics/elements/histogram.rb in ctioga2-0.10.1 vs lib/ctioga2/graphics/elements/histogram.rb in ctioga2-0.11
- old
+ new
@@ -226,11 +226,16 @@
#
# Later, we'll have to use a conversion function for X
# values (which means in particular that they won't be
# positioned at the exact X value, but that's already the
# case anyway).
- width = (x_values.max - x_values.min)/(x_values.size - 1)
+ width = (x_values.max - x_values.min)/(x_values.size - 1).to_f
+ if width.nan? || width == 0.0
+ # Only 1 X value, we use a width of 1
+ # ??
+ width = 0.8
+ end
# Available width
aw = width - intra_sep - inter_sep
if aw < 0
error { "Too much padding around the histograms leading to negative size. Try using smaller intra-sep or inter-sep. Ignoring them for now" }
@@ -248,10 +253,10 @@
c[:width] = iw
c[:x_offset] = offset
offset += iw
next unless col
if col.first.histogram_style.intra_sep
- offset += h.histogram_style.intra_sep.to_figure(t, :x)
+ offset += col.first.histogram_style.intra_sep.to_figure(t, :x)
end
for h in col
cache[h] = c
end
end