diff --git a/src/Axis.vala b/src/Axis.vala index 58f29eb..de2512a 100644 --- a/src/Axis.vala +++ b/src/Axis.vala @@ -497,8 +497,6 @@ namespace CairoChart { protected virtual void draw_recs (Float128 step, double max_rec_size, Float128 min) { // 5. Draw records, update cur_{x,y}_{min,max}. - var ctx = chart.ctx; - for (Float128 v = min, max = range.zmax; Math.point_belong (v, min, max); v += step) { if (is_x && chart.joint_x || !is_x && chart.joint_y) { chart.color = chart.joint_color; @@ -512,89 +510,71 @@ namespace CairoChart { } var scr_v = scr_pos (v); var text_t = new Text(chart, text, font, color); - switch (position) { case Axis.Position.LOW: if (is_x) { var print_y = chart.evarea.y1 - font.vspacing - (title.text == "" ? 0 : title.height + font.vspacing); var print_x = compact_rec_pos (v, text_t); - ctx.move_to (print_x, print_y); + chart.ctx.move_to (print_x, print_y); switch (dtype) { - case Axis.DType.NUMBERS: - text_t.show(); - break; + case Axis.DType.NUMBERS: text_t.show(); break; case Axis.DType.DATE_TIME: if (date_format != "") text_t.show(); var time_text_t = new Text(chart, time_text, font, color); print_x = compact_rec_pos (v, time_text_t); - ctx.move_to (print_x, print_y - (date_format == "" ? 0 : text_t.height + font.vspacing)); + chart.ctx.move_to (print_x, print_y - (date_format == "" ? 0 : text_t.height + font.vspacing)); if (time_format != "") time_text_t.show(); break; } // 6. Draw grid lines to the ser.axis_y.place.zmin. ser.grid.style.apply(chart); double y = chart.evarea.y1 - max_rec_size - font.vspacing - (title.text == "" ? 0 : title.height + font.vspacing); - ctx.move_to (scr_v, y); - if (chart.joint_x) - ctx.line_to (scr_v, chart.plarea.y0); - else - ctx.line_to (scr_v, double.min (y, chart.plarea.y0 + chart.plarea.height * (1 - ser.axis_y.place.zmax))); + chart.ctx.move_to (scr_v, y); + if (chart.joint_x) chart.ctx.line_to (scr_v, chart.plarea.y0); + else chart.ctx.line_to (scr_v, double.min (y, chart.plarea.y0 + chart.plarea.height * (1 - ser.axis_y.place.zmax))); break; } else { - ctx.move_to (chart.evarea.x0 + max_rec_size - text_t.width + font.hspacing - + (title.text == "" ? 0 : title.width + font.hspacing), - compact_rec_pos (v, text_t)); + chart.ctx.move_to (chart.evarea.x0 + max_rec_size - text_t.width + font.hspacing + (title.text == "" ? 0 : title.width + font.hspacing), compact_rec_pos (v, text_t)); text_t.show(); // 6. Draw grid lines to the ser.axis_x.place.zmin. ser.grid.style.apply(chart); double x = chart.evarea.x0 + max_rec_size + font.hspacing + (title.text == "" ? 0 : title.width + font.hspacing); - ctx.move_to (x, scr_v); - if (chart.joint_y) - ctx.line_to (chart.plarea.x1, scr_v); - else - ctx.line_to (double.max (x, chart.plarea.x0 + chart.plarea.width * ser.axis_x.place.zmax), scr_v); + chart.ctx.move_to (x, scr_v); + if (chart.joint_y) chart.ctx.line_to (chart.plarea.x1, scr_v); + else chart.ctx.line_to (double.max (x, chart.plarea.x0 + chart.plarea.width * ser.axis_x.place.zmax), scr_v); break; } case Axis.Position.HIGH: if (is_x) { var print_y = chart.evarea.y0 + max_rec_size + font.vspacing + (title.text == "" ? 0 : title.height + font.vspacing); var print_x = compact_rec_pos (v, text_t); - ctx.move_to (print_x, print_y); - + chart.ctx.move_to (print_x, print_y); switch (dtype) { - case Axis.DType.NUMBERS: - text_t.show(); - break; + case Axis.DType.NUMBERS: text_t.show(); break; case Axis.DType.DATE_TIME: if (date_format != "") text_t.show(); var time_text_t = new Text(chart, time_text, font, color); print_x = compact_rec_pos (v, time_text_t); - ctx.move_to (print_x, print_y - (date_format == "" ? 0 : text_t.height + font.vspacing)); + chart.ctx.move_to (print_x, print_y - (date_format == "" ? 0 : text_t.height + font.vspacing)); if (time_format != "") time_text_t.show(); break; } // 6. Draw grid lines to the ser.axis_y.place.zmax. ser.grid.style.apply(chart); double y = chart.evarea.y0 + max_rec_size + font.vspacing + (title.text == "" ? 0 : title.height + font.vspacing); - ctx.move_to (scr_v, y); - if (chart.joint_x) - ctx.line_to (scr_v, chart.plarea.y1); - else - ctx.line_to (scr_v, double.max (y, chart.plarea.y0 + chart.plarea.height * (1 - ser.axis_y.place.zmin))); + chart.ctx.move_to (scr_v, y); + if (chart.joint_x) chart.ctx.line_to (scr_v, chart.plarea.y1); + else chart.ctx.line_to (scr_v, double.max (y, chart.plarea.y0 + chart.plarea.height * (1 - ser.axis_y.place.zmin))); break; } else { - ctx.move_to (chart.evarea.x1 - text_t.width - font.hspacing - - (title.text == "" ? 0 : title.width + font.hspacing), - compact_rec_pos (v, text_t)); + chart.ctx.move_to (chart.evarea.x1 - text_t.width - font.hspacing - (title.text == "" ? 0 : title.width + font.hspacing), compact_rec_pos (v, text_t)); text_t.show(); // 6. Draw grid lines to the ser.axis_x.place.zmax. ser.grid.style.apply(chart); double x = chart.evarea.x1 - max_rec_size - font.hspacing - (title.text == "" ? 0 : title.width + font.hspacing); - ctx.move_to (x, scr_v); - if (chart.joint_y) - ctx.line_to (chart.plarea.x0, scr_v); - else - ctx.line_to (double.min (x, chart.plarea.x0 + chart.plarea.width * ser.axis_x.place.zmin), scr_v); + chart.ctx.move_to (x, scr_v); + if (chart.joint_y) chart.ctx.line_to (chart.plarea.x0, scr_v); + else chart.ctx.line_to (double.min (x, chart.plarea.x0 + chart.plarea.width * ser.axis_x.place.zmin), scr_v); break; } }