GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
- float xscale = allocation.width / (priv->maxx - priv->minx);
- float yscale = allocation.height / (priv->miny - priv->maxy);
+ int margin = 3;
+ float xscale = (allocation.width - 2 * margin) / (priv->maxx - priv->minx);
+ float yscale = (allocation.height - 2 * margin) / (priv->miny - priv->maxy);
cairo_set_source_rgb(cr, 0.0, 0.0, 1.0);
struct BVChartPoint *start =
&g_array_index(priv->points, struct BVChartPoint, 0);
- cairo_move_to(cr, xscale * (start->x - priv->minx),
- yscale * (start->y - priv->maxy));
+ cairo_move_to(cr, xscale * (start->x - priv->minx) + margin,
+ yscale * (start->y - priv->maxy) + margin);
for (guint i = 1; i < priv->points->len; i++) {
struct BVChartPoint *p =
&g_array_index(priv->points, struct BVChartPoint, i);
- cairo_line_to(cr, xscale * (p->x - priv->minx),
- yscale * (p->y - priv->maxy));
+ cairo_line_to(cr, xscale * (p->x - priv->minx) + margin,
+ yscale * (p->y - priv->maxy) + margin);
}
cairo_stroke(cr);