Merge branch '#160_check_spacings' into develop

This commit is contained in:
Kolan Sh 2018-02-19 12:19:10 +03:00
commit e73e92c3ef
4 changed files with 27 additions and 27 deletions

View File

@ -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_height = title.text == "" ? 0 : title.height + font.vspacing;
@ -387,7 +387,7 @@ namespace CairoChart {
if (nskip != 0) {--nskip; return;}
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);
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_height = title.text == "" ? 0 : title.height + font.vspacing;
@ -445,8 +445,8 @@ namespace CairoChart {
switch (axis.dtype) {
case DType.NUMBERS:
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_height = double.max (max_rec_height, text.height);
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 + (horizontal ? 0 : text.font.vspacing));
break;
case DType.DATE_TIME:
string date, time;
@ -455,12 +455,12 @@ namespace CairoChart {
var h = 0.0;
if (axis.date_format != "") {
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;
}
if (axis.time_format != "") {
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;
}
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);
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_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,
a2.title.text == "" ? 0

View File

@ -34,12 +34,12 @@ namespace CairoChart {
/**
* Vertical spacing.
*/
public double vspacing = 4;
public double vspacing = 2;
/**
* Horizontal spacing.
*/
public double hspacing = 4;
public double hspacing = 2;
/**
* Both vertical & horizontal spacing (set only).
@ -51,7 +51,7 @@ namespace CairoChart {
set {
vspacing = hspacing = value;
}
default = 4;
default = 2;
}
/**
@ -67,8 +67,8 @@ namespace CairoChart {
Cairo.FontSlant slant = Cairo.FontSlant.NORMAL,
Cairo.FontWeight weight = Cairo.FontWeight.NORMAL,
Gtk.Orientation orient = Gtk.Orientation.HORIZONTAL,
double vspacing = 4,
double hspacing = 4
double vspacing = 2,
double hspacing = 2
) {
this.family = family;
this.size = size;

View File

@ -180,8 +180,8 @@ namespace CairoChart {
switch (position) {
case Position.TOP:
case Position.BOTTOM:
var ser_title_width = s.title.width + line_length;
if (leg_width_sum + (leg_width_sum == 0 ? 0 : s.title.font.hspacing) + ser_title_width > chart.area.width) { // carry
var ser_title_width = line_length + s.title.width + s.title.font.hspacing * 2;
if (leg_width_sum + ser_title_width > chart.area.width) { // carry
leg_height_sum += max_font_h;
switch (process_type) {
case ProcessType.CALC:
@ -200,43 +200,43 @@ namespace CairoChart {
switch (process_type) {
case ProcessType.DRAW:
var x = legend_x0 + leg_width_sum + (leg_width_sum == 0 ? 0 : s.title.font.hspacing);
var y = legend_y0 + leg_height_sum + mfh[heights_idx] / 2 + s.title.height / 2;
var x = legend_x0 + leg_width_sum + s.title.font.hspacing;
var y = legend_y0 + leg_height_sum + mfh[heights_idx] / 2;
// 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;
s.title.show();
// series line style
chart.ctx.move_to (x, y - s.title.height / 2);
chart.ctx.move_to (x, y);
s.line_style.apply(chart);
chart.ctx.rel_line_to (line_length, 0);
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;
}
switch (position) {
case Position.TOP:
case Position.BOTTOM:
var ser_title_width = s.title.width + line_length;
leg_width_sum += (leg_width_sum == 0 ? 0 : s.title.font.hspacing) + ser_title_width;
max_font_h = double.max (max_font_h, s.title.height) + (leg_height_sum != 0 ? s.title.font.vspacing : 0);
var ser_title_width = line_length + s.title.width + s.title.font.hspacing * 2;
leg_width_sum += ser_title_width;
max_font_h = double.max (max_font_h, s.title.height + s.title.font.vspacing * 2);
break;
case Position.LEFT:
case Position.RIGHT:
switch (process_type) {
case ProcessType.CALC:
mfh += s.title.height + (leg_height_sum != 0 ? s.title.font.vspacing : 0);
width = double.max (width, s.title.width + line_length);
mfh += s.title.height + s.title.font.vspacing * 2;
width = double.max (width, s.title.font.hspacing * 2 + line_length + s.title.width);
break;
case ProcessType.DRAW:
heights_idx++;
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;
}
}