In progress...
This commit is contained in:
parent
621dd5f685
commit
df3c3b1693
|
@ -2,10 +2,10 @@ namespace CairoChart {
|
|||
|
||||
public class Chart {
|
||||
|
||||
public double x_min = 0.0;
|
||||
public double y_min = 0.0;
|
||||
public double width = 0.0;
|
||||
public double height = 0.0;
|
||||
/**
|
||||
* Chart Position.
|
||||
*/
|
||||
public Cairo.Rectangle pos = Cairo.Rectangle();
|
||||
|
||||
public Cairo.Context context = null;
|
||||
|
||||
|
@ -69,7 +69,6 @@ namespace CairoChart {
|
|||
chart.cur_y_max = this.cur_y_max;
|
||||
chart.cur_y_min = this.cur_y_min;
|
||||
chart.cursors = this.cursors.copy();
|
||||
chart.height = this.height;
|
||||
chart.legend = this.legend.copy();
|
||||
chart.plot_x_max = this.plot_x_max;
|
||||
chart.plot_x_min = this.plot_x_min;
|
||||
|
@ -85,9 +84,7 @@ namespace CairoChart {
|
|||
chart.title_height = this.title_height;
|
||||
chart.title_indent = this.title_indent;
|
||||
chart.title_width = this.title_width;
|
||||
chart.width = this.width;
|
||||
chart.x_min = this.x_min;
|
||||
chart.y_min = this.y_min;
|
||||
chart.pos = this.pos;
|
||||
chart.zoom_first_show = this.zoom_first_show;
|
||||
return chart;
|
||||
}
|
||||
|
@ -115,10 +112,10 @@ namespace CairoChart {
|
|||
|
||||
public virtual bool draw () {
|
||||
|
||||
cur_x_min = x_min;
|
||||
cur_y_min = y_min;
|
||||
cur_x_max = x_min + width;
|
||||
cur_y_max = y_min + height;
|
||||
cur_x_min = pos.x;
|
||||
cur_y_min = pos.y;
|
||||
cur_x_max = pos.x + pos.width;
|
||||
cur_y_max = pos.y + pos.height;
|
||||
|
||||
draw_chart_title ();
|
||||
check_cur_values ();
|
||||
|
@ -154,7 +151,7 @@ namespace CairoChart {
|
|||
title_height = sz.height + (legend.position == Legend.Position.TOP ? title_indent * 2 : title_indent);
|
||||
cur_y_min += title_height;
|
||||
color = title.color;
|
||||
context.move_to (width/2 - sz.width/2, sz.height + title_indent);
|
||||
context.move_to (pos.width/2 - sz.width/2, sz.height + title_indent);
|
||||
title.show(context);
|
||||
}
|
||||
public virtual void draw_selection (Cairo.Rectangle rect) {
|
||||
|
|
|
@ -301,10 +301,10 @@ namespace CairoChart {
|
|||
var time_text_t = new Text(time_text, s.axis_x.font_style, s.axis_x.color);
|
||||
var print_y = 0.0;
|
||||
switch (s.axis_x.position) {
|
||||
case Axis.Position.LOW: print_y = chart.y_min + chart.height - s.axis_x.font_indent
|
||||
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.y_min + chart.title_height + s.axis_x.font_indent
|
||||
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);
|
||||
switch (s.axis_x.type) {
|
||||
case Axis.Type.NUMBERS:
|
||||
|
@ -348,11 +348,11 @@ namespace CairoChart {
|
|||
var print_x = 0.0;
|
||||
switch (s.axis_y.position) {
|
||||
case Axis.Position.LOW:
|
||||
print_x = chart.x_min + s.axis_y.font_indent
|
||||
print_x = chart.pos.x + s.axis_y.font_indent
|
||||
+ (chart.legend.position == Legend.Position.LEFT ? chart.legend.width : 0);
|
||||
break;
|
||||
case Axis.Position.HIGH:
|
||||
print_x = chart.x_min + chart.width - text_t.get_width(chart.context) - s.axis_y.font_indent
|
||||
print_x = chart.pos.x + chart.pos.width - text_t.get_width(chart.context) - s.axis_y.font_indent
|
||||
- (chart.legend.position == Legend.Position.RIGHT ? chart.legend.width : 0);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -51,23 +51,23 @@ namespace CairoChart {
|
|||
if (chart.context != null) {
|
||||
switch (position) {
|
||||
case Position.TOP:
|
||||
x0 = (chart.width - width) / 2;
|
||||
x0 = (chart.pos.width - width) / 2;
|
||||
y0 = chart.title_height;
|
||||
break;
|
||||
|
||||
case Position.BOTTOM:
|
||||
x0 = (chart.width - width) / 2;
|
||||
y0 = chart.height - height;
|
||||
x0 = (chart.pos.width - width) / 2;
|
||||
y0 = chart.pos.height - height;
|
||||
break;
|
||||
|
||||
case Position.LEFT:
|
||||
x0 = 0;
|
||||
y0 = (chart.height - height) / 2;
|
||||
y0 = (chart.pos.height - height) / 2;
|
||||
break;
|
||||
|
||||
case Position.RIGHT:
|
||||
x0 = chart.width - width;
|
||||
y0 = (chart.height - height) / 2;
|
||||
x0 = chart.pos.width - width;
|
||||
y0 = (chart.pos.height - height) / 2;
|
||||
break;
|
||||
}
|
||||
chart.color = bg_color;
|
||||
|
@ -120,7 +120,7 @@ namespace CairoChart {
|
|||
case Position.TOP:
|
||||
case Position.BOTTOM:
|
||||
var ser_title_width = title_sz.width + line_length;
|
||||
if (leg_width_sum + (leg_width_sum == 0 ? 0 : text_hspace) + ser_title_width > chart.width) { // carry
|
||||
if (leg_width_sum + (leg_width_sum == 0 ? 0 : text_hspace) + ser_title_width > chart.pos.width) { // carry
|
||||
leg_height_sum += max_font_h;
|
||||
switch (process_type) {
|
||||
case ProcessType.CALC:
|
||||
|
|
|
@ -415,8 +415,8 @@ int main (string[] args) {
|
|||
|
||||
da.draw.connect((context) => {
|
||||
chart.context = context;
|
||||
chart.width = da.get_allocated_width();
|
||||
chart.height = da.get_allocated_height();
|
||||
chart.pos.width = da.get_allocated_width();
|
||||
chart.pos.height = da.get_allocated_height();
|
||||
chart.clear();
|
||||
|
||||
// user's pre draw operations here...
|
||||
|
|
Loading…
Reference in New Issue