In progress...

This commit is contained in:
Kolan Sh 2018-01-15 18:58:23 +03:00
parent bd232baeb8
commit a0b1c0fb6a
1 changed files with 50 additions and 43 deletions

View File

@ -472,6 +472,54 @@ namespace CairoChart {
}
}
protected virtual void draw_vertical_records (Series s, Float128 step, double max_rec_width, Float128 y_min) {
// 5. Draw records, update cur_{x,y}_{min,max}.
for (Float128 y = y_min, y_max = s.axis_y.zoom_max; math.point_belong (y, y_min, y_max); y += step) {
if (joint_y) set_source_rgba(joint_axis_color);
else set_source_rgba(s.axis_y.color);
var text = s.axis_y.format.printf((LongDouble)y);
var scr_y = get_scr_y (s, y);
var text_t = new Text(text, s.axis_y.font_style, s.axis_y.color);
var text_sz = text_t.get_size(context);
var sz = s.axis_y.title.get_size(context);
switch (s.axis_y.position) {
case Axis.Position.LOW:
context.move_to (cur_x_min + max_rec_width - text_sz.width + s.axis_y.font_indent
+ (s.axis_y.title.text == "" ? 0 : sz.width + s.axis_y.font_indent),
compact_rec_y_pos (s, y, text_t));
text_t.show(context);
// 6. Draw grid lines to the s.place.zoom_x_min.
var line_style = s.grid.line_style;
if (joint_y) line_style.color = Color(0, 0, 0, 0.5);
line_style.set(this);
double x = cur_x_min + max_rec_width + s.axis_y.font_indent + (s.axis_y.title.text == "" ? 0 : sz.width + s.axis_y.font_indent);
context.move_to (x, scr_y);
if (joint_y)
context.line_to (plot_x_max, scr_y);
else
context.line_to (double.max (x, plot_x_min + (plot_x_max - plot_x_min) * s.place.zoom_x_max), scr_y);
break;
case Axis.Position.HIGH:
context.move_to (cur_x_max - text_sz.width - s.axis_y.font_indent
- (s.axis_y.title.text == "" ? 0 : sz.width + s.axis_y.font_indent),
compact_rec_y_pos (s, y, text_t));
text_t.show(context);
// 6. Draw grid lines to the s.place.zoom_x_max.
var line_style = s.grid.line_style;
if (joint_y) line_style.color = Color(0, 0, 0, 0.5);
line_style.set(this);
double x = cur_x_max - max_rec_width - s.axis_y.font_indent - (s.axis_y.title.text == "" ? 0 : sz.width + s.axis_y.font_indent);
context.move_to (x, scr_y);
if (joint_y)
context.line_to (plot_x_min, scr_y);
else
context.line_to (double.min (x, plot_x_min + (plot_x_max - plot_x_min) * s.place.zoom_x_min), scr_y);
break;
}
}
}
protected virtual void draw_vertical_axes () {
for (var si = series.length - 1, nskip = 0; si >=0; --si) {
var s = series[si];
@ -529,49 +577,8 @@ namespace CairoChart {
s.axis_y.title.show(context);
}
// 5. Draw records, update cur_{x,y}_{min,max}.
for (Float128 y = y_min, y_max = s.axis_y.zoom_max; math.point_belong (y, y_min, y_max); y += step) {
if (joint_y) set_source_rgba(joint_axis_color);
else set_source_rgba(s.axis_y.color);
var text = s.axis_y.format.printf((LongDouble)y);
var scr_y = get_scr_y (s, y);
var text_t = new Text(text, s.axis_y.font_style, s.axis_y.color);
var text_sz = text_t.get_size(context);
switch (s.axis_y.position) {
case Axis.Position.LOW:
context.move_to (cur_x_min + max_rec_width - text_sz.width + s.axis_y.font_indent
+ (s.axis_y.title.text == "" ? 0 : sz.width + s.axis_y.font_indent),
compact_rec_y_pos (s, y, text_t));
text_t.show(context);
// 6. Draw grid lines to the s.place.zoom_x_min.
var line_style = s.grid.line_style;
if (joint_y) line_style.color = Color(0, 0, 0, 0.5);
line_style.set(this);
double x = cur_x_min + max_rec_width + s.axis_y.font_indent + (s.axis_y.title.text == "" ? 0 : sz.width + s.axis_y.font_indent);
context.move_to (x, scr_y);
if (joint_y)
context.line_to (plot_x_max, scr_y);
else
context.line_to (double.max (x, plot_x_min + (plot_x_max - plot_x_min) * s.place.zoom_x_max), scr_y);
break;
case Axis.Position.HIGH:
context.move_to (cur_x_max - text_sz.width - s.axis_y.font_indent
- (s.axis_y.title.text == "" ? 0 : sz.width + s.axis_y.font_indent),
compact_rec_y_pos (s, y, text_t));
text_t.show(context);
// 6. Draw grid lines to the s.place.zoom_x_max.
var line_style = s.grid.line_style;
if (joint_y) line_style.color = Color(0, 0, 0, 0.5);
line_style.set(this);
double x = cur_x_max - max_rec_width - s.axis_y.font_indent - (s.axis_y.title.text == "" ? 0 : sz.width + s.axis_y.font_indent);
context.move_to (x, scr_y);
if (joint_y)
context.line_to (plot_x_min, scr_y);
else
context.line_to (double.min (x, plot_x_min + (plot_x_max - plot_x_min) * s.place.zoom_x_min), scr_y);
break;
}
}
draw_vertical_records (s, step, max_rec_width, y_min);
context.stroke ();
double tmp1 = 0, tmp2 = 0, tmp3 = 0, tmp4 = 0;