OK In progress...

This commit is contained in:
Kolan Sh 2018-01-22 18:21:29 +03:00
parent 5b8b712cea
commit bd83013c40
8 changed files with 68 additions and 30 deletions

View File

@ -5,11 +5,11 @@ namespace CairoChart {
*/ */
public class Axis { public class Axis {
Chart chart; protected Chart chart;
string _format = "%.2Lf"; protected string _format = "%.2Lf";
string _date_format = "%Y.%m.%d"; protected string _date_format = "%Y.%m.%d";
string _time_format = "%H:%M:%S"; protected string _time_format = "%H:%M:%S";
int _dsec_signs = 2; // 2 signs = centiseconds protected int _dsec_signs = 2; // 2 signs = centiseconds
/** /**
* ``Axis`` title. * ``Axis`` title.

View File

@ -309,7 +309,6 @@ namespace CairoChart {
protected virtual void eval_plarea () { protected virtual void eval_plarea () {
plarea = evarea.copy(); plarea = evarea.copy();
legend.show = false;
if (legend.show) if (legend.show)
switch(legend.position) { switch(legend.position) {
case Legend.Position.TOP: plarea.y0 += legend.spacing; break; case Legend.Position.TOP: plarea.y0 += legend.spacing; break;

View File

@ -1,18 +1,35 @@
namespace CairoChart { namespace CairoChart {
/**
* {@link Chart} cursors.
*/
public class Cursors { public class Cursors {
protected Chart chart;
protected List<Point?> list = new List<Point?> (); protected List<Point?> list = new List<Point?> ();
protected Point active_cursor = Point(); // { get; protected set; default = Point128 (); } protected Point active_cursor = Point(); // { get; protected set; default = Point128 (); }
protected bool is_cursor_active = false; // { get; protected set; default = false; } protected bool is_cursor_active = false; // { get; protected set; default = false; }
public Cursors.Style cursor_style = Cursors.Style();
public Cursors.CursorCrossings[] crossings = {};
Chart chart;
/**
*
*/
public Cursors.Style cursor_style = Cursors.Style();
/**
*
*/
public Cursors.CursorCrossings[] crossings = {};
/**
*
*/
public Cursors (Chart chart) { public Cursors (Chart chart) {
this.chart = chart; this.chart = chart;
} }
/**
*
*/
public Cursors copy () { public Cursors copy () {
var c = new Cursors (chart); var c = new Cursors (chart);
c.list = list.copy(); c.list = list.copy();
@ -23,17 +40,36 @@ namespace CairoChart {
return c; return c;
} }
/**
*
*/
protected enum Orientation { protected enum Orientation {
VERTICAL = 0, // default VERTICAL = 0,
HORIZONTAL HORIZONTAL
} }
/**
*
*/
protected struct Style { protected struct Style {
/**
*
*/
public Orientation orientation; public Orientation orientation;
/**
*
*/
public double select_distance; public double select_distance;
/**
*
*/
public LineStyle line_style; public LineStyle line_style;
/**
*
*/
public Style () { public Style () {
orientation = Orientation.VERTICAL; orientation = Orientation.VERTICAL;
select_distance = 32; select_distance = 32;

View File

@ -5,8 +5,8 @@ namespace CairoChart {
*/ */
public class Legend { public class Legend {
Chart chart; protected Chart chart;
double [] max_font_heights; protected double [] max_font_heights;
/** /**
* ``Legend`` position. * ``Legend`` position.
@ -158,12 +158,14 @@ namespace CairoChart {
var leg_height_sum = 0.0; var leg_height_sum = 0.0;
var max_font_h = 0.0; var max_font_h = 0.0;
double [] mfh = max_font_heights;
// prepare // prepare
switch (process_type) { switch (process_type) {
case ProcessType.CALC: case ProcessType.CALC:
width = 0; width = 0;
height = 0; height = 0;
max_font_heights = {}; mfh = {};
heights_idx = 0; heights_idx = 0;
break; break;
case ProcessType.DRAW: case ProcessType.DRAW:
@ -172,7 +174,6 @@ namespace CairoChart {
} }
foreach (var s in chart.series) { foreach (var s in chart.series) {
if (!s.zoom_show) continue; if (!s.zoom_show) continue;
// carry // carry
@ -184,7 +185,7 @@ namespace CairoChart {
leg_height_sum += max_font_h; leg_height_sum += max_font_h;
switch (process_type) { switch (process_type) {
case ProcessType.CALC: case ProcessType.CALC:
max_font_heights += max_font_h; mfh += max_font_h;
width = double.max(width, leg_width_sum); width = double.max(width, leg_width_sum);
break; break;
case ProcessType.DRAW: case ProcessType.DRAW:
@ -200,7 +201,7 @@ 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 + (leg_width_sum == 0 ? 0 : s.title.font.hspacing);
var y = legend_y0 + leg_height_sum + max_font_heights[heights_idx] / 2 + s.title.height / 2; var y = legend_y0 + leg_height_sum + mfh[heights_idx] / 2 + s.title.height / 2;
// series title // series title
chart.ctx.move_to (x + line_length, y); chart.ctx.move_to (x + line_length, y);
@ -228,7 +229,7 @@ namespace CairoChart {
case Position.RIGHT: case Position.RIGHT:
switch (process_type) { switch (process_type) {
case ProcessType.CALC: case ProcessType.CALC:
max_font_heights += s.title.height + (leg_height_sum != 0 ? s.title.font.vspacing : 0); mfh += s.title.height + (leg_height_sum != 0 ? s.title.font.vspacing : 0);
width = double.max (width, s.title.width + line_length); width = double.max (width, s.title.width + line_length);
break; break;
case ProcessType.DRAW: case ProcessType.DRAW:
@ -248,7 +249,7 @@ namespace CairoChart {
leg_height_sum += max_font_h; leg_height_sum += max_font_h;
switch (process_type) { switch (process_type) {
case ProcessType.CALC: case ProcessType.CALC:
max_font_heights += max_font_h; mfh += max_font_h;
width = double.max(width, leg_width_sum); width = double.max(width, leg_width_sum);
break; break;
} }
@ -267,6 +268,8 @@ namespace CairoChart {
} }
break; break;
} }
max_font_heights = mfh;
} }
} }
} }

View File

@ -5,7 +5,7 @@ namespace CairoChart {
*/ */
public class Marker { public class Marker {
Chart chart; protected Chart chart;
/** /**
* ``Marker`` shape. * ``Marker`` shape.

View File

@ -5,10 +5,10 @@ namespace CairoChart {
*/ */
public class Place { public class Place {
double _x0 = 0; protected double _x0 = 0;
double _x1 = 1; protected double _x1 = 1;
double _y0 = 0; protected double _y0 = 0;
double _y1 = 1; protected double _y1 = 1;
/** /**
* Zoomed Left bound. * Zoomed Left bound.

View File

@ -5,8 +5,8 @@ namespace CairoChart {
*/ */
public class Range { public class Range {
Float128 _min = 0; protected Float128 _min = 0;
Float128 _max = 1; protected Float128 _max = 1;
/** /**
* Zoomed min bound. * Zoomed min bound.

View File

@ -5,10 +5,10 @@ namespace CairoChart {
*/ */
public class Text { public class Text {
Chart chart; protected Chart chart;
string _text; protected string _text;
Font _font; protected Font _font;
Cairo.TextExtents? _ext; protected Cairo.TextExtents? _ext;
/** /**
* ``Text`` string. * ``Text`` string.