I have been working on this code for a few days and can’t seem to figure
out what I am doing wrong… Labeling gruff is pretty easy for the most
part (just put it in hash format) but I can’t get this to work for
anything…
This is basically the code that I am working on:
I won’t go through the code to get the first input and the last input
for both the hour and the minute, but I am fine on that part of the code
and I named them: last_min_hour, last_time_min, last_time_hour and
first_time_min.
count_incr += 0
access_bar_hash = Hash.new(0)
time_regex = /d{1,2}:[5][0]/ # looks for only 50 minute intervals
reads = 60 # this will change based on how many times the program runs
label_spacing = 60/reads # 60 is how many columns there are
incr_hash[count_incr] = final_first_time
while count_incr < 8 # the 8 will actually be dynamic, but use this for
now
if incr_hash[count_incr] =~ time_regex
first_time_hour += 1
first_time_min = ‘00’
else
first_time_min = first_time_min.to_i
first_time_min += 10
end
count_incr += 1
incr_hash[count_incr] = [first_time_hour, first_time_min].join(":")
spacer = label_spacing * (count_reads)
access_bar_hash[(label_spacing * count_incr)] =
incr_hash[count_incr]
end
access_bar.labels = access_bar_hash
What I don’t understand is that if i take the output of what
access_bar_hash gives me, it input that directly into the
access_bar.labels, this works perfect. But I must be putting this into
the hash wrong somehow… Can anyone take a look at this and give me
some help?
reads = 60 # this will change based on how many times the program runs
label_spacing = 60/reads # 60 is how many columns there are
Just guessing, make sure your labels are for “exactly the right x
locations”–are you trying to label x or y? What happens currently?
What did you expect to happen instead?
Thanks!
-=R
Rereading through my description above, this isn’t a very good
description of what I am trying to do… Essentially I am trying to
dynamically update the x-axis. I am reading in apache’s server every 60
seconds and storing the data to a csv file. Then in this program, I take
that csv file and graph the data. And for the labels, I need to print a
label at every 10 minute interval. So if the program runs from 7:00 to
8:00, I should have 7:00, 7:10, etc… 8:00.
The error message that I am getting is something about annotation.
“cannot convert fixnum to string.”
The error message that I am getting is something about annotation.
“cannot convert fixnum to string.”
Odd
I’d first make sure you’re passing in something like
g.labels = {
0 => ‘5/6’,
2 => ‘5/15’,
4 => ‘5/24’,
6 => ‘5/30’,
}
-=R
It turned out, my problem was that when I initialized my hash, I
shouldn’t have ended with the (0). I didn’t think it was a big deal but
it worked perfect as soon as I took it away…
Thanks for your help on the matter though. Much appreciated.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.