In progress... Before Moscow 09.01

This commit is contained in:
Kolan Sh 2018-01-08 23:33:13 +03:00
parent b75386a476
commit d67e2c2691
18 changed files with 623 additions and 595 deletions

View File

@ -1,4 +1,4 @@
namespace Gtk.CairoChart { namespace CairoChart {
// If one of axis:title or axis:min/max are different // If one of axis:title or axis:min/max are different
// then draw separate axis for each/all series // then draw separate axis for each/all series
// or specify series name near the axis // or specify series name near the axis
@ -72,9 +72,9 @@ namespace Gtk.CairoChart {
} }
default = 2; default = 2;
} }
public FontStyle font_style = FontStyle (); public Font.Style font_style = Font.Style ();
public Color color = Color (); public Color color = Color ();
public LineStyle line_style = LineStyle (); public Line.Style line_style = Line.Style ();
public double font_indent = 5; public double font_indent = 5;
public Axis copy () { public Axis copy () {

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
namespace Gtk.CairoChart { namespace CairoChart {
public struct Color { public struct Color {
double red; double red;
double green; double green;

23
src/Cursor.vala Normal file
View File

@ -0,0 +1,23 @@
namespace CairoChart {
public class Cursor {
public enum Orientation {
VERTICAL = 0, // default
HORIZONTAL
}
public struct Style {
public Orientation orientation;
public double select_distance;
public Line.Style line_style;
public Style () {
orientation = Orientation.VERTICAL;
select_distance = 32;
line_style = Line.Style(Color(0.2, 0.2, 0.2, 0.8));
}
}
}
}

31
src/Font.vala Normal file
View File

@ -0,0 +1,31 @@
namespace CairoChart {
public class Font {
public enum Orientation {
HORIZONTAL = 0,
VERTICAL
}
public struct Style {
string family;
Cairo.FontSlant slant;
Cairo.FontWeight weight;
Orientation orientation;
double size;
public Style (string family = "Sans",
Cairo.FontSlant slant = Cairo.FontSlant.NORMAL,
Cairo.FontWeight weight = Cairo.FontWeight.NORMAL,
double size = 10,
Font.Orientation orientation = Font.Orientation.HORIZONTAL) {
this.family = family;
this.slant = slant;
this.weight = weight;
this.size = size;
this.orientation = orientation;
}
}
}
}

View File

@ -1,27 +0,0 @@
namespace Gtk.CairoChart {
public enum FontOrient {
HORIZONTAL = 0,
VERTICAL
}
public struct FontStyle {
string family;
Cairo.FontSlant slant;
Cairo.FontWeight weight;
FontOrient orientation;
double size;
public FontStyle (string family = "Sans",
Cairo.FontSlant slant = Cairo.FontSlant.NORMAL,
Cairo.FontWeight weight = Cairo.FontWeight.NORMAL,
double size = 10,
FontOrient orientation = FontOrient.HORIZONTAL) {
this.family = family;
this.slant = slant;
this.weight = weight;
this.size = size;
this.orientation = orientation;
}
}
}

View File

@ -1,4 +1,4 @@
namespace Gtk.CairoChart { namespace CairoChart {
public class Grid { public class Grid {
/*public enum GridType { /*public enum GridType {
PRICK_LINE = 0, // default PRICK_LINE = 0, // default
@ -6,7 +6,7 @@ namespace Gtk.CairoChart {
}*/ }*/
public Color color = Color (0, 0, 0, 0.1); public Color color = Color (0, 0, 0, 0.1);
public LineStyle line_style = LineStyle (); public Line.Style line_style = Line.Style ();
public Grid copy () { public Grid copy () {
var grid = new Grid (); var grid = new Grid ();

12
src/Label.vala Normal file
View File

@ -0,0 +1,12 @@
namespace CairoChart {
public class Label {
public struct Style {
Font.Style font_style;
Line.Style frame_line_style;
Color bg_color;
Color frame_color;
}
}
}

View File

@ -1,8 +0,0 @@
namespace Gtk.CairoChart {
public struct LabelStyle {
FontStyle font_style;
LineStyle frame_line_style;
Color bg_color;
Color frame_color;
}
}

View File

@ -1,16 +1,25 @@
namespace Gtk.CairoChart { namespace CairoChart {
public class Legend { public class Legend {
public enum Position { public enum Position {
TOP = 0, // default TOP = 0, // default
LEFT, LEFT,
RIGHT, RIGHT,
BOTTOM BOTTOM
} }
public Position position = Position.TOP; public Position position = Position.TOP;
public FontStyle font_style = FontStyle(); public Font.Style font_style = Font.Style();
public Color bg_color = Color(1, 1, 1); public Color bg_color = Color(1, 1, 1);
public LineStyle border_style = LineStyle (); public Line.Style border_style = Line.Style ();
public double indent = 5; public double indent = 5;
public double width = 0;
public double height = 0;
public double line_length = 30.0;
public double text_hspace = 10.0;
public double text_vspace = 2.0;
public bool show = true;
public Legend copy () { public Legend copy () {
var legend = new Legend (); var legend = new Legend ();
@ -18,11 +27,194 @@ namespace Gtk.CairoChart {
legend.font_style = this.font_style; legend.font_style = this.font_style;
legend.bg_color = this.bg_color; legend.bg_color = this.bg_color;
legend.indent = this.indent; legend.indent = this.indent;
legend.height = this.height;
legend.line_length = this.line_length;
legend.text_hspace = this.text_hspace;
legend.text_vspace = this.text_vspace;
legend.width = this.width;
legend.show = this.show;
legend.max_font_heights = this.max_font_heights;
return legend; return legend;
} }
public Legend () { public Legend () {
border_style.color = Color (0, 0, 0, 0.3); border_style.color = Color (0, 0, 0, 0.3);
} }
public virtual void draw (Chart chart) {
process (chart, ProcessType.CALC);
process (chart, ProcessType.DRAW);
}
public virtual void draw_rect (Chart chart, out double x0, out double y0) {
x0 = y0 = 0.0;
if (chart.context != null) {
switch (position) {
case Position.TOP:
x0 = (chart.width - width) / 2;
y0 = chart.title_height;
break;
case Position.BOTTOM:
x0 = (chart.width - width) / 2;
y0 = chart.height - height;
break;
case Position.LEFT:
x0 = 0;
y0 = (chart.height - height) / 2;
break;
case Position.RIGHT:
x0 = chart.width - width;
y0 = (chart.height - height) / 2;
break;
}
chart.set_source_rgba(bg_color);
chart.context.rectangle (x0, y0, width, height);
chart.context.fill();
chart.set_line_style(border_style);
chart.context.move_to (x0, y0);
chart.context.rel_line_to (width, 0);
chart.context.rel_line_to (0, height);
chart.context.rel_line_to (-width, 0);
chart.context.rel_line_to (0, -height);
chart.context.stroke ();
}
}
public enum ProcessType {
CALC = 0, // default
DRAW
}
double [] max_font_heights;
public virtual void process (Chart chart, ProcessType process_type) {
var legend_x0 = 0.0, legend_y0 = 0.0;
var heights_idx = 0;
var leg_width_sum = 0.0;
var leg_height_sum = 0.0;
double max_font_h = 0.0;
// prepare
switch (process_type) {
case ProcessType.CALC:
width = 0.0;
height = 0.0;
max_font_heights = {};
heights_idx = 0;
break;
case ProcessType.DRAW:
draw_rect(chart, out legend_x0, out legend_y0);
break;
}
foreach (var s in chart.series) {
if (!s.zoom_show) continue;
var title_sz = s.title.get_size(chart.context);
// carry
switch (position) {
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
leg_height_sum += max_font_h;
switch (process_type) {
case ProcessType.CALC:
max_font_heights += max_font_h;
width = double.max(width, leg_width_sum);
break;
case ProcessType.DRAW:
heights_idx++;
break;
}
leg_width_sum = 0.0;
max_font_h = 0;
}
break;
}
switch (process_type) {
case ProcessType.DRAW:
var x = legend_x0 + leg_width_sum + (leg_width_sum == 0.0 ? 0.0 : text_hspace);
var y = legend_y0 + leg_height_sum + max_font_heights[heights_idx];
// series title
chart.context.move_to (x + line_length, y);
chart.set_source_rgba (s.title.color);
chart.show_text(s.title);
// series line style
chart.context.move_to (x, y - title_sz.height / 2);
chart.set_line_style(s.line_style);
chart.context.rel_line_to (line_length, 0);
chart.context.stroke();
chart.draw_marker_at_pos (s.marker_type, x + line_length / 2, y - title_sz.height / 2);
break;
}
switch (position) {
case Position.TOP:
case Position.BOTTOM:
var ser_title_width = title_sz.width + line_length;
leg_width_sum += (leg_width_sum == 0 ? 0 : text_hspace) + ser_title_width;
max_font_h = double.max (max_font_h, title_sz.height) + (leg_height_sum != 0 ? text_vspace : 0);
break;
case Position.LEFT:
case Position.RIGHT:
switch (process_type) {
case ProcessType.CALC:
max_font_heights += title_sz.height + (leg_height_sum != 0 ? text_vspace : 0);
width = double.max (width, title_sz.width + line_length);
break;
case ProcessType.DRAW:
heights_idx++;
break;
}
leg_height_sum += title_sz.height + (leg_height_sum != 0 ? text_vspace : 0);
break;
}
}
// TOP, BOTTOM
switch (position) {
case Position.TOP:
case Position.BOTTOM:
if (leg_width_sum != 0) {
leg_height_sum += max_font_h;
switch (process_type) {
case ProcessType.CALC:
max_font_heights += max_font_h;
width = double.max(width, leg_width_sum);
break;
}
}
break;
}
switch (process_type) {
case ProcessType.CALC:
height = leg_height_sum;
switch (position) {
case Position.TOP:
chart.cur_y_min += height;
break;
case Position.BOTTOM:
chart.cur_y_max -= height;
break;
case Position.LEFT:
chart.cur_x_min += width;
break;
case Position.RIGHT:
chart.cur_x_max -= width;
break;
}
break;
}
}
} }
} }

29
src/Line.vala Normal file
View File

@ -0,0 +1,29 @@
namespace CairoChart {
public class Line {
public struct Style {
double width;
Cairo.LineJoin join;
Cairo.LineCap cap;
double[]? dashes;
double dash_offset;
Color color;
public Style (Color color = Color(),
double width = 1,
double[]? dashes = null, double dash_offset = 0,
Cairo.LineJoin join = Cairo.LineJoin.MITER,
Cairo.LineCap cap = Cairo.LineCap.ROUND
) {
this.width = width;
this.join = join;
this.cap = cap;
this.dashes = dashes;
this.dash_offset = dash_offset;
this.color = color;
}
}
}
}

View File

@ -1,24 +0,0 @@
namespace Gtk.CairoChart {
public struct LineStyle {
double width;
Cairo.LineJoin line_join;
Cairo.LineCap line_cap;
double[]? dashes;
double dash_offset;
Color color;
public LineStyle (Color color = Color(),
double width = 1,
double[]? dashes = null, double dash_offset = 0,
Cairo.LineJoin line_join = Cairo.LineJoin.MITER,
Cairo.LineCap line_cap = Cairo.LineCap.ROUND
) {
this.width = width;
this.line_join = line_join;
this.line_cap = line_cap;
this.dashes = dashes;
this.dash_offset = dash_offset;
this.color = color;
}
}
}

View File

@ -1,52 +1,52 @@
namespace Gtk.CairoChart { namespace CairoChart {
public class Place { public class Place {
double _x_low = 0; double _x_min = 0;
double _x_high = 0; double _x_max = 0;
double _y_low = 0; double _y_min = 0;
double _y_high = 0; double _y_max = 0;
public double x_low { public double x_min {
get { return _x_low; } get { return _x_min; }
set { _x_low = zoom_x_low = value; } set { _x_min = zoom_x_min = value; }
default = 0; default = 0;
} }
public double x_high { public double x_max {
get { return _x_high; } get { return _x_max; }
set { _x_high = zoom_x_high = value; } set { _x_max = zoom_x_max = value; }
default = 0; default = 0;
} }
public double y_low { public double y_min {
get { return _y_low; } get { return _y_min; }
set { _y_low = zoom_y_low = value; } set { _y_min = zoom_y_min = value; }
default = 0; default = 0;
} }
public double y_high { public double y_max {
get { return _y_high; } get { return _y_max; }
set { _y_high = zoom_y_high = value; } set { _y_max = zoom_y_max = value; }
default = 0; default = 0;
} }
public double zoom_x_low = 0; public double zoom_x_min = 0;
public double zoom_x_high = 1; public double zoom_x_max = 1;
public double zoom_y_low = 0; public double zoom_y_min = 0;
public double zoom_y_high = 1; public double zoom_y_max = 1;
public Place copy () { public Place copy () {
var place = new Place (); var place = new Place ();
place.x_low = this.x_low; place.x_min = this.x_min;
place.x_high = this.x_high; place.x_max = this.x_max;
place.y_low = this.y_low; place.y_min = this.y_min;
place.y_high = this.y_high; place.y_max = this.y_max;
return place; return place;
} }
public Place (double x_low = 0, double x_high = 1, double y_low = 0, double y_high = 1) { public Place (double x_min = 0, double x_max = 1, double y_min = 0, double y_max = 1) {
this.x_low = x_low; this.x_min = x_min;
this.x_high = x_high; this.x_max = x_max;
this.y_low = y_low; this.y_min = y_min;
this.y_high = y_high; this.y_max = y_max;
zoom_x_low = x_low; zoom_x_min = x_min;
zoom_x_high = x_high; zoom_x_max = x_max;
zoom_y_low = y_low; zoom_y_min = y_min;
zoom_y_high = y_high; zoom_y_max = y_max;
} }
} }
} }

View File

@ -1,4 +1,4 @@
namespace Gtk.CairoChart { namespace CairoChart {
public struct Point { public struct Point {
Float128 x; Float128 x;
Float128 y; Float128 y;

View File

@ -1,6 +1,6 @@
using Cairo; using Cairo;
namespace Gtk.CairoChart { namespace CairoChart {
public class Series { public class Series {
@ -8,7 +8,7 @@ namespace Gtk.CairoChart {
public enum Sort { public enum Sort {
BY_X = 0, BY_X = 0,
BY_Y = 1, BY_Y = 1,
NO_SORT UNSORTED
} }
public Sort sort = Sort.BY_X; public Sort sort = Sort.BY_X;
@ -31,7 +31,7 @@ namespace Gtk.CairoChart {
public Grid grid = new Grid (); public Grid grid = new Grid ();
public LineStyle line_style = LineStyle (); public Line.Style line_style = Line.Style ();
protected Color _color = Color (0.0, 0.0, 0.0, 1.0); protected Color _color = Color (0.0, 0.0, 0.0, 1.0);
public Color color { public Color color {

View File

@ -1,8 +1,8 @@
namespace Gtk.CairoChart { namespace CairoChart {
[Compact] [Compact]
public class Text { public class Text {
public string text = ""; public string text = "";
public FontStyle style = FontStyle (); public Font.Style style = Font.Style ();
public Color color = Color(); public Color color = Color();
public Cairo.TextExtents get_extents (Cairo.Context context) { public Cairo.TextExtents get_extents (Cairo.Context context) {
@ -16,8 +16,8 @@ namespace Gtk.CairoChart {
public double get_width (Cairo.Context context) { public double get_width (Cairo.Context context) {
var extents = get_extents (context); var extents = get_extents (context);
switch (style.orientation) { switch (style.orientation) {
case FontOrient.HORIZONTAL: return extents.width; case Font.Orientation.HORIZONTAL: return extents.width;
case FontOrient.VERTICAL: return extents.height; case Font.Orientation.VERTICAL: return extents.height;
default: return 0.0; default: return 0.0;
} }
} }
@ -25,8 +25,8 @@ namespace Gtk.CairoChart {
public double get_height (Cairo.Context context) { public double get_height (Cairo.Context context) {
var extents = get_extents (context); var extents = get_extents (context);
switch (style.orientation) { switch (style.orientation) {
case FontOrient.HORIZONTAL: return extents.height; case Font.Orientation.HORIZONTAL: return extents.height;
case FontOrient.VERTICAL: return extents.width; case Font.Orientation.VERTICAL: return extents.width;
default: return 0.0; default: return 0.0;
} }
} }
@ -36,15 +36,15 @@ namespace Gtk.CairoChart {
double height; double height;
} }
public Size size (Cairo.Context context) { public Size get_size (Cairo.Context context) {
var sz = Size(); var sz = Size();
var extents = get_extents (context); var extents = get_extents (context);
switch (style.orientation) { switch (style.orientation) {
case FontOrient.HORIZONTAL: case Font.Orientation.HORIZONTAL:
sz.width = extents.width + extents.x_bearing; sz.width = extents.width + extents.x_bearing;
sz.height = extents.height; sz.height = extents.height;
break; break;
case FontOrient.VERTICAL: case Font.Orientation.VERTICAL:
sz.width = extents.height; // + extents.x_bearing ? sz.width = extents.height; // + extents.x_bearing ?
sz.height = extents.width; // +- extents.y_bearing ? sz.height = extents.width; // +- extents.y_bearing ?
break; break;
@ -53,7 +53,7 @@ namespace Gtk.CairoChart {
} }
public Text (string text = "", public Text (string text = "",
FontStyle style = FontStyle(), Font.Style style = Font.Style(),
Color color = Color()) { Color color = Color()) {
this.text = text; this.text = text;
this.style = style; this.style = style;

View File

@ -1,4 +1,4 @@
namespace Gtk.CairoChart { namespace CairoChart {
[CCode (cname = "cairo_chart_float128", has_type_id = false, cheader_filename = "cairo-chart-float128type.h")] [CCode (cname = "cairo_chart_float128", has_type_id = false, cheader_filename = "cairo-chart-float128type.h")]
public struct Float128 : double {} public struct Float128 : double {}
[CCode (cname = "cairo_chart_long_double", has_type_id = false, cheader_filename = "cairo-chart-float128type.h")] [CCode (cname = "cairo_chart_long_double", has_type_id = false, cheader_filename = "cairo-chart-float128type.h")]

View File

@ -17,18 +17,18 @@ void plot_chart1 (Chart chart) {
s1.axis_x.min = 0; s1.axis_x.max = 2; s1.axis_x.min = 0; s1.axis_x.max = 2;
s1.axis_y.min = 0; s1.axis_y.max = 3; s1.axis_y.min = 0; s1.axis_y.max = 3;
s1.place.x_low = 0.25; s1.place.x_high = 0.75; s1.place.x_min = 0.25; s1.place.x_max = 0.75;
s1.place.y_low = 0.3; s1.place.y_high = 0.9; s1.place.y_min = 0.3; s1.place.y_max = 0.9;
s2.axis_x.min = -15; s2.axis_x.max = 30; s2.axis_x.min = -15; s2.axis_x.max = 30;
s2.axis_y.min = -20; s2.axis_y.max = 200; s2.axis_y.min = -20; s2.axis_y.max = 200;
s2.place.x_low = 0.5; s2.place.x_high = 1; s2.place.x_min = 0.5; s2.place.x_max = 1;
s2.place.y_low = 0.0; s2.place.y_high = 0.5; s2.place.y_min = 0.0; s2.place.y_max = 0.5;
s3.axis_x.min = 0; s3.axis_x.max = 130; s3.axis_x.min = 0; s3.axis_x.max = 130;
s3.axis_y.min = 15; s3.axis_y.max = 35; s3.axis_y.min = 15; s3.axis_y.max = 35;
s3.place.x_low = 0; s3.place.x_high = 0.5; s3.place.x_min = 0; s3.place.x_max = 0.5;
s3.place.y_low = 0.5; s3.place.y_high = 1.0; s3.place.y_min = 0.5; s3.place.y_max = 1.0;
s2.marker_type = Series.MarkerType.CIRCLE; s2.marker_type = Series.MarkerType.CIRCLE;
s3.marker_type = Series.MarkerType.PRICLE_TRIANGLE; s3.marker_type = Series.MarkerType.PRICLE_TRIANGLE;
@ -60,18 +60,18 @@ void plot_chart2 (Chart chart) {
s1.axis_x.min = -15; s1.axis_x.max = 30; s1.axis_x.min = -15; s1.axis_x.max = 30;
s1.axis_y.min = 0; s1.axis_y.max = 3; s1.axis_y.min = 0; s1.axis_y.max = 3;
s1.place.x_low = 0.0; s1.place.x_high = 1.0; s1.place.x_min = 0.0; s1.place.x_max = 1.0;
s1.place.y_low = 0.3; s1.place.y_high = 0.9; s1.place.y_min = 0.3; s1.place.y_max = 0.9;
s2.axis_x.min = -15; s2.axis_x.max = 30; s2.axis_x.min = -15; s2.axis_x.max = 30;
s2.axis_y.min = -20; s2.axis_y.max = 200; s2.axis_y.min = -20; s2.axis_y.max = 200;
s2.place.x_low = 0.0; s2.place.x_high = 1.0; s2.place.x_min = 0.0; s2.place.x_max = 1.0;
s2.place.y_low = 0.0; s2.place.y_high = 0.5; s2.place.y_min = 0.0; s2.place.y_max = 0.5;
s3.axis_x.min = -15; s3.axis_x.max = 30; s3.axis_x.min = -15; s3.axis_x.max = 30;
s3.axis_y.min = 15; s3.axis_y.max = 35; s3.axis_y.min = 15; s3.axis_y.max = 35;
s3.place.x_low = 0.0; s3.place.x_high = 1.0; s3.place.x_min = 0.0; s3.place.x_max = 1.0;
s3.place.y_low = 0.5; s3.place.y_high = 1.0; s3.place.y_min = 0.5; s3.place.y_max = 1.0;
s1.marker_type = Series.MarkerType.PRICLE_CIRCLE; s1.marker_type = Series.MarkerType.PRICLE_CIRCLE;
s2.marker_type = Series.MarkerType.PRICLE_SQUARE; s2.marker_type = Series.MarkerType.PRICLE_SQUARE;
@ -109,18 +109,18 @@ void plot_chart3 (Chart chart) {
s1.axis_x.min = 0; s1.axis_x.max = 2; s1.axis_x.min = 0; s1.axis_x.max = 2;
s1.axis_y.min = -20; s1.axis_y.max = 200; s1.axis_y.min = -20; s1.axis_y.max = 200;
s1.place.x_low = 0.25; s1.place.x_high = 0.75; s1.place.x_min = 0.25; s1.place.x_max = 0.75;
s1.place.y_low = 0.0; s1.place.y_high = 1.0; s1.place.y_min = 0.0; s1.place.y_max = 1.0;
s2.axis_x.min = -15; s2.axis_x.max = 30; s2.axis_x.min = -15; s2.axis_x.max = 30;
s2.axis_y.min = -20; s2.axis_y.max = 200; s2.axis_y.min = -20; s2.axis_y.max = 200;
s2.place.x_low = 0.5; s2.place.x_high = 1; s2.place.x_min = 0.5; s2.place.x_max = 1;
s2.place.y_low = 0.0; s2.place.y_high = 1.0; s2.place.y_min = 0.0; s2.place.y_max = 1.0;
s3.axis_x.min = 0; s3.axis_x.max = 130; s3.axis_x.min = 0; s3.axis_x.max = 130;
s3.axis_y.min = -20; s3.axis_y.max = 200; s3.axis_y.min = -20; s3.axis_y.max = 200;
s3.place.x_low = 0; s3.place.x_high = 0.5; s3.place.x_min = 0; s3.place.x_max = 0.5;
s3.place.y_low = 0.0; s3.place.y_high = 1.0; s3.place.y_min = 0.0; s3.place.y_max = 1.0;
s2.marker_type = Series.MarkerType.PRICLE_CIRCLE; s2.marker_type = Series.MarkerType.PRICLE_CIRCLE;
s3.marker_type = Series.MarkerType.TRIANGLE; s3.marker_type = Series.MarkerType.TRIANGLE;
@ -167,23 +167,23 @@ void plot_chart4 (Chart chart) {
s1.axis_x.min = now - 100000; s1.axis_x.max = now + 100000; s1.axis_x.min = now - 100000; s1.axis_x.max = now + 100000;
s1.axis_y.min = -20; s1.axis_y.max = 200; s1.axis_y.min = -20; s1.axis_y.max = 200;
s1.place.x_low = 0.25; s1.place.x_high = 0.75; s1.place.x_min = 0.25; s1.place.x_max = 0.75;
s1.place.y_low = 0.0; s1.place.y_high = 1.0; s1.place.y_min = 0.0; s1.place.y_max = 1.0;
s2.axis_x.min = -15; s2.axis_x.max = 30; s2.axis_x.min = -15; s2.axis_x.max = 30;
s2.axis_y.min = -20; s2.axis_y.max = 200; s2.axis_y.min = -20; s2.axis_y.max = 200;
s2.place.x_low = 0.2; s2.place.x_high = 1; s2.place.x_min = 0.2; s2.place.x_max = 1;
s2.place.y_low = 0.0; s2.place.y_high = 1.0; s2.place.y_min = 0.0; s2.place.y_max = 1.0;
s3.axis_x.min = high - 2; s3.axis_x.max = high + 1; s3.axis_x.min = high - 2; s3.axis_x.max = high + 1;
s3.axis_y.min = -20; s3.axis_y.max = 200; s3.axis_y.min = -20; s3.axis_y.max = 200;
s3.place.x_low = 0; s3.place.x_high = 0.8; s3.place.x_min = 0; s3.place.x_max = 0.8;
s3.place.y_low = 0.0; s3.place.y_high = 1.0; s3.place.y_min = 0.0; s3.place.y_max = 1.0;
s4.axis_x.min = high + 0.0049; s4.axis_x.max = high + 0.0054; s4.axis_x.min = high + 0.0049; s4.axis_x.max = high + 0.0054;
s4.axis_y.min = -20; s4.axis_y.max = 200; s4.axis_y.min = -20; s4.axis_y.max = 200;
s4.place.x_low = 0.2; s4.place.x_high = 1.0; s4.place.x_min = 0.2; s4.place.x_max = 1.0;
s4.place.y_low = 0.0; s4.place.y_high = 1.0; s4.place.y_min = 0.0; s4.place.y_max = 1.0;
s2.marker_type = Series.MarkerType.PRICLE_CIRCLE; s2.marker_type = Series.MarkerType.PRICLE_CIRCLE;
s3.marker_type = Series.MarkerType.TRIANGLE; s3.marker_type = Series.MarkerType.TRIANGLE;
@ -202,10 +202,10 @@ void plot_chart4 (Chart chart) {
} }
bool point_in_chart (Chart chart, double x, double y) { bool point_in_chart (Chart chart, double x, double y) {
if (x < chart.plot_area_x_min) return false; if (x < chart.plot_x_min) return false;
if (x > chart.plot_area_x_max) return false; if (x > chart.plot_x_max) return false;
if (y < chart.plot_area_y_min) return false; if (y < chart.plot_y_min) return false;
if (y > chart.plot_area_y_max) return false; if (y > chart.plot_y_max) return false;
return true; return true;
} }
@ -230,10 +230,10 @@ int main (string[] args) {
var chart2 = new Chart(); var chart2 = new Chart();
var chart3 = new Chart(); var chart3 = new Chart();
var chart4 = new Chart(); var chart4 = new Chart();
var label = new Label ("Chart Test!"); var label = new Gtk.Label ("Chart Test!");
var button1 = new Button.with_label("Separate axes"); var button1 = new Button.with_label("Separate axes");
var button2 = new Button.with_label("Common X axes"); var button2 = new Button.with_label("Joint X axes");
var button3 = new Button.with_label("Common Y axes"); var button3 = new Button.with_label("Joint Y axes");
var button4 = new Button.with_label("Dates/Times"); var button4 = new Button.with_label("Dates/Times");
var button5 = new Button.with_label("rm Axis Titles"); var button5 = new Button.with_label("rm Axis Titles");
var button6 = new Button.with_label("Dates only"); var button6 = new Button.with_label("Dates only");
@ -245,7 +245,7 @@ int main (string[] args) {
plot_chart3 (chart3); plot_chart3 (chart3);
plot_chart4 (chart4); plot_chart4 (chart4);
chart1.selection_style = LineStyle(Color(0.3, 0.3, 0.3, 0.7), 1); chart1.selection_style = Line.Style(Color(0.3, 0.3, 0.3, 0.7), 1);
var da = new DrawingArea(); var da = new DrawingArea();
da.set_events ( Gdk.EventMask.BUTTON_PRESS_MASK da.set_events ( Gdk.EventMask.BUTTON_PRESS_MASK
@ -270,9 +270,9 @@ int main (string[] args) {
case Legend.Position.LEFT: radio_button3.set_active(true); break; case Legend.Position.LEFT: radio_button3.set_active(true); break;
case Legend.Position.BOTTOM: radio_button4.set_active(true); break; case Legend.Position.BOTTOM: radio_button4.set_active(true); break;
} }
switch (chart.cursors_orientation) { switch (chart.cursor_style.orientation) {
case Chart.CursorOrientation.VERTICAL: radio_button7.set_active(true); break; case Cursor.Orientation.VERTICAL: radio_button7.set_active(true); break;
case Chart.CursorOrientation.HORIZONTAL: radio_button8.set_active(true); break; case Cursor.Orientation.HORIZONTAL: radio_button8.set_active(true); break;
} }
}); });
button2.clicked.connect (() => { button2.clicked.connect (() => {
@ -283,9 +283,9 @@ int main (string[] args) {
case Legend.Position.LEFT: radio_button3.set_active(true); break; case Legend.Position.LEFT: radio_button3.set_active(true); break;
case Legend.Position.BOTTOM: radio_button4.set_active(true); break; case Legend.Position.BOTTOM: radio_button4.set_active(true); break;
} }
switch (chart.cursors_orientation) { switch (chart.cursor_style.orientation) {
case Chart.CursorOrientation.VERTICAL: radio_button7.set_active(true); break; case Cursor.Orientation.VERTICAL: radio_button7.set_active(true); break;
case Chart.CursorOrientation.HORIZONTAL: radio_button8.set_active(true); break; case Cursor.Orientation.HORIZONTAL: radio_button8.set_active(true); break;
} }
}); });
button3.clicked.connect (() => { button3.clicked.connect (() => {
@ -296,9 +296,9 @@ int main (string[] args) {
case Legend.Position.LEFT: radio_button3.set_active(true); break; case Legend.Position.LEFT: radio_button3.set_active(true); break;
case Legend.Position.BOTTOM: radio_button4.set_active(true); break; case Legend.Position.BOTTOM: radio_button4.set_active(true); break;
} }
switch (chart.cursors_orientation) { switch (chart.cursor_style.orientation) {
case Chart.CursorOrientation.VERTICAL: radio_button7.set_active(true); break; case Cursor.Orientation.VERTICAL: radio_button7.set_active(true); break;
case Chart.CursorOrientation.HORIZONTAL: radio_button8.set_active(true); break; case Cursor.Orientation.HORIZONTAL: radio_button8.set_active(true); break;
} }
}); });
button4.clicked.connect (() => { button4.clicked.connect (() => {
@ -309,9 +309,9 @@ int main (string[] args) {
case Legend.Position.LEFT: radio_button4.set_active(true); break; case Legend.Position.LEFT: radio_button4.set_active(true); break;
case Legend.Position.BOTTOM: radio_button4.set_active(true); break; case Legend.Position.BOTTOM: radio_button4.set_active(true); break;
} }
switch (chart.cursors_orientation) { switch (chart.cursor_style.orientation) {
case Chart.CursorOrientation.VERTICAL: radio_button7.set_active(true); break; case Cursor.Orientation.VERTICAL: radio_button7.set_active(true); break;
case Chart.CursorOrientation.HORIZONTAL: radio_button8.set_active(true); break; case Cursor.Orientation.HORIZONTAL: radio_button8.set_active(true); break;
} }
}); });
button5.clicked.connect (() => { button5.clicked.connect (() => {
@ -393,13 +393,13 @@ int main (string[] args) {
radio_button7.toggled.connect ((button) => { radio_button7.toggled.connect ((button) => {
if (button.get_active()) { if (button.get_active()) {
chart.cursors_orientation = Chart.CursorOrientation.VERTICAL; chart.cursor_style.orientation = Cursor.Orientation.VERTICAL;
da.queue_draw_area(0, 0, da.get_allocated_width(), da.get_allocated_height()); da.queue_draw_area(0, 0, da.get_allocated_width(), da.get_allocated_height());
} }
}); });
radio_button8.toggled.connect ((button) => { radio_button8.toggled.connect ((button) => {
if (button.get_active()) { if (button.get_active()) {
chart.cursors_orientation = Chart.CursorOrientation.HORIZONTAL; chart.cursor_style.orientation = Cursor.Orientation.HORIZONTAL;
da.queue_draw_area(0, 0, da.get_allocated_width(), da.get_allocated_height()); da.queue_draw_area(0, 0, da.get_allocated_width(), da.get_allocated_height());
} }
}); });
@ -431,13 +431,13 @@ int main (string[] args) {
var text_t = new Text(text); var text_t = new Text(text);
var w = text_t.get_width(context); var w = text_t.get_width(context);
var h = text_t.get_height(context); var h = text_t.get_height(context);
var x0 = chart.plot_area_x_max - w - 5; var x0 = chart.plot_x_max - w - 5;
var y0 = chart.plot_area_y_min + h + 5; var y0 = chart.plot_y_min + h + 5;
chart.set_source_rgba(chart.legend.bg_color); chart.set_source_rgba(chart.legend.bg_color);
context.rectangle (x0, y0 - h, w, h); context.rectangle (x0, y0 - h, w, h);
context.fill(); context.fill();
context.move_to (x0, y0); context.move_to (x0, y0);
chart.set_source_rgba(chart.common_axis_color); chart.set_source_rgba(chart.joint_axis_color);
context.show_text(text); context.show_text(text);
} }