Fix cursors value on common axes.

This commit is contained in:
Kolan Sh 2017-12-07 04:21:27 +03:00
parent 7a1fd94532
commit f4b89194d6
2 changed files with 31 additions and 4 deletions

View File

@ -1414,12 +1414,19 @@ namespace Gtk.CairoChart {
- (legend.position == Legend.Position.BOTTOM ? legend_height : 0); - (legend.position == Legend.Position.BOTTOM ? legend_height : 0);
break; break;
case Axis.Position.HIGH: print_y = y_min + title_height + s.axis_x.font_indent case Axis.Position.HIGH: print_y = y_min + title_height + s.axis_x.font_indent
+ (legend.position == Legend.Position.TOP ? legend_height : 0) + (legend.position == Legend.Position.TOP ? legend_height : 0);
+ (s.axis_x.date_format == "" ? 0 : text_t.get_height(context)) switch (s.axis_x.type) {
case Axis.Type.NUMBERS:
print_y += text_t.get_height(context);
break;
case Axis.Type.DATE_TIME:
print_y += (s.axis_x.date_format == "" ? 0 : text_t.get_height(context))
+ (s.axis_x.time_format == "" ? 0 : time_text_t.get_height(context)) + (s.axis_x.time_format == "" ? 0 : time_text_t.get_height(context))
+ (s.axis_x.date_format == "" || s.axis_x.time_format == "" ? 0 : s.axis_x.font_indent); + (s.axis_x.date_format == "" || s.axis_x.time_format == "" ? 0 : s.axis_x.font_indent);
break; break;
} }
break;
}
var print_x = compact_rec_x_pos (s, x, text_t); var print_x = compact_rec_x_pos (s, x, text_t);
context.move_to (print_x, print_y); context.move_to (print_x, print_y);
@ -1453,6 +1460,24 @@ namespace Gtk.CairoChart {
// TODO: show values // TODO: show values
if (common_y_axes) { if (common_y_axes) {
// show common Y value // show common Y value
var y = get_real_y(s, rel2scr_y(c.y));
var text_t = new Text(s.axis_y.format.printf((LongDouble)y));
var print_y = compact_rec_y_pos (s, y, text_t);
var print_x = 0.0;
switch (s.axis_y.position) {
case Axis.Position.LOW:
print_x = x_min + s.axis_y.font_indent
+ (legend.position == Legend.Position.LEFT ? legend_width : 0);
break;
case Axis.Position.HIGH:
print_x = x_min + width - text_t.get_width(context) - s.axis_y.font_indent
- (legend.position == Legend.Position.RIGHT ? legend_width : 0);
break;
}
context.move_to (print_x, print_y);
show_text(text_t);
context.stroke ();
// show only X value // show only X value
; ;

View File

@ -131,6 +131,8 @@ void plot_chart3 (Chart chart) {
s3.axis_x.title = new Text("Series 3: Axis X."); s3.axis_x.title = new Text("Series 3: Axis X.");
s3.axis_y.title = new Text("Series 3: Axis Y."); s3.axis_y.title = new Text("Series 3: Axis Y.");
//s1.axis_y.position = s2.axis_y.position = s3.axis_y.position = Axis.Position.LOW;
chart.series = { s1, s2, s3 }; chart.series = { s1, s2, s3 };
} }