On Jun 2, 2006, at 18:20, Jeff P. wrote:
I’m finding it a bit surprising that anybody is interested in
horizontal
bar graphs. I’ve always found them a bit off-putting. Like I’m
supposed to lay my head on the table while I look at them. Will it be
unforgivably incomplete without support for horizontal bars?
I’d be perplexed, to be sure. As somebody else pointed out, because our
language lays out in horizontal boxes, you can just naturally get a lot
more information into a space if the labels are running the same
direction as the bars.
a
graph?
I sort of expect that a Graph would expect an array of GraphItems.
GraphItem would be something like
:value (required, numeric)
:label (default nil)
:barcolor (default to nil, aka Graph.barcolor)
:barimage (default to nil, aka Graph.barimage)
I could pass in an array like
[3, 65, 43, 1, 0, 0, 5]
or I could send in
[[4, “PCs”], [18, “Macs”], [9, “Other”]]
or I could do
[:rutabagas => 30, :pomegranates=>54, :kiwifruit => 4325]
or I could do
[ <#GraphItem:@label=“Spoon!”, @value=43, @barcolor=“FF0000”,
@barimage=nil>, <#GraphItem:@label=“Fork”, @value=12,
@barcolor=“777777”, @barimage=nil>, <#GraphItem:@label=“Knife”,
@value=14, @barcolor=“777777”, @barimage=nil>
- I want to make labeling pretty simple. I’m thinking just set it up
such that there are ten evenly spaced “slots” for placing a custom ‘y’
label. If none are supplied it would fill these ten spots in with
calculated values based on the min and max.
I think you’ll find value-axis labels to be a bit of a problem. If
they’re just numbers on a vertical graph, they’ll usually work OK. Big
numbers on a horiz. graph will be prone to distortion due to label
length. Vertically, it may not be very clear where the ‘tick’ mark
would be for that number. Would you try to span each label across two
rows? And what if my values are “3” “4” and “5”? Do I just get unevenly
spaced labels, or a graph with some dead space at some point?
- I’m thinking an optional method that allows you to supply an array of
‘x’ labels - one per bar. If nothing is supplied, nothing will be
“drawn”
Are these bar labels or value-axis labels? I’m not sure which one you
think is “x”, although since you seem to think in terms of vertical
graphs, I guess they’re bar labels.
I’d want to supply bar labels at the same time that I provided bar
values, not have to break them out and load them separately, which
seems kind of weird . . . but maybe that’s just me.
- I’m thinking that “titling” of the graph can be done outside of the
graph and not handled by the library
- In ‘erb’ land, is there any advantage to making it a “one liner”,
where the constructor is big and hairy and allows all possible
parameters to be filled in, and the constructor automatically provides
the html output?
That wouldn’t be hard if Graph.new accepts an array, no?
print Graph.new(datapoints).html
I can see people wanting to also pass in .min, .max, .bar_color, and
the rest, although personally I’d probably prefer being able to set
defaults for the class.
Graph.default_bar_image = “/images/bargraph.gif”
Graph.default_bar_color = htmlColors[:yellow]
mmmm. Default symbolic colors…