From a6839c3211eaea06531699d47f319d0947791726 Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Mon, 22 Jan 2018 13:10:27 +0300 Subject: [PATCH] OK In progress... --- src/Legend.vala | 2 +- src/Marker.vala | 19 +++++++++---------- src/Series.vala | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Legend.vala b/src/Legend.vala index b0378af..cd93d02 100644 --- a/src/Legend.vala +++ b/src/Legend.vala @@ -153,7 +153,7 @@ namespace CairoChart { s.line_style.apply(chart); chart.ctx.rel_line_to (line_length, 0); chart.ctx.stroke(); - s.marker.draw_at_pos (x + line_length / 2, y - s.title.height / 2); + s.marker.draw_at_pos (Point(x + line_length / 2, y - s.title.height / 2)); break; } diff --git a/src/Marker.vala b/src/Marker.vala index dd47177..0b28862 100644 --- a/src/Marker.vala +++ b/src/Marker.vala @@ -53,24 +53,23 @@ namespace CairoChart { /** * Draws the ``Marker`` at specific position. - * @param x x-coordinate. - * @param y y-coordinate. + * @param p coordinates. */ - public virtual void draw_at_pos (double x, double y) { - chart.ctx.move_to (x, y); + public virtual void draw_at_pos (Point p) { + chart.ctx.move_to (p.x, p.y); switch (type) { case Shape.SQUARE: - chart.ctx.rectangle (x - size / 2, y - size / 2, size, size); + chart.ctx.rectangle (p.x - size / 2, p.y - size / 2, size, size); chart.ctx.fill(); break; case Shape.CIRCLE: - chart.ctx.arc (x, y, size / 2, 0, 2 * GLib.Math.PI); + chart.ctx.arc (p.x, p.y, size / 2, 0, 2 * GLib.Math.PI); chart.ctx.fill(); break; case Shape.TRIANGLE: - chart.ctx.move_to (x - size / 2, y - size / 2); + chart.ctx.move_to (p.x - size / 2, p.y - size / 2); chart.ctx.rel_line_to (size, 0); chart.ctx.rel_line_to (-size / 2, size); chart.ctx.rel_line_to (-size / 2, -size); @@ -78,17 +77,17 @@ namespace CairoChart { break; case Shape.PRICLE_SQUARE: - chart.ctx.rectangle (x - size / 2, y - size / 2, size, size); + chart.ctx.rectangle (p.x - size / 2, p.y - size / 2, size, size); chart.ctx.stroke(); break; case Shape.PRICLE_CIRCLE: - chart.ctx.arc (x, y, size / 2, 0, 2 * GLib.Math.PI); + chart.ctx.arc (p.x, p.y, size / 2, 0, 2 * GLib.Math.PI); chart.ctx.stroke(); break; case Shape.PRICLE_TRIANGLE: - chart.ctx.move_to (x - size / 2, y - size / 2); + chart.ctx.move_to (p.x - size / 2, p.y - size / 2); chart.ctx.rel_line_to (size, 0); chart.ctx.rel_line_to (-size / 2, size); chart.ctx.rel_line_to (-size / 2, -size); diff --git a/src/Series.vala b/src/Series.vala index b627ed2..4d8f2f4 100644 --- a/src/Series.vala +++ b/src/Series.vala @@ -88,7 +88,7 @@ namespace CairoChart { var y = get_scr_y(points[i].y); if (Math.point_in_rect (Point(x, y), chart.plarea.x0, chart.plarea.x1, chart.plarea.y0, chart.plarea.y1)) - marker.draw_at_pos(x, y); + marker.draw_at_pos(Point(x, y)); } }