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 {
Chart chart;
string _format = "%.2Lf";
string _date_format = "%Y.%m.%d";
string _time_format = "%H:%M:%S";
int _dsec_signs = 2; // 2 signs = centiseconds
protected Chart chart;
protected string _format = "%.2Lf";
protected string _date_format = "%Y.%m.%d";
protected string _time_format = "%H:%M:%S";
protected int _dsec_signs = 2; // 2 signs = centiseconds
/**
* ``Axis`` title.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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