In the wfrog user forum I posted the code for drawing vertival stripes for
exact scaling the x-axis at first minutes of hour / first hour of day / first
day of week and first day of month.
https://groups.google.com/forum/?fromgroups#!topic/wfrog-users/X9JWYFmZGWg
See my attached screenshot with a 7 days view. The vertical stripe changed the
colour at midnight.
This is only a sample code. I don't understand all wfrog data objects. With a
dirty hack I reengineered the time spans from the labels of charts.
> cat -n ./wfrender/renderer/chart.py
405 # begin with stripe generation#
406 # Set the vertical stripes
407 # use chart.fill_linear_stripes(Chart.CHART, 0, 'CCCCCC', 0.2, 'FFFFFF', 0.2)
408 max_stripes=11
409
410 #refill hh:mm from lbl2
411 t_b = data[self.labels.split('.')[0]]['series']['lbl2'][0]
412 t_b = t_b+'2001/01/01 00:00'[len(t_b):]
413 t_begin = datetime.datetime.strptime(t_b, "%Y/%m/%d %H:%M")
414 t_e = data[self.labels.split('.')[0]]['series']['lbl2'][-1]
415 t_e = t_e+'2001/01/01 00:00'[len(t_e):]
416 t_end = datetime.datetime.strptime(t_e, "%Y/%m/%d %H:%M")
417 #print str(t_begin) +" bis "+ str(t_end)
418 t_first = t_begin
419 t_minutes = t_end - t_begin
420 t_minutes_max = t_minutes.seconds/60 + t_minutes.days*1440
421 tm=1
422
423 if t_minutes_max < 60*max_stripes:
424 # calc next hour
425 t_delta=datetime.timedelta(hours=1)
426 t_first=t_first.replace(minute=0)+t_delta
427 elif t_minutes_max < 60*24*max_stripes:
428 # calc next day
429 t_delta=datetime.timedelta(days=1)
430 t_first=t_first.replace(hour=0,minute=0)+t_delta
431 elif t_minutes_max < 60*24*7*max_stripes:
432 # calc next monday
433 t_first=t_first.replace(hour=0,minute=0)+datetime.timedelta(days=7-t_first.weekday())
434 t_delta=datetime.timedelta(days=7)
435 else:
436 # calc first day of next month
437 t_first=t_first.replace(day=1)+datetime.timedelta(days=32)
438 t_first=t_first.replace(day=1,hour=0,minute=0)
439 tm=0
440
441 # generate stripes (calc with minutes of segments)
442 stripe=[]
443 i=0
444 t_minutes_first= 0
445 while t_first < t_end:
446 t_1 = t_first-t_begin
447 # print t_1
448 t_minutes_next = t_1.seconds/60 + t_1.days*1440
449 #print t_minutes
450 if i%2 == 0:
451 stripe.append('FFFFFF')
452 else:
453 stripe.append('F0F0F0')
454 i=i+1
455 stripe.append(round(float(t_minutes_next-t_minutes_first)/t_minutes_max,2))
456 t_minutes_first=t_minutes_next
457 if tm == 1:
458 t_first=t_first+t_delta
459 else:
460 ## calc first day of next month
461 t_first=t_first.replace(day=1)+datetime.timedelta(days=32)
462 t_first=t_first.replace(day=1)
463
464 # calc last broken stripe (until length 1,0)
465 if i%2 == 0:
466 stripe.append('FFFFFF')
467 else:
468 stripe.append('F0F0F0')
469 i=float(1-round(float(t_minutes_first)/t_minutes_max,2))
470 stripe.append(i)
471
472 # now draw stripes
473 chart.fill_linear_stripes(Chart.CHART, 0, *stripe)
474 # end of stripe generation#
Original issue reported on code.google.com by f.friedr...@googlemail.com on 3 Apr 2012 at 11:09
Original issue reported on code.google.com by
f.friedr...@googlemail.com
on 3 Apr 2012 at 11:09Attachments: