OK In progress...
This commit is contained in:
parent
8bc81c7508
commit
e02c30e374
|
@ -58,7 +58,7 @@ namespace CairoChart {
|
||||||
/**
|
/**
|
||||||
* Cursor style.
|
* Cursor style.
|
||||||
*/
|
*/
|
||||||
public Cursors.Style cursor_style = Cursors.Style();
|
public Cursors.Style style = Cursors.Style();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Has crossings.
|
* Has crossings.
|
||||||
|
@ -81,7 +81,7 @@ namespace CairoChart {
|
||||||
c.list = list.copy();
|
c.list = list.copy();
|
||||||
c.active_cursor = active_cursor;
|
c.active_cursor = active_cursor;
|
||||||
c.is_cursor_active = is_cursor_active;
|
c.is_cursor_active = is_cursor_active;
|
||||||
c.cursor_style = cursor_style;
|
c.style = style;
|
||||||
c.crossings = crossings;
|
c.crossings = crossings;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ namespace CairoChart {
|
||||||
uint i = 0;
|
uint i = 0;
|
||||||
foreach (var c in list) {
|
foreach (var c in list) {
|
||||||
double d = distance;
|
double d = distance;
|
||||||
switch (cursor_style.orientation) {
|
switch (style.orientation) {
|
||||||
case Cursors.Orientation.VERTICAL: d = (rel2scr_x(c.x) - rel2scr_x(active_cursor.x)).abs(); break;
|
case Cursors.Orientation.VERTICAL: d = (rel2scr_x(c.x) - rel2scr_x(active_cursor.x)).abs(); break;
|
||||||
case Cursors.Orientation.HORIZONTAL: d = (rel2scr_y(c.y) - rel2scr_y(active_cursor.y)).abs(); break;
|
case Cursors.Orientation.HORIZONTAL: d = (rel2scr_y(c.y) - rel2scr_y(active_cursor.y)).abs(); break;
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ namespace CairoChart {
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
if (distance < cursor_style.select_distance)
|
if (distance < style.select_distance)
|
||||||
list.delete_link(list.nth(rm_indx));
|
list.delete_link(list.nth(rm_indx));
|
||||||
is_cursor_active = false;
|
is_cursor_active = false;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ namespace CairoChart {
|
||||||
|
|
||||||
for (var ci = 0, max_ci = all_cursors.length(); ci < max_ci; ++ci) {
|
for (var ci = 0, max_ci = all_cursors.length(); ci < max_ci; ++ci) {
|
||||||
var c = all_cursors.nth_data(ci);
|
var c = all_cursors.nth_data(ci);
|
||||||
switch (cursor_style.orientation) {
|
switch (style.orientation) {
|
||||||
case Orientation.VERTICAL: if (c.x <= chart.zoom.x0 || c.x >= chart.zoom.x1) continue; break;
|
case Orientation.VERTICAL: if (c.x <= chart.zoom.x0 || c.x >= chart.zoom.x1) continue; break;
|
||||||
case Orientation.HORIZONTAL: if (c.y <= chart.zoom.y0 || c.y >= chart.zoom.y1) continue; break;
|
case Orientation.HORIZONTAL: if (c.y <= chart.zoom.y0 || c.y >= chart.zoom.y1) continue; break;
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ namespace CairoChart {
|
||||||
var points = Math.sort_points (s, s.sort);
|
var points = Math.sort_points (s, s.sort);
|
||||||
|
|
||||||
for (var i = 0; i + 1 < points.length; ++i) {
|
for (var i = 0; i + 1 < points.length; ++i) {
|
||||||
switch (cursor_style.orientation) {
|
switch (style.orientation) {
|
||||||
case Orientation.VERTICAL:
|
case Orientation.VERTICAL:
|
||||||
Float128 y = 0;
|
Float128 y = 0;
|
||||||
if (Math.vcross(s.get_scr_point(points[i]), s.get_scr_point(points[i+1]), rel2scr_x(c.x),
|
if (Math.vcross(s.get_scr_point(points[i]), s.get_scr_point(points[i+1]), rel2scr_x(c.x),
|
||||||
|
@ -202,7 +202,7 @@ namespace CairoChart {
|
||||||
var low = Point128(chart.plarea.x1, chart.plarea.y1); // low and high
|
var low = Point128(chart.plarea.x1, chart.plarea.y1); // low and high
|
||||||
var high = Point128(chart.plarea.x0, chart.plarea.y0); // points of the cursor
|
var high = Point128(chart.plarea.x0, chart.plarea.y0); // points of the cursor
|
||||||
unowned CursorCross[] ccs = crossings[cci].crossings;
|
unowned CursorCross[] ccs = crossings[cci].crossings;
|
||||||
cursor_style.line_style.apply(chart);
|
style.line_style.apply(chart);
|
||||||
for (var ci = 0, max_ci = ccs.length; ci < max_ci; ++ci) {
|
for (var ci = 0, max_ci = ccs.length; ci < max_ci; ++ci) {
|
||||||
var si = ccs[ci].series_index;
|
var si = ccs[ci].series_index;
|
||||||
var s = chart.series[si];
|
var s = chart.series[si];
|
||||||
|
@ -241,7 +241,7 @@ namespace CairoChart {
|
||||||
|
|
||||||
var c = all_cursors.nth_data(crossings[cci].cursor_index);
|
var c = all_cursors.nth_data(crossings[cci].cursor_index);
|
||||||
|
|
||||||
switch (cursor_style.orientation) {
|
switch (style.orientation) {
|
||||||
case Orientation.VERTICAL:
|
case Orientation.VERTICAL:
|
||||||
if (low.y > high.y) continue;
|
if (low.y > high.y) continue;
|
||||||
chart.ctx.move_to (rel2scr_x(c.x), low.y);
|
chart.ctx.move_to (rel2scr_x(c.x), low.y);
|
||||||
|
@ -392,7 +392,7 @@ namespace CairoChart {
|
||||||
delta = 0;
|
delta = 0;
|
||||||
if (chart.series.length == 0) return false;
|
if (chart.series.length == 0) return false;
|
||||||
if (list.length() + (is_cursor_active ? 1 : 0) != 2) return false;
|
if (list.length() + (is_cursor_active ? 1 : 0) != 2) return false;
|
||||||
if (chart.joint_x && cursor_style.orientation == Orientation.VERTICAL) {
|
if (chart.joint_x && style.orientation == Orientation.VERTICAL) {
|
||||||
Float128 val1 = chart.series[chart.zoom_1st_idx].get_real_x(rel2scr_x(list.nth_data(0).x));
|
Float128 val1 = chart.series[chart.zoom_1st_idx].get_real_x(rel2scr_x(list.nth_data(0).x));
|
||||||
Float128 val2 = 0;
|
Float128 val2 = 0;
|
||||||
if (is_cursor_active)
|
if (is_cursor_active)
|
||||||
|
@ -405,7 +405,7 @@ namespace CairoChart {
|
||||||
delta = val1 - val2;
|
delta = val1 - val2;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (chart.joint_y && cursor_style.orientation == Orientation.HORIZONTAL) {
|
if (chart.joint_y && style.orientation == Orientation.HORIZONTAL) {
|
||||||
Float128 val1 = chart.series[chart.zoom_1st_idx].get_real_y(rel2scr_y(list.nth_data(0).y));
|
Float128 val1 = chart.series[chart.zoom_1st_idx].get_real_y(rel2scr_y(list.nth_data(0).y));
|
||||||
Float128 val2 = 0;
|
Float128 val2 = 0;
|
||||||
if (is_cursor_active)
|
if (is_cursor_active)
|
||||||
|
@ -494,7 +494,7 @@ namespace CairoChart {
|
||||||
protected virtual void cross_what_to_show (Series s, out bool show_x, out bool show_time,
|
protected virtual void cross_what_to_show (Series s, out bool show_x, out bool show_time,
|
||||||
out bool show_date, out bool show_y) {
|
out bool show_date, out bool show_y) {
|
||||||
show_x = show_time = show_date = show_y = false;
|
show_x = show_time = show_date = show_y = false;
|
||||||
switch (cursor_style.orientation) {
|
switch (style.orientation) {
|
||||||
case Orientation.VERTICAL:
|
case Orientation.VERTICAL:
|
||||||
show_y = true;
|
show_y = true;
|
||||||
if (!chart.joint_x)
|
if (!chart.joint_x)
|
||||||
|
|
|
@ -111,7 +111,7 @@ namespace CairoChart {
|
||||||
|
|
||||||
// for 4.2. Cursor values for joint X axis
|
// for 4.2. Cursor values for joint X axis
|
||||||
if (si == chart.zoom_1st_idx && chart.cursors.has_crossings) {
|
if (si == chart.zoom_1st_idx && chart.cursors.has_crossings) {
|
||||||
switch (chart.cursors.cursor_style.orientation) {
|
switch (chart.cursors.style.orientation) {
|
||||||
case Cursors.Orientation.VERTICAL:
|
case Cursors.Orientation.VERTICAL:
|
||||||
if (is_x && chart.joint_x) {
|
if (is_x && chart.joint_x) {
|
||||||
var tmp = max_rec_height + axis.font.vspacing;
|
var tmp = max_rec_height + axis.font.vspacing;
|
||||||
|
@ -178,7 +178,7 @@ namespace CairoChart {
|
||||||
if (x_min < s.axis_x.range.zmin) x_min += step;
|
if (x_min < s.axis_x.range.zmin) x_min += step;
|
||||||
|
|
||||||
// 4.2. Cursor values for joint X axis
|
// 4.2. Cursor values for joint X axis
|
||||||
if (chart.joint_x && chart.cursors.cursor_style.orientation == Cursors.Orientation.VERTICAL && chart.cursors.has_crossings) {
|
if (chart.joint_x && chart.cursors.style.orientation == Cursors.Orientation.VERTICAL && chart.cursors.has_crossings) {
|
||||||
var tmp = max_rec_height + s.axis_x.font.vspacing;
|
var tmp = max_rec_height + s.axis_x.font.vspacing;
|
||||||
switch (s.axis_x.position) {
|
switch (s.axis_x.position) {
|
||||||
case Axis.Position.LOW: chart.evarea.y1 -= tmp; break;
|
case Axis.Position.LOW: chart.evarea.y1 -= tmp; break;
|
||||||
|
@ -245,7 +245,7 @@ namespace CairoChart {
|
||||||
if (y_min < s.axis_y.range.zmin) y_min += step;
|
if (y_min < s.axis_y.range.zmin) y_min += step;
|
||||||
|
|
||||||
// 4.2. Cursor values for joint Y axis
|
// 4.2. Cursor values for joint Y axis
|
||||||
if (chart.joint_y && chart.cursors.cursor_style.orientation == Cursors.Orientation.HORIZONTAL && chart.cursors.has_crossings) {
|
if (chart.joint_y && chart.cursors.style.orientation == Cursors.Orientation.HORIZONTAL && chart.cursors.has_crossings) {
|
||||||
var tmp = max_rec_width + s.axis_y.font.hspacing;
|
var tmp = max_rec_width + s.axis_y.font.hspacing;
|
||||||
switch (s.axis_y.position) {
|
switch (s.axis_y.position) {
|
||||||
case Axis.Position.LOW: chart.evarea.x0 += tmp; break;
|
case Axis.Position.LOW: chart.evarea.x0 += tmp; break;
|
||||||
|
|
|
@ -165,6 +165,7 @@ void plot_chart3 (Chart chart) {
|
||||||
s3.axis_y.title = new Text(chart, "All Series: Axis Y.");
|
s3.axis_y.title = new Text(chart, "All Series: Axis Y.");
|
||||||
|
|
||||||
//s1.axis_y.position = s2.axis_y.position = s3.axis_y.position = Axis.Position.LOW;
|
//s1.axis_y.position = s2.axis_y.position = s3.axis_y.position = Axis.Position.LOW;
|
||||||
|
chart.cursors.style.orientation = Cursors.Orientation.HORIZONTAL;
|
||||||
|
|
||||||
chart.series = { s1, s2, s3 };
|
chart.series = { s1, s2, s3 };
|
||||||
}
|
}
|
||||||
|
@ -231,6 +232,8 @@ void plot_chart4 (Chart chart) {
|
||||||
s4.axis_x.title = new Text(chart, "Series 4: Axis X.");
|
s4.axis_x.title = new Text(chart, "Series 4: Axis X.");
|
||||||
s4.axis_y.title = new Text(chart, "All Series: Axis Y.");
|
s4.axis_y.title = new Text(chart, "All Series: Axis Y.");
|
||||||
|
|
||||||
|
chart.cursors.style.orientation = Cursors.Orientation.HORIZONTAL;
|
||||||
|
|
||||||
chart.series = { s1, s2, s3, s4 };
|
chart.series = { s1, s2, s3, s4 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,7 +306,7 @@ 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.cursor_style.orientation) {
|
switch (chart.cursors.style.orientation) {
|
||||||
case Cursors.Orientation.VERTICAL: radio_button7.set_active(true); break;
|
case Cursors.Orientation.VERTICAL: radio_button7.set_active(true); break;
|
||||||
case Cursors.Orientation.HORIZONTAL: radio_button8.set_active(true); break;
|
case Cursors.Orientation.HORIZONTAL: radio_button8.set_active(true); break;
|
||||||
}
|
}
|
||||||
|
@ -316,7 +319,7 @@ 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.cursor_style.orientation) {
|
switch (chart.cursors.style.orientation) {
|
||||||
case Cursors.Orientation.VERTICAL: radio_button7.set_active(true); break;
|
case Cursors.Orientation.VERTICAL: radio_button7.set_active(true); break;
|
||||||
case Cursors.Orientation.HORIZONTAL: radio_button8.set_active(true); break;
|
case Cursors.Orientation.HORIZONTAL: radio_button8.set_active(true); break;
|
||||||
}
|
}
|
||||||
|
@ -329,7 +332,7 @@ 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.cursor_style.orientation) {
|
switch (chart.cursors.style.orientation) {
|
||||||
case Cursors.Orientation.VERTICAL: radio_button7.set_active(true); break;
|
case Cursors.Orientation.VERTICAL: radio_button7.set_active(true); break;
|
||||||
case Cursors.Orientation.HORIZONTAL: radio_button8.set_active(true); break;
|
case Cursors.Orientation.HORIZONTAL: radio_button8.set_active(true); break;
|
||||||
}
|
}
|
||||||
|
@ -342,7 +345,7 @@ 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.cursor_style.orientation) {
|
switch (chart.cursors.style.orientation) {
|
||||||
case Cursors.Orientation.VERTICAL: radio_button7.set_active(true); break;
|
case Cursors.Orientation.VERTICAL: radio_button7.set_active(true); break;
|
||||||
case Cursors.Orientation.HORIZONTAL: radio_button8.set_active(true); break;
|
case Cursors.Orientation.HORIZONTAL: radio_button8.set_active(true); break;
|
||||||
}
|
}
|
||||||
|
@ -426,13 +429,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.cursor_style.orientation = Cursors.Orientation.VERTICAL;
|
chart.cursors.style.orientation = Cursors.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.cursor_style.orientation = Cursors.Orientation.HORIZONTAL;
|
chart.cursors.style.orientation = Cursors.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());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue