Fixes #160: All .{h,v}spacing fxd.
This commit is contained in:
parent
aac0a8bf0d
commit
d32370cf8a
|
@ -305,7 +305,7 @@ namespace CairoChart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var max_rec_spacing = is_x ? font.vspacing : font.hspacing;
|
var max_rec_spacing = 2 * (is_x ? font.vspacing : font.hspacing);
|
||||||
var max_title_width = title.text == "" ? 0 : title.width + font.hspacing;
|
var max_title_width = title.text == "" ? 0 : title.width + font.hspacing;
|
||||||
var max_title_height = title.text == "" ? 0 : title.height + font.vspacing;
|
var max_title_height = title.text == "" ? 0 : title.height + font.vspacing;
|
||||||
|
|
||||||
|
@ -387,7 +387,7 @@ namespace CairoChart {
|
||||||
if (nskip != 0) {--nskip; return;}
|
if (nskip != 0) {--nskip; return;}
|
||||||
var max_rec_width = 0.0, max_rec_height = 0.0;
|
var max_rec_width = 0.0, max_rec_height = 0.0;
|
||||||
calc_rec_sizes (this, out max_rec_width, out max_rec_height, is_x);
|
calc_rec_sizes (this, out max_rec_width, out max_rec_height, is_x);
|
||||||
var max_rec_spacing = is_x ? font.vspacing : font.hspacing;
|
var max_rec_spacing = 2 * (is_x ? font.vspacing : font.hspacing);
|
||||||
var max_title_width = title.text == "" ? 0 : title.width + font.hspacing;
|
var max_title_width = title.text == "" ? 0 : title.width + font.hspacing;
|
||||||
var max_title_height = title.text == "" ? 0 : title.height + font.vspacing;
|
var max_title_height = title.text == "" ? 0 : title.height + font.vspacing;
|
||||||
|
|
||||||
|
@ -445,8 +445,8 @@ namespace CairoChart {
|
||||||
switch (axis.dtype) {
|
switch (axis.dtype) {
|
||||||
case DType.NUMBERS:
|
case DType.NUMBERS:
|
||||||
var text = new Text (chart, axis.format.printf((LongDouble)x) + (horizontal ? "_" : ""), axis.font);
|
var text = new Text (chart, axis.format.printf((LongDouble)x) + (horizontal ? "_" : ""), axis.font);
|
||||||
max_rec_width = double.max (max_rec_width, text.width);
|
max_rec_width = double.max (max_rec_width, text.width + (horizontal ? text.font.hspacing : 0));
|
||||||
max_rec_height = double.max (max_rec_height, text.height);
|
max_rec_height = double.max (max_rec_height, text.height + (horizontal ? 0 : text.font.vspacing));
|
||||||
break;
|
break;
|
||||||
case DType.DATE_TIME:
|
case DType.DATE_TIME:
|
||||||
string date, time;
|
string date, time;
|
||||||
|
@ -455,12 +455,12 @@ namespace CairoChart {
|
||||||
var h = 0.0;
|
var h = 0.0;
|
||||||
if (axis.date_format != "") {
|
if (axis.date_format != "") {
|
||||||
var text = new Text (chart, date + (horizontal ? "_" : ""), axis.font);
|
var text = new Text (chart, date + (horizontal ? "_" : ""), axis.font);
|
||||||
max_rec_width = double.max (max_rec_width, text.width);
|
max_rec_width = double.max (max_rec_width, text.width + text.font.hspacing);
|
||||||
h = text.height;
|
h = text.height;
|
||||||
}
|
}
|
||||||
if (axis.time_format != "") {
|
if (axis.time_format != "") {
|
||||||
var text = new Text (chart, time + (horizontal ? "_" : ""), axis.font);
|
var text = new Text (chart, time + (horizontal ? "_" : ""), axis.font);
|
||||||
max_rec_width = double.max (max_rec_width, text.width);
|
max_rec_width = double.max (max_rec_width, text.width + text.font.hspacing);
|
||||||
h += text.height;
|
h += text.height;
|
||||||
}
|
}
|
||||||
max_rec_height = double.max (max_rec_height, h);
|
max_rec_height = double.max (max_rec_height, h);
|
||||||
|
@ -497,7 +497,7 @@ namespace CairoChart {
|
||||||
calc_rec_sizes (a2, out tmp_max_rec_width, out tmp_max_rec_height, is_x);
|
calc_rec_sizes (a2, out tmp_max_rec_width, out tmp_max_rec_height, is_x);
|
||||||
max_rec_width = double.max (max_rec_width, tmp_max_rec_width);
|
max_rec_width = double.max (max_rec_width, tmp_max_rec_width);
|
||||||
max_rec_height = double.max (max_rec_height, tmp_max_rec_height);
|
max_rec_height = double.max (max_rec_height, tmp_max_rec_height);
|
||||||
max_rec_spacing = double.max (max_rec_spacing, is_x ? a2.font.vspacing : a2.font.hspacing);
|
max_rec_spacing = double.max (max_rec_spacing, 2 * (is_x ? a2.font.vspacing : a2.font.hspacing));
|
||||||
max_title_size = double.max (
|
max_title_size = double.max (
|
||||||
max_title_size,
|
max_title_size,
|
||||||
a2.title.text == "" ? 0
|
a2.title.text == "" ? 0
|
||||||
|
|
|
@ -34,12 +34,12 @@ namespace CairoChart {
|
||||||
/**
|
/**
|
||||||
* Vertical spacing.
|
* Vertical spacing.
|
||||||
*/
|
*/
|
||||||
public double vspacing = 4;
|
public double vspacing = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Horizontal spacing.
|
* Horizontal spacing.
|
||||||
*/
|
*/
|
||||||
public double hspacing = 4;
|
public double hspacing = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Both vertical & horizontal spacing (set only).
|
* Both vertical & horizontal spacing (set only).
|
||||||
|
@ -51,7 +51,7 @@ namespace CairoChart {
|
||||||
set {
|
set {
|
||||||
vspacing = hspacing = value;
|
vspacing = hspacing = value;
|
||||||
}
|
}
|
||||||
default = 4;
|
default = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,8 +67,8 @@ namespace CairoChart {
|
||||||
Cairo.FontSlant slant = Cairo.FontSlant.NORMAL,
|
Cairo.FontSlant slant = Cairo.FontSlant.NORMAL,
|
||||||
Cairo.FontWeight weight = Cairo.FontWeight.NORMAL,
|
Cairo.FontWeight weight = Cairo.FontWeight.NORMAL,
|
||||||
Gtk.Orientation orient = Gtk.Orientation.HORIZONTAL,
|
Gtk.Orientation orient = Gtk.Orientation.HORIZONTAL,
|
||||||
double vspacing = 4,
|
double vspacing = 2,
|
||||||
double hspacing = 4
|
double hspacing = 2
|
||||||
) {
|
) {
|
||||||
this.family = family;
|
this.family = family;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
|
|
@ -180,8 +180,8 @@ namespace CairoChart {
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case Position.TOP:
|
case Position.TOP:
|
||||||
case Position.BOTTOM:
|
case Position.BOTTOM:
|
||||||
var ser_title_width = s.title.width + line_length;
|
var ser_title_width = line_length + s.title.width + s.title.font.hspacing * 2;
|
||||||
if (leg_width_sum + (leg_width_sum == 0 ? 0 : s.title.font.hspacing) + ser_title_width > chart.area.width) { // carry
|
if (leg_width_sum + ser_title_width > chart.area.width) { // carry
|
||||||
leg_height_sum += max_font_h;
|
leg_height_sum += max_font_h;
|
||||||
switch (process_type) {
|
switch (process_type) {
|
||||||
case ProcessType.CALC:
|
case ProcessType.CALC:
|
||||||
|
@ -200,43 +200,43 @@ namespace CairoChart {
|
||||||
|
|
||||||
switch (process_type) {
|
switch (process_type) {
|
||||||
case ProcessType.DRAW:
|
case ProcessType.DRAW:
|
||||||
var x = legend_x0 + leg_width_sum + (leg_width_sum == 0 ? 0 : s.title.font.hspacing);
|
var x = legend_x0 + leg_width_sum + s.title.font.hspacing;
|
||||||
var y = legend_y0 + leg_height_sum + mfh[heights_idx] / 2 + s.title.height / 2;
|
var y = legend_y0 + leg_height_sum + mfh[heights_idx] / 2;
|
||||||
|
|
||||||
// series title
|
// series title
|
||||||
chart.ctx.move_to (x + line_length, y);
|
chart.ctx.move_to (x + line_length, y + s.title.height / 2);
|
||||||
chart.color = s.title.color;
|
chart.color = s.title.color;
|
||||||
s.title.show();
|
s.title.show();
|
||||||
|
|
||||||
// series line style
|
// series line style
|
||||||
chart.ctx.move_to (x, y - s.title.height / 2);
|
chart.ctx.move_to (x, y);
|
||||||
s.line_style.apply(chart);
|
s.line_style.apply(chart);
|
||||||
chart.ctx.rel_line_to (line_length, 0);
|
chart.ctx.rel_line_to (line_length, 0);
|
||||||
chart.ctx.stroke();
|
chart.ctx.stroke();
|
||||||
s.marker.draw_at_pos (Point(x + line_length / 2, y - s.title.height / 2));
|
s.marker.draw_at_pos (Point(x + line_length / 2, y));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case Position.TOP:
|
case Position.TOP:
|
||||||
case Position.BOTTOM:
|
case Position.BOTTOM:
|
||||||
var ser_title_width = s.title.width + line_length;
|
var ser_title_width = line_length + s.title.width + s.title.font.hspacing * 2;
|
||||||
leg_width_sum += (leg_width_sum == 0 ? 0 : s.title.font.hspacing) + ser_title_width;
|
leg_width_sum += ser_title_width;
|
||||||
max_font_h = double.max (max_font_h, s.title.height) + (leg_height_sum != 0 ? s.title.font.vspacing : 0);
|
max_font_h = double.max (max_font_h, s.title.height + s.title.font.vspacing * 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Position.LEFT:
|
case Position.LEFT:
|
||||||
case Position.RIGHT:
|
case Position.RIGHT:
|
||||||
switch (process_type) {
|
switch (process_type) {
|
||||||
case ProcessType.CALC:
|
case ProcessType.CALC:
|
||||||
mfh += s.title.height + (leg_height_sum != 0 ? s.title.font.vspacing : 0);
|
mfh += s.title.height + s.title.font.vspacing * 2;
|
||||||
width = double.max (width, s.title.width + line_length);
|
width = double.max (width, s.title.font.hspacing * 2 + line_length + s.title.width);
|
||||||
break;
|
break;
|
||||||
case ProcessType.DRAW:
|
case ProcessType.DRAW:
|
||||||
heights_idx++;
|
heights_idx++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
leg_height_sum += s.title.height + (leg_height_sum != 0 ? s.title.font.vspacing : 0);
|
leg_height_sum += s.title.height + s.title.font.vspacing * 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue