From d3f73e135b853c7a6582feebda79eb08604bdf67 Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Mon, 22 Jan 2018 14:54:58 +0300 Subject: [PATCH] OK In progress... --- src/Axis.vala | 10 +++++----- src/Cursor.vala | 22 +++++++++++----------- src/Label.vala | 2 +- src/Legend.vala | 4 ++-- src/Series.vala | 8 ++++---- test/ChartTest.vala | 12 ++++++------ 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/Axis.vala b/src/Axis.vala index 11f922f..0aa33d1 100644 --- a/src/Axis.vala +++ b/src/Axis.vala @@ -131,7 +131,7 @@ namespace CairoChart { } default = 2; } - public Font font_style = new Font (); + public Font font = new Font (); public Color color = Color (); public LineStyle line_style = LineStyle (); public double font_spacing = 5; @@ -149,7 +149,7 @@ namespace CairoChart { axis._time_format = this._time_format; axis.color = this.color; axis.font_spacing = this.font_spacing; - axis.font_style = this.font_style; + axis.font = this.font; axis.line_style = this.line_style; axis.range.max = this.range.max; axis.range.min = this.range.min; @@ -178,7 +178,7 @@ namespace CairoChart { Float128 x = (int64)(range.zmin + range.zrange / nrecords * i) + 1.0/3.0; switch (dtype) { case Axis.DType.NUMBERS: - var text = new Text (chart, format.printf((LongDouble)x) + (horizontal ? "_" : ""), font_style); + var text = new Text (chart, format.printf((LongDouble)x) + (horizontal ? "_" : ""), font); max_rec_width = double.max (max_rec_width, text.width); max_rec_height = double.max (max_rec_height, text.height); break; @@ -188,12 +188,12 @@ namespace CairoChart { var h = 0.0; if (date_format != "") { - var text = new Text (chart, date + (horizontal ? "_" : ""), font_style); + var text = new Text (chart, date + (horizontal ? "_" : ""), font); max_rec_width = double.max (max_rec_width, text.width); h = text.height; } if (time_format != "") { - var text = new Text (chart, time + (horizontal ? "_" : ""), font_style); + var text = new Text (chart, time + (horizontal ? "_" : ""), font); max_rec_width = double.max (max_rec_width, text.width); h += text.height; } diff --git a/src/Cursor.vala b/src/Cursor.vala index ae59d96..845a038 100644 --- a/src/Cursor.vala +++ b/src/Cursor.vala @@ -209,10 +209,10 @@ namespace CairoChart { size = Point128 (); string date, time; s.axis_x.format_date_time(p.x, out date, out time); - var date_t = new Text(chart, date, s.axis_x.font_style, s.axis_x.color); - var time_t = new Text(chart, time, s.axis_x.font_style, s.axis_x.color); - var x_t = new Text(chart, s.axis_x.format.printf((LongDouble)p.x), s.axis_x.font_style, s.axis_x.color); - var y_t = new Text(chart, s.axis_y.format.printf((LongDouble)p.y), s.axis_y.font_style, s.axis_y.color); + var date_t = new Text(chart, date, s.axis_x.font, s.axis_x.color); + var time_t = new Text(chart, time, s.axis_x.font, s.axis_x.color); + var x_t = new Text(chart, s.axis_x.format.printf((LongDouble)p.x), s.axis_x.font, s.axis_x.color); + var y_t = new Text(chart, s.axis_y.format.printf((LongDouble)p.y), s.axis_y.font, s.axis_y.color); double h_x = 0.0, h_y = 0.0; if (show_x) { size.x = x_t.width; h_x = x_t.height; } if (show_date) { size.x = date_t.width; h_x = date_t.height; } @@ -287,8 +287,8 @@ namespace CairoChart { case Axis.DType.NUMBERS: text = s.axis_x.format.printf((LongDouble)x); break; case Axis.DType.DATE_TIME: s.axis_x.format_date_time(x, out text, out time_text); break; } - var text_t = new Text(chart, text, s.axis_x.font_style, s.axis_x.color); - var time_text_t = new Text(chart, time_text, s.axis_x.font_style, s.axis_x.color); + var text_t = new Text(chart, text, s.axis_x.font, s.axis_x.color); + var time_text_t = new Text(chart, time_text, s.axis_x.font, s.axis_x.color); var print_y = 0.0; switch (s.axis_x.position) { case Axis.Position.LOW: print_y = chart.area.y1 - s.axis_x.font_spacing @@ -336,7 +336,7 @@ namespace CairoChart { if (chart.joint_y) { var s = chart.series[chart.zoom_1st_idx]; var y = s.get_real_y(rel2scr_y(c.y)); - var text_t = new Text(chart, s.axis_y.format.printf((LongDouble)y, s.axis_y.font_style)); + var text_t = new Text(chart, s.axis_y.format.printf((LongDouble)y, s.axis_y.font)); var print_y = s.compact_rec_y_pos (y, text_t); var print_x = 0.0; switch (s.axis_y.position) { @@ -374,7 +374,7 @@ namespace CairoChart { if (show_x) { chart.color = s.axis_x.color; - var text_t = new Text(chart, s.axis_x.format.printf((LongDouble)point.x), s.axis_x.font_style); + var text_t = new Text(chart, s.axis_x.format.printf((LongDouble)point.x), s.axis_x.font); chart.ctx.move_to (svp.x - size.x / 2, svp.y + text_t.height / 2); if (chart.joint_x) chart.color = chart.joint_color; text_t.show(); @@ -384,7 +384,7 @@ namespace CairoChart { chart.color = s.axis_x.color; string date = "", time = ""; s.axis_x.format_date_time(point.x, out date, out time); - var text_t = new Text(chart, time, s.axis_x.font_style); + var text_t = new Text(chart, time, s.axis_x.font); var y = svp.y + text_t.height / 2; if (show_date) y -= text_t.height / 2 + s.axis_x.font_spacing / 2; chart.ctx.move_to (svp.x - size.x / 2, y); @@ -396,7 +396,7 @@ namespace CairoChart { chart.color = s.axis_x.color; string date = "", time = ""; s.axis_x.format_date_time(point.x, out date, out time); - var text_t = new Text(chart, date, s.axis_x.font_style); + var text_t = new Text(chart, date, s.axis_x.font); var y = svp.y + text_t.height / 2; if (show_time) y += text_t.height / 2 + s.axis_x.font_spacing / 2; chart.ctx.move_to (svp.x - size.x / 2, y); @@ -406,7 +406,7 @@ namespace CairoChart { if (show_y) { chart.color = s.axis_y.color; - var text_t = new Text(chart, s.axis_y.format.printf((LongDouble)point.y), s.axis_y.font_style); + var text_t = new Text(chart, s.axis_y.format.printf((LongDouble)point.y), s.axis_y.font); chart.ctx.move_to (svp.x + size.x / 2 - text_t.width, svp.y + text_t.height / 2); if (chart.joint_y) chart.color = chart.joint_color; text_t.show(); diff --git a/src/Label.vala b/src/Label.vala index 3c5ef83..2983f0f 100644 --- a/src/Label.vala +++ b/src/Label.vala @@ -8,7 +8,7 @@ namespace CairoChart { /** * Font style. */ - Font font_style; + Font font; /** * Frame line style. diff --git a/src/Legend.vala b/src/Legend.vala index cd93d02..9987934 100644 --- a/src/Legend.vala +++ b/src/Legend.vala @@ -10,7 +10,7 @@ namespace CairoChart { } public Position position = Position.TOP; - public Font font_style = new Font(); + public Font font = new Font(); public Color bg_color = Color(1, 1, 1); public LineStyle border_style = LineStyle (); public double spacing = 5; @@ -24,7 +24,7 @@ namespace CairoChart { public virtual Legend copy () { var legend = new Legend (); legend.position = this.position; - legend.font_style = this.font_style; + legend.font = this.font; legend.bg_color = this.bg_color; legend.spacing = this.spacing; legend.height = this.height; diff --git a/src/Series.vala b/src/Series.vala index e860f96..7f8f63a 100644 --- a/src/Series.vala +++ b/src/Series.vala @@ -260,7 +260,7 @@ namespace CairoChart { case Axis.DType.DATE_TIME: axis_x.format_date_time(x, out text, out time_text); break; } var scr_x = get_scr_x (x); - var text_t = new Text(chart, text, axis_x.font_style, axis_x.color); + var text_t = new Text(chart, text, axis_x.font, axis_x.color); switch (axis_x.position) { case Axis.Position.LOW: @@ -273,7 +273,7 @@ namespace CairoChart { break; case Axis.DType.DATE_TIME: if (axis_x.date_format != "") text_t.show(); - var time_text_t = new Text(chart, time_text, axis_x.font_style, axis_x.color); + var time_text_t = new Text(chart, time_text, axis_x.font, axis_x.color); print_x = compact_rec_x_pos (x, time_text_t); ctx.move_to (print_x, print_y - (axis_x.date_format == "" ? 0 : text_t.height + axis_x.font_spacing)); if (axis_x.time_format != "") time_text_t.show(); @@ -301,7 +301,7 @@ namespace CairoChart { break; case Axis.DType.DATE_TIME: if (axis_x.date_format != "") text_t.show(); - var time_text_t = new Text(chart, time_text, axis_x.font_style, axis_x.color); + var time_text_t = new Text(chart, time_text, axis_x.font, axis_x.color); print_x = compact_rec_x_pos (x, time_text_t); ctx.move_to (print_x, print_y - (axis_x.date_format == "" ? 0 : text_t.height + axis_x.font_spacing)); if (axis_x.time_format != "") time_text_t.show(); @@ -400,7 +400,7 @@ namespace CairoChart { else chart.color = axis_y.color; var text = axis_y.format.printf((LongDouble)y); var scr_y = get_scr_y (y); - var text_t = new Text(chart, text, axis_y.font_style, axis_y.color); + var text_t = new Text(chart, text, axis_y.font, axis_y.color); switch (axis_y.position) { case Axis.Position.LOW: diff --git a/test/ChartTest.vala b/test/ChartTest.vala index b6ed627..0a1d4b1 100644 --- a/test/ChartTest.vala +++ b/test/ChartTest.vala @@ -61,12 +61,12 @@ void plot_chart1 (Chart chart) { s2.axis_y.title.font.slant = Cairo.FontSlant.ITALIC; s2.axis_y.title.font.weight = Cairo.FontWeight.BOLD; s3.axis_y.title.font.size = 18; - s1.axis_x.font_style.size = 12; - s2.axis_x.font_style.size = 12; - s3.axis_x.font_style.size = 12; - s1.axis_y.font_style.size = 12; - s2.axis_y.font_style.size = 12; - s3.axis_y.font_style.size = 14; + s1.axis_x.font.size = 12; + s2.axis_x.font.size = 12; + s3.axis_x.font.size = 12; + s1.axis_y.font.size = 12; + s2.axis_y.font.size = 12; + s3.axis_y.font.size = 14; s1.marker.size = 6; s2.marker.size = 8; s3.marker.size = 7;