Merge branch '#155_LabelStyle_not_used' into develop

This commit is contained in:
Kolan Sh 2018-01-24 11:27:47 +03:00
commit 16ae304ef7
2 changed files with 48 additions and 15 deletions

View File

@ -60,6 +60,11 @@ namespace CairoChart {
*/ */
public Style style = Style(); public Style style = Style();
/**
* Value label style.
*/
public LabelStyle label_style = new LabelStyle();
/** /**
* Has crossings. * Has crossings.
*/ */
@ -82,6 +87,7 @@ namespace CairoChart {
c.active_cursor = active_cursor; c.active_cursor = active_cursor;
c.is_cursor_active = is_cursor_active; c.is_cursor_active = is_cursor_active;
c.style = style; c.style = style;
c.label_style = label_style.copy();
c.crossings = crossings; c.crossings = crossings;
return c; return c;
} }
@ -340,9 +346,18 @@ namespace CairoChart {
var show_time = ccs[ci].show_time; var show_time = ccs[ci].show_time;
var show_y = ccs[ci].show_y; var show_y = ccs[ci].show_y;
chart.color = chart.bg_color; // value label background
chart.color = label_style.bg_color;
chart.ctx.rectangle (svp.x - size.x / 2, svp.y - size.y / 2, size.x, size.y); chart.ctx.rectangle (svp.x - size.x / 2, svp.y - size.y / 2, size.x, size.y);
chart.ctx.fill(); chart.ctx.fill();
// value label frame
label_style.frame_style.apply(chart);
chart.ctx.move_to (svp.x - size.x / 2, svp.y - size.y / 2);
chart.ctx.rel_line_to (size.x, 0);
chart.ctx.rel_line_to (0, size.y);
chart.ctx.rel_line_to (-size.x, 0);
chart.ctx.rel_line_to (0, -size.y);
chart.ctx.stroke();
if (show_x) { if (show_x) {
chart.color = s.axis_x.color; chart.color = s.axis_x.color;

View File

@ -3,26 +3,44 @@ namespace CairoChart {
/** /**
* ``LabelStyle`` Style. * ``LabelStyle`` Style.
*/ */
public struct LabelStyle { public class LabelStyle {
/**
* Font style.
*/
Font font;
/**
* Frame line style.
*/
LineStyle frame_line_style;
/** /**
* Background color. * Background color.
*/ */
Color bg_color; public Color bg_color;
/** /**
* Frame/border color. * Frame line style.
*/ */
Color frame_color; public LineStyle frame_style;
/**
* Font style.
*/
public Font font;
/**
* Constructs a new ``LabelStyle``.
* @param font font style.
* @param bg_color background color.
* @param frame_style frame line style.
*/
public LabelStyle (
Color bg_color = Color(1, 1, 1, 1),
LineStyle frame_style = LineStyle(Color(0, 0, 0, 0.1)),
Font font = new Font()
) {
this.bg_color = bg_color;
this.frame_style = frame_style;
this.font = font;
}
/**
* Gets a copy of the ``LabelStyle``.
*/
public virtual LabelStyle copy () {
return new LabelStyle(bg_color, frame_style, font);
}
} }
} }