OK In progress...

This commit is contained in:
Kolan Sh 2018-01-22 14:54:58 +03:00
parent 857b6f38e4
commit d3f73e135b
6 changed files with 29 additions and 29 deletions

View File

@ -131,7 +131,7 @@ namespace CairoChart {
} }
default = 2; default = 2;
} }
public Font font_style = new Font (); public Font font = new Font ();
public Color color = Color (); public Color color = Color ();
public LineStyle line_style = LineStyle (); public LineStyle line_style = LineStyle ();
public double font_spacing = 5; public double font_spacing = 5;
@ -149,7 +149,7 @@ namespace CairoChart {
axis._time_format = this._time_format; axis._time_format = this._time_format;
axis.color = this.color; axis.color = this.color;
axis.font_spacing = this.font_spacing; axis.font_spacing = this.font_spacing;
axis.font_style = this.font_style; axis.font = this.font;
axis.line_style = this.line_style; axis.line_style = this.line_style;
axis.range.max = this.range.max; axis.range.max = this.range.max;
axis.range.min = this.range.min; 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; Float128 x = (int64)(range.zmin + range.zrange / nrecords * i) + 1.0/3.0;
switch (dtype) { switch (dtype) {
case Axis.DType.NUMBERS: 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_width = double.max (max_rec_width, text.width);
max_rec_height = double.max (max_rec_height, text.height); max_rec_height = double.max (max_rec_height, text.height);
break; break;
@ -188,12 +188,12 @@ namespace CairoChart {
var h = 0.0; var h = 0.0;
if (date_format != "") { 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); max_rec_width = double.max (max_rec_width, text.width);
h = text.height; h = text.height;
} }
if (time_format != "") { 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); max_rec_width = double.max (max_rec_width, text.width);
h += text.height; h += text.height;
} }

View File

