In progress...

This commit is contained in:
Kolan Sh 2018-01-21 15:41:04 +03:00
parent d9f79241dc
commit dc9b896232
3 changed files with 11 additions and 6 deletions

View File

@ -154,7 +154,7 @@ namespace CairoChart {
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 (chart, x + line_length / 2, y - title_sz.height / 2); s.marker.draw_at_pos (x + line_length / 2, y - title_sz.height / 2);
break; break;
} }

View File

@ -5,6 +5,8 @@ namespace CairoChart {
*/ */
public class Marker { public class Marker {
Chart chart = null;
/** /**
* ``Marker`` shape. * ``Marker`` shape.
*/ */
@ -33,9 +35,11 @@ namespace CairoChart {
* @param type ``Marker`` shape. * @param type ``Marker`` shape.
* @param size ``Marker`` size. * @param size ``Marker`` size.
*/ */
public Marker (Type type = Type.NONE, public Marker (Chart chart,
Type type = Type.NONE,
double size = 8.0 double size = 8.0
) { ) {
this.chart = chart;
this.type = type; this.type = type;
this.size = size; this.size = size;
} }
@ -44,7 +48,7 @@ namespace CairoChart {
* Gets a copy of the ``Marker``. * Gets a copy of the ``Marker``.
*/ */
public virtual Marker copy () { public virtual Marker copy () {
return new Marker (type, size); return new Marker (chart, type, size);
} }
/** /**
@ -52,7 +56,7 @@ namespace CairoChart {
* @param x x-coordinate. * @param x x-coordinate.
* @param y y-coordinate. * @param y y-coordinate.
*/ */
public virtual void draw_at_pos (Chart chart, double x, double y) { public virtual void draw_at_pos (double x, double y) {
chart.ctx.move_to (x, y); chart.ctx.move_to (x, y);
switch (type) { switch (type) {
case Type.SQUARE: case Type.SQUARE:

View File

@ -17,7 +17,7 @@ namespace CairoChart {
public Place place = new Place(); public Place place = new Place();
public Text title = new Text (); public Text title = new Text ();
public Marker marker = new Marker (); public Marker marker = null;
public Grid grid = new Grid (); public Grid grid = new Grid ();
@ -45,6 +45,7 @@ namespace CairoChart {
public Series (Chart chart) { public Series (Chart chart) {
this.chart = chart; this.chart = chart;
this.marker = new Marker(chart);
} }
public virtual Series copy () { public virtual Series copy () {
@ -86,7 +87,7 @@ namespace CairoChart {
var y = get_scr_y(points[i].y); var y = get_scr_y(points[i].y);
if (Math.point_in_rect (Point(x, y), chart.plarea.x0, chart.plarea.x1, if (Math.point_in_rect (Point(x, y), chart.plarea.x0, chart.plarea.x1,
chart.plarea.y0, chart.plarea.y1)) chart.plarea.y0, chart.plarea.y1))
marker.draw_at_pos(chart, x, y); marker.draw_at_pos(x, y);
} }
} }