OLD | NEW |
1 ''' | 1 ''' |
2 Created on May 16, 2011 | 2 Created on May 16, 2011 |
3 | 3 |
4 @author: bungeman | 4 @author: bungeman |
5 ''' | 5 ''' |
6 import bench_util | 6 import bench_util |
7 import getopt | 7 import getopt |
8 import httplib | 8 import httplib |
9 import itertools | 9 import itertools |
10 import json | 10 import json |
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 pic_width = max(rev_width*3 | 802 pic_width = max(rev_width*3 |
803 , pic_height * (float(rev_width) / time_height)) | 803 , pic_height * (float(rev_width) / time_height)) |
804 | 804 |
805 return (pic_width, pic_height) | 805 return (pic_width, pic_height) |
806 | 806 |
807 def output_svg(lines, regressions, requested_width, requested_height): | 807 def output_svg(lines, regressions, requested_width, requested_height): |
808 """Outputs an svg view of the data.""" | 808 """Outputs an svg view of the data.""" |
809 | 809 |
810 (global_min_x, _), (global_max_x, global_max_y) = bounds(lines) | 810 (global_min_x, _), (global_max_x, global_max_y) = bounds(lines) |
811 max_up_slope, min_down_slope = bounds_slope(regressions) | 811 max_up_slope, min_down_slope = bounds_slope(regressions) |
812 | 812 |
813 #output | 813 #output |
814 global_min_y = 0 | 814 global_min_y = 0 |
815 x = global_min_x | 815 x = global_min_x |
816 y = global_min_y | 816 y = global_min_y |
817 w = global_max_x - global_min_x | 817 w = global_max_x - global_min_x |
818 h = global_max_y - global_min_y | 818 h = global_max_y - global_min_y |
819 font_size = 16 | 819 font_size = 16 |
820 line_width = 2 | 820 line_width = 2 |
821 | 821 |
| 822 # If there is nothing to see, don't try to draw anything. |
| 823 if w == 0 or h == 0: |
| 824 return |
| 825 |
822 pic_width, pic_height = compute_size(requested_width, requested_height | 826 pic_width, pic_height = compute_size(requested_width, requested_height |
823 , w, h) | 827 , w, h) |
824 | 828 |
825 def cw(w1): | 829 def cw(w1): |
826 """Converts a revision difference to display width.""" | 830 """Converts a revision difference to display width.""" |
827 return (pic_width / float(w)) * w1 | 831 return (pic_width / float(w)) * w1 |
828 def cx(x): | 832 def cx(x): |
829 """Converts a revision to a horizontal display position.""" | 833 """Converts a revision to a horizontal display position.""" |
830 return cw(x - global_min_x) | 834 return cw(x - global_min_x) |
831 | 835 |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 print '<a id="rev_link" xlink:href="" target="_top">' | 1038 print '<a id="rev_link" xlink:href="" target="_top">' |
1035 print '<text id="revision" x="0" y=%s style="' % qa(font_size*2) | 1039 print '<text id="revision" x="0" y=%s style="' % qa(font_size*2) |
1036 print 'font-size: %s; ' % qe(font_size) | 1040 print 'font-size: %s; ' % qe(font_size) |
1037 print 'stroke: #0000dd; text-decoration: underline; ' | 1041 print 'stroke: #0000dd; text-decoration: underline; ' |
1038 print '"> </text></a>' | 1042 print '"> </text></a>' |
1039 | 1043 |
1040 print '</svg>' | 1044 print '</svg>' |
1041 | 1045 |
1042 if __name__ == "__main__": | 1046 if __name__ == "__main__": |
1043 main() | 1047 main() |
OLD | NEW |