Gruff labels

R

Rick Jones

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

final_last_time = [last_time_hour, last_time_min].join(":")
final_first_time = [first_time_hour, first_time_min].join(":")

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?
 
R

Rick Jones

I said up there that "reads = 60" but actually reads should equal 8 for
now... That shouldn't matter too much though.
 
R

Roger Pack

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
 
R

Rick Jones

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."
 
R

Roger Pack

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
 
R

Rick Jones

Roger said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top