In progress...

This commit is contained in:
Kolan Sh 2018-01-15 18:36:58 +03:00
parent 42feb73732
commit c948a37cea
1 changed files with 79 additions and 73 deletions

View File

@ -318,59 +318,7 @@ namespace CairoChart {
public CairoChart.Math math = new Math();
protected virtual void draw_horizontal_axis (int si, ref int nskip) {
var s = series[si];
if (!s.zoom_show) return;
if (joint_x && si != zoom_first_show) return;
// 1. Detect max record width/height by axis.nrecords equally selected points using format.
double max_rec_width, max_rec_height;
s.axis_x.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.
long max_nrecs = (long) ((plot_x_max - plot_x_min) * (s.place.zoom_x_max - s.place.zoom_x_min) / max_rec_width);
// 3. Calculate grid step.
Float128 step = math.calc_round_step ((s.axis_x.zoom_max - s.axis_x.zoom_min) / max_nrecs, s.axis_x.type == Axis.Type.DATE_TIME);
if (step > s.axis_x.zoom_max - s.axis_x.zoom_min)
step = s.axis_x.zoom_max - s.axis_x.zoom_min;
// 4. Calculate x_min (s.axis_x.zoom_min / step, round, multiply on step, add step if < s.axis_x.zoom_min).
Float128 x_min = 0.0;
if (step >= 1) {
int64 x_min_nsteps = (int64) (s.axis_x.zoom_min / step);
x_min = x_min_nsteps * step;
} else {
int64 round_axis_x_min = (int64)s.axis_x.zoom_min;
int64 x_min_nsteps = (int64) ((s.axis_x.zoom_min - round_axis_x_min) / step);
x_min = round_axis_x_min + x_min_nsteps * step;
}
if (x_min < s.axis_x.zoom_min) x_min += step;
// 4.2. Cursor values for joint X axis
if (joint_x && cursor_style.orientation == Cursor.Orientation.VERTICAL && cursors_crossings.length != 0) {
switch (s.axis_x.position) {
case Axis.Position.LOW: cur_y_max -= max_rec_height + s.axis_x.font_indent; break;
case Axis.Position.HIGH: cur_y_min += max_rec_height + s.axis_x.font_indent; break;
}
}
var sz = s.axis_x.title.get_size(context);
// 4.5. Draw Axis title
if (s.axis_x.title.text != "") {
var scr_x = plot_x_min + (plot_x_max - plot_x_min) * (s.place.zoom_x_min + s.place.zoom_x_max) / 2.0;
double scr_y = 0.0;
switch (s.axis_x.position) {
case Axis.Position.LOW: scr_y = cur_y_max - s.axis_x.font_indent; break;
case Axis.Position.HIGH: scr_y = cur_y_min + s.axis_x.font_indent + sz.height; break;
}
context.move_to(scr_x - sz.width / 2.0, scr_y);
set_source_rgba(s.axis_x.color);
if (joint_x) set_source_rgba(joint_axis_color);
s.axis_x.title.show(context);
}
protected virtual void draw_records_h (Series s, Float128 step, double max_rec_height, Float128 x_min) {
// 5. Draw records, update cur_{x,y}_{min,max}.
for (Float128 x = x_min, x_max = s.axis_x.zoom_max; math.point_belong (x, x_min, x_max); x += step) {
if (joint_x) set_source_rgba(joint_axis_color);
@ -386,6 +334,8 @@ namespace CairoChart {
}
var scr_x = get_scr_x (s, x);
var text_t = new Text(text, s.axis_x.font_style, s.axis_x.color);
var sz = s.axis_x.title.get_size(context);
switch (s.axis_x.position) {
case Axis.Position.LOW:
var print_y = cur_y_max - s.axis_x.font_indent - (s.axis_x.title.text == "" ? 0 : sz.height + s.axis_x.font_indent);
@ -444,6 +394,63 @@ namespace CairoChart {
break;
}
}
}
protected virtual void draw_horizontal_axis (int si, ref int nskip) {
var s = series[si];
if (!s.zoom_show) return;
if (joint_x && si != zoom_first_show) return;
// 1. Detect max record width/height by axis.nrecords equally selected points using format.
double max_rec_width, max_rec_height;
s.axis_x.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.
long max_nrecs = (long) ((plot_x_max - plot_x_min) * (s.place.zoom_x_max - s.place.zoom_x_min) / max_rec_width);
// 3. Calculate grid step.
Float128 step = math.calc_round_step ((s.axis_x.zoom_max - s.axis_x.zoom_min) / max_nrecs, s.axis_x.type == Axis.Type.DATE_TIME);
if (step > s.axis_x.zoom_max - s.axis_x.zoom_min)
step = s.axis_x.zoom_max - s.axis_x.zoom_min;
// 4. Calculate x_min (s.axis_x.zoom_min / step, round, multiply on step, add step if < s.axis_x.zoom_min).
Float128 x_min = 0.0;
if (step >= 1) {
int64 x_min_nsteps = (int64) (s.axis_x.zoom_min / step);
x_min = x_min_nsteps * step;
} else {
int64 round_axis_x_min = (int64)s.axis_x.zoom_min;
int64 x_min_nsteps = (int64) ((s.axis_x.zoom_min - round_axis_x_min) / step);
x_min = round_axis_x_min + x_min_nsteps * step;
}
if (x_min < s.axis_x.zoom_min) x_min += step;
// 4.2. Cursor values for joint X axis
if (joint_x && cursor_style.orientation == Cursor.Orientation.VERTICAL && cursors_crossings.length != 0) {
switch (s.axis_x.position) {
case Axis.Position.LOW: cur_y_max -= max_rec_height + s.axis_x.font_indent; break;
case Axis.Position.HIGH: cur_y_min += max_rec_height + s.axis_x.font_indent; break;
}
}
var sz = s.axis_x.title.get_size(context);
// 4.5. Draw Axis title
if (s.axis_x.title.text != "") {
var scr_x = plot_x_min + (plot_x_max - plot_x_min) * (s.place.zoom_x_min + s.place.zoom_x_max) / 2.0;
double scr_y = 0.0;
switch (s.axis_x.position) {
case Axis.Position.LOW: scr_y = cur_y_max - s.axis_x.font_indent; break;
case Axis.Position.HIGH: scr_y = cur_y_min + s.axis_x.font_indent + sz.height; break;
}
context.move_to(scr_x - sz.width / 2.0, scr_y);
set_source_rgba(s.axis_x.color);
if (joint_x) set_source_rgba(joint_axis_color);
s.axis_x.title.show(context);
}
draw_records_h (s, step, max_rec_height, x_min);
context.stroke ();
double tmp1 = 0, tmp2 = 0, tmp3 = 0, tmp4 = 0;
@ -461,7 +468,6 @@ namespace CairoChart {
+ (s.axis_x.title.text == "" ? 0 : sz.height + s.axis_x.font_indent);
break;
}
}
protected virtual void draw_horizontal_axes () {