In progress...

This commit is contained in:
Kolan Sh 2018-01-19 11:09:33 +03:00
parent 272cefc395
commit b2d629c455
4 changed files with 15 additions and 11 deletions

View File

@ -97,12 +97,6 @@ namespace CairoChart {
default = Color();
}
/**
* TODO: remove all spacing fields / evaluate automatically.
*/
[Version (deprecated = true)]
public double title_spacing = 4;
/**
* Constructs a new ``Chart``.
*/
@ -129,7 +123,6 @@ namespace CairoChart {
chart.selection_style = this.selection_style;
chart.series = this.series;
chart.title = this.title.copy();
chart.title_spacing = this.title_spacing;
chart.zoom = this.zoom;
chart.zoom_1st_idx = this.zoom_1st_idx;
return chart;
@ -350,11 +343,11 @@ namespace CairoChart {
}
protected virtual void draw_title () {
var sz = title.get_size(ctx);
var title_height = sz.height + (legend.position == Legend.Position.TOP ? title_spacing * 2 : title_spacing);
var title_height = sz.height + (legend.position == Legend.Position.TOP ? title.vspacing * 2 : title.vspacing);
evarea.y += title_height;
evarea.height -= title_height;
color = title.color;
ctx.move_to (area.width/2 - sz.width/2, sz.height + title_spacing);
ctx.move_to (area.width/2 - sz.width/2, sz.height + title.vspacing);
title.show(ctx);
}
protected virtual void draw_haxes () {

View File

@ -317,7 +317,7 @@ namespace CairoChart {
break;
case Axis.Position.HIGH:
var title_height = chart.title.get_height(chart.ctx) + (chart.legend.position == Legend.Position.TOP ?
chart.title_spacing * 2 : chart.title_spacing);
chart.title.vspacing * 2 : chart.title.vspacing);
print_y = chart.area.y + title_height + s.axis_x.font_spacing
+ (chart.legend.position == Legend.Position.TOP ? chart.legend.height : 0);
switch (s.axis_x.type) {

View File

@ -53,7 +53,7 @@ namespace CairoChart {
case Position.TOP:
x0 = (chart.area.width - width) / 2;
var title_height = chart.title.get_height(chart.ctx) + (chart.legend.position == Legend.Position.TOP ?
chart.title_spacing * 2 : chart.title_spacing);
chart.title.vspacing * 2 : chart.title.vspacing);
y0 = title_height;
break;

View File

@ -3,6 +3,17 @@ namespace CairoChart {
public string text = "";
public Font.Style style = Font.Style ();
public Color color = Color();
public double vspacing = 4;
public double hspacing = 4;
public double spacing {
protected get {
return 0;
}
set {
vspacing = hspacing = value;
}
default = 4;
}
public virtual Cairo.TextExtents get_extents (Cairo.Context ctx) {
ctx.select_font_face (style.family, style.slant, style.weight);