@ -209,10 +209,10 @@ namespace CairoChart {
size = Point128 (); size = Point128 ();
string date, time; string date, time;
s.axis_x.format_date_time(p.x, out date, out 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 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_style, 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_style, 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_style, s.axis_y.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; double h_x = 0.0, h_y = 0.0;
if (show_x) { size.x = x_t.width; h_x = x_t.height; } 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; } 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.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; 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 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_style, 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; var print_y = 0.0;
switch (s.axis_x.position) { switch (s.axis_x.position) {
case Axis.Position.LOW: print_y = chart.area.y1 - s.axis_x.font_spacing case Axis.Position.LOW: print_y = chart.area.y1 - s.axis_x.font_spacing
@ -336,7 +336,7 @@ namespace CairoChart {
if (chart.joint_y) { if (chart.joint_y) {
var s = chart.series[chart.zoom_1st_idx]; var s = chart.series[chart.zoom_1st_idx];
var y = s.get_real_y(rel2scr_y(c.y)); 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_y = s.compact_rec_y_pos (y, text_t);
var print_x = 0.0; var print_x = 0.0;
switch (s.axis_y.position) { switch (s.axis_y.position) {
@ -374,7 +374,7 @@ namespace CairoChart {
if (show_x) { if (show_x) {
chart.color = s.axis_x.color; 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); chart.ctx.move_to (svp.x - size.x / 2, svp.y + text_t.height / 2);
if (chart.joint_x) chart.color = chart.joint_color; if (chart.joint_x) chart.color = chart.joint_color;
text_t.show(); text_t.show();
@ -384,7 +384,7 @@ namespace CairoChart {
chart.color = s.axis_x.color; chart.color = s.axis_x.color;
string date = "", time = ""; string date = "", time = "";
s.axis_x.format_date_time(point.x, out date, out 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; var y = svp.y + text_t.height / 2;
if (show_date) y -= text_t.height / 2 + s.axis_x.font_spacing / 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); chart.ctx.move_to (svp.x - size.x / 2, y);
@ -396,7 +396,7 @@ namespace CairoChart {
chart.color = s.axis_x.color; chart.color = s.axis_x.color;
string date = "", time = ""; string date = "", time = "";
s.axis_x.format_date_time(point.x, out date, out 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; var y = svp.y + text_t.height / 2;
if (show_time) y += text_t.height / 2 + s.axis_x.font_spacing / 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); chart.ctx.move_to (svp.x - size.x / 2, y);
@ -406,7 +406,7 @@ namespace CairoChart {
if (show_y) { if (show_y) {
chart.color = s.axis_y.color; 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); 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; if (chart.joint_y) chart.color = chart.joint_color;
text_t.show(); text_t.show();

View File

@ -8,7 +8,7 @@ namespace CairoChart {
/** /**
* Font style. * Font style.
*/ */
Font font_style; Font font;
/** /**
* Frame line style. * Frame line style.

View File

@ -10,7 +10,7 @@ namespace CairoChart {
} }
public Position position = Position.TOP; 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 Color bg_color = Color(1, 1, 1);
public LineStyle border_style = LineStyle (); public LineStyle border_style = LineStyle ();
public double spacing = 5; public double spacing = 5;
@ -24,7 +24,7 @@ namespace CairoChart {
public virtual Legend copy () { public virtual Legend copy () {
var legend = new Legend (); var legend = new Legend ();
legend.position = this.position; legend.position = this.position;
legend.font_style = this.font_style; legend.font = this.font;
legend.bg_color = this.bg_color; legend.bg_color = this.bg_color;
legend.spacing = this.spacing; legend.spacing = this.spacing;
legend.height = this.height; legend.height = this.height;

View File

@ -260,7 +260,7 @@ namespace CairoChart {
case Axis.DType.DATE_TIME: axis_x.format_date_time(x, out text, out time_text); break; 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 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) { switch (axis_x.position) {
case Axis.Position.LOW: case Axis.Position.LOW:
@ -273,7 +273,7 @@ namespace CairoChart {
break; break;
case Axis.DType.DATE_TIME: case Axis.DType.DATE_TIME:
if (axis_x.date_format != "") text_t.show(); 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); 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)); 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(); if (axis_x.time_format != "") time_text_t.show();
@ -301,7 +301,7 @@ namespace CairoChart {
break; break;
case Axis.DType.DATE_TIME: case Axis.DType.DATE_TIME:
if (axis_x.date_format != "") text_t.show(); 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); 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)); 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(); if (axis_x.time_format != "") time_text_t.show();
@ -400,7 +400,7 @@ namespace CairoChart {
else chart.color = axis_y.color; else chart.color = axis_y.color;
var text = axis_y.format.printf((LongDouble)y); var text = axis_y.format.printf((LongDouble)y);
var scr_y = get_scr_y (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) { switch (axis_y.position) {
case Axis.Position.LOW: case Axis.Position.LOW:

View File

@ -61,12 +61,12 @@ void plot_chart1 (Chart chart) {
s2.axis_y.title.font.slant = Cairo.FontSlant.ITALIC; s2.axis_y.title.font.slant = Cairo.FontSlant.ITALIC;
s2.axis_y.title.font.weight = Cairo.FontWeight.BOLD; s2.axis_y.title.font.weight = Cairo.FontWeight.BOLD;
s3.axis_y.title.font.size = 18; s3.axis_y.title.font.size = 18;
s1.axis_x.font_style.size = 12; s1.axis_x.font.size = 12;
s2.axis_x.font_style.size = 12; s2.axis_x.font.size = 12;
s3.axis_x.font_style.size = 12; s3.axis_x.font.size = 12;
s1.axis_y.font_style.size = 12; s1.axis_y.font.size = 12;
s2.axis_y.font_style.size = 12; s2.axis_y.font.size = 12;
s3.axis_y.font_style.size = 14; s3.axis_y.font.size = 14;
s1.marker.size = 6; s1.marker.size = 6;
s2.marker.size = 8; s2.marker.size = 8;
s3.marker.size = 7; s3.marker.size = 7;