OK In progress...

This commit is contained in:
Kolan Sh 2018-01-22 17:47:00 +03:00
parent 1eee87fb1a
commit 7029f1f906
9 changed files with 53 additions and 53 deletions

View File

@ -21,7 +21,7 @@ namespace CairoChart {
public Area evarea = new Area.with_abs(0, 0, 1, 1);
/**
* Zoom area limits (relative coordinates: 0.0-1.0).
* Zoom area limits (relative coordinates: 0-1).
*/
public Area zoom = new Area.with_abs(0, 0, 1, 1);
@ -205,25 +205,25 @@ namespace CairoChart {
}
if (real_x0 >= s.axis_x.range.zmin) {
s.axis_x.range.zmin = real_x0;
s.place.zx0 = 0.0;
s.place.zx0 = 0;
} else {
s.place.zx0 = (s.axis_x.range.zmin - real_x0) / real_width;
}
if (real_x1 <= s.axis_x.range.zmax) {
s.axis_x.range.zmax = real_x1;
s.place.zx1 = 1.0;
s.place.zx1 = 1;
} else {
s.place.zx1 = (s.axis_x.range.zmax - real_x0) / real_width;
}
if (real_y1 >= s.axis_y.range.zmin) {
s.axis_y.range.zmin = real_y1;
s.place.zy0 = 0.0;
s.place.zy0 = 0;
} else {
s.place.zy0 = (s.axis_y.range.zmin - real_y1) / real_height;
}
if (real_y0 <= s.axis_y.range.zmax) {
s.axis_y.range.zmax = real_y0;
s.place.zy1 = 1.0;
s.place.zy1 = 1;
} else {
s.place.zy1 = (s.axis_y.range.zmax - real_y1) / real_height;
}

View File

@ -32,10 +32,10 @@ namespace CairoChart {
* @param blue blue component.
* @param alpha alpha component.
*/
public Color (double red = 0.0,
double green = 0.0,
double blue = 0.0,
double alpha = 1.0
public Color (double red = 0,
double green = 0,
double blue = 0,
double alpha = 1
) {
this.red = red;
this.green = green;

View File

@ -78,7 +78,7 @@ namespace CairoChart {
public virtual void remove_active_cursor () {
if (list.length() == 0) return;
var distance = 1024.0 * 1024.0;//width * width;
var distance = 1024.0 * 1024;//width * width;
uint rm_indx = 0;
uint i = 0;
foreach (var c in list) {
@ -127,7 +127,7 @@ namespace CairoChart {
for (var i = 0; i + 1 < points.length; ++i) {
switch (cursor_style.orientation) {
case Orientation.VERTICAL:
Float128 y = 0.0;
Float128 y = 0;
if (Math.vcross(s.get_scr_point(points[i]), s.get_scr_point(points[i+1]), rel2scr_x(c.x),
chart.plarea.y0, chart.plarea.y1, out y)) {
var point = Point128(s.get_real_x(rel2scr_x(c.x)), s.get_real_y(y));
@ -139,7 +139,7 @@ namespace CairoChart {
}
break;
case Orientation.HORIZONTAL:
Float128 x = 0.0;
Float128 x = 0;
if (Math.hcross(s.get_scr_point(points[i]), s.get_scr_point(points[i+1]),
chart.plarea.x0, chart.plarea.x1, rel2scr_y(c.y), out x)) {
var point = Point128(s.get_real_x(x), s.get_real_y(rel2scr_y(c.y)));
@ -213,7 +213,7 @@ namespace CairoChart {
var time_t = new Text(chart, time, s.axis_x.font, s.axis_x.color);
var x_t = new Text(chart, s.axis_x.format.printf((LongDouble)p.x), s.axis_x.font, s.axis_x.color);
var y_t = new Text(chart, s.axis_y.format.printf((LongDouble)p.y), s.axis_y.font, s.axis_y.color);
double h_x = 0.0, h_y = 0.0;
var h_x = 0.0, h_y = 0.0;
if (show_x) { size.x = x_t.width; h_x = x_t.height; }
if (show_date) { size.x = date_t.width; h_x = date_t.height; }
if (show_time) { size.x = double.max(size.x, time_t.width); h_x += time_t.height; }
@ -416,7 +416,7 @@ namespace CairoChart {
}
public bool get_cursors_delta (out Float128 delta) {
delta = 0.0;
delta = 0;
if (chart.series.length == 0) return false;
if (list.length() + (is_cursor_active ? 1 : 0) != 2) return false;
if (chart.joint_x && cursor_style.orientation == Orientation.VERTICAL) {
@ -449,7 +449,7 @@ namespace CairoChart {
}
public string get_cursors_delta_str () {
Float128 delta = 0.0;
Float128 delta = 0;
if (!get_cursors_delta(out delta)) return "";
var str = "";
var s = chart.series[chart.zoom_1st_idx];

View File

@ -65,7 +65,7 @@ namespace CairoChart {
/**
* {@link Series} line length.
*/
public double line_length = 30.0;
public double line_length = 30;
/**
* Show legend?
@ -107,7 +107,7 @@ namespace CairoChart {
}
protected virtual void draw_rect (out double x0, out double y0) {
x0 = y0 = 0.0;
x0 = y0 = 0;
if (chart.ctx != null) {
switch (position) {
case Position.TOP:
@ -156,13 +156,13 @@ namespace CairoChart {
var heights_idx = 0;
var leg_width_sum = 0.0;
var leg_height_sum = 0.0;
double max_font_h = 0.0;
var max_font_h = 0.0;
// prepare
switch (process_type) {
case ProcessType.CALC:
width = 0.0;
height = 0.0;
width = 0;
height = 0;
max_font_heights = {};
heights_idx = 0;
break;
@ -191,7 +191,7 @@ namespace CairoChart {
heights_idx++;
break;
}
leg_width_sum = 0.0;
leg_width_sum = 0;
max_font_h = 0;
}
break;

View File

@ -38,7 +38,7 @@ namespace CairoChart {
*/
public Marker (Chart chart,
Shape shape = Shape.NONE,
double size = 8.0
double size = 8
) {
this.chart = chart;
this.shape = shape;

View File

@ -3,9 +3,9 @@ namespace CairoChart {
namespace Math {
internal Float128 calc_round_step (Float128 aver_step, bool date_time = false) {
Float128 step = 1.0;
Float128 step = 1;
if (aver_step > 1.0) {
if (aver_step > 1) {
if (date_time) while (step < aver_step) step *= 60;
if (date_time) while (step < aver_step) step *= 60;
if (date_time) while (step < aver_step) step *= 24;

View File

@ -20,7 +20,7 @@ namespace CairoChart {
* @param x x-coordinate.
* @param y y-coordinate.
*/
public Point (double x = 0.0, double y = 0.0) {
public Point (double x = 0, double y = 0) {
this.x = x; this.y = y;
}
}
@ -45,7 +45,7 @@ namespace CairoChart {
* @param x x-coordinate.
* @param y y-coordinate.
*/
public Point128 (Float128 x = 0.0, Float128 y = 0.0) {
public Point128 (Float128 x = 0, Float128 y = 0) {
this.x = x; this.y = y;
}
}

View File

@ -23,7 +23,7 @@ namespace CairoChart {
public LineStyle line_style = LineStyle ();
protected Color _color = Color (0.0, 0.0, 0.0, 1.0);
protected Color _color = Color (0, 0, 0, 1);
public Color color {
get { return _color; }
set {
@ -34,7 +34,7 @@ namespace CairoChart {
grid.style.color = _color;
grid.style.color.alpha = 0.5;
}
default = Color (0.0, 0.0, 0.0, 1.0);
default = Color (0, 0, 0, 1);
}
public bool zoom_show = true;
@ -119,7 +119,7 @@ namespace CairoChart {
protected virtual void calc_rec_sizes (Axis axis, out double max_rec_width, out double max_rec_height, bool horizontal = true) {
max_rec_width = max_rec_height = 0;
for (var i = 0; i < axis.nrecords; ++i) {
Float128 x = (int64)(axis.range.zmin + axis.range.zrange / axis.nrecords * i) + 1.0/3.0;
Float128 x = (int64)(axis.range.zmin + axis.range.zrange / axis.nrecords * i) + 1/3.0;
switch (axis.dtype) {
case Axis.DType.NUMBERS:
var text = new Text (chart, axis.format.printf((LongDouble)x) + (horizontal ? "_" : ""), axis.font);
@ -153,7 +153,7 @@ namespace CairoChart {
if (!is_x) axis = s.axis_y;
if (!s.zoom_show) return;
if (nskip != 0) {--nskip; return;}
double max_rec_width = 0; double max_rec_height = 0;
var max_rec_width = 0.0, max_rec_height = 0.0;
calc_rec_sizes (axis, out max_rec_width, out max_rec_height, is_x);
var max_font_spacing = is_x ? axis.font.vspacing : axis.font.hspacing;
var max_axis_font_width = axis.title.text == "" ? 0 : axis.title.width + axis.font.hspacing;
@ -226,7 +226,7 @@ namespace CairoChart {
}
if (!has_intersection) {
if (calc_max_values) {
double tmp_max_rec_width = 0; double tmp_max_rec_height = 0;
var tmp_max_rec_width = 0.0, tmp_max_rec_height = 0.0;
calc_rec_sizes (s2.axis_x, out tmp_max_rec_width, out tmp_max_rec_height, true);
max_rec_width = double.max (max_rec_width, tmp_max_rec_width);
max_rec_height = double.max (max_rec_height, tmp_max_rec_height);
@ -263,7 +263,7 @@ namespace CairoChart {
}
}
if (!has_intersection) {
double tmp_max_rec_width = 0; double tmp_max_rec_height = 0;
var tmp_max_rec_width = 0.0, tmp_max_rec_height = 0.0;
calc_rec_sizes (s2.axis_y, out tmp_max_rec_width, out tmp_max_rec_height, false);
max_rec_width = double.max (max_rec_width, tmp_max_rec_width);
max_rec_height = double.max (max_rec_height, tmp_max_rec_height);
@ -319,7 +319,7 @@ namespace CairoChart {
if (joint_x)
ctx.line_to (scr_x, chart.plarea.y0);
else
ctx.line_to (scr_x, double.min (y, chart.plarea.y0 + chart.plarea.height * (1.0 - place.zy1)));
ctx.line_to (scr_x, double.min (y, chart.plarea.y0 + chart.plarea.height * (1 - place.zy1)));
break;
case Axis.Position.HIGH:
var print_y = chart.evarea.y0 + max_rec_height + axis_x.font.vspacing + (axis_x.title.text == "" ? 0 : axis_x.title.height + axis_x.font.vspacing);
@ -347,7 +347,7 @@ namespace CairoChart {
if (joint_x)
ctx.line_to (scr_x, chart.plarea.y1);
else
ctx.line_to (scr_x, double.max (y, chart.plarea.y0 + chart.plarea.height * (1.0 - place.zy0)));
ctx.line_to (scr_x, double.max (y, chart.plarea.y0 + chart.plarea.height * (1 - place.zy0)));
break;
}
}
@ -371,7 +371,7 @@ namespace CairoChart {
step = s.axis_x.range.zrange;
// 4. Calculate x_min (s.axis_x.range.zmin / step, round, multiply on step, add step if < s.axis_x.range.zmin).
Float128 x_min = 0.0;
Float128 x_min = 0;
if (step >= 1) {
int64 x_min_nsteps = (int64) (s.axis_x.range.zmin / step);
x_min = x_min_nsteps * step;
@ -393,13 +393,13 @@ namespace CairoChart {
// 4.5. Draw Axis title
if (s.axis_x.title.text != "") {
var scr_x = chart.plarea.x0 + chart.plarea.width * (s.place.zx0 + s.place.zx1) / 2.0;
double scr_y = 0.0;
var scr_x = chart.plarea.x0 + chart.plarea.width * (s.place.zx0 + s.place.zx1) / 2;
var scr_y = 0.0;
switch (s.axis_x.position) {
case Axis.Position.LOW: scr_y = chart.evarea.y1 - s.axis_x.font.vspacing; break;
case Axis.Position.HIGH: scr_y = chart.evarea.y0 + s.axis_x.font.vspacing + axis_x.title.height; break;
}
chart.ctx.move_to(scr_x - axis_x.title.width / 2.0, scr_y);
chart.ctx.move_to(scr_x - axis_x.title.width / 2, scr_y);
chart.color = s.axis_x.color;
if (chart.joint_x) chart.color = chart.joint_color;
s.axis_x.title.show();
@ -409,7 +409,7 @@ namespace CairoChart {
chart.ctx.stroke ();
double tmp1 = 0, tmp2 = 0, tmp3 = 0, tmp4 = 0;
var tmp1 = 0.0, tmp2 = 0.0, tmp3 = 0.0, tmp4 = 0.0;
s.join_relative_x_axes (si, false, ref tmp1, ref tmp2, ref tmp3, ref tmp4, ref nskip);
if (nskip != 0) {--nskip; return;}
@ -487,7 +487,7 @@ namespace CairoChart {
step = s.axis_y.range.zrange;
// 4. Calculate y_min (s.axis_y.range.zmin / step, round, multiply on step, add step if < s.axis_y.range.zmin).
Float128 y_min = 0.0;
Float128 y_min = 0;
if (step >= 1) {
int64 y_min_nsteps = (int64) (s.axis_y.range.zmin / step);
y_min = y_min_nsteps * step;
@ -509,15 +509,15 @@ namespace CairoChart {
// 4.5. Draw Axis title
if (s.axis_y.title.text != "") {
var scr_y = chart.plarea.y0 + chart.plarea.height * (1.0 - (s.place.zy0 + s.place.zy1) / 2.0);
var scr_y = chart.plarea.y0 + chart.plarea.height * (1 - (s.place.zy0 + s.place.zy1) / 2);
switch (s.axis_y.position) {
case Axis.Position.LOW:
var scr_x = chart.evarea.x0 + s.axis_y.font.hspacing + axis_y.title.width;
chart.ctx.move_to(scr_x, scr_y + axis_y.title.height / 2.0);
chart.ctx.move_to(scr_x, scr_y + axis_y.title.height / 2);
break;
case Axis.Position.HIGH:
var scr_x = chart.evarea.x1 - s.axis_y.font.hspacing;
chart.ctx.move_to(scr_x, scr_y + axis_y.title.height / 2.0);
chart.ctx.move_to(scr_x, scr_y + axis_y.title.height / 2);
break;
}
chart.color = s.axis_y.color;
@ -529,7 +529,7 @@ namespace CairoChart {
chart.ctx.stroke ();
double tmp1 = 0, tmp2 = 0, tmp3 = 0, tmp4 = 0;
var tmp1 = 0.0, tmp2 = 0.0, tmp3 = 0.0, tmp4 = 0.0;
s.join_relative_y_axes (si, false, ref tmp1, ref tmp2, ref tmp3, ref tmp4, ref nskip);
if (nskip != 0) {--nskip; return;}
@ -542,13 +542,13 @@ namespace CairoChart {
}
public virtual double compact_rec_x_pos (Float128 x, Text text) {
return get_scr_x(x) - text.width / 2.0
- text.width * (x - (axis_x.range.zmin + axis_x.range.zmax) / 2.0) / axis_x.range.zrange;
return get_scr_x(x) - text.width / 2
- text.width * (x - (axis_x.range.zmin + axis_x.range.zmax) / 2) / axis_x.range.zrange;
}
public virtual double compact_rec_y_pos (Float128 y, Text text) {
return get_scr_y(y) + text.height / 2.0
+ text.height * (y - (axis_y.range.zmin + axis_y.range.zmax) / 2.0) / axis_y.range.zrange;
return get_scr_y(y) + text.height / 2
+ text.height * (y - (axis_y.range.zmin + axis_y.range.zmax) / 2) / axis_y.range.zrange;
}
public virtual double get_scr_x (Float128 x) {
@ -556,7 +556,7 @@ namespace CairoChart {
}
public virtual double get_scr_y (Float128 y) {
return chart.plarea.y0 + chart.plarea.height * (1.0 - (place.zy0 + (y - axis_y.range.zmin) / axis_y.range.zrange * place.zheight));
return chart.plarea.y0 + chart.plarea.height * (1 - (place.zy0 + (y - axis_y.range.zmin) / axis_y.range.zrange * place.zheight));
}
public virtual Point get_scr_point (Point128 p) {

View File

@ -68,7 +68,7 @@ namespace CairoChart {
switch (font.orient) {
case Gtk.Orientation.HORIZONTAL: return ext.width + ext.x_bearing;
case Gtk.Orientation.VERTICAL: return ext.height;
default: return 0.0;
default: return 0;
}
}
protected set {
@ -83,7 +83,7 @@ namespace CairoChart {
switch (font.orient) {
case Gtk.Orientation.HORIZONTAL: return ext.height; // + ext.x_bearing ?
case Gtk.Orientation.VERTICAL: return ext.width; // +- ext.y_bearing ?
default: return 0.0;
default: return 0;
}
}
protected set {
@ -99,9 +99,9 @@ namespace CairoChart {
font.weight);
chart.ctx.set_font_size(font.size);
if (font.orient == Gtk.Orientation.VERTICAL) {
chart.ctx.rotate(- GLib.Math.PI / 2.0);
chart.ctx.rotate(- GLib.Math.PI / 2);
chart.ctx.show_text(text);
chart.ctx.rotate(GLib.Math.PI / 2.0);
chart.ctx.rotate(GLib.Math.PI / 2);
} else {
chart.ctx.show_text(text);
}