OK In progress...

This commit is contained in:
Kolan Sh 2018-01-18 12:29:43 +03:00
parent b14abc7ef6
commit 2d1f588393
3 changed files with 22 additions and 19 deletions

View File

@ -52,7 +52,10 @@ namespace CairoChart {
public Cairo.Rectangle zoom = Cairo.Rectangle() public Cairo.Rectangle zoom = Cairo.Rectangle()
{ x = 0, y = 0, width = 1, height = 1 }; { x = 0, y = 0, width = 1, height = 1 };
public int zoom_first_show { get; protected set; default = 0; } /**
* 1'st shown series index in zoom area.
*/
public int zoom_1st_idx { get; protected set; default = 0; }
public double title_width { get; protected set; default = 0.0; } public double title_width { get; protected set; default = 0.0; }
public double title_height { get; protected set; default = 0.0; } public double title_height { get; protected set; default = 0.0; }
@ -103,7 +106,7 @@ namespace CairoChart {
chart.title_indent = this.title_indent; chart.title_indent = this.title_indent;
chart.title_width = this.title_width; chart.title_width = this.title_width;
chart.pos = this.pos; chart.pos = this.pos;
chart.zoom_first_show = this.zoom_first_show; chart.zoom_1st_idx = this.zoom_1st_idx;
return chart; return chart;
} }
@ -241,10 +244,10 @@ namespace CairoChart {
} }
} }
zoom_first_show = 0; zoom_1st_idx = 0;
for (var si = 0, max_i = series.length; si < max_i; ++si) for (var si = 0, max_i = series.length; si < max_i; ++si)
if (series[si].zoom_show) { if (series[si].zoom_show) {
zoom_first_show = si; zoom_1st_idx = si;
break; break;
} }
var new_zoom = zoom; var new_zoom = zoom;
@ -270,7 +273,7 @@ namespace CairoChart {
s.place.zoom_y_max = s.place.y_max; s.place.zoom_y_max = s.place.y_max;
} }
zoom = Cairo.Rectangle() { x = 0, y = 0, width = 1, height = 1 }; zoom = Cairo.Rectangle() { x = 0, y = 0, width = 1, height = 1 };
zoom_first_show = 0; zoom_1st_idx = 0;
} }
public virtual void move (Point delta) { public virtual void move (Point delta) {
var d = delta; var d = delta;

View File

@ -283,7 +283,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_first_show]; var s = chart.series[chart.zoom_1st_idx];
var x = s.get_real_x(chart.rel2scr_x(c.x)); var x = s.get_real_x(chart.rel2scr_x(c.x));
string text = "", time_text = ""; string text = "", time_text = "";
switch (s.axis_x.type) { switch (s.axis_x.type) {
@ -341,7 +341,7 @@ namespace CairoChart {
// show joint Y value // show joint Y value
if (chart.joint_y) { if (chart.joint_y) {
var s = chart.series[chart.zoom_first_show]; var s = chart.series[chart.zoom_1st_idx];
var y = s.get_real_y(chart.rel2scr_y(c.y)); var y = s.get_real_y(chart.rel2scr_y(c.y));
var text_t = new Text(s.axis_y.format.printf((LongDouble)y, s.axis_y.font_style)); var text_t = new Text(s.axis_y.format.printf((LongDouble)y, s.axis_y.font_style));
var print_y = s.compact_rec_y_pos (y, text_t); var print_y = s.compact_rec_y_pos (y, text_t);
@ -430,12 +430,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 && cursor_style.orientation == Orientation.VERTICAL) { if (chart.joint_x && cursor_style.orientation == Orientation.VERTICAL) {
Float128 val1 = chart.series[chart.zoom_first_show].get_real_x(chart.rel2scr_x(list.nth_data(0).x)); Float128 val1 = chart.series[chart.zoom_1st_idx].get_real_x(chart.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_first_show].get_real_x(chart.rel2scr_x(active_cursor.x)); val2 = chart.series[chart.zoom_1st_idx].get_real_x(chart.rel2scr_x(active_cursor.x));
else else
val2 = chart.series[chart.zoom_first_show].get_real_x(chart.rel2scr_x(list.nth_data(1).x)); val2 = chart.series[chart.zoom_1st_idx].get_real_x(chart.rel2scr_x(list.nth_data(1).x));
if (val2 > val1) if (val2 > val1)
delta = val2 - val1; delta = val2 - val1;
else else
@ -443,12 +443,12 @@ namespace CairoChart {
return true; return true;
} }
if (chart.joint_y && cursor_style.orientation == Orientation.HORIZONTAL) { if (chart.joint_y && cursor_style.orientation == Orientation.HORIZONTAL) {
Float128 val1 = chart.series[chart.zoom_first_show].get_real_y(chart.rel2scr_y(list.nth_data(0).y)); Float128 val1 = chart.series[chart.zoom_1st_idx].get_real_y(chart.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_first_show].get_real_y(chart.rel2scr_y(active_cursor.y)); val2 = chart.series[chart.zoom_1st_idx].get_real_y(chart.rel2scr_y(active_cursor.y));
else else
val2 = chart.series[chart.zoom_first_show].get_real_y(chart.rel2scr_y(list.nth_data(1).y)); val2 = chart.series[chart.zoom_1st_idx].get_real_y(chart.rel2scr_y(list.nth_data(1).y));
if (val2 > val1) if (val2 > val1)
delta = val2 - val1; delta = val2 - val1;
else else
@ -462,7 +462,7 @@ namespace CairoChart {
Float128 delta = 0.0; Float128 delta = 0.0;
if (!get_cursors_delta(chart, out delta)) return ""; if (!get_cursors_delta(chart, out delta)) return "";
var str = ""; var str = "";
var s = chart.series[chart.zoom_first_show]; var s = chart.series[chart.zoom_1st_idx];
if (chart.joint_x) if (chart.joint_x)
switch (s.axis_x.type) { switch (s.axis_x.type) {
case Axis.Type.NUMBERS: case Axis.Type.NUMBERS:

View File

@ -131,7 +131,7 @@ namespace CairoChart {
s.join_relative_y_axes (si, true, ref max_rec_width, ref max_rec_height, ref max_font_indent, ref max_axis_font_width, ref nskip); s.join_relative_y_axes (si, true, ref max_rec_width, ref max_rec_height, ref max_font_indent, ref max_axis_font_width, ref nskip);
// for 4.2. Cursor values for joint X axis // for 4.2. Cursor values for joint X axis
if (si == chart.zoom_first_show && chart.cursors.cursors_crossings.length != 0) { if (si == chart.zoom_1st_idx && chart.cursors.cursors_crossings.length != 0) {
switch (chart.cursors.cursor_style.orientation) { switch (chart.cursors.cursor_style.orientation) {
case Cursors.Orientation.VERTICAL: case Cursors.Orientation.VERTICAL:
if (is_x && chart.joint_x) if (is_x && chart.joint_x)
@ -149,12 +149,12 @@ namespace CairoChart {
break; break;
} }
} }
if (is_x && (!chart.joint_x || si == chart.zoom_first_show)) if (is_x && (!chart.joint_x || si == chart.zoom_1st_idx))
switch (axis.position) { switch (axis.position) {
case Axis.Position.LOW: chart.plot_y_max -= max_rec_height + max_font_indent + max_axis_font_height; break; case Axis.Position.LOW: chart.plot_y_max -= max_rec_height + max_font_indent + max_axis_font_height; break;
case Axis.Position.HIGH: chart.plot_y_min += max_rec_height + max_font_indent + max_axis_font_height; break; case Axis.Position.HIGH: chart.plot_y_min += max_rec_height + max_font_indent + max_axis_font_height; break;
} }
if (!is_x && (!chart.joint_y || si == chart.zoom_first_show)) if (!is_x && (!chart.joint_y || si == chart.zoom_1st_idx))
switch (s.axis_y.position) { switch (s.axis_y.position) {
case Axis.Position.LOW: chart.plot_x_min += max_rec_width + max_font_indent + max_axis_font_width; break; case Axis.Position.LOW: chart.plot_x_min += max_rec_width + max_font_indent + max_axis_font_width; break;
case Axis.Position.HIGH: chart.plot_x_max -= max_rec_width + max_font_indent + max_axis_font_width; break; case Axis.Position.HIGH: chart.plot_x_max -= max_rec_width + max_font_indent + max_axis_font_width; break;
@ -319,7 +319,7 @@ namespace CairoChart {
public virtual void draw_horizontal_axis (int si, ref int nskip) { public virtual void draw_horizontal_axis (int si, ref int nskip) {
var s = chart.series[si]; var s = chart.series[si];
if (!s.zoom_show) return; if (!s.zoom_show) return;
if (chart.joint_x && si != chart.zoom_first_show) 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;
@ -444,7 +444,7 @@ namespace CairoChart {
public virtual void draw_vertical_axis (int si, ref int nskip) { public virtual void draw_vertical_axis (int si, ref int nskip) {
var s = chart.series[si]; var s = chart.series[si];
if (!s.zoom_show) return; if (!s.zoom_show) return;
if (chart.joint_y && si != chart.zoom_first_show) 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;
s.axis_y.calc_rec_sizes (chart, out max_rec_width, out max_rec_height, false); s.axis_y.calc_rec_sizes (chart, out max_rec_width, out max_rec_height, false);