OK In progress...
This commit is contained in:
parent
a1709429fa
commit
4191423b91
212
src/Axis.vala
212
src/Axis.vala
|
@ -256,8 +256,8 @@ namespace CairoChart {
|
||||||
break;
|
break;
|
||||||
case Cursors.Orientation.HORIZONTAL:
|
case Cursors.Orientation.HORIZONTAL:
|
||||||
if (!is_x && chart.joint_y) {
|
if (!is_x && chart.joint_y) {
|
||||||
var tmp = max_rec_width + axis_y.font.hspacing;
|
var tmp = max_rec_width + font.hspacing;
|
||||||
switch (axis_y.position) {
|
switch (position) {
|
||||||
case Axis.Position.LOW: chart.plarea.x0 += tmp; break;
|
case Axis.Position.LOW: chart.plarea.x0 += tmp; break;
|
||||||
case Axis.Position.HIGH: chart.plarea.x1 -= tmp; break;
|
case Axis.Position.HIGH: chart.plarea.x1 -= tmp; break;
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ namespace CairoChart {
|
||||||
}
|
}
|
||||||
if (!is_x && (!chart.joint_y || si == chart.zoom_1st_idx)) {
|
if (!is_x && (!chart.joint_y || si == chart.zoom_1st_idx)) {
|
||||||
var tmp = max_rec_width + max_font_spacing + max_axis_font_width;
|
var tmp = max_rec_width + max_font_spacing + max_axis_font_width;
|
||||||
switch (axis_y.position) {
|
switch (position) {
|
||||||
case Axis.Position.LOW: chart.plarea.x0 += tmp; break;
|
case Axis.Position.LOW: chart.plarea.x0 += tmp; break;
|
||||||
case Axis.Position.HIGH: chart.plarea.x1 -= tmp; break;
|
case Axis.Position.HIGH: chart.plarea.x1 -= tmp; break;
|
||||||
}
|
}
|
||||||
|
@ -286,58 +286,58 @@ namespace CairoChart {
|
||||||
* @param nskip number of series to skip printing.
|
* @param nskip number of series to skip printing.
|
||||||
*/
|
*/
|
||||||
public virtual void draw_horizontal_axis (ref int nskip) {
|
public virtual void draw_horizontal_axis (ref int nskip) {
|
||||||
if (!zoom_show) return;
|
if (!ser.zoom_show) return;
|
||||||
|
|
||||||
var si = Math.find_arr<Series>(chart.series, this);
|
var si = Math.find_arr<Series>(chart.series, ser);
|
||||||
if (si == -1) return;
|
if (si == -1) return;
|
||||||
|
|
||||||
if (chart.joint_x && si != chart.zoom_1st_idx) return;
|
if (chart.joint_x && si != chart.zoom_1st_idx) return;
|
||||||
|
|
||||||
// 1. Detect max record width/height by axis.nrecords equally selected points using format.
|
// 1. Detect max record width/height by axis.nrecords equally selected points using format.
|
||||||
double max_rec_width, max_rec_height;
|
double max_rec_width, max_rec_height;
|
||||||
calc_rec_sizes (axis_x, out max_rec_width, out max_rec_height, true);
|
calc_rec_sizes (this, out max_rec_width, out max_rec_height, true);
|
||||||
|
|
||||||
// 2. Calculate maximal available number of records, take into account the space width.
|
// 2. Calculate maximal available number of records, take into account the space width.
|
||||||
long max_nrecs = (long) (chart.plarea.width * place.zwidth / max_rec_width);
|
long max_nrecs = (long) (chart.plarea.width * place.zrange / max_rec_width);
|
||||||
|
|
||||||
// 3. Calculate grid step.
|
// 3. Calculate grid step.
|
||||||
Float128 step = Math.calc_round_step (axis_x.range.zrange / max_nrecs, axis_x.dtype == Axis.DType.DATE_TIME);
|
Float128 step = Math.calc_round_step (range.zrange / max_nrecs, dtype == Axis.DType.DATE_TIME);
|
||||||
if (step > axis_x.range.zrange)
|
if (step > range.zrange)
|
||||||
step = axis_x.range.zrange;
|
step = range.zrange;
|
||||||
|
|
||||||
// 4. Calculate x_min (axis_x.range.zmin / step, round, multiply on step, add step if < axis_x.range.zmin).
|
// 4. Calculate x_min (range.zmin / step, round, multiply on step, add step if < range.zmin).
|
||||||
Float128 x_min = 0;
|
Float128 x_min = 0;
|
||||||
if (step >= 1) {
|
if (step >= 1) {
|
||||||
int64 x_min_nsteps = (int64) (axis_x.range.zmin / step);
|
int64 x_min_nsteps = (int64) (range.zmin / step);
|
||||||
x_min = x_min_nsteps * step;
|
x_min = x_min_nsteps * step;
|
||||||
} else {
|
} else {
|
||||||
int64 round_axis_x_min = (int64)axis_x.range.zmin;
|
int64 round_axis_x_min = (int64)range.zmin;
|
||||||
int64 x_min_nsteps = (int64) ((axis_x.range.zmin - round_axis_x_min) / step);
|
int64 x_min_nsteps = (int64) ((range.zmin - round_axis_x_min) / step);
|
||||||
x_min = round_axis_x_min + x_min_nsteps * step;
|
x_min = round_axis_x_min + x_min_nsteps * step;
|
||||||
}
|
}
|
||||||
if (x_min < axis_x.range.zmin) x_min += step;
|
if (x_min < range.zmin) x_min += step;
|
||||||
|
|
||||||
// 4.2. Cursor values for joint X axis
|
// 4.2. Cursor values for joint X axis
|
||||||
if (chart.joint_x && chart.cursors.style.orientation == Cursors.Orientation.VERTICAL && chart.cursors.has_crossings) {
|
if (chart.joint_x && chart.cursors.style.orientation == Cursors.Orientation.VERTICAL && chart.cursors.has_crossings) {
|
||||||
var tmp = max_rec_height + axis_x.font.vspacing;
|
var tmp = max_rec_height + font.vspacing;
|
||||||
switch (axis_x.position) {
|
switch (position) {
|
||||||
case Axis.Position.LOW: chart.evarea.y1 -= tmp; break;
|
case Axis.Position.LOW: chart.evarea.y1 -= tmp; break;
|
||||||
case Axis.Position.HIGH: chart.evarea.y0 += tmp; break;
|
case Axis.Position.HIGH: chart.evarea.y0 += tmp; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4.5. Draw Axis title
|
// 4.5. Draw Axis title
|
||||||
if (axis_x.title.text != "") {
|
if (title.text != "") {
|
||||||
var scr_x = chart.plarea.x0 + chart.plarea.width * (place.zx0 + place.zx1) / 2;
|
var scr_x = chart.plarea.x0 + chart.plarea.width * (place.zmin + place.zmax) / 2;
|
||||||
var scr_y = 0.0;
|
var scr_y = 0.0;
|
||||||
switch (axis_x.position) {
|
switch (position) {
|
||||||
case Axis.Position.LOW: scr_y = chart.evarea.y1 - axis_x.font.vspacing; break;
|
case Axis.Position.LOW: scr_y = chart.evarea.y1 - font.vspacing; break;
|
||||||
case Axis.Position.HIGH: scr_y = chart.evarea.y0 + axis_x.font.vspacing + axis_x.title.height; break;
|
case Axis.Position.HIGH: scr_y = chart.evarea.y0 + font.vspacing + title.height; break;
|
||||||
}
|
}
|
||||||
chart.ctx.move_to(scr_x - axis_x.title.width / 2, scr_y);
|
chart.ctx.move_to(scr_x - title.width / 2, scr_y);
|
||||||
chart.color = axis_x.color;
|
chart.color = color;
|
||||||
if (chart.joint_x) chart.color = chart.joint_color;
|
if (chart.joint_x) chart.color = chart.joint_color;
|
||||||
axis_x.title.show();
|
title.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_horizontal_records (step, max_rec_height, x_min);
|
draw_horizontal_records (step, max_rec_height, x_min);
|
||||||
|
@ -349,8 +349,8 @@ namespace CairoChart {
|
||||||
|
|
||||||
if (nskip != 0) {--nskip; return;}
|
if (nskip != 0) {--nskip; return;}
|
||||||
|
|
||||||
var tmp = max_rec_height + axis_x.font.vspacing + (axis_x.title.text == "" ? 0 : axis_x.title.height + axis_x.font.vspacing);
|
var tmp = max_rec_height + font.vspacing + (title.text == "" ? 0 : title.height + font.vspacing);
|
||||||
switch (axis_x.position) {
|
switch (position) {
|
||||||
case Axis.Position.LOW: chart.evarea.y1 -= tmp; break;
|
case Axis.Position.LOW: chart.evarea.y1 -= tmp; break;
|
||||||
case Axis.Position.HIGH: chart.evarea.y0 += tmp; break;
|
case Axis.Position.HIGH: chart.evarea.y0 += tmp; break;
|
||||||
}
|
}
|
||||||
|
@ -361,61 +361,61 @@ namespace CairoChart {
|
||||||
* @param nskip number of series to skip printing.
|
* @param nskip number of series to skip printing.
|
||||||
*/
|
*/
|
||||||
public virtual void draw_vertical_axis (ref int nskip) {
|
public virtual void draw_vertical_axis (ref int nskip) {
|
||||||
if (!zoom_show) return;
|
if (!ser.zoom_show) return;
|
||||||
|
|
||||||
var si = Math.find_arr<Series>(chart.series, this);
|
var si = Math.find_arr<Series>(chart.series, ser);
|
||||||
if (si == -1) return;
|
if (si == -1) return;
|
||||||
|
|
||||||
if (chart.joint_y && si != chart.zoom_1st_idx) return;
|
if (chart.joint_y && si != chart.zoom_1st_idx) return;
|
||||||
// 1. Detect max record width/height by axis.nrecords equally selected points using format.
|
// 1. Detect max record width/height by axis.nrecords equally selected points using format.
|
||||||
double max_rec_width, max_rec_height;
|
double max_rec_width, max_rec_height;
|
||||||
calc_rec_sizes (axis_y, out max_rec_width, out max_rec_height, false);
|
calc_rec_sizes (this, out max_rec_width, out max_rec_height, false);
|
||||||
|
|
||||||
// 2. Calculate maximal available number of records, take into account the space width.
|
// 2. Calculate maximal available number of records, take into account the space width.
|
||||||
long max_nrecs = (long) (chart.plarea.height * place.zheight / max_rec_height);
|
long max_nrecs = (long) (chart.plarea.height * place.zrange / max_rec_height);
|
||||||
|
|
||||||
// 3. Calculate grid step.
|
// 3. Calculate grid step.
|
||||||
Float128 step = Math.calc_round_step (axis_y.range.zrange / max_nrecs);
|
Float128 step = Math.calc_round_step (range.zrange / max_nrecs);
|
||||||
if (step > axis_y.range.zrange)
|
if (step > range.zrange)
|
||||||
step = axis_y.range.zrange;
|
step = range.zrange;
|
||||||
|
|
||||||
// 4. Calculate y_min (axis_y.range.zmin / step, round, multiply on step, add step if < axis_y.range.zmin).
|
// 4. Calculate y_min (range.zmin / step, round, multiply on step, add step if < range.zmin).
|
||||||
Float128 y_min = 0;
|
Float128 y_min = 0;
|
||||||
if (step >= 1) {
|
if (step >= 1) {
|
||||||
int64 y_min_nsteps = (int64) (axis_y.range.zmin / step);
|
int64 y_min_nsteps = (int64) (range.zmin / step);
|
||||||
y_min = y_min_nsteps * step;
|
y_min = y_min_nsteps * step;
|
||||||
} else {
|
} else {
|
||||||
int64 round_axis_y_min = (int64)axis_y.range.zmin;
|
int64 round_axis_y_min = (int64)range.zmin;
|
||||||
int64 y_min_nsteps = (int64) ((axis_y.range.zmin - round_axis_y_min) / step);
|
int64 y_min_nsteps = (int64) ((range.zmin - round_axis_y_min) / step);
|
||||||
y_min = round_axis_y_min + y_min_nsteps * step;
|
y_min = round_axis_y_min + y_min_nsteps * step;
|
||||||
}
|
}
|
||||||
if (y_min < axis_y.range.zmin) y_min += step;
|
if (y_min < range.zmin) y_min += step;
|
||||||
|
|
||||||
// 4.2. Cursor values for joint Y axis
|
// 4.2. Cursor values for joint Y axis
|
||||||
if (chart.joint_y && chart.cursors.style.orientation == Cursors.Orientation.HORIZONTAL && chart.cursors.has_crossings) {
|
if (chart.joint_y && chart.cursors.style.orientation == Cursors.Orientation.HORIZONTAL && chart.cursors.has_crossings) {
|
||||||
var tmp = max_rec_width + axis_y.font.hspacing;
|
var tmp = max_rec_width + font.hspacing;
|
||||||
switch (axis_y.position) {
|
switch (position) {
|
||||||
case Axis.Position.LOW: chart.evarea.x0 += tmp; break;
|
case Axis.Position.LOW: chart.evarea.x0 += tmp; break;
|
||||||
case Axis.Position.HIGH: chart.evarea.x1 -= tmp; break;
|
case Axis.Position.HIGH: chart.evarea.x1 -= tmp; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4.5. Draw Axis title
|
// 4.5. Draw Axis title
|
||||||
if (axis_y.title.text != "") {
|
if (title.text != "") {
|
||||||
var scr_y = chart.plarea.y0 + chart.plarea.height * (1 - (place.zy0 + place.zy1) / 2);
|
var scr_y = chart.plarea.y0 + chart.plarea.height * (1 - (place.zmin + place.zmax) / 2);
|
||||||
switch (axis_y.position) {
|
switch (position) {
|
||||||
case Axis.Position.LOW:
|
case Axis.Position.LOW:
|
||||||
var scr_x = chart.evarea.x0 + axis_y.font.hspacing + axis_y.title.width;
|
var scr_x = chart.evarea.x0 + font.hspacing + title.width;
|
||||||
chart.ctx.move_to(scr_x, scr_y + axis_y.title.height / 2);
|
chart.ctx.move_to(scr_x, scr_y + title.height / 2);
|
||||||
break;
|
break;
|
||||||
case Axis.Position.HIGH:
|
case Axis.Position.HIGH:
|
||||||
var scr_x = chart.evarea.x1 - axis_y.font.hspacing;
|
var scr_x = chart.evarea.x1 - font.hspacing;
|
||||||
chart.ctx.move_to(scr_x, scr_y + axis_y.title.height / 2);
|
chart.ctx.move_to(scr_x, scr_y + title.height / 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
chart.color = axis_y.color;
|
chart.color = color;
|
||||||
if (chart.joint_y) chart.color = chart.joint_color;
|
if (chart.joint_y) chart.color = chart.joint_color;
|
||||||
axis_y.title.show();
|
title.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_vertical_records (step, max_rec_width, y_min);
|
draw_vertical_records (step, max_rec_width, y_min);
|
||||||
|
@ -427,8 +427,8 @@ namespace CairoChart {
|
||||||
|
|
||||||
if (nskip != 0) {--nskip; return;}
|
if (nskip != 0) {--nskip; return;}
|
||||||
|
|
||||||
var tmp = max_rec_width + axis_y.font.hspacing + (axis_y.title.text == "" ? 0 : axis_y.title.width + axis_y.font.hspacing);
|
var tmp = max_rec_width + font.hspacing + (title.text == "" ? 0 : title.width + font.hspacing);
|
||||||
switch (axis_y.position) {
|
switch (position) {
|
||||||
case Axis.Position.LOW: chart.evarea.x0 += tmp; break;
|
case Axis.Position.LOW: chart.evarea.x0 += tmp; break;
|
||||||
case Axis.Position.HIGH: chart.evarea.x1 -= tmp; break;
|
case Axis.Position.HIGH: chart.evarea.x1 -= tmp; break;
|
||||||
}
|
}
|
||||||
|
@ -441,7 +441,7 @@ 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
|
return get_scr_x(x) - text.width / 2
|
||||||
- text.width * (x - (axis_x.range.zmin + axis_x.range.zmax) / 2) / axis_x.range.zrange;
|
- text.width * (x - (range.zmin + range.zmax) / 2) / range.zrange;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -451,7 +451,7 @@ namespace CairoChart {
|
||||||
*/
|
*/
|
||||||
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
|
return get_scr_y(y) + text.height / 2
|
||||||
+ text.height * (y - (axis_y.range.zmin + axis_y.range.zmax) / 2) / axis_y.range.zrange;
|
+ text.height * (y - (range.zmin + range.zmax) / 2) / range.zrange;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -459,7 +459,7 @@ namespace CairoChart {
|
||||||
* @param x real ``Series`` X-value.
|
* @param x real ``Series`` X-value.
|
||||||
*/
|
*/
|
||||||
public virtual double get_scr_x (Float128 x) {
|
public virtual double get_scr_x (Float128 x) {
|
||||||
return chart.plarea.x0 + chart.plarea.width * (place.zx0 + (x - axis_x.range.zmin) / axis_x.range.zrange * place.zwidth);
|
return chart.plarea.x0 + chart.plarea.width * (place.zmin + (x - range.zmin) / range.zrange * place.zrange);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -467,7 +467,7 @@ namespace CairoChart {
|
||||||
* @param y real ``Series`` Y-value.
|
* @param y real ``Series`` Y-value.
|
||||||
*/
|
*/
|
||||||
public virtual double get_scr_y (Float128 y) {
|
public virtual double get_scr_y (Float128 y) {
|
||||||
return chart.plarea.y0 + chart.plarea.height * (1 - (place.zy0 + (y - axis_y.range.zmin) / axis_y.range.zrange * place.zheight));
|
return chart.plarea.y0 + chart.plarea.height * (1 - (place.zmin + (y - range.zmin) / range.zrange * place.zrange));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -475,7 +475,7 @@ namespace CairoChart {
|
||||||
* @param scr_x screen X-position.
|
* @param scr_x screen X-position.
|
||||||
*/
|
*/
|
||||||
public virtual Float128 get_real_x (double scr_x) {
|
public virtual Float128 get_real_x (double scr_x) {
|
||||||
return axis_x.range.zmin + ((scr_x - chart.plarea.x0) / chart.plarea.width - place.zx0) * axis_x.range.zrange / place.zwidth;
|
return range.zmin + ((scr_x - chart.plarea.x0) / chart.plarea.width - place.zmin) * range.zrange / place.zrange;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -483,7 +483,7 @@ namespace CairoChart {
|
||||||
* @param scr_y screen Y-position.
|
* @param scr_y screen Y-position.
|
||||||
*/
|
*/
|
||||||
public virtual Float128 get_real_y (double scr_y) {
|
public virtual Float128 get_real_y (double scr_y) {
|
||||||
return axis_y.range.zmin + ((chart.plarea.y1 - scr_y) / chart.plarea.height - place.zy0) * axis_y.range.zrange / place.zheight;
|
return range.zmin + ((chart.plarea.y1 - scr_y) / chart.plarea.height - place.zmin) * range.zrange / place.zrange;
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -531,7 +531,7 @@ namespace CairoChart {
|
||||||
for (int sk = si; sk > sj; --sk) {
|
for (int sk = si; sk > sj; --sk) {
|
||||||
var s3 = chart.series[sk];
|
var s3 = chart.series[sk];
|
||||||
if (!s3.zoom_show) continue;
|
if (!s3.zoom_show) continue;
|
||||||
if (Math.coord_cross(s2.place.zx0, s2.place.zx1, s3.place.zx0, s3.place.zx1)
|
if (Math.coord_cross(s2.axis_x.place.zmin, s2.axis_x.place.zmax, s3.axis_x.place.zmin, s3.axis_x.place.zmax)
|
||||||
|| s2.axis_x.position != s3.axis_x.position
|
|| s2.axis_x.position != s3.axis_x.position
|
||||||
|| s2.axis_x.dtype != s3.axis_x.dtype) {
|
|| s2.axis_x.dtype != s3.axis_x.dtype) {
|
||||||
has_intersection = true;
|
has_intersection = true;
|
||||||
|
@ -546,7 +546,7 @@ namespace CairoChart {
|
||||||
max_rec_height = double.max (max_rec_height, tmp_max_rec_height);
|
max_rec_height = double.max (max_rec_height, tmp_max_rec_height);
|
||||||
max_font_spacing = double.max (max_font_spacing, s2.axis_x.font.vspacing);
|
max_font_spacing = double.max (max_font_spacing, s2.axis_x.font.vspacing);
|
||||||
max_axis_font_height = double.max (max_axis_font_height, s2.axis_x.title.text == "" ? 0 :
|
max_axis_font_height = double.max (max_axis_font_height, s2.axis_x.title.text == "" ? 0 :
|
||||||
s2.axis_x.title.height + this.axis_x.font.vspacing);
|
s2.axis_x.title.height + font.vspacing);
|
||||||
}
|
}
|
||||||
++nskip;
|
++nskip;
|
||||||
} else {
|
} else {
|
||||||
|
@ -569,7 +569,7 @@ namespace CairoChart {
|
||||||
for (int sk = si; sk > sj; --sk) {
|
for (int sk = si; sk > sj; --sk) {
|
||||||
var s3 = chart.series[sk];
|
var s3 = chart.series[sk];
|
||||||
if (!s3.zoom_show) continue;
|
if (!s3.zoom_show) continue;
|
||||||
if (Math.coord_cross(s2.place.zy0, s2.place.zy1, s3.place.zy0, s3.place.zy1)
|
if (Math.coord_cross(s2.axis_y.place.zmin, s2.axis_y.place.zmax, s3.axis_y.place.zmin, s3.axis_y.place.zmax)
|
||||||
|| s2.axis_y.position != s3.axis_y.position
|
|| s2.axis_y.position != s3.axis_y.position
|
||||||
|| s2.axis_y.dtype != s3.axis_y.dtype) {
|
|| s2.axis_y.dtype != s3.axis_y.dtype) {
|
||||||
has_intersection = true;
|
has_intersection = true;
|
||||||
|
@ -583,7 +583,7 @@ namespace CairoChart {
|
||||||
max_rec_height = double.max (max_rec_height, tmp_max_rec_height);
|
max_rec_height = double.max (max_rec_height, tmp_max_rec_height);
|
||||||
max_font_spacing = double.max (max_font_spacing, s2.axis_y.font.hspacing);
|
max_font_spacing = double.max (max_font_spacing, s2.axis_y.font.hspacing);
|
||||||
max_axis_font_width = double.max (max_axis_font_width, s2.axis_y.title.text == "" ? 0
|
max_axis_font_width = double.max (max_axis_font_width, s2.axis_y.title.text == "" ? 0
|
||||||
: s2.axis_y.title.width + this.axis_y.font.hspacing);
|
: s2.axis_y.title.width + font.hspacing);
|
||||||
++nskip;
|
++nskip;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
@ -596,72 +596,72 @@ namespace CairoChart {
|
||||||
var ctx = chart.ctx;
|
var ctx = chart.ctx;
|
||||||
var joint_x = chart.joint_x;
|
var joint_x = chart.joint_x;
|
||||||
|
|
||||||
for (Float128 x = x_min, x_max = axis_x.range.zmax; Math.point_belong (x, x_min, x_max); x += step) {
|
for (Float128 x = x_min, x_max = range.zmax; Math.point_belong (x, x_min, x_max); x += step) {
|
||||||
if (joint_x) chart.color = chart.joint_color;
|
if (joint_x) chart.color = chart.joint_color;
|
||||||
else chart.color = axis_x.color;
|
else chart.color = color;
|
||||||
string text = "", time_text = "";
|
string text = "", time_text = "";
|
||||||
switch (axis_x.dtype) {
|
switch (dtype) {
|
||||||
case Axis.DType.NUMBERS: text = axis_x.format.printf((LongDouble)x); break;
|
case Axis.DType.NUMBERS: text = format.printf((LongDouble)x); break;
|
||||||
case Axis.DType.DATE_TIME: axis_x.print_dt(x, out text, out time_text); break;
|
case Axis.DType.DATE_TIME: print_dt(x, out text, out time_text); break;
|
||||||
}
|
}
|
||||||
var scr_x = get_scr_x (x);
|
var scr_x = get_scr_x (x);
|
||||||
var text_t = new Text(chart, text, axis_x.font, axis_x.color);
|
var text_t = new Text(chart, text, font, color);
|
||||||
|
|
||||||
switch (axis_x.position) {
|
switch (position) {
|
||||||
case Axis.Position.LOW:
|
case Axis.Position.LOW:
|
||||||
var print_y = chart.evarea.y1 - axis_x.font.vspacing - (axis_x.title.text == "" ? 0 : axis_x.title.height + axis_x.font.vspacing);
|
var print_y = chart.evarea.y1 - font.vspacing - (title.text == "" ? 0 : title.height + font.vspacing);
|
||||||
var print_x = compact_rec_x_pos (x, text_t);
|
var print_x = compact_rec_x_pos (x, text_t);
|
||||||
ctx.move_to (print_x, print_y);
|
ctx.move_to (print_x, print_y);
|
||||||
switch (axis_x.dtype) {
|
switch (dtype) {
|
||||||
case Axis.DType.NUMBERS:
|
case Axis.DType.NUMBERS:
|
||||||
text_t.show();
|
text_t.show();
|
||||||
break;
|
break;
|
||||||
case Axis.DType.DATE_TIME:
|
case Axis.DType.DATE_TIME:
|
||||||
if (axis_x.date_format != "") text_t.show();
|
if (date_format != "") text_t.show();
|
||||||
var time_text_t = new Text(chart, time_text, axis_x.font, axis_x.color);
|
var time_text_t = new Text(chart, time_text, font, color);
|
||||||
print_x = compact_rec_x_pos (x, time_text_t);
|
print_x = compact_rec_x_pos (x, time_text_t);
|
||||||
ctx.move_to (print_x, print_y - (axis_x.date_format == "" ? 0 : text_t.height + axis_x.font.vspacing));
|
ctx.move_to (print_x, print_y - (date_format == "" ? 0 : text_t.height + font.vspacing));
|
||||||
if (axis_x.time_format != "") time_text_t.show();
|
if (time_format != "") time_text_t.show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// 6. Draw grid lines to the place.zy0.
|
// 6. Draw grid lines to the ser.axis_y.place.zmin.
|
||||||
var grid_style = grid.style;
|
var grid_style = ser.grid.style;
|
||||||
if (joint_x) grid_style.color = Color(0, 0, 0, 0.5);
|
if (joint_x) grid_style.color = Color(0, 0, 0, 0.5);
|
||||||
grid_style.apply(chart);
|
grid_style.apply(chart);
|
||||||
double y = chart.evarea.y1 - max_rec_height - axis_x.font.vspacing - (axis_x.title.text == "" ? 0 : axis_x.title.height + axis_x.font.vspacing);
|
double y = chart.evarea.y1 - max_rec_height - font.vspacing - (title.text == "" ? 0 : title.height + font.vspacing);
|
||||||
ctx.move_to (scr_x, y);
|
ctx.move_to (scr_x, y);
|
||||||
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 - place.zy1)));
|
ctx.line_to (scr_x, double.min (y, chart.plarea.y0 + chart.plarea.height * (1 - ser.axis_y.place.zmax)));
|
||||||
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 + font.vspacing + (title.text == "" ? 0 : title.height + font.vspacing);
|
||||||
var print_x = compact_rec_x_pos (x, text_t);
|
var print_x = compact_rec_x_pos (x, text_t);
|
||||||
ctx.move_to (print_x, print_y);
|
ctx.move_to (print_x, print_y);
|
||||||
|
|
||||||
switch (axis_x.dtype) {
|
switch (dtype) {
|
||||||
case Axis.DType.NUMBERS:
|
case Axis.DType.NUMBERS:
|
||||||
text_t.show();
|
text_t.show();
|
||||||
break;
|
break;
|
||||||
case Axis.DType.DATE_TIME:
|
case Axis.DType.DATE_TIME:
|
||||||
if (axis_x.date_format != "") text_t.show();
|
if (date_format != "") text_t.show();
|
||||||
var time_text_t = new Text(chart, time_text, axis_x.font, axis_x.color);
|
var time_text_t = new Text(chart, time_text, font, color);
|
||||||
print_x = compact_rec_x_pos (x, time_text_t);
|
print_x = compact_rec_x_pos (x, time_text_t);
|
||||||
ctx.move_to (print_x, print_y - (axis_x.date_format == "" ? 0 : text_t.height + axis_x.font.vspacing));
|
ctx.move_to (print_x, print_y - (date_format == "" ? 0 : text_t.height + font.vspacing));
|
||||||
if (axis_x.time_format != "") time_text_t.show();
|
if (time_format != "") time_text_t.show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// 6. Draw grid lines to the place.zy1.
|
// 6. Draw grid lines to the ser.axis_y.place.zmax.
|
||||||
var grid_style = grid.style;
|
var grid_style = ser.grid.style;
|
||||||
if (joint_x) grid_style.color = Color(0, 0, 0, 0.5);
|
if (joint_x) grid_style.color = Color(0, 0, 0, 0.5);
|
||||||
grid_style.apply(chart);
|
grid_style.apply(chart);
|
||||||
double y = chart.evarea.y0 + max_rec_height + axis_x.font.vspacing + (axis_x.title.text == "" ? 0 : axis_x.title.height + axis_x.font.vspacing);
|
double y = chart.evarea.y0 + max_rec_height + font.vspacing + (title.text == "" ? 0 : title.height + font.vspacing);
|
||||||
ctx.move_to (scr_x, y);
|
ctx.move_to (scr_x, y);
|
||||||
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 - place.zy0)));
|
ctx.line_to (scr_x, double.max (y, chart.plarea.y0 + chart.plarea.height * (1 - ser.axis_y.place.zmin)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -672,45 +672,45 @@ namespace CairoChart {
|
||||||
var ctx = chart.ctx;
|
var ctx = chart.ctx;
|
||||||
var joint_y = chart.joint_y;
|
var joint_y = chart.joint_y;
|
||||||
|
|
||||||
for (Float128 y = y_min, y_max = axis_y.range.zmax; Math.point_belong (y, y_min, y_max); y += step) {
|
for (Float128 y = y_min, y_max = range.zmax; Math.point_belong (y, y_min, y_max); y += step) {
|
||||||
if (joint_y) chart.color = chart.joint_color;
|
if (joint_y) chart.color = chart.joint_color;
|
||||||
else chart.color = axis_y.color;
|
else chart.color = color;
|
||||||
var text = axis_y.format.printf((LongDouble)y);
|
var text = format.printf((LongDouble)y);
|
||||||
var scr_y = get_scr_y (y);
|
var scr_y = get_scr_y (y);
|
||||||
var text_t = new Text(chart, text, axis_y.font, axis_y.color);
|
var text_t = new Text(chart, text, font, color);
|
||||||
|
|
||||||
switch (axis_y.position) {
|
switch (position) {
|
||||||
case Axis.Position.LOW:
|
case Axis.Position.LOW:
|
||||||
ctx.move_to (chart.evarea.x0 + max_rec_width - text_t.width + axis_y.font.hspacing
|
ctx.move_to (chart.evarea.x0 + max_rec_width - text_t.width + font.hspacing
|
||||||
+ (axis_y.title.text == "" ? 0 : axis_y.title.width + axis_y.font.hspacing),
|
+ (title.text == "" ? 0 : title.width + font.hspacing),
|
||||||
compact_rec_y_pos (y, text_t));
|
compact_rec_y_pos (y, text_t));
|
||||||
text_t.show();
|
text_t.show();
|
||||||
// 6. Draw grid lines to the place.zx0.
|
// 6. Draw grid lines to the ser.axis_x.place.zmin.
|
||||||
var grid_style = grid.style;
|
var grid_style = ser.grid.style;
|
||||||
if (joint_y) grid_style.color = Color(0, 0, 0, 0.5);
|
if (joint_y) grid_style.color = Color(0, 0, 0, 0.5);
|
||||||
grid_style.apply(chart);
|
grid_style.apply(chart);
|
||||||
double x = chart.evarea.x0 + max_rec_width + axis_y.font.hspacing + (axis_y.title.text == "" ? 0 : axis_y.title.width + axis_y.font.hspacing);
|
double x = chart.evarea.x0 + max_rec_width + font.hspacing + (title.text == "" ? 0 : title.width + font.hspacing);
|
||||||
ctx.move_to (x, scr_y);
|
ctx.move_to (x, scr_y);
|
||||||
if (joint_y)
|
if (joint_y)
|
||||||
ctx.line_to (chart.plarea.x1, scr_y);
|
ctx.line_to (chart.plarea.x1, scr_y);
|
||||||
else
|
else
|
||||||
ctx.line_to (double.max (x, chart.plarea.x0 + chart.plarea.width * place.zx1), scr_y);
|
ctx.line_to (double.max (x, chart.plarea.x0 + chart.plarea.width * ser.axis_x.place.zmax), scr_y);
|
||||||
break;
|
break;
|
||||||
case Axis.Position.HIGH:
|
case Axis.Position.HIGH:
|
||||||
ctx.move_to (chart.evarea.x1 - text_t.width - axis_y.font.hspacing
|
ctx.move_to (chart.evarea.x1 - text_t.width - font.hspacing
|
||||||
- (axis_y.title.text == "" ? 0 : axis_y.title.width + axis_y.font.hspacing),
|
- (title.text == "" ? 0 : title.width + font.hspacing),
|
||||||
compact_rec_y_pos (y, text_t));
|
compact_rec_y_pos (y, text_t));
|
||||||
text_t.show();
|
text_t.show();
|
||||||
// 6. Draw grid lines to the place.zx1.
|
// 6. Draw grid lines to the ser.axis_x.place.zmax.
|
||||||
var grid_style = grid.style;
|
var grid_style = ser.grid.style;
|
||||||
if (joint_y) grid_style.color = Color(0, 0, 0, 0.5);
|
if (joint_y) grid_style.color = Color(0, 0, 0, 0.5);
|
||||||
grid_style.apply(chart);
|
grid_style.apply(chart);
|
||||||
double x = chart.evarea.x1 - max_rec_width - axis_y.font.hspacing - (axis_y.title.text == "" ? 0 : axis_y.title.width + axis_y.font.hspacing);
|
double x = chart.evarea.x1 - max_rec_width - font.hspacing - (title.text == "" ? 0 : title.width + font.hspacing);
|
||||||
ctx.move_to (x, scr_y);
|
ctx.move_to (x, scr_y);
|
||||||
if (joint_y)
|
if (joint_y)
|
||||||
ctx.line_to (chart.plarea.x0, scr_y);
|
ctx.line_to (chart.plarea.x0, scr_y);
|
||||||
else
|
else
|
||||||
ctx.line_to (double.min (x, chart.plarea.x0 + chart.plarea.width * place.zx0), scr_y);
|
ctx.line_to (double.min (x, chart.plarea.x0 + chart.plarea.width * ser.axis_x.place.zmin), scr_y);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,11 +191,11 @@ namespace CairoChart {
|
||||||
public virtual void zoom_in (Area area) {
|
public virtual void zoom_in (Area area) {
|
||||||
foreach (var s in series) {
|
foreach (var s in series) {
|
||||||
if (!s.zoom_show) continue;
|
if (!s.zoom_show) continue;
|
||||||
var real_x0 = s.get_real_x (area.x0);
|
var real_x0 = s.axis_x.get_real_x (area.x0);
|
||||||
var real_x1 = s.get_real_x (area.x1);
|
var real_x1 = s.axis_x.get_real_x (area.x1);
|
||||||
var real_width = real_x1 - real_x0;
|
var real_width = real_x1 - real_x0;
|
||||||
var real_y0 = s.get_real_y (area.y0);
|
var real_y0 = s.axis_y.get_real_y (area.y0);
|
||||||
var real_y1 = s.get_real_y (area.y1);
|
var real_y1 = s.axis_y.get_real_y (area.y1);
|
||||||
var real_height = real_y0 - real_y1;
|
var real_height = real_y0 - real_y1;
|
||||||
// if selected square does not intersect with the series's square
|
// if selected square does not intersect with the series's square
|
||||||
if ( real_x1 <= s.axis_x.range.zmin || real_x0 >= s.axis_x.range.zmax
|
if ( real_x1 <= s.axis_x.range.zmin || real_x0 >= s.axis_x.range.zmax
|
||||||
|
@ -205,27 +205,27 @@ 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;
|
s.axis_x.place.zmin = 0;
|
||||||
} else {
|
} else {
|
||||||
s.place.zx0 = (s.axis_x.range.zmin - real_x0) / real_width;
|
s.axis_x.place.zmin = (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;
|
s.axis_x.place.zmax = 1;
|
||||||
} else {
|
} else {
|
||||||
s.place.zx1 = (s.axis_x.range.zmax - real_x0) / real_width;
|
s.axis_x.place.zmax = (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;
|
s.axis_y.place.zmin = 0;
|
||||||
} else {
|
} else {
|
||||||
s.place.zy0 = (s.axis_y.range.zmin - real_y1) / real_height;
|
s.axis_y.place.zmin = (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;
|
s.axis_y.place.zmax = 1;
|
||||||
} else {
|
} else {
|
||||||
s.place.zy1 = (s.axis_y.range.zmax - real_y1) / real_height;
|
s.axis_y.place.zmax = (s.axis_y.range.zmax - real_y1) / real_height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,8 +311,8 @@ namespace CairoChart {
|
||||||
if ( s1.axis_x.position != s2.axis_x.position
|
if ( s1.axis_x.position != s2.axis_x.position
|
||||||
|| s1.axis_x.range.zmin != s2.axis_x.range.zmin
|
|| s1.axis_x.range.zmin != s2.axis_x.range.zmin
|
||||||
|| s1.axis_x.range.zmax != s2.axis_x.range.zmax
|
|| s1.axis_x.range.zmax != s2.axis_x.range.zmax
|
||||||
|| s1.place.zx0 != s2.place.zx0
|
|| s1.axis_x.place.zmin != s2.axis_x.place.zmin
|
||||||
|| s1.place.zx1 != s2.place.zx1
|
|| s1.axis_x.place.zmax != s2.axis_x.place.zmax
|
||||||
|| s1.axis_x.dtype != s2.axis_x.dtype
|
|| s1.axis_x.dtype != s2.axis_x.dtype
|
||||||
)
|
)
|
||||||
return false;
|
return false;
|
||||||
|
@ -323,8 +323,8 @@ namespace CairoChart {
|
||||||
if ( s1.axis_y.position != s2.axis_y.position
|
if ( s1.axis_y.position != s2.axis_y.position
|
||||||
|| s1.axis_y.range.zmin != s2.axis_y.range.zmin
|
|| s1.axis_y.range.zmin != s2.axis_y.range.zmin
|
||||||
|| s1.axis_y.range.zmax != s2.axis_y.range.zmax
|
|| s1.axis_y.range.zmax != s2.axis_y.range.zmax
|
||||||
|| s1.place.zy0 != s2.place.zy0
|
|| s1.axis_y.place.zmin != s2.axis_y.place.zmin
|
||||||
|| s1.place.zy1 != s2.place.zy1
|
|| s1.axis_y.place.zmax != s2.axis_y.place.zmax
|
||||||
|| s1.axis_y.dtype != s2.axis_y.dtype
|
|| s1.axis_y.dtype != s2.axis_y.dtype
|
||||||
)
|
)
|
||||||
return false;
|
return false;
|
||||||
|
@ -353,10 +353,10 @@ namespace CairoChart {
|
||||||
if (nshow == 1) joint_x = joint_y = false;
|
if (nshow == 1) joint_x = joint_y = false;
|
||||||
|
|
||||||
for (var si = series.length - 1, nskip = 0; si >= 0; --si)
|
for (var si = series.length - 1, nskip = 0; si >= 0; --si)
|
||||||
series[si].join_axes(true, ref nskip);
|
series[si].axis_x.join_axes(true, ref nskip);
|
||||||
|
|
||||||
for (var si = series.length - 1, nskip = 0; si >= 0; --si)
|
for (var si = series.length - 1, nskip = 0; si >= 0; --si)
|
||||||
series[si].join_axes(false, ref nskip);
|
series[si].axis_y.join_axes(false, ref nskip);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void draw_plarea_border () {
|
protected virtual void draw_plarea_border () {
|
||||||
|
@ -374,11 +374,11 @@ namespace CairoChart {
|
||||||
}
|
}
|
||||||
protected virtual void draw_haxes () {
|
protected virtual void draw_haxes () {
|
||||||
for (var si = series.length - 1, nskip = 0; si >=0; --si)
|
for (var si = series.length - 1, nskip = 0; si >=0; --si)
|
||||||
series[si].draw_horizontal_axis (ref nskip);
|
series[si].axis_x.draw_horizontal_axis (ref nskip);
|
||||||
}
|
}
|
||||||
protected virtual void draw_vaxes () {
|
protected virtual void draw_vaxes () {
|
||||||
for (var si = series.length - 1, nskip = 0; si >=0; --si)
|
for (var si = series.length - 1, nskip = 0; si >=0; --si)
|
||||||
series[si].draw_vertical_axis (ref nskip);
|
series[si].axis_y.draw_vertical_axis (ref nskip);
|
||||||
}
|
}
|
||||||
protected virtual void draw_series () {
|
protected virtual void draw_series () {
|
||||||
foreach (var s in series)
|
foreach (var s in series)
|
||||||
|
|
|
@ -158,7 +158,7 @@ namespace CairoChart {
|
||||||
Float128 y = 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.axis_x.get_real_x(rel2scr_x(c.x)), s.axis_y.get_real_y(y));
|
||||||
Point128 size; bool show_x, show_date, show_time, show_y;
|
Point128 size; bool show_x, show_date, show_time, show_y;
|
||||||
cross_what_to_show(s, out show_x, out show_time, out show_date, out show_y);
|
cross_what_to_show(s, out show_x, out show_time, out show_date, out show_y);
|
||||||
calc_cross_sizes (s, point, out size, show_x, show_time, show_date, show_y);
|
calc_cross_sizes (s, point, out size, show_x, show_time, show_date, show_y);
|
||||||
|
@ -170,7 +170,7 @@ namespace CairoChart {
|
||||||
Float128 x = 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.axis_x.get_real_x(x), s.axis_y.get_real_y(rel2scr_y(c.y)));
|
||||||
Point128 size; bool show_x, show_date, show_time, show_y;
|
Point128 size; bool show_x, show_date, show_time, show_y;
|
||||||
cross_what_to_show(s, out show_x, out show_time, out show_date, out show_y);
|
cross_what_to_show(s, out show_x, out show_time, out show_date, out show_y);
|
||||||
calc_cross_sizes (s, point, out size, show_x, show_time, show_date, show_y);
|
calc_cross_sizes (s, point, out size, show_x, show_time, show_date, show_y);
|
||||||
|
@ -207,12 +207,11 @@ namespace CairoChart {
|
||||||
var si = ccs[ci].series_index;
|
var si = ccs[ci].series_index;
|
||||||
var s = chart.series[si];
|
var s = chart.series[si];
|
||||||
var p = ccs[ci].point;
|
var p = ccs[ci].point;
|
||||||
var scrx = s.get_scr_x(p.x);
|
var scrp = s.get_scr_point(p);
|
||||||
var scry = s.get_scr_y(p.y);
|
if (scrp.x < low.x) low.x = scrp.x;
|
||||||
if (scrx < low.x) low.x = scrx;
|
if (scrp.y < low.y) low.y = scrp.y;
|
||||||
if (scry < low.y) low.y = scry;
|
if (scrp.x > high.x) high.x = scrp.x;
|
||||||
if (scrx > high.x) high.x = scrx;
|
if (scrp.y > high.y) high.y = scrp.y;
|
||||||
if (scry > high.y) high.y = scry;
|
|
||||||
|
|
||||||
if (chart.joint_x) {
|
if (chart.joint_x) {
|
||||||
switch (s.axis_x.position) {
|
switch (s.axis_x.position) {
|
||||||
|
@ -250,7 +249,7 @@ namespace CairoChart {
|
||||||
// show joint X value
|
// show joint X value
|
||||||
if (chart.joint_x) {
|
if (chart.joint_x) {
|
||||||
var s = chart.series[chart.zoom_1st_idx];
|
var s = chart.series[chart.zoom_1st_idx];
|
||||||
var x = s.get_real_x(rel2scr_x(c.x));
|
var x = s.axis_x.get_real_x(rel2scr_x(c.x));
|
||||||
string text = "", time_text = "";
|
string text = "", time_text = "";
|
||||||
switch (s.axis_x.dtype) {
|
switch (s.axis_x.dtype) {
|
||||||
case Axis.DType.NUMBERS: text = s.axis_x.format.printf((LongDouble)x); break;
|
case Axis.DType.NUMBERS: text = s.axis_x.format.printf((LongDouble)x); break;
|
||||||
|
@ -280,7 +279,7 @@ namespace CairoChart {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
var print_x = s.compact_rec_x_pos (x, text_t);
|
var print_x = s.axis_x.compact_rec_x_pos (x, text_t);
|
||||||
chart.ctx.move_to (print_x, print_y);
|
chart.ctx.move_to (print_x, print_y);
|
||||||
|
|
||||||
switch (s.axis_x.dtype) {
|
switch (s.axis_x.dtype) {
|
||||||
|
@ -289,7 +288,7 @@ namespace CairoChart {
|
||||||
break;
|
break;
|
||||||
case Axis.DType.DATE_TIME:
|
case Axis.DType.DATE_TIME:
|
||||||
if (s.axis_x.date_format != "") text_t.show();
|
if (s.axis_x.date_format != "") text_t.show();
|
||||||
print_x = s.compact_rec_x_pos (x, time_text_t);
|
print_x = s.axis_x.compact_rec_x_pos (x, time_text_t);
|
||||||
chart.ctx.move_to (print_x, print_y - (s.axis_x.date_format == "" ? 0 : text_t.height + s.axis_x.font.vspacing));
|
chart.ctx.move_to (print_x, print_y - (s.axis_x.date_format == "" ? 0 : text_t.height + s.axis_x.font.vspacing));
|
||||||
if (s.axis_x.time_format != "") time_text_t.show();
|
if (s.axis_x.time_format != "") time_text_t.show();
|
||||||
break;
|
break;
|
||||||
|
@ -304,9 +303,9 @@ namespace CairoChart {
|
||||||
// show joint Y value
|
// show joint Y value
|
||||||
if (chart.joint_y) {
|
if (chart.joint_y) {
|
||||||
var s = chart.series[chart.zoom_1st_idx];
|
var s = chart.series[chart.zoom_1st_idx];
|
||||||
var y = s.get_real_y(rel2scr_y(c.y));
|
var y = s.axis_y.get_real_y(rel2scr_y(c.y));
|
||||||
var text_t = new Text(chart, s.axis_y.format.printf((LongDouble)y, s.axis_y.font));
|
var text_t = new Text(chart, s.axis_y.format.printf((LongDouble)y, s.axis_y.font));
|
||||||
var print_y = s.compact_rec_y_pos (y, text_t);
|
var print_y = s.axis_y.compact_rec_y_pos (y, text_t);
|
||||||
var print_x = 0.0;
|
var print_x = 0.0;
|
||||||
switch (s.axis_y.position) {
|
switch (s.axis_y.position) {
|
||||||
case Axis.Position.LOW:
|
case Axis.Position.LOW:
|
||||||
|
@ -393,12 +392,12 @@ namespace CairoChart {
|
||||||
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 && style.orientation == Orientation.VERTICAL) {
|
if (chart.joint_x && style.orientation == Orientation.VERTICAL) {
|
||||||
Float128 val1 = chart.series[chart.zoom_1st_idx].get_real_x(rel2scr_x(list.nth_data(0).x));
|
Float128 val1 = chart.series[chart.zoom_1st_idx].axis_x.get_real_x(rel2scr_x(list.nth_data(0).x));
|
||||||
Float128 val2 = 0;
|
Float128 val2 = 0;
|
||||||
if (is_cursor_active)
|
if (is_cursor_active)
|
||||||
val2 = chart.series[chart.zoom_1st_idx].get_real_x(rel2scr_x(active_cursor.x));
|
val2 = chart.series[chart.zoom_1st_idx].axis_x.get_real_x(rel2scr_x(active_cursor.x));
|
||||||
else
|
else
|
||||||
val2 = chart.series[chart.zoom_1st_idx].get_real_x(rel2scr_x(list.nth_data(1).x));
|
val2 = chart.series[chart.zoom_1st_idx].axis_x.get_real_x(rel2scr_x(list.nth_data(1).x));
|
||||||
if (val2 > val1)
|
if (val2 > val1)
|
||||||
delta = val2 - val1;
|
delta = val2 - val1;
|
||||||
else
|
else
|
||||||
|
@ -406,12 +405,12 @@ namespace CairoChart {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (chart.joint_y && style.orientation == Orientation.HORIZONTAL) {
|
if (chart.joint_y && style.orientation == Orientation.HORIZONTAL) {
|
||||||
Float128 val1 = chart.series[chart.zoom_1st_idx].get_real_y(rel2scr_y(list.nth_data(0).y));
|
Float128 val1 = chart.series[chart.zoom_1st_idx].axis_y.get_real_y(rel2scr_y(list.nth_data(0).y));
|
||||||
Float128 val2 = 0;
|
Float128 val2 = 0;
|
||||||
if (is_cursor_active)
|
if (is_cursor_active)
|
||||||
val2 = chart.series[chart.zoom_1st_idx].get_real_y(rel2scr_y(active_cursor.y));
|
val2 = chart.series[chart.zoom_1st_idx].axis_y.get_real_y(rel2scr_y(active_cursor.y));
|
||||||
else
|
else
|
||||||
val2 = chart.series[chart.zoom_1st_idx].get_real_y(rel2scr_y(list.nth_data(1).y));
|
val2 = chart.series[chart.zoom_1st_idx].axis_y.get_real_y(rel2scr_y(list.nth_data(1).y));
|
||||||
if (val2 > val1)
|
if (val2 > val1)
|
||||||
delta = val2 - val1;
|
delta = val2 - val1;
|
||||||
else
|
else
|
||||||
|
|
|
@ -130,8 +130,8 @@ namespace CairoChart {
|
||||||
if (Math.cut_line (
|
if (Math.cut_line (
|
||||||
Point(chart.plarea.x0, chart.plarea.y0),
|
Point(chart.plarea.x0, chart.plarea.y0),
|
||||||
Point(chart.plarea.x1, chart.plarea.y1),
|
Point(chart.plarea.x1, chart.plarea.y1),
|
||||||
Point(get_scr_x(points[i - 1].x), get_scr_y(points[i - 1].y)),
|
get_scr_point(points[i-1]),
|
||||||
Point(get_scr_x(points[i].x), get_scr_y(points[i].y)),
|
get_scr_point(points[i]),
|
||||||
out c, out d)
|
out c, out d)
|
||||||
) {
|
) {
|
||||||
chart.ctx.move_to (c.x, c.y);
|
chart.ctx.move_to (c.x, c.y);
|
||||||
|
@ -140,11 +140,10 @@ namespace CairoChart {
|
||||||
}
|
}
|
||||||
chart.ctx.stroke();
|
chart.ctx.stroke();
|
||||||
for (int i = 0; i < points.length; ++i) {
|
for (int i = 0; i < points.length; ++i) {
|
||||||
var x = get_scr_x(points[i].x);
|
var p = get_scr_point(points[i]);
|
||||||
var y = get_scr_y(points[i].y);
|
if (Math.point_in_rect (p, 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(Point(x, y));
|
marker.draw_at_pos(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +152,7 @@ namespace CairoChart {
|
||||||
* @param p real ``Series`` (X;Y) value.
|
* @param p real ``Series`` (X;Y) value.
|
||||||
*/
|
*/
|
||||||
public virtual Point get_scr_point (Point128 p) {
|
public virtual Point get_scr_point (Point128 p) {
|
||||||
return Point (get_scr_x(p.x), get_scr_y(p.y));
|
return Point(axis_x.get_scr_x(p.x), axis_y.get_scr_y(p.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -161,7 +160,7 @@ namespace CairoChart {
|
||||||
* @param p (X;Y) screen point.
|
* @param p (X;Y) screen point.
|
||||||
*/
|
*/
|
||||||
public virtual Point128 get_real_point (Point p) {
|
public virtual Point128 get_real_point (Point p) {
|
||||||
return Point128 (get_real_x(p.x), get_real_y(p.y));
|
return Point128 (axis_x.get_real_x(p.x), axis_y.get_real_y(p.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue