OK In progress...

This commit is contained in:
Kolan Sh 2018-01-23 17:08:55 +03:00
parent 63346514fd
commit c07de77845
1 changed files with 20 additions and 40 deletions

View File

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