OK In progress...
This commit is contained in:
parent
1eee87fb1a
commit
7029f1f906
|
@ -21,7 +21,7 @@ namespace CairoChart {
|
||||||
public Area evarea = new Area.with_abs(0, 0, 1, 1);
|
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);
|
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) {
|
if (real_x0 >= s.axis_x.range.zmin) {
|
||||||
s.axis_x.range.zmin = real_x0;
|
s.axis_x.range.zmin = real_x0;
|
||||||
s.place.zx0 = 0.0;
|
s.place.zx0 = 0;
|
||||||
} else {
|
} else {
|
||||||
s.place.zx0 = (s.axis_x.range.zmin - real_x0) / real_width;
|
s.place.zx0 = (s.axis_x.range.zmin - real_x0) / real_width;
|
||||||
}
|
}
|
||||||
if (real_x1 <= s.axis_x.range.zmax) {
|
if (real_x1 <= s.axis_x.range.zmax) {
|
||||||
s.axis_x.range.zmax = real_x1;
|
s.axis_x.range.zmax = real_x1;
|
||||||
s.place.zx1 = 1.0;
|
s.place.zx1 = 1;
|
||||||
} else {
|
} else {
|
||||||
s.place.zx1 = (s.axis_x.range.zmax - real_x0) / real_width;
|
s.place.zx1 = (s.axis_x.range.zmax - real_x0) / real_width;
|
||||||
}
|
}
|
||||||
if (real_y1 >= s.axis_y.range.zmin) {
|
if (real_y1 >= s.axis_y.range.zmin) {
|
||||||
s.axis_y.range.zmin = real_y1;
|
s.axis_y.range.zmin = real_y1;
|
||||||
s.place.zy0 = 0.0;
|
s.place.zy0 = 0;
|
||||||
} else {
|
} else {
|
||||||
s.place.zy0 = (s.axis_y.range.zmin - real_y1) / real_height;
|
s.place.zy0 = (s.axis_y.range.zmin - real_y1) / real_height;
|
||||||
}
|
}
|
||||||
if (real_y0 <= s.axis_y.range.zmax) {
|
if (real_y0 <= s.axis_y.range.zmax) {
|
||||||
s.axis_y.range.zmax = real_y0;
|
s.axis_y.range.zmax = real_y0;
|
||||||
s.place.zy1 = 1.0;
|
s.place.zy1 = 1;
|
||||||
} else {
|
} else {
|
||||||
s.place.zy1 = (s.axis_y.range.zmax - real_y1) / real_height;
|
s.place.zy1 = (s.axis_y.range.zmax - real_y1) / real_height;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,10 +32,10 @@ namespace CairoChart {
|
||||||
* @param blue blue component.
|
* @param blue blue component.
|
||||||
* @param alpha alpha component.
|
* @param alpha alpha component.
|
||||||
*/
|
*/
|
||||||
public Color (double red = 0.0,
|
public Color (double red = 0,
|
||||||
double green = 0.0,
|
double green = 0,
|
||||||
double blue = 0.0,
|
double blue = 0,
|
||||||
double alpha = 1.0
|
double alpha = 1
|
||||||
) {
|
) {
|
||||||
this.red = red;
|
this.red = red;
|
||||||
this.green = green;
|
this.green = green;
|
||||||
|
|
|
@ -78,7 +78,7 @@ namespace CairoChart {
|
||||||
|
|
||||||
public virtual void remove_active_cursor () {
|
public virtual void remove_active_cursor () {
|
||||||
if (list.length() == 0) return;
|
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 rm_indx = 0;
|
||||||
uint i = 0;
|
uint i = 0;
|
||||||
foreach (var c in list) {
|
foreach (var c in list) {
|
||||||
|
@ -127,7 +127,7 @@ namespace CairoChart {
|
||||||
for (var i = 0; i + 1 < points.length; ++i) {
|
for (var i = 0; i + 1 < points.length; ++i) {
|
||||||
switch (cursor_style.orientation) {
|
switch (cursor_style.orientation) {
|
||||||
case Orientation.VERTICAL:
|
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),
|
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)) {
|
chart.plarea.y0, chart.plarea.y1, out y)) {
|
||||||
var point = Point128(s.get_real_x(rel2scr_x(c.x)), s.get_real_y(y));
|
var point = Point128(s.get_real_x(rel2scr_x(c.x)), s.get_real_y(y));
|
||||||
|
@ -139,7 +139,7 @@ namespace CairoChart {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Orientation.HORIZONTAL:
|
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]),
|
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)) {
|
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)));
|
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 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 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);
|
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_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_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; }
|
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) {
|
public bool get_cursors_delta (out Float128 delta) {
|
||||||
delta = 0.0;
|
delta = 0;
|
||||||
if (chart.series.length == 0) return false;
|
if (chart.series.length == 0) return false;
|
||||||
if (list.length() + (is_cursor_active ? 1 : 0) != 2) return false;
|
if (list.length() + (is_cursor_active ? 1 : 0) != 2) return false;
|
||||||
if (chart.joint_x && cursor_style.orientation == Orientation.VERTICAL) {
|
if (chart.joint_x && cursor_style.orientation == Orientation.VERTICAL) {
|
||||||
|
@ -449,7 +449,7 @@ namespace CairoChart {
|
||||||
}
|
}
|
||||||
|
|
||||||
public string get_cursors_delta_str () {
|
public string get_cursors_delta_str () {
|
||||||
Float128 delta = 0.0;
|
Float128 delta = 0;
|
||||||
if (!get_cursors_delta(out delta)) return "";
|
if (!get_cursors_delta(out delta)) return "";
|
||||||
var str = "";
|
var str = "";
|
||||||
var s = chart.series[chart.zoom_1st_idx];
|
var s = chart.series[chart.zoom_1st_idx];
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace CairoChart {
|
||||||
/**
|
/**
|
||||||
* {@link Series} line length.
|
* {@link Series} line length.
|
||||||
*/
|
*/
|
||||||
public double line_length = 30.0;
|
public double line_length = 30;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show legend?
|
* Show legend?
|
||||||
|
@ -107,7 +107,7 @@ namespace CairoChart {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void draw_rect (out double x0, out double y0) {
|
protected virtual void draw_rect (out double x0, out double y0) {
|
||||||
x0 = y0 = 0.0;
|
x0 = y0 = 0;
|
||||||
if (chart.ctx != null) {
|
if (chart.ctx != null) {
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case Position.TOP:
|
case Position.TOP:
|
||||||
|
@ -156,13 +156,13 @@ namespace CairoChart {
|
||||||
var heights_idx = 0;
|
var heights_idx = 0;
|
||||||
var leg_width_sum = 0.0;
|
var leg_width_sum = 0.0;
|
||||||
var leg_height_sum = 0.0;
|
var leg_height_sum = 0.0;
|
||||||
double max_font_h = 0.0;
|
var max_font_h = 0.0;
|
||||||
|
|
||||||
// prepare
|
// prepare
|
||||||
switch (process_type) {
|
switch (process_type) {
|
||||||
case ProcessType.CALC:
|
case ProcessType.CALC:
|
||||||
width = 0.0;
|
width = 0;
|
||||||
height = 0.0;
|
height = 0;
|
||||||
max_font_heights = {};
|
max_font_heights = {};
|
||||||
heights_idx = 0;
|
heights_idx = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -191,7 +191,7 @@ namespace CairoChart {
|
||||||
heights_idx++;
|
heights_idx++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
leg_width_sum = 0.0;
|
leg_width_sum = 0;
|
||||||
max_font_h = 0;
|
max_font_h = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace CairoChart {
|
||||||
*/
|
*/
|
||||||
public Marker (Chart chart,
|
public Marker (Chart chart,
|
||||||
Shape shape = Shape.NONE,
|
Shape shape = Shape.NONE,
|
||||||
double size = 8.0
|
double size = 8
|
||||||
) {
|
) {
|
||||||
this.chart = chart;
|
this.chart = chart;
|
||||||
this.shape = shape;
|
this.shape = shape;
|
||||||
|
|
|
@ -3,9 +3,9 @@ namespace CairoChart {
|
||||||
namespace Math {
|
namespace Math {
|
||||||
|
|
||||||
internal Float128 calc_round_step (Float128 aver_step, bool date_time = false) {
|
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 *= 60;
|
if (date_time) while (step < aver_step) step *= 60;
|
||||||
if (date_time) while (step < aver_step) step *= 24;
|
if (date_time) while (step < aver_step) step *= 24;
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace CairoChart {
|
||||||
* @param x x-coordinate.
|
* @param x x-coordinate.
|
||||||
* @param y y-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;
|
this.x = x; this.y = y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ namespace CairoChart {
|
||||||
* @param x x-coordinate.
|
* @param x x-coordinate.
|
||||||
* @param y y-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;
|
this.x = x; this.y = y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace CairoChart {
|
||||||
|
|
||||||
public LineStyle line_style = LineStyle ();
|
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 {
|
public Color color {
|
||||||
get { return _color; }
|
get { return _color; }
|
||||||
set {
|
set {
|
||||||
|
@ -34,7 +34,7 @@ namespace CairoChart {
|
||||||
grid.style.color = _color;
|
grid.style.color = _color;
|
||||||
grid.style.color.alpha = 0.5;
|
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;
|
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) {
|
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;
|
max_rec_width = max_rec_height = 0;
|
||||||
for (var i = 0; i < axis.nrecords; ++i) {
|
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) {
|
switch (axis.dtype) {
|
||||||
case Axis.DType.NUMBERS:
|
case Axis.DType.NUMBERS:
|
||||||
var text = new Text (chart, axis.format.printf((LongDouble)x) + (horizontal ? "_" : ""), axis.font);
|
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 (!is_x) axis = s.axis_y;
|
||||||
if (!s.zoom_show) return;
|
if (!s.zoom_show) return;
|
||||||
if (nskip != 0) {--nskip; 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);
|
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_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;
|
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 (!has_intersection) {
|
||||||
if (calc_max_values) {
|
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);
|
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_width = double.max (max_rec_width, tmp_max_rec_width);
|
||||||
max_rec_height = double.max (max_rec_height, tmp_max_rec_height);
|
max_rec_height = double.max (max_rec_height, tmp_max_rec_height);
|
||||||
|
@ -263,7 +263,7 @@ namespace CairoChart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!has_intersection) {
|
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);
|
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_width = double.max (max_rec_width, tmp_max_rec_width);
|
||||||
max_rec_height = double.max (max_rec_height, tmp_max_rec_height);
|
max_rec_height = double.max (max_rec_height, tmp_max_rec_height);
|
||||||
|
@ -319,7 +319,7 @@ namespace CairoChart {
|
||||||
if (joint_x)
|
if (joint_x)
|
||||||
ctx.line_to (scr_x, chart.plarea.y0);
|
ctx.line_to (scr_x, chart.plarea.y0);
|
||||||
else
|
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;
|
break;
|
||||||
case Axis.Position.HIGH:
|
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);
|
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)
|
if (joint_x)
|
||||||
ctx.line_to (scr_x, chart.plarea.y1);
|
ctx.line_to (scr_x, chart.plarea.y1);
|
||||||
else
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -371,7 +371,7 @@ namespace CairoChart {
|
||||||
step = s.axis_x.range.zrange;
|
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).
|
// 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) {
|
if (step >= 1) {
|
||||||
int64 x_min_nsteps = (int64) (s.axis_x.range.zmin / step);
|
int64 x_min_nsteps = (int64) (s.axis_x.range.zmin / step);
|
||||||
x_min = x_min_nsteps * step;
|
x_min = x_min_nsteps * step;
|
||||||
|
@ -393,13 +393,13 @@ namespace CairoChart {
|
||||||
|
|
||||||
// 4.5. Draw Axis title
|
// 4.5. Draw Axis title
|
||||||
if (s.axis_x.title.text != "") {
|
if (s.axis_x.title.text != "") {
|
||||||
var scr_x = chart.plarea.x0 + chart.plarea.width * (s.place.zx0 + s.place.zx1) / 2.0;
|
var scr_x = chart.plarea.x0 + chart.plarea.width * (s.place.zx0 + s.place.zx1) / 2;
|
||||||
double scr_y = 0.0;
|
var scr_y = 0.0;
|
||||||
switch (s.axis_x.position) {
|
switch (s.axis_x.position) {
|
||||||
case Axis.Position.LOW: scr_y = chart.evarea.y1 - s.axis_x.font.vspacing; break;
|
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;
|
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;
|
chart.color = s.axis_x.color;
|
||||||
if (chart.joint_x) chart.color = chart.joint_color;
|
if (chart.joint_x) chart.color = chart.joint_color;
|
||||||
s.axis_x.title.show();
|
s.axis_x.title.show();
|
||||||
|
@ -409,7 +409,7 @@ namespace CairoChart {
|
||||||
|
|
||||||
chart.ctx.stroke ();
|
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);
|
s.join_relative_x_axes (si, false, ref tmp1, ref tmp2, ref tmp3, ref tmp4, ref nskip);
|
||||||
|
|
||||||
if (nskip != 0) {--nskip; return;}
|
if (nskip != 0) {--nskip; return;}
|
||||||
|
@ -487,7 +487,7 @@ namespace CairoChart {
|
||||||
step = s.axis_y.range.zrange;
|
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).
|
// 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) {
|
if (step >= 1) {
|
||||||
int64 y_min_nsteps = (int64) (s.axis_y.range.zmin / step);
|
int64 y_min_nsteps = (int64) (s.axis_y.range.zmin / step);
|
||||||
y_min = y_min_nsteps * step;
|
y_min = y_min_nsteps * step;
|
||||||
|
@ -509,15 +509,15 @@ namespace CairoChart {
|
||||||
|
|
||||||
// 4.5. Draw Axis title
|
// 4.5. Draw Axis title
|
||||||
if (s.axis_y.title.text != "") {
|
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) {
|
switch (s.axis_y.position) {
|
||||||
case Axis.Position.LOW:
|
case Axis.Position.LOW:
|
||||||
var scr_x = chart.evarea.x0 + s.axis_y.font.hspacing + axis_y.title.width;
|
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;
|
break;
|
||||||
case Axis.Position.HIGH:
|
case Axis.Position.HIGH:
|
||||||
var scr_x = chart.evarea.x1 - s.axis_y.font.hspacing;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
chart.color = s.axis_y.color;
|
chart.color = s.axis_y.color;
|
||||||
|
@ -529,7 +529,7 @@ namespace CairoChart {
|
||||||
|
|
||||||
chart.ctx.stroke ();
|
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);
|
s.join_relative_y_axes (si, false, ref tmp1, ref tmp2, ref tmp3, ref tmp4, ref nskip);
|
||||||
|
|
||||||
if (nskip != 0) {--nskip; return;}
|
if (nskip != 0) {--nskip; return;}
|
||||||
|
@ -542,13 +542,13 @@ namespace CairoChart {
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual double compact_rec_x_pos (Float128 x, Text text) {
|
public virtual double compact_rec_x_pos (Float128 x, Text text) {
|
||||||
return get_scr_x(x) - text.width / 2.0
|
return get_scr_x(x) - text.width / 2
|
||||||
- text.width * (x - (axis_x.range.zmin + axis_x.range.zmax) / 2.0) / axis_x.range.zrange;
|
- 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) {
|
public virtual double compact_rec_y_pos (Float128 y, Text text) {
|
||||||
return get_scr_y(y) + text.height / 2.0
|
return get_scr_y(y) + text.height / 2
|
||||||
+ text.height * (y - (axis_y.range.zmin + axis_y.range.zmax) / 2.0) / axis_y.range.zrange;
|
+ text.height * (y - (axis_y.range.zmin + axis_y.range.zmax) / 2) / axis_y.range.zrange;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual double get_scr_x (Float128 x) {
|
public virtual double get_scr_x (Float128 x) {
|
||||||
|
@ -556,7 +556,7 @@ namespace CairoChart {
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual double get_scr_y (Float128 y) {
|
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) {
|
public virtual Point get_scr_point (Point128 p) {
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace CairoChart {
|
||||||
switch (font.orient) {
|
switch (font.orient) {
|
||||||
case Gtk.Orientation.HORIZONTAL: return ext.width + ext.x_bearing;
|
case Gtk.Orientation.HORIZONTAL: return ext.width + ext.x_bearing;
|
||||||
case Gtk.Orientation.VERTICAL: return ext.height;
|
case Gtk.Orientation.VERTICAL: return ext.height;
|
||||||
default: return 0.0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected set {
|
protected set {
|
||||||
|
@ -83,7 +83,7 @@ namespace CairoChart {
|
||||||
switch (font.orient) {
|
switch (font.orient) {
|
||||||
case Gtk.Orientation.HORIZONTAL: return ext.height; // + ext.x_bearing ?
|
case Gtk.Orientation.HORIZONTAL: return ext.height; // + ext.x_bearing ?
|
||||||
case Gtk.Orientation.VERTICAL: return ext.width; // +- ext.y_bearing ?
|
case Gtk.Orientation.VERTICAL: return ext.width; // +- ext.y_bearing ?
|
||||||
default: return 0.0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected set {
|
protected set {
|
||||||
|
@ -99,9 +99,9 @@ namespace CairoChart {
|
||||||
font.weight);
|
font.weight);
|
||||||
chart.ctx.set_font_size(font.size);
|
chart.ctx.set_font_size(font.size);
|
||||||
if (font.orient == Gtk.Orientation.VERTICAL) {
|
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.show_text(text);
|
||||||
chart.ctx.rotate(GLib.Math.PI / 2.0);
|
chart.ctx.rotate(GLib.Math.PI / 2);
|
||||||
} else {
|
} else {
|
||||||
chart.ctx.show_text(text);
|
chart.ctx.show_text(text);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue