diff --git a/src/Chart.vala b/src/Chart.vala index 1d3aa5c..7161bd8 100644 --- a/src/Chart.vala +++ b/src/Chart.vala @@ -57,9 +57,6 @@ namespace CairoChart { */ public int zoom_1st_idx { get; protected set; default = 0; } - public double title_width { get; protected set; default = 0.0; } - public double title_height { get; protected set; default = 0.0; } - public double title_indent = 4; public Line.Style selection_style = Line.Style (); @@ -102,9 +99,7 @@ namespace CairoChart { chart.selection_style = this.selection_style; chart.series = this.series; chart.title = this.title.copy(); - chart.title_height = this.title_height; chart.title_indent = this.title_indent; - chart.title_width = this.title_width; chart.pos = this.pos; chart.zoom_1st_idx = this.zoom_1st_idx; return chart; @@ -164,7 +159,7 @@ namespace CairoChart { } protected virtual void draw_chart_title () { var sz = title.get_size(ctx); - title_height = sz.height + (legend.position == Legend.Position.TOP ? title_indent * 2 : title_indent); + var title_height = sz.height + (legend.position == Legend.Position.TOP ? title_indent * 2 : title_indent); calc_pos.y += title_height; calc_pos.height -= title_height; color = title.color; diff --git a/src/Cursor.vala b/src/Cursor.vala index 63c57fc..0fd1b78 100644 --- a/src/Cursor.vala +++ b/src/Cursor.vala @@ -304,8 +304,11 @@ namespace CairoChart { case Axis.Position.LOW: print_y = chart.pos.y + chart.pos.height - s.axis_x.font_indent - (chart.legend.position == Legend.Position.BOTTOM ? chart.legend.height : 0); break; - case Axis.Position.HIGH: print_y = chart.pos.y + chart.title_height + s.axis_x.font_indent - + (chart.legend.position == Legend.Position.TOP ? chart.legend.height : 0); + case Axis.Position.HIGH: + var title_height = chart.title.get_height(chart.ctx) + (chart.legend.position == Legend.Position.TOP ? + chart.title_indent * 2 : chart.title_indent); + print_y = chart.pos.y + title_height + s.axis_x.font_indent + + (chart.legend.position == Legend.Position.TOP ? chart.legend.height : 0); switch (s.axis_x.type) { case Axis.Type.NUMBERS: print_y += sz.height; diff --git a/src/Legend.vala b/src/Legend.vala index 25597c5..bd52386 100644 --- a/src/Legend.vala +++ b/src/Legend.vala @@ -52,7 +52,9 @@ namespace CairoChart { switch (position) { case Position.TOP: x0 = (chart.pos.width - width) / 2; - y0 = chart.title_height; + var title_height = chart.title.get_height(chart.ctx) + (chart.legend.position == Legend.Position.TOP ? + chart.title_indent * 2 : chart.title_indent); + y0 = title_height; break; case Position.BOTTOM: