In progress...

This commit is contained in:
Kolan Sh 2018-01-16 14:29:24 +03:00
parent bc63b1ef99
commit e5fa432384
2 changed files with 32 additions and 17 deletions

View File

@ -41,8 +41,14 @@ namespace CairoChart {
public bool zoom_show = true;
protected Chart chart { get; protected set; default = null; }
public Series (Chart chart) {
this.chart = chart;
}
public virtual Series copy () {
var series = new Series ();
var series = new Series (chart);
series._color = this._color;
series.axis_x = this.axis_x.copy ();
series.axis_y = this.axis_y.copy ();
@ -57,9 +63,6 @@ namespace CairoChart {
return series;
}
public Series () {
}
public virtual void draw (Chart chart) {
var points = chart.math.sort_points(this, sort);
line_style.set(chart);
@ -466,5 +469,17 @@ namespace CairoChart {
+ (s.axis_y.title.text == "" ? 0 : sz.width + s.axis_y.font_indent); break;
}
}
public virtual double compact_rec_x_pos (Series s, Float128 x, Text text) {
var sz = text.get_size(chart.context);
return chart.get_scr_x(s, x) - sz.width / 2.0
- sz.width * (x - (s.axis_x.zoom_min + s.axis_x.zoom_max) / 2.0) / (s.axis_x.zoom_max - s.axis_x.zoom_min);
}
public virtual double compact_rec_y_pos (Series s, Float128 y, Text text) {
var sz = text.get_size(chart.context);
return chart.get_scr_y(s, y) + sz.height / 2.0
+ sz.height * (y - (s.axis_y.zoom_min + s.axis_y.zoom_max) / 2.0) / (s.axis_y.zoom_max - s.axis_y.zoom_min);
}
}
}

View File

@ -1,9 +1,9 @@
using Gtk, CairoChart;
void plot_chart1 (Chart chart) {
var s1 = new Series ();
var s2 = new Series ();
var s3 = new Series ();
var s1 = new Series (chart);
var s2 = new Series (chart);
var s3 = new Series (chart);
s1.title = new Text("Series 1"); s1.color = Color (1, 0, 0);
s1.points = {Point128(0, 0), Point128(2, 1), Point128(1, 3)};
@ -45,9 +45,9 @@ void plot_chart1 (Chart chart) {
}
void plot_chart2 (Chart chart) {
var s1 = new Series ();
var s2 = new Series ();
var s3 = new Series ();
var s1 = new Series (chart);
var s2 = new Series (chart);
var s3 = new Series (chart);
s1.title = new Text("Series 1"); s1.color = Color (1, 0, 0);
s1.points = {Point128(-12, 0), Point128(2, 1), Point128(20, 3)};
@ -93,9 +93,9 @@ void plot_chart2 (Chart chart) {
}
void plot_chart3 (Chart chart) {
var s1 = new Series ();
var s2 = new Series ();
var s3 = new Series ();
var s1 = new Series (chart);
var s2 = new Series (chart);
var s3 = new Series (chart);
s1.title = new Text("Series 1"); s1.color = Color (1, 0, 0);
s1.points = {Point128(0, 70), Point128(2, 155), Point128(1, -3)};
@ -141,10 +141,10 @@ void plot_chart3 (Chart chart) {
}
void plot_chart4 (Chart chart) {
var s1 = new Series ();
var s2 = new Series ();
var s3 = new Series ();
var s4 = new Series ();
var s1 = new Series (chart);
var s2 = new Series (chart);
var s3 = new Series (chart);
var s4 = new Series (chart);
s1.axis_x.type = Axis.Type.DATE_TIME;
s3.axis_x.type = Axis.Type.DATE_TIME;