OK In progress...
This commit is contained in:
parent
0d142ac4db
commit
e0f9197cea
|
@ -182,7 +182,10 @@ namespace CairoChart {
|
||||||
return axis;
|
return axis;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void format_date_time (Float128 x, out string date, out string time) {
|
/**
|
||||||
|
* Prints date/time to strings with a current formats.
|
||||||
|
*/
|
||||||
|
public virtual void print_dt (Float128 x, out string date, out string time) {
|
||||||
date = time = "";
|
date = time = "";
|
||||||
var dt = new DateTime.from_unix_utc((int64)x);
|
var dt = new DateTime.from_unix_utc((int64)x);
|
||||||
date = dt.format(date_format);
|
date = dt.format(date_format);
|
||||||
|
@ -191,6 +194,7 @@ namespace CairoChart {
|
||||||
time = dt.format(time_format) + dsec_str;
|
time = dt.format(time_format) + dsec_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: move to Series.vala
|
||||||
public virtual void calc_rec_sizes (out double max_rec_width, out double max_rec_height, bool horizontal = true) {
|
public virtual void calc_rec_sizes (out double max_rec_width, out double max_rec_height, bool horizontal = true) {
|
||||||
max_rec_width = max_rec_height = 0;
|
max_rec_width = max_rec_height = 0;
|
||||||
for (var i = 0; i < nrecords; ++i) {
|
for (var i = 0; i < nrecords; ++i) {
|
||||||
|
@ -203,7 +207,7 @@ namespace CairoChart {
|
||||||
break;
|
break;
|
||||||
case Axis.DType.DATE_TIME:
|
case Axis.DType.DATE_TIME:
|
||||||
string date, time;
|
string date, time;
|
||||||
format_date_time(x, out date, out time);
|
print_dt(x, out date, out time);
|
||||||
|
|
||||||
var h = 0.0;
|
var h = 0.0;
|
||||||
if (date_format != "") {
|
if (date_format != "") {
|
||||||
|
|
|
@ -208,7 +208,7 @@ namespace CairoChart {
|
||||||
cross_what_to_show(s, out show_x, out show_time, out show_date, out show_y);
|
cross_what_to_show(s, out show_x, out show_time, out show_date, out show_y);
|
||||||
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.print_dt(p.x, out date, out time);
|
||||||
var date_t = new Text(chart, date, s.axis_x.font, 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, 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 x_t = new Text(chart, s.axis_x.format.printf((LongDouble)p.x), s.axis_x.font, s.axis_x.color);
|
||||||
|
@ -285,7 +285,7 @@ namespace CairoChart {
|
||||||
string text = "", time_text = "";
|
string text = "", time_text = "";
|
||||||
switch (s.axis_x.dtype) {
|
switch (s.axis_x.dtype) {
|
||||||
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.print_dt(x, out text, out time_text); break;
|
||||||
}
|
}
|
||||||
var text_t = new Text(chart, text, s.axis_x.font, 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 time_text_t = new Text(chart, time_text, s.axis_x.font, s.axis_x.color);
|
||||||
|
@ -383,7 +383,7 @@ namespace CairoChart {
|
||||||
if (show_time) {
|
if (show_time) {
|
||||||
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.print_dt(point.x, out date, out time);
|
||||||
var text_t = new Text(chart, time, s.axis_x.font);
|
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.vspacing / 2;
|
if (show_date) y -= text_t.height / 2 + s.axis_x.font.vspacing / 2;
|
||||||
|
@ -395,7 +395,7 @@ namespace CairoChart {
|
||||||
if (show_date) {
|
if (show_date) {
|
||||||
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.print_dt(point.x, out date, out time);
|
||||||
var text_t = new Text(chart, date, s.axis_x.font);
|
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.vspacing / 2;
|
if (show_time) y += text_t.height / 2 + s.axis_x.font.vspacing / 2;
|
||||||
|
@ -461,7 +461,7 @@ namespace CairoChart {
|
||||||
case Axis.DType.DATE_TIME:
|
case Axis.DType.DATE_TIME:
|
||||||
var date = "", time = "";
|
var date = "", time = "";
|
||||||
int64 days = (int64)(delta / 24 / 3600);
|
int64 days = (int64)(delta / 24 / 3600);
|
||||||
s.axis_x.format_date_time(delta, out date, out time);
|
s.axis_x.print_dt(delta, out date, out time);
|
||||||
str = days.to_string() + " + " + time;
|
str = days.to_string() + " + " + time;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,7 +257,7 @@ namespace CairoChart {
|
||||||
string text = "", time_text = "";
|
string text = "", time_text = "";
|
||||||
switch (axis_x.dtype) {
|
switch (axis_x.dtype) {
|
||||||
case Axis.DType.NUMBERS: text = axis_x.format.printf((LongDouble)x); break;
|
case Axis.DType.NUMBERS: text = axis_x.format.printf((LongDouble)x); break;
|
||||||
case Axis.DType.DATE_TIME: axis_x.format_date_time(x, out text, out time_text); break;
|
case Axis.DType.DATE_TIME: axis_x.print_dt(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, axis_x.color);
|
var text_t = new Text(chart, text, axis_x.font, axis_x.color);
|
||||||
|
|
Loading…
Reference in New Issue