diff options
Diffstat (limited to 'src/plugins/stats/statistics.c')
-rw-r--r-- | src/plugins/stats/statistics.c | 55 |
1 files changed, 46 insertions, 9 deletions
diff --git a/src/plugins/stats/statistics.c b/src/plugins/stats/statistics.c index db44f720..2ea19cb5 100644 --- a/src/plugins/stats/statistics.c +++ b/src/plugins/stats/statistics.c | |||
@@ -67,6 +67,8 @@ static void load_graph_draw(LoadGraph *g) { | |||
67 | guint j; | 67 | guint j; |
68 | gint dely; | 68 | gint dely; |
69 | float delx; | 69 | float delx; |
70 | float max; | ||
71 | GdkFont * font; | ||
70 | 72 | ||
71 | if (!g->disp->window) | 73 | if (!g->disp->window) |
72 | return; | 74 | return; |
@@ -111,13 +113,48 @@ static void load_graph_draw(LoadGraph *g) { | |||
111 | g->draw_width, | 113 | g->draw_width, |
112 | g->disp->allocation.height); | 114 | g->disp->allocation.height); |
113 | 115 | ||
114 | dely = g->draw_height / 5; | 116 | max = 0.26; /* force showing at least the 25% line */ |
115 | for (i = 1; i <5; i++) { | 117 | for (i = 0; i < g->num_points - 1; i++) |
118 | for (j=0;j<g->count;j++) | ||
119 | if (g->data[i][j] > max) | ||
120 | max = g->data[i][j]; | ||
121 | max = max * 1.01; /* leave top 1% free */ | ||
122 | |||
123 | font = gdk_font_load("fixed"); /* deprecated, but pango is far more than | ||
124 | what we need here -- fix later? */ | ||
125 | /* draw lines at 25%, 50%, 75% and 100% of max */ | ||
126 | dely = g->draw_height / max / 4; | ||
127 | for (i = 1; i < 5; i++) { | ||
116 | gint y1 = g->draw_height + 1 - i * dely; | 128 | gint y1 = g->draw_height + 1 - i * dely; |
117 | gdk_draw_line (g->pixmap, g->gc, | 129 | if ( (dely < 30) && (i != 4) ) |
118 | 0, y1, g->draw_width, y1); | 130 | continue; /* only print additional |
131 | lines if there is enough space! */ | ||
132 | if (y1 > 0) { | ||
133 | const gchar * label[] = { | ||
134 | NULL, | ||
135 | " 25%", | ||
136 | " 50%", | ||
137 | " 75%", | ||
138 | "100%", | ||
139 | }; | ||
140 | gdk_draw_string(g->pixmap, | ||
141 | font, | ||
142 | g->gc, | ||
143 | 10, | ||
144 | y1 - 8, | ||
145 | label[i]); | ||
146 | gdk_draw_line (g->pixmap, g->gc, | ||
147 | 0, y1, g->draw_width, y1); | ||
148 | if (i == 4) { | ||
149 | /* extra-thick line at 100% */ | ||
150 | gdk_draw_line (g->pixmap, g->gc, | ||
151 | 0, y1 - 1, g->draw_width, y1 - 1); | ||
152 | gdk_draw_line (g->pixmap, g->gc, | ||
153 | 0, y1 + 1, g->draw_width, y1 + 1); | ||
154 | |||
155 | } | ||
156 | } | ||
119 | } | 157 | } |
120 | |||
121 | gdk_gc_set_line_attributes(g->gc, | 158 | gdk_gc_set_line_attributes(g->gc, |
122 | 2, | 159 | 2, |
123 | GDK_LINE_SOLID, | 160 | GDK_LINE_SOLID, |
@@ -130,8 +167,8 @@ static void load_graph_draw(LoadGraph *g) { | |||
130 | for (i = 0; i < g->num_points - 1; i++) { | 167 | for (i = 0; i < g->num_points - 1; i++) { |
131 | gint x1 = i * delx; | 168 | gint x1 = i * delx; |
132 | gint x2 = (i + 1) * delx; | 169 | gint x2 = (i + 1) * delx; |
133 | gint y1 = g->data[i][j] * g->draw_height - 1; | 170 | gint y1 = g->data[i][j] / max * g->draw_height - 1; |
134 | gint y2 = g->data[i+1][j] * g->draw_height - 1; | 171 | gint y2 = g->data[i+1][j] / max * g->draw_height - 1; |
135 | 172 | ||
136 | if ((g->data[i][j] != -1) && (g->data[i+1][j] != -1)) { | 173 | if ((g->data[i][j] != -1) && (g->data[i+1][j] != -1)) { |
137 | if (stats[g->statIdx].fill == NO) { | 174 | if (stats[g->statIdx].fill == NO) { |
@@ -153,8 +190,8 @@ static void load_graph_draw(LoadGraph *g) { | |||
153 | points[2].y = g->draw_height; | 190 | points[2].y = g->draw_height; |
154 | points[3].y = g->draw_height; | 191 | points[3].y = g->draw_height; |
155 | } else { | 192 | } else { |
156 | gint ly1 = g->data[i][j-1] * g->draw_height - 1; | 193 | gint ly1 = g->data[i][j-1] / max * g->draw_height - 1; |
157 | gint ly2 = g->data[i+1][j-1] * g->draw_height - 1; | 194 | gint ly2 = g->data[i+1][j-1] / max * g->draw_height - 1; |
158 | points[2].y = g->draw_height - ly1; | 195 | points[2].y = g->draw_height - ly1; |
159 | points[3].y = g->draw_height - ly2; | 196 | points[3].y = g->draw_height - ly2; |
160 | } | 197 | } |