join_relative_y_axes -> Series.vala

This commit is contained in:
Kolan Sh 2018-01-15 14:57:35 +03:00
parent 2b25f9c554
commit eb8fada021
2 changed files with 41 additions and 39 deletions

View File

@ -271,43 +271,6 @@ namespace CairoChart {
}
}
protected virtual void join_relative_y_axes (Series s,
int si,
bool calc_max_values,
ref double max_rec_width,
ref double max_rec_height,
ref double max_font_indent,
ref double max_axis_font_width,
ref int nskip) {
for (int sj = si - 1; sj >= 0; --sj) {
var s2 = series[sj];
if (!s2.zoom_show) continue;
bool has_intersection = false;
for (int sk = si; sk > sj; --sk) {
var s3 = series[sk];
if (!s3.zoom_show) continue;
if (math.are_intersect(s2.place.zoom_y_min, s2.place.zoom_y_max, s3.place.zoom_y_min, s3.place.zoom_y_max)
|| s2.axis_y.position != s3.axis_y.position
|| s2.axis_y.type != s3.axis_y.type) {
has_intersection = true;
break;
}
}
if (!has_intersection) {
double tmp_max_rec_width = 0; double tmp_max_rec_height = 0;
s2.axis_y.calc_rec_sizes (this, 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);
max_font_indent = double.max (max_font_indent, s2.axis_y.font_indent);
max_axis_font_width = double.max (max_axis_font_width, s2.axis_y.title.text == "" ? 0
: s2.axis_y.title.get_width(context) + s.axis_y.font_indent);
++nskip;
} else {
break;
}
}
}
protected virtual void calc_plot_area () {
plot_x_min = cur_x_min + legend.indent;
plot_x_max = cur_x_max - legend.indent;
@ -363,7 +326,7 @@ namespace CairoChart {
var max_font_indent = s.axis_y.font_indent;
var max_axis_font_width = s.axis_y.title.text == "" ? 0 : s.axis_y.title.get_width(context) + s.axis_y.font_indent;
join_relative_y_axes (s, 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 (this, 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 Y axis
if (joint_y && si == zoom_first_show && cursor_style.orientation == Cursor.Orientation.HORIZONTAL && cursors_crossings.length != 0) {
@ -645,7 +608,7 @@ namespace CairoChart {
context.stroke ();
double tmp1 = 0, tmp2 = 0, tmp3 = 0, tmp4 = 0;
join_relative_y_axes (s, si, false, ref tmp1, ref tmp2, ref tmp3, ref tmp4, ref nskip);
s.join_relative_y_axes (this, si, false, ref tmp1, ref tmp2, ref tmp3, ref tmp4, ref nskip);
if (nskip != 0) {--nskip; continue;}

View File

@ -109,5 +109,44 @@ namespace CairoChart {
return false;
return true;
}
public virtual void join_relative_y_axes (Chart chart,
int si,
bool calc_max_values,
ref double max_rec_width,
ref double max_rec_height,
ref double max_font_indent,
ref double max_axis_font_width,
ref int nskip) {
for (int sj = si - 1; sj >= 0; --sj) {
var s2 = chart.series[sj];
if (!s2.zoom_show) continue;
bool has_intersection = false;
for (int sk = si; sk > sj; --sk) {
var s3 = chart.series[sk];
if (!s3.zoom_show) continue;
if (chart.math.are_intersect(s2.place.zoom_y_min, s2.place.zoom_y_max, s3.place.zoom_y_min, s3.place.zoom_y_max)
|| s2.axis_y.position != s3.axis_y.position
|| s2.axis_y.type != s3.axis_y.type) {
has_intersection = true;
break;
}
}
if (!has_intersection) {
double tmp_max_rec_width = 0; double tmp_max_rec_height = 0;
s2.axis_y.calc_rec_sizes (chart, 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);
max_font_indent = double.max (max_font_indent, s2.axis_y.font_indent);
max_axis_font_width = double.max (max_axis_font_width, s2.axis_y.title.text == "" ? 0
: s2.axis_y.title.get_width(chart.context) + this.axis_y.font_indent);
++nskip;
} else {
break;
}
}
}
}
}