Compare commits
244 Commits
Author | SHA1 | Date |
---|---|---|
Kolan Sh | 21f8e595ec | |
Kolan Sh | 74ba064a56 | |
Kolan Sh | 36aba3995a | |
Kolan Sh | 3fd9f3f9b1 | |
Kolan Sh | b5a173f4ed | |
Kolan Sh | d285906004 | |
Kolan Sh | e11e8466a1 | |
Kolan Sh | 2a0870a482 | |
Kolan Sh | 85eedafd2a | |
Kolan Sh | 803a7c3cb6 | |
Kolan Sh | 9c3a43590c | |
Kolan Sh | a1af698985 | |
Kolan Sh | 6672e08132 | |
Kolan Sh | 2f0ee8b45a | |
Kolan Sh | 6336779adc | |
Kolan Sh | ea84cb3a0c | |
Kolan Sh | 4b8947eaf3 | |
Kolan Sh | 6e351ff465 | |
Kolan Sh | ca6392a6d9 | |
Kolan Sh | 9ce7f7b174 | |
Kolan Sh | 7de36e6dad | |
Kolan Sh | 7791e4e1a5 | |
Kolan Sh | d8d2578b79 | |
Kolan Sh | a0ae3227a7 | |
Kolan Sh | c4b3002913 | |
Kolan Sh | 7cb09a99e8 | |
Kolan Sh | 72c2be67d4 | |
Kolan Sh | a0fd760218 | |
Kolan Sh | 50bf6bcdc3 | |
Kolan Sh | c07de77845 | |
Kolan Sh | 63346514fd | |
Kolan Sh | f844b70f26 | |
Kolan Sh | 08e154ce6a | |
Kolan Sh | fa93997f27 | |
Kolan Sh | 7759d914a0 | |
Kolan Sh | dc60f2ea92 | |
Kolan Sh | ca63a3af3b | |
Kolan Sh | bb2b61421b | |
Kolan Sh | e7cb034b68 | |
Kolan Sh | c35376d566 | |
Kolan Sh | e7d9dfb5d3 | |
Kolan Sh | 4191423b91 | |
Kolan Sh | a1709429fa | |
Kolan Sh | 615c333baf | |
Kolan Sh | e9ab537a56 | |
Kolan Sh | ee6dde9731 | |
Kolan Sh | 796cabe307 | |
Kolan Sh | 3e89c9dfdf | |
Kolan Sh | 30c15c62bc | |
Kolan Sh | e02c30e374 | |
Kolan Sh | 8bc81c7508 | |
Kolan Sh | 10fc250f5f | |
Kolan Sh | 6de38bdb9f | |
Kolan Sh | 6f7bc6761d | |
Kolan Sh | 5c556195e3 | |
Kolan Sh | 8aeadccda2 | |
Kolan Sh | bd83013c40 | |
Kolan Sh | 5b8b712cea | |
Kolan Sh | d676040023 | |
Kolan Sh | 7029f1f906 | |
Kolan Sh | 1eee87fb1a | |
Kolan Sh | 820e5d4526 | |
Kolan Sh | 171c5d51ba | |
Kolan Sh | b401f53077 | |
Kolan Sh | 4626587d45 | |
Kolan Sh | 491c303d4f | |
Kolan Sh | 26334b2704 | |
Kolan Sh | 18968bd3a9 | |
Kolan Sh | 96d275c339 | |
Kolan Sh | d24149d215 | |
Kolan Sh | e0f9197cea | |
Kolan Sh | 0d142ac4db | |
Kolan Sh | 4628b6cdd7 | |
Kolan Sh | 5342b49bf7 | |
Kolan Sh | 5db6dfc490 | |
Kolan Sh | b46de48825 | |
Kolan Sh | e5c0f4d898 | |
Kolan Sh | d3f73e135b | |
Kolan Sh | 857b6f38e4 | |
Kolan Sh | 1161b6a75b | |
Kolan Sh | 47bc860e3d | |
Kolan Sh | bcb847c65e | |
Kolan Sh | ded95b77ce | |
Kolan Sh | f304e98f80 | |
Kolan Sh | 56ed4a5f3e | |
Kolan Sh | 946974b3d0 | |
Kolan Sh | 644c7b4409 | |
Kolan Sh | 97721385fc | |
Kolan Sh | 9d1f368a93 | |
Kolan Sh | 31beca41d7 | |
Kolan Sh | d867098745 | |
Kolan Sh | a6839c3211 | |
Kolan Sh | e01bc80210 | |
Kolan Sh | cf0e81e076 | |
Kolan Sh | b4ada02aa5 | |
Kolan Sh | 6adc0a57b6 | |
Kolan Sh | b382247757 | |
Kolan Sh | e402ee7ec4 | |
Kolan Sh | 46fe83e78c | |
Kolan Sh | 4e6045d160 | |
Kolan Sh | 9a03af4b85 | |
Kolan Sh | cf0527be5f | |
Kolan Sh | fb190923ab | |
Kolan Sh | d0c87519ee | |
Kolan Sh | b7f6e6cf79 | |
Kolan Sh | 26030290d4 | |
Kolan Sh | a3f83df580 | |
Kolan Sh | e6cad468e0 | |
Kolan Sh | a45ac5d20f | |
Kolan Sh | bd4e6089c9 | |
Kolan Sh | ee52791eca | |
Kolan Sh | 2d4d01d532 | |
Kolan Sh | dc9b896232 | |
Kolan Sh | d9f79241dc | |
Kolan Sh | 67a8067bd4 | |
Kolan Sh | dd7ee462c8 | |
Kolan Sh | 94734a26fc | |
Kolan Sh | 2e625bf58c | |
Kolan Sh | 56dcbf348d | |
Kolan Sh | 2f0aa310b9 | |
Kolan Sh | 2059f787af | |
Kolan Sh | fca07bd695 | |
Kolan Sh | 3d3eb05c3c | |
Kolan Sh | d5e18999f8 | |
Kolan Sh | 545221c11f | |
Kolan Sh | 5c8904d502 | |
Kolan Sh | 6bbce0fd5e | |
Kolan Sh | 21c39c46a0 | |
Kolan Sh | 2390bfdf8d | |
Kolan Sh | 620a1c167c | |
Kolan Sh | 89132d91fc | |
Kolan Sh | 7fcacaed2d | |
Kolan Sh | ca8340946b | |
Kolan Sh | 3c295b0bf8 | |
Kolan Sh | 80cc8bfade | |
Kolan Sh | 54b8d430dc | |
Kolan Sh | 5f39fa57b6 | |
Kolan Sh | f60b3f474e | |
Kolan Sh | 776ff5e01b | |
Kolan Sh | ad04ed2e2a | |
Kolan Sh | 15e244ada3 | |
Kolan Sh | 548863c0e8 | |
Kolan Sh | 277e0a407b | |
Kolan Sh | 0336a401ec | |
Kolan Sh | a0ba04bdad | |
Kolan Sh | 40ca272825 | |
Kolan Sh | c3acff1a4c | |
Kolan Sh | b77501b03c | |
Kolan Sh | 036d9db437 | |
Kolan Sh | 6e09e42b95 | |
Kolan Sh | b685e371dd | |
Kolan Sh | b623e216dc | |
Kolan Sh | 825f9ac978 | |
Kolan Sh | 26212825dd | |
Kolan Sh | 3a00c0c9d7 | |
Kolan Sh | d77af13521 | |
Kolan Sh | e2c43bad45 | |
Kolan Sh | 54d805fc36 | |
Kolan Sh | 715d4185b8 | |
Kolan Sh | e48c8a1f5a | |
Kolan Sh | 014761c393 | |
Kolan Sh | 7aedf10a4e | |
Kolan Sh | 229adb7028 | |
Kolan Sh | a2ed8e2e25 | |
Kolan Sh | 0a1ccba521 | |
Kolan Sh | 11b87fe895 | |
Kolan Sh | 6b0013eb8e | |
Kolan Sh | 9004e4e835 | |
Kolan Sh | 35018eeb4d | |
Kolan Sh | 0a24356ae6 | |
Kolan Sh | b2d629c455 | |
Kolan Sh | 272cefc395 | |
Kolan Sh | 92c3548943 | |
Kolan Sh | 91cd77c5cd | |
Kolan Sh | ad5c5420b0 | |
Kolan Sh | 219a27f73c | |
Kolan Sh | 0fed63c109 | |
Kolan Sh | 3aaa53e96c | |
Kolan Sh | a8d3939ff6 | |
Kolan Sh | 3dd7e4ce88 | |
Kolan Sh | 29b4cac4f9 | |
Kolan Sh | 87e05a20b2 | |
Kolan Sh | ebd7e17978 | |
Kolan Sh | d3209aec5b | |
Kolan Sh | b4bc90c45d | |
Kolan Sh | e0bf3884c4 | |
Kolan Sh | 55f2ced6bb | |
Kolan Sh | ada0922c69 | |
Kolan Sh | cb90a82119 | |
Kolan Sh | 2d1f588393 | |
Kolan Sh | b14abc7ef6 | |
Kolan Sh | 7bb7ca1b6f | |
Kolan Sh | 43836e1c56 | |
Kolan Sh | a79254c716 | |
Kolan Sh | df3c3b1693 | |
Kolan Sh | 621dd5f685 | |
Kolan Sh | cb4f15f24d | |
Kolan Sh | 1aed98dfec | |
Kolan Sh | efa0c07ccb | |
Kolan Sh | 8fd012dce5 | |
Kolan Sh | 374b07e049 | |
Kolan Sh | 117796a64c | |
Kolan Sh | b6a8c4e6ee | |
Kolan Sh | fb7971fed6 | |
Kolan Sh | 597007a6f9 | |
Kolan Sh | e682d881ff | |
Kolan Sh | e5fa432384 | |
Kolan Sh | bc63b1ef99 | |
Kolan Sh | 7db26d2154 | |
Kolan Sh | 20e73e9649 | |
Kolan Sh | f5beec873b | |
Kolan Sh | 0cc6f1cf07 | |
Kolan Sh | bcad51fa89 | |
Kolan Sh | 57d5b886d4 | |
Kolan Sh | c73ad17848 | |
Kolan Sh | a0b1c0fb6a | |
Kolan Sh | bd232baeb8 | |
Kolan Sh | 5b32dbec64 | |
Kolan Sh | c948a37cea | |
Kolan Sh | 42feb73732 | |
Kolan Sh | 4ff32b797e | |
Kolan Sh | a3bbf50b6f | |
Kolan Sh | dcfb85126e | |
Kolan Sh | 328a579ad7 | |
Kolan Sh | eb8fada021 | |
Kolan Sh | 2b25f9c554 | |
Kolan Sh | db93ad0bd3 | |
Kolan Sh | a7aa97bea5 | |
Kolan Sh | 73b0ebdcb0 | |
Kolan Sh | a73d81fc89 | |
Kolan Sh | 1d9912da49 | |
Kolan Sh | 4fdde11861 | |
Kolan Sh | 348fae7605 | |
Kolan Sh | 3a57fdfde1 | |
Kolan Sh | 912446f296 | |
Kolan Sh | d114385034 | |
Kolan Sh | c0ca87a207 | |
Kolan Sh | 76fb9d8797 | |
Kolan Sh | 6e577891ae | |
Kolan Sh | 94ed3ecabb | |
Kolan Sh | eeb6fca796 | |
Kolan Sh | 00278899fd | |
Kolan Sh | 6f5e5773d2 | |
Kolan Sh | d67e2c2691 |
|
@ -6,8 +6,8 @@ SET (PROJECT_LOWERCASE_NAME "cairo-chart")
|
||||||
SET (PROJECT_DESCRIPTION "GtkChart for Gtk.DrawingArea (Cairo).")
|
SET (PROJECT_DESCRIPTION "GtkChart for Gtk.DrawingArea (Cairo).")
|
||||||
|
|
||||||
SET (MAJOR 0)
|
SET (MAJOR 0)
|
||||||
SET (MINOR 2)
|
SET (MINOR 1)
|
||||||
SET (PATCH 0)
|
SET (PATCH 1)
|
||||||
|
|
||||||
LIST (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/backbone)
|
LIST (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/backbone)
|
||||||
|
|
||||||
|
|
17
README.md
17
README.md
|
@ -8,14 +8,13 @@ Git: https://git.backbone.ws/gtk/cairo-chart
|
||||||
|
|
||||||
## View YouTube movie
|
## View YouTube movie
|
||||||
|
|
||||||
[![View video](https://img.youtube.com/vi/GpnObfofqYI/0.jpg)](https://www.youtube.com/watch?v=GpnObfofqYI)
|
[![View video](https://img.youtube.com/vi/wmZAw2csjQg/0.jpg)](https://www.youtube.com/watch?v=wmZAw2csjQg)
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
![Screenshot1](https://redmine.backbone.ws/attachments/download/444/20180221_122422.png)
|
![Screenshot1](https://redmine.backbone.ws/attachments/download/424/20171225_020441.png)
|
||||||
![Screenshot2](https://redmine.backbone.ws/attachments/download/443/20180221_122449.png)
|
![Screenshot2](https://redmine.backbone.ws/attachments/download/425/20171225_020414.png)
|
||||||
![Screenshot3](https://redmine.backbone.ws/attachments/download/442/20180221_122459.png)
|
![Screenshot3](https://redmine.backbone.ws/attachments/download/426/20171225_020350.png)
|
||||||
![Screenshot4](https://redmine.backbone.ws/attachments/download/441/20180221_122508.png)
|
![Screenshot4](https://redmine.backbone.ws/attachments/download/427/20171225_020330.png)
|
||||||
![Screenshot5](https://redmine.backbone.ws/attachments/download/440/20180221_122535.png)
|
![Screenshot5](https://redmine.backbone.ws/attachments/download/428/20171225_020315.png)
|
||||||
![Screenshot6](https://redmine.backbone.ws/attachments/download/439/20180221_122520.png)
|
![Screenshot6](https://redmine.backbone.ws/attachments/download/429/20171225_020301.png)
|
||||||
![Screenshot7](https://redmine.backbone.ws/attachments/download/438/20180221_122546.png)
|
![Screenshot7](https://redmine.backbone.ws/attachments/download/430/20171225_020237.png)
|
||||||
![Screenshot8](https://redmine.backbone.ws/attachments/download/437/20180221_122553.png)
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 9ba1995060ebb1c65ac9855e3671b3992c859059
|
Subproject commit 5aec8e830a52e88f61c8844ac15dca72b1ef7f06
|
109
src/Axis.vala
109
src/Axis.vala
|
@ -156,12 +156,12 @@ namespace CairoChart {
|
||||||
/**
|
/**
|
||||||
* ``Axis`` line style.
|
* ``Axis`` line style.
|
||||||
*/
|
*/
|
||||||
public LineStyle grid_style = LineStyle(Color(0, 0, 0, 0.25)); // Color(), 1, {2, 3});
|
public LineStyle grid_style = LineStyle (Color(), 1, {2, 3});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of equally placed points to evaluate records sizes.
|
* Number of equally placed points to evaluate records sizes.
|
||||||
*/
|
*/
|
||||||
public int nrecords = 8;
|
public int nrecords = 128;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new ``Axis``.
|
* Constructs a new ``Axis``.
|
||||||
|
@ -250,7 +250,7 @@ namespace CairoChart {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws axis.
|
* Draws horizontal axis.
|
||||||
* @param nskip number of series to skip printing.
|
* @param nskip number of series to skip printing.
|
||||||
*/
|
*/
|
||||||
public virtual void draw (ref int nskip) {
|
public virtual void draw (ref int nskip) {
|
||||||
|
@ -305,40 +305,6 @@ namespace CairoChart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var max_rec_spacing = 2 * (is_x ? font.vspacing : font.hspacing);
|
|
||||||
var max_title_width = title.text == "" ? 0 : title.width + font.hspacing;
|
|
||||||
var max_title_height = title.text == "" ? 0 : title.height + font.vspacing;
|
|
||||||
|
|
||||||
var dx = max_rec_width + max_rec_spacing + max_title_width;
|
|
||||||
var dy = max_rec_height + max_rec_spacing + max_title_height;
|
|
||||||
chart.evarea.x0 -= dx; chart.evarea.x1 += dx; chart.evarea.y0 -= dy; chart.evarea.y1 += dy;
|
|
||||||
|
|
||||||
if (nskip != 0)
|
|
||||||
--nskip;
|
|
||||||
else {
|
|
||||||
var max_rec_height_all = max_rec_height;
|
|
||||||
var max_rec_width_all = max_rec_width;
|
|
||||||
if (is_x)
|
|
||||||
join_rel_axes (si, true, ref max_rec_width_all, ref max_rec_height_all, ref max_rec_spacing, ref max_title_height, ref nskip);
|
|
||||||
else
|
|
||||||
join_rel_axes (si, true, ref max_rec_width_all, ref max_rec_height_all, ref max_rec_spacing, ref max_title_width, ref nskip);
|
|
||||||
|
|
||||||
if (is_x && (!chart.joint_x || si == chart.zoom_1st_idx)) {
|
|
||||||
var tmp = max_rec_height_all + max_rec_spacing + max_title_height;
|
|
||||||
switch (position) {
|
|
||||||
case Position.LOW: chart.evarea.y1 -= tmp; break;
|
|
||||||
case Position.HIGH: chart.evarea.y0 += tmp; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!is_x && (!chart.joint_y || si == chart.zoom_1st_idx)) {
|
|
||||||
var tmp = max_rec_width_all + max_rec_spacing + max_title_width;
|
|
||||||
switch (position) {
|
|
||||||
case Position.LOW: chart.evarea.x0 += tmp; break;
|
|
||||||
case Position.HIGH: chart.evarea.x1 -= tmp; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4.5. Draw Axis title
|
// 4.5. Draw Axis title
|
||||||
if (title.text != "") {
|
if (title.text != "") {
|
||||||
if (is_x) {
|
if (is_x) {
|
||||||
|
@ -373,9 +339,26 @@ namespace CairoChart {
|
||||||
if (is_x) draw_recs (min, step, max_rec_height);
|
if (is_x) draw_recs (min, step, max_rec_height);
|
||||||
else draw_recs (min, step, max_rec_width);
|
else draw_recs (min, step, max_rec_width);
|
||||||
|
|
||||||
chart.evarea.x0 += dx; chart.evarea.x1 -= dx; chart.evarea.y0 += dy; chart.evarea.y1 -= dy;
|
|
||||||
|
|
||||||
chart.ctx.stroke ();
|
chart.ctx.stroke ();
|
||||||
|
|
||||||
|
var tmp1 = 0.0, tmp2 = 0.0, tmp3 = 0.0, tmp4 = 0.0;
|
||||||
|
join_rel_axes (si, false, ref tmp1, ref tmp2, ref tmp3, ref tmp4, ref nskip);
|
||||||
|
|
||||||
|
if (nskip != 0) {--nskip; return;}
|
||||||
|
|
||||||
|
var tmp = 0.0;
|
||||||
|
if (is_x) tmp = max_rec_height + font.vspacing + (title.text == "" ? 0 : title.height + font.vspacing);
|
||||||
|
else tmp = max_rec_width + font.hspacing + (title.text == "" ? 0 : title.width + font.hspacing);
|
||||||
|
switch (position) {
|
||||||
|
case Position.LOW:
|
||||||
|
if (is_x) chart.evarea.y1 -= tmp;
|
||||||
|
else chart.evarea.x0 += tmp;
|
||||||
|
break;
|
||||||
|
case Position.HIGH:
|
||||||
|
if (is_x) chart.evarea.y0 += tmp;
|
||||||
|
else chart.evarea.x1 -= tmp;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -383,29 +366,30 @@ namespace CairoChart {
|
||||||
* @param nskip returns number of series to skip printing.
|
* @param nskip returns number of series to skip printing.
|
||||||
*/
|
*/
|
||||||
public virtual void join_axes (ref int nskip) {
|
public virtual void join_axes (ref int nskip) {
|
||||||
|
Axis axis = this;
|
||||||
if (!ser.zoom_show) return;
|
if (!ser.zoom_show) return;
|
||||||
if (nskip != 0) {--nskip; return;}
|
if (nskip != 0) {--nskip; return;}
|
||||||
var max_rec_width = 0.0, max_rec_height = 0.0;
|
var max_rec_width = 0.0, max_rec_height = 0.0;
|
||||||
calc_rec_sizes (this, out max_rec_width, out max_rec_height, is_x);
|
calc_rec_sizes (axis, out max_rec_width, out max_rec_height, is_x);
|
||||||
var max_rec_spacing = 2 * (is_x ? font.vspacing : font.hspacing);
|
var max_font_spacing = is_x ? axis.font.vspacing : axis.font.hspacing;
|
||||||
var max_title_width = title.text == "" ? 0 : title.width + font.hspacing;
|
var max_axis_font_width = axis.title.text == "" ? 0 : axis.title.width + axis.font.hspacing;
|
||||||
var max_title_height = title.text == "" ? 0 : title.height + font.vspacing;
|
var max_axis_font_height = axis.title.text == "" ? 0 : axis.title.height + axis.font.vspacing;
|
||||||
|
|
||||||
var si = Math.find_arr<Series>(chart.series, ser);
|
var si = Math.find_arr<Series>(chart.series, ser);
|
||||||
if (si == -1) return;
|
if (si == -1) return;
|
||||||
|
|
||||||
if (is_x)
|
if (is_x)
|
||||||
join_rel_axes (si, true, ref max_rec_width, ref max_rec_height, ref max_rec_spacing, ref max_title_height, ref nskip);
|
join_rel_axes (si, true, ref max_rec_width, ref max_rec_height, ref max_font_spacing, ref max_axis_font_height, ref nskip);
|
||||||
else
|
else
|
||||||
join_rel_axes (si, true, ref max_rec_width, ref max_rec_height, ref max_rec_spacing, ref max_title_width, ref nskip);
|
join_rel_axes (si, true, ref max_rec_width, ref max_rec_height, ref max_font_spacing, ref max_axis_font_width, ref nskip);
|
||||||
|
|
||||||
// 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.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 + font.vspacing;
|
var tmp = max_rec_height + axis.font.vspacing;
|
||||||
switch (position) {
|
switch (axis.position) {
|
||||||
case Position.LOW: chart.plarea.y1 -= tmp; break;
|
case Position.LOW: chart.plarea.y1 -= tmp; break;
|
||||||
case Position.HIGH: chart.plarea.y0 += tmp; break;
|
case Position.HIGH: chart.plarea.y0 += tmp; break;
|
||||||
}
|
}
|
||||||
|
@ -423,14 +407,14 @@ namespace CairoChart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_x && (!chart.joint_x || si == chart.zoom_1st_idx)) {
|
if (is_x && (!chart.joint_x || si == chart.zoom_1st_idx)) {
|
||||||
var tmp = max_rec_height + max_rec_spacing + max_title_height;
|
var tmp = max_rec_height + max_font_spacing + max_axis_font_height;
|
||||||
switch (position) {
|
switch (axis.position) {
|
||||||
case Position.LOW: chart.plarea.y1 -= tmp; break;
|
case Position.LOW: chart.plarea.y1 -= tmp; break;
|
||||||
case Position.HIGH: chart.plarea.y0 += tmp; break;
|
case Position.HIGH: chart.plarea.y0 += tmp; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!is_x && (!chart.joint_y || si == chart.zoom_1st_idx)) {
|
if (!is_x && (!chart.joint_y || si == chart.zoom_1st_idx)) {
|
||||||
var tmp = max_rec_width + max_rec_spacing + max_title_width;
|
var tmp = max_rec_width + max_font_spacing + max_axis_font_width;
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case Position.LOW: chart.plarea.x0 += tmp; break;
|
case Position.LOW: chart.plarea.x0 += tmp; break;
|
||||||
case Position.HIGH: chart.plarea.x1 -= tmp; break;
|
case Position.HIGH: chart.plarea.x1 -= tmp; break;
|
||||||
|
@ -445,8 +429,8 @@ namespace CairoChart {
|
||||||
switch (axis.dtype) {
|
switch (axis.dtype) {
|
||||||
case DType.NUMBERS:
|
case DType.NUMBERS:
|
||||||
var text = new Text (chart, axis.format.printf((LongDouble)x) + (horizontal ? "_" : ""), axis.font);
|
var text = new Text (chart, axis.format.printf((LongDouble)x) + (horizontal ? "_" : ""), axis.font);
|
||||||
max_rec_width = double.max (max_rec_width, text.width + 2 * text.font.hspacing);
|
max_rec_width = double.max (max_rec_width, text.width);
|
||||||
max_rec_height = double.max (max_rec_height, text.height + 2 * text.font.vspacing);
|
max_rec_height = double.max (max_rec_height, text.height);
|
||||||
break;
|
break;
|
||||||
case DType.DATE_TIME:
|
case DType.DATE_TIME:
|
||||||
string date, time;
|
string date, time;
|
||||||
|
@ -455,12 +439,12 @@ namespace CairoChart {
|
||||||
var h = 0.0;
|
var h = 0.0;
|
||||||
if (axis.date_format != "") {
|
if (axis.date_format != "") {
|
||||||
var text = new Text (chart, date + (horizontal ? "_" : ""), axis.font);
|
var text = new Text (chart, date + (horizontal ? "_" : ""), axis.font);
|
||||||
max_rec_width = double.max (max_rec_width, text.width + 2 * text.font.hspacing);
|
max_rec_width = double.max (max_rec_width, text.width);
|
||||||
h = text.height;
|
h = text.height;
|
||||||
}
|
}
|
||||||
if (axis.time_format != "") {
|
if (axis.time_format != "") {
|
||||||
var text = new Text (chart, time + (horizontal ? "_" : ""), axis.font);
|
var text = new Text (chart, time + (horizontal ? "_" : ""), axis.font);
|
||||||
max_rec_width = double.max (max_rec_width, text.width + 2 * text.font.hspacing);
|
max_rec_width = double.max (max_rec_width, text.width);
|
||||||
h += text.height;
|
h += text.height;
|
||||||
}
|
}
|
||||||
max_rec_height = double.max (max_rec_height, h);
|
max_rec_height = double.max (max_rec_height, h);
|
||||||
|
@ -473,8 +457,8 @@ namespace CairoChart {
|
||||||
bool calc_max_values,
|
bool calc_max_values,
|
||||||
ref double max_rec_width,
|
ref double max_rec_width,
|
||||||
ref double max_rec_height,
|
ref double max_rec_height,
|
||||||
ref double max_rec_spacing,
|
ref double max_font_spacing,
|
||||||
ref double max_title_size,
|
ref double max_axis_font_size,
|
||||||
ref int nskip) {
|
ref int nskip) {
|
||||||
for (int sj = si - 1; sj >= 0; --sj) {
|
for (int sj = si - 1; sj >= 0; --sj) {
|
||||||
var s2 = chart.series[sj];
|
var s2 = chart.series[sj];
|
||||||
|
@ -497,13 +481,11 @@ namespace CairoChart {
|
||||||
calc_rec_sizes (a2, out tmp_max_rec_width, out tmp_max_rec_height, is_x);
|
calc_rec_sizes (a2, out tmp_max_rec_width, out tmp_max_rec_height, is_x);
|
||||||
max_rec_width = double.max (max_rec_width, tmp_max_rec_width);
|
max_rec_width = double.max (max_rec_width, tmp_max_rec_width);
|
||||||
max_rec_height = double.max (max_rec_height, tmp_max_rec_height);
|
max_rec_height = double.max (max_rec_height, tmp_max_rec_height);
|
||||||
max_rec_spacing = double.max (max_rec_spacing, 2 * (is_x ? a2.font.vspacing : a2.font.hspacing));
|
max_font_spacing = double.max (max_font_spacing, is_x ? a2.font.vspacing : a2.font.hspacing);
|
||||||
max_title_size = double.max (
|
max_axis_font_size = double.max (max_axis_font_size,
|
||||||
max_title_size,
|
|
||||||
a2.title.text == "" ? 0
|
a2.title.text == "" ? 0
|
||||||
: is_x ? a2.title.height + font.vspacing
|
: is_x ? a2.title.height + font.vspacing
|
||||||
: a2.title.width + font.hspacing
|
: a2.title.width + font.hspacing);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
++nskip;
|
++nskip;
|
||||||
} else {
|
} else {
|
||||||
|
@ -516,9 +498,8 @@ namespace CairoChart {
|
||||||
for (Float128 v = min; Math.point_belong (v, min, range.zmax); v += step) {
|
for (Float128 v = min; Math.point_belong (v, min, range.zmax); v += step) {
|
||||||
if (is_x && chart.joint_x || !is_x && chart.joint_y) {
|
if (is_x && chart.joint_x || !is_x && chart.joint_y) {
|
||||||
chart.color = chart.joint_color;
|
chart.color = chart.joint_color;
|
||||||
grid_style.color.red = chart.joint_color.red;
|
ser.axis_x.grid_style.color = Color(0, 0, 0, 0.5);
|
||||||
grid_style.color.green = chart.joint_color.green;
|
ser.axis_y.grid_style.color = Color(0, 0, 0, 0.5);
|
||||||
grid_style.color.blue = chart.joint_color.blue;
|
|
||||||
} else
|
} else
|
||||||
chart.color = color;
|
chart.color = color;
|
||||||
string text = "", time_text = ""; var time_text_t = new Text(chart); var crpt = 0.0;
|
string text = "", time_text = ""; var time_text_t = new Text(chart); var crpt = 0.0;
|
||||||
|
|
|
@ -45,11 +45,6 @@ namespace CairoChart {
|
||||||
*/
|
*/
|
||||||
public LineStyle selection_style = LineStyle ();
|
public LineStyle selection_style = LineStyle ();
|
||||||
|
|
||||||
/**
|
|
||||||
* Zoom Scroll speed.
|
|
||||||
*/
|
|
||||||
public double zoom_scroll_speed = 64.0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plot area bounds.
|
* Plot area bounds.
|
||||||
*/
|
*/
|
||||||
|
@ -187,7 +182,7 @@ namespace CairoChart {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Zooms in the ``Chart``.
|
* Zooms the ``Chart``.
|
||||||
* @param area selected zoom area.
|
* @param area selected zoom area.
|
||||||
*/
|
*/
|
||||||
public virtual void zoom_in (Area area) {
|
public virtual void zoom_in (Area area) {
|
||||||
|
@ -267,8 +262,6 @@ namespace CairoChart {
|
||||||
public virtual void move (Point delta) {
|
public virtual void move (Point delta) {
|
||||||
var d = delta;
|
var d = delta;
|
||||||
|
|
||||||
if (plarea.width.abs() < 1 || plarea.height.abs() < 1) return;
|
|
||||||
|
|
||||||
d.x /= -plarea.width; d.y /= -plarea.height;
|
d.x /= -plarea.width; d.y /= -plarea.height;
|
||||||
|
|
||||||
var z = zoom.copy();
|
var z = zoom.copy();
|
||||||
|
@ -284,10 +277,13 @@ namespace CairoChart {
|
||||||
|
|
||||||
d.x *= z.width; d.y *= z.height;
|
d.x *= z.width; d.y *= z.height;
|
||||||
|
|
||||||
|
var px1 = plarea.x1;
|
||||||
|
var py1 = plarea.y1;
|
||||||
|
|
||||||
if (x0 + d.x < plarea.x0) d.x = plarea.x0 - x0;
|
if (x0 + d.x < plarea.x0) d.x = plarea.x0 - x0;
|
||||||
if (x1 + d.x > plarea.x1) d.x = plarea.x1 - x1;
|
if (x1 + d.x > px1) d.x = px1 - x1;
|
||||||
if (y0 + d.y < plarea.y0) d.y = plarea.y0 - y0;
|
if (y0 + d.y < plarea.y0) d.y = plarea.y0 - y0;
|
||||||
if (y1 + d.y > plarea.y1) d.y = plarea.y1 - y1;
|
if (y1 + d.y > py1) d.y = py1 - y1;
|
||||||
|
|
||||||
zoom_in(
|
zoom_in(
|
||||||
new Area.with_rel(
|
new Area.with_rel(
|
||||||
|
@ -299,52 +295,6 @@ namespace CairoChart {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Zooms in the ``Chart`` by event point (scrolling).
|
|
||||||
* @param p event position.
|
|
||||||
*/
|
|
||||||
public virtual void zoom_scroll_in (Point p) {
|
|
||||||
var w = plarea.width, h = plarea.height;
|
|
||||||
if (w < 8 || h < 8) return;
|
|
||||||
zoom_in (
|
|
||||||
new Area.with_abs(
|
|
||||||
plarea.x0 + (p.x - plarea.x0) / w * zoom_scroll_speed,
|
|
||||||
plarea.y0 + (p.y - plarea.y0) / h * zoom_scroll_speed,
|
|
||||||
plarea.x1 - (plarea.x1 - p.x) / w * zoom_scroll_speed,
|
|
||||||
plarea.y1 - (plarea.y1 - p.y) / h * zoom_scroll_speed
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Zooms out the ``Chart`` by event point (scrolling).
|
|
||||||
* @param p event position.
|
|
||||||
*/
|
|
||||||
public virtual void zoom_scroll_out (Point p) {
|
|
||||||
var z = zoom.copy(), pa = plarea.copy();
|
|
||||||
var w = plarea.width, h = plarea.height;
|
|
||||||
if (w < 8 || h < 8) return;
|
|
||||||
|
|
||||||
zoom_out();
|
|
||||||
|
|
||||||
var x0 = plarea.x0 + plarea.width * z.x0;
|
|
||||||
var x1 = plarea.x0 + plarea.width * z.x1;
|
|
||||||
var y0 = plarea.y0 + plarea.height * z.y0;
|
|
||||||
var y1 = plarea.y0 + plarea.height * z.y1;
|
|
||||||
|
|
||||||
var dx0 = (p.x - pa.x0) / w * zoom_scroll_speed;
|
|
||||||
var dx1 = (pa.x1 - p.x) / w * zoom_scroll_speed;
|
|
||||||
var dy0 = (p.y - pa.y0) / h * zoom_scroll_speed;
|
|
||||||
var dy1 = (pa.y1 - p.y) / h * zoom_scroll_speed;
|
|
||||||
|
|
||||||
if (x0 - dx0 < plarea.x0) x0 = plarea.x0; else x0 -= dx0;
|
|
||||||
if (x1 + dx1 > plarea.x1) x1 = plarea.x1; else x1 += dx1;
|
|
||||||
if (y0 - dy0 < plarea.y0) y0 = plarea.y0; else y0 -= dy0;
|
|
||||||
if (y1 + dy1 > plarea.y1) y1 = plarea.y1; else y1 += dy1;
|
|
||||||
|
|
||||||
zoom_in (new Area.with_abs(x0, y0, x1, y1));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void fix_evarea () {
|
protected virtual void fix_evarea () {
|
||||||
if (evarea.width < 0) evarea.width = 0;
|
if (evarea.width < 0) evarea.width = 0;
|
||||||
if (evarea.height < 0) evarea.height = 0;
|
if (evarea.height < 0) evarea.height = 0;
|
||||||
|
@ -380,6 +330,13 @@ namespace CairoChart {
|
||||||
|
|
||||||
protected virtual void eval_plarea () {
|
protected virtual void eval_plarea () {
|
||||||
plarea = evarea.copy();
|
plarea = evarea.copy();
|
||||||
|
if (legend.show)
|
||||||
|
switch(legend.position) {
|
||||||
|
case Legend.Position.TOP: plarea.y0 += legend.spacing; break;
|
||||||
|
case Legend.Position.BOTTOM: plarea.y1 -= legend.spacing; break;
|
||||||
|
case Legend.Position.LEFT: plarea.x0 += legend.spacing; break;
|
||||||
|
case Legend.Position.RIGHT: plarea.x1 -= legend.spacing; break;
|
||||||
|
}
|
||||||
|
|
||||||
// Check for joint axes
|
// Check for joint axes
|
||||||
joint_x = joint_y = true;
|
joint_x = joint_y = true;
|
||||||
|
@ -400,8 +357,8 @@ namespace CairoChart {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void draw_plarea_border () {
|
protected virtual void draw_plarea_border () {
|
||||||
LineStyle().apply(this);
|
|
||||||
color = border_color;
|
color = border_color;
|
||||||
|
ctx.set_dash(null, 0);
|
||||||
ctx.rectangle(plarea.x0, plarea.y0, plarea.width, plarea.height);
|
ctx.rectangle(plarea.x0, plarea.y0, plarea.width, plarea.height);
|
||||||
ctx.stroke ();
|
ctx.stroke ();
|
||||||
}
|
}
|
||||||
|
@ -413,9 +370,9 @@ namespace CairoChart {
|
||||||
title.show();
|
title.show();
|
||||||
}
|
}
|
||||||
protected virtual void draw_axes () {
|
protected virtual void draw_axes () {
|
||||||
for (var si = series.length - 1, nskip = 0; si >= 0; --si)
|
for (var si = series.length - 1, nskip = 0; si >=0; --si)
|
||||||
series[si].axis_x.draw(ref nskip);
|
series[si].axis_x.draw(ref nskip);
|
||||||
for (var si = series.length - 1, nskip = 0; si >= 0; --si)
|
for (var si = series.length - 1, nskip = 0; si >=0; --si)
|
||||||
series[si].axis_y.draw(ref nskip);
|
series[si].axis_y.draw(ref nskip);
|
||||||
}
|
}
|
||||||
protected virtual void draw_series () {
|
protected virtual void draw_series () {
|
||||||
|
|
113
src/Cursor.vala
113
src/Cursor.vala
|
@ -60,11 +60,6 @@ namespace CairoChart {
|
||||||
*/
|
*/
|
||||||
public Style style = Style();
|
public Style style = Style();
|
||||||
|
|
||||||
/**
|
|
||||||
* Value label style.
|
|
||||||
*/
|
|
||||||
public LabelStyle label_style = new LabelStyle();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Has crossings.
|
* Has crossings.
|
||||||
*/
|
*/
|
||||||
|
@ -87,7 +82,6 @@ namespace CairoChart {
|
||||||
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.style = style;
|
c.style = style;
|
||||||
c.label_style = label_style.copy();
|
|
||||||
c.crossings = crossings;
|
c.crossings = crossings;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
@ -346,18 +340,9 @@ namespace CairoChart {
|
||||||
var show_time = ccs[ci].show_time;
|
var show_time = ccs[ci].show_time;
|
||||||
var show_y = ccs[ci].show_y;
|
var show_y = ccs[ci].show_y;
|
||||||
|
|
||||||
// value label background
|
chart.color = chart.bg_color;
|
||||||
chart.color = label_style.bg_color;
|
|
||||||
chart.ctx.rectangle (svp.x - size.x / 2, svp.y - size.y / 2, size.x, size.y);
|
chart.ctx.rectangle (svp.x - size.x / 2, svp.y - size.y / 2, size.x, size.y);
|
||||||
chart.ctx.fill();
|
chart.ctx.fill();
|
||||||
// value label frame
|
|
||||||
label_style.frame_style.apply(chart);
|
|
||||||
chart.ctx.move_to (svp.x - size.x / 2, svp.y - size.y / 2);
|
|
||||||
chart.ctx.rel_line_to (size.x, 0);
|
|
||||||
chart.ctx.rel_line_to (0, size.y);
|
|
||||||
chart.ctx.rel_line_to (-size.x, 0);
|
|
||||||
chart.ctx.rel_line_to (0, -size.y);
|
|
||||||
chart.ctx.stroke();
|
|
||||||
|
|
||||||
if (show_x) {
|
if (show_x) {
|
||||||
chart.color = s.axis_x.color;
|
chart.color = s.axis_x.color;
|
||||||
|
@ -431,7 +416,7 @@ namespace CairoChart {
|
||||||
if (Math.vcross(s.scr_pnt(points[i]), s.scr_pnt(points[i+1]), rel2scr_x(c.x),
|
if (Math.vcross(s.scr_pnt(points[i]), s.scr_pnt(points[i+1]), rel2scr_x(c.x),
|
||||||
chart.plarea.y0, chart.plarea.y1, out y)) {
|
chart.plarea.y0, chart.plarea.y1, out y)) {
|
||||||
var point = Point128(s.axis_x.axis_val(rel2scr_x(c.x)), s.axis_y.axis_val(y));
|
var point = Point128(s.axis_x.axis_val(rel2scr_x(c.x)), s.axis_y.axis_val(y));
|
||||||
Point size; bool show_x, show_date, show_time, show_y;
|
Point128 size; bool show_x, show_date, show_time, show_y;
|
||||||
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);
|
||||||
calc_cross_sizes (s, point, out size, show_x, show_time, show_date, show_y);
|
calc_cross_sizes (s, point, out size, show_x, show_time, show_date, show_y);
|
||||||
Cross cc = {si, point, size, show_x, show_date, show_time, show_y};
|
Cross cc = {si, point, size, show_x, show_date, show_time, show_y};
|
||||||
|
@ -443,7 +428,7 @@ namespace CairoChart {
|
||||||
if (Math.hcross(s.scr_pnt(points[i]), s.scr_pnt(points[i+1]),
|
if (Math.hcross(s.scr_pnt(points[i]), s.scr_pnt(points[i+1]),
|
||||||
chart.plarea.x0, chart.plarea.x1, rel2scr_y(c.y), out x)) {
|
chart.plarea.x0, chart.plarea.x1, rel2scr_y(c.y), out x)) {
|
||||||
var point = Point128(s.axis_x.axis_val(x), s.axis_y.axis_val(rel2scr_y(c.y)));
|
var point = Point128(s.axis_x.axis_val(x), s.axis_y.axis_val(rel2scr_y(c.y)));
|
||||||
Point size; bool show_x, show_date, show_time, show_y;
|
Point128 size; bool show_x, show_date, show_time, show_y;
|
||||||
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);
|
||||||
calc_cross_sizes (s, point, out size, show_x, show_time, show_date, show_y);
|
calc_cross_sizes (s, point, out size, show_x, show_time, show_date, show_y);
|
||||||
Cross cc = {si, point, size, show_x, show_date, show_time, show_y};
|
Cross cc = {si, point, size, show_x, show_date, show_time, show_y};
|
||||||
|
@ -464,7 +449,7 @@ namespace CairoChart {
|
||||||
protected struct Cross {
|
protected struct Cross {
|
||||||
uint series_index;
|
uint series_index;
|
||||||
Point128 point;
|
Point128 point;
|
||||||
Point size;
|
Point128 size;
|
||||||
bool show_x;
|
bool show_x;
|
||||||
bool show_date;
|
bool show_date;
|
||||||
bool show_time;
|
bool show_time;
|
||||||
|
@ -493,90 +478,14 @@ namespace CairoChart {
|
||||||
return all_cursors;
|
return all_cursors;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void scr2cell (int m, int n, Point p, out int i, out int j) {
|
|
||||||
i = (int)((p.x - chart.plarea.x0) / chart.plarea.width * m);
|
|
||||||
j = (int)((p.y - chart.plarea.y0) / chart.plarea.height * n);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void cell2scr (int m, int n, int i, int j, out Point p) {
|
|
||||||
p = Point(chart.plarea.x0 + chart.plarea.width * (i + 0.5) / m,
|
|
||||||
chart.plarea.y0 + chart.plarea.height * (j + 0.5)/ n);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void calc_cursors_value_positions () {
|
protected virtual void calc_cursors_value_positions () {
|
||||||
// 1. Find maximum width/height of cursors values.
|
|
||||||
var max_width = 1.0, max_height = 1.0;
|
|
||||||
for (var ccsi = 0, max_ccsi = crossings.length; ccsi < max_ccsi; ++ccsi) {
|
|
||||||
for (var cci = 0, max_cci = crossings[ccsi].crossings.length; cci < max_cci; ++cci) {
|
|
||||||
unowned Cross[] cr = crossings[ccsi].crossings;
|
|
||||||
max_width = double.max(max_width, cr[cci].size.x
|
|
||||||
+ 4 * double.max(chart.series[cr[cci].series_index].axis_x.font.hspacing,
|
|
||||||
chart.series[cr[cci].series_index].axis_y.font.hspacing));
|
|
||||||
max_height = double.max(max_height, cr[cci].size.y
|
|
||||||
+ 4 * double.max(chart.series[cr[cci].series_index].axis_x.font.vspacing,
|
|
||||||
chart.series[cr[cci].series_index].axis_y.font.vspacing));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. Calculate 2D-array sizes.
|
|
||||||
var m = (int.max(1, (int)(chart.plarea.width / max_width))),
|
|
||||||
n = (int.max(1, (int)(chart.plarea.height / max_height)));
|
|
||||||
|
|
||||||
// 3. Create 2D-array of bool or links to cursors values.
|
|
||||||
var arr2d_e = new bool[m, n];
|
|
||||||
|
|
||||||
// 4. Set Busy/Cross Cells
|
|
||||||
for (var ccsi = 0, max_ccsi = crossings.length; ccsi < max_ccsi; ++ccsi) {
|
for (var ccsi = 0, max_ccsi = crossings.length; ccsi < max_ccsi; ++ccsi) {
|
||||||
for (var cci = 0, max_cci = crossings[ccsi].crossings.length; cci < max_cci; ++cci) {
|
for (var cci = 0, max_cci = crossings[ccsi].crossings.length; cci < max_cci; ++cci) {
|
||||||
|
// TODO: Ticket #142: find smart algorithm of cursors values placements
|
||||||
unowned Cross[] cr = crossings[ccsi].crossings;
|
unowned Cross[] cr = crossings[ccsi].crossings;
|
||||||
cr[cci].scr_point = chart.series[cr[cci].series_index].scr_pnt (cr[cci].point);
|
cr[cci].scr_point = chart.series[cr[cci].series_index].scr_pnt (cr[cci].point);
|
||||||
int i = 0, j = 0;
|
var d_max = double.max (cr[cci].size.x / 1.5, cr[cci].size.y / 1.5);
|
||||||
scr2cell(m, n, cr[cci].scr_point, out i, out j);
|
cr[cci].scr_value_point = Point (cr[cci].scr_point.x + d_max, cr[cci].scr_point.y - d_max);
|
||||||
arr2d_e[i, j] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5. Calculate positions.
|
|
||||||
for (var ccsi = 0, max_ccsi = crossings.length; ccsi < max_ccsi; ++ccsi) {
|
|
||||||
for (var cci = 0, max_cci = crossings[ccsi].crossings.length; cci < max_cci; ++cci) {
|
|
||||||
unowned Cross[] cr = crossings[ccsi].crossings;
|
|
||||||
int i = 0, j = 0;
|
|
||||||
scr2cell(m, n, cr[cci].scr_point, out i, out j);
|
|
||||||
for (var radius = 1; radius < int.max(m, n); ++radius) {
|
|
||||||
bool found = false;
|
|
||||||
|
|
||||||
// top, bottom
|
|
||||||
int[] ll = {int.max(0, j - radius), int.min(n - 1, j + radius)};
|
|
||||||
foreach (var l in ll) {
|
|
||||||
for (var k = int.max(0, i - radius); k <= int.min(m - 1, i + radius); ++k) {
|
|
||||||
if (k == i) continue;
|
|
||||||
if (!arr2d_e[k, l]) {
|
|
||||||
arr2d_e[k, l] = true;
|
|
||||||
cell2scr(m, n, k, l, out cr[cci].scr_value_point);
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (found) break;
|
|
||||||
}
|
|
||||||
if (found) break;
|
|
||||||
|
|
||||||
// left, right
|
|
||||||
int[] kk = {int.max(0, i - radius), int.min(m - 1, i + radius)};
|
|
||||||
foreach (var k in kk) {
|
|
||||||
for (var l = int.max(0, j - radius); l <= int.min(n - 1, j + radius); ++l) {
|
|
||||||
if (l == j) continue;
|
|
||||||
if (!arr2d_e[k, l]) {
|
|
||||||
arr2d_e[k, l] = true;
|
|
||||||
cell2scr(m, n, k, l, out cr[cci].scr_value_point);
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (found) break;
|
|
||||||
}
|
|
||||||
if (found) break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -609,12 +518,12 @@ namespace CairoChart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void calc_cross_sizes (Series s, Point128 p, out Point size,
|
protected virtual void calc_cross_sizes (Series s, Point128 p, out Point128 size,
|
||||||
bool show_x = false, bool show_time = false,
|
bool show_x = false, bool show_time = false,
|
||||||
bool show_date = false, bool show_y = false) {
|
bool show_date = false, bool show_y = false) {
|
||||||
if (show_x == show_time == show_date == show_y == false)
|
if (show_x == show_time == show_date == show_y == false)
|
||||||
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 = Point ();
|
size = Point128 ();
|
||||||
string date, time;
|
string date, time;
|
||||||
s.axis_x.print_dt(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);
|
||||||
|
@ -626,8 +535,8 @@ namespace CairoChart {
|
||||||
if (show_date) { size.x = date_t.width; h_x = date_t.height; }
|
if (show_date) { size.x = date_t.width; h_x = date_t.height; }
|
||||||
if (show_time) { size.x = double.max(size.x, time_t.width); h_x += time_t.height; }
|
if (show_time) { size.x = double.max(size.x, time_t.width); h_x += time_t.height; }
|
||||||
if (show_y) { size.x += y_t.width; h_y = y_t.height; }
|
if (show_y) { size.x += y_t.width; h_y = y_t.height; }
|
||||||
if ((show_x || show_date || show_time) && show_y) size.x += s.axis_x.font.hspacing + s.axis_y.font.hspacing;
|
if ((show_x || show_date || show_time) && show_y) size.x += double.max(s.axis_x.font.hspacing, s.axis_y.font.hspacing);
|
||||||
if (show_date && show_time) h_x += s.axis_x.font.vspacing;
|
if (show_date && show_time) h_x += s.axis_x.font.hspacing;
|
||||||
size.y = double.max (h_x, h_y);
|
size.y = double.max (h_x, h_y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,12 +34,12 @@ namespace CairoChart {
|
||||||
/**
|
/**
|
||||||
* Vertical spacing.
|
* Vertical spacing.
|
||||||
*/
|
*/
|
||||||
public double vspacing = 2;
|
public double vspacing = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Horizontal spacing.
|
* Horizontal spacing.
|
||||||
*/
|
*/
|
||||||
public double hspacing = 2;
|
public double hspacing = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Both vertical & horizontal spacing (set only).
|
* Both vertical & horizontal spacing (set only).
|
||||||
|
@ -51,7 +51,7 @@ namespace CairoChart {
|
||||||
set {
|
set {
|
||||||
vspacing = hspacing = value;
|
vspacing = hspacing = value;
|
||||||
}
|
}
|
||||||
default = 2;
|
default = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,8 +67,8 @@ namespace CairoChart {
|
||||||
Cairo.FontSlant slant = Cairo.FontSlant.NORMAL,
|
Cairo.FontSlant slant = Cairo.FontSlant.NORMAL,
|
||||||
Cairo.FontWeight weight = Cairo.FontWeight.NORMAL,
|
Cairo.FontWeight weight = Cairo.FontWeight.NORMAL,
|
||||||
Gtk.Orientation orient = Gtk.Orientation.HORIZONTAL,
|
Gtk.Orientation orient = Gtk.Orientation.HORIZONTAL,
|
||||||
double vspacing = 2,
|
double vspacing = 4,
|
||||||
double hspacing = 2
|
double hspacing = 4
|
||||||
) {
|
) {
|
||||||
this.family = family;
|
this.family = family;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
|
|
@ -1,46 +1,28 @@
|
||||||
namespace CairoChart {
|
namespace CairoChart {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ``Cursors`` values style.
|
* ``LabelStyle`` Style.
|
||||||
*/
|
*/
|
||||||
public class LabelStyle {
|
public struct LabelStyle {
|
||||||
|
|
||||||
/**
|
|
||||||
* Background color.
|
|
||||||
*/
|
|
||||||
public Color bg_color;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Frame line style.
|
|
||||||
*/
|
|
||||||
public LineStyle frame_style;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Font style.
|
* Font style.
|
||||||
*/
|
*/
|
||||||
public Font font;
|
Font font;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new ``LabelStyle``.
|
* Frame line style.
|
||||||
* @param font font style.
|
|
||||||
* @param bg_color background color.
|
|
||||||
* @param frame_style frame line style.
|
|
||||||
*/
|
*/
|
||||||
public LabelStyle (
|
LineStyle frame_line_style;
|
||||||
Color bg_color = Color(1, 1, 1, 1),
|
|
||||||
LineStyle frame_style = LineStyle(Color(0, 0, 0, 0.1)),
|
|
||||||
Font font = new Font()
|
|
||||||
) {
|
|
||||||
this.bg_color = bg_color;
|
|
||||||
this.frame_style = frame_style;
|
|
||||||
this.font = font;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a copy of the ``LabelStyle``.
|
* Background color.
|
||||||
*/
|
*/
|
||||||
public virtual LabelStyle copy () {
|
Color bg_color;
|
||||||
return new LabelStyle(bg_color, frame_style, font);
|
|
||||||
}
|
/**
|
||||||
|
* Frame/border color.
|
||||||
|
*/
|
||||||
|
Color frame_color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,8 +180,8 @@ namespace CairoChart {
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case Position.TOP:
|
case Position.TOP:
|
||||||
case Position.BOTTOM:
|
case Position.BOTTOM:
|
||||||
var ser_title_width = line_length + s.title.width + s.title.font.hspacing * 2;
|
var ser_title_width = s.title.width + line_length;
|
||||||
if (leg_width_sum + ser_title_width > chart.area.width) { // carry
|
if (leg_width_sum + (leg_width_sum == 0 ? 0 : s.title.font.hspacing) + ser_title_width > chart.area.width) { // carry
|
||||||
leg_height_sum += max_font_h;
|
leg_height_sum += max_font_h;
|
||||||
switch (process_type) {
|
switch (process_type) {
|
||||||
case ProcessType.CALC:
|
case ProcessType.CALC:
|
||||||
|
@ -200,43 +200,43 @@ namespace CairoChart {
|
||||||
|
|
||||||
switch (process_type) {
|
switch (process_type) {
|
||||||
case ProcessType.DRAW:
|
case ProcessType.DRAW:
|
||||||
var x = legend_x0 + leg_width_sum + s.title.font.hspacing;
|
var x = legend_x0 + leg_width_sum + (leg_width_sum == 0 ? 0 : s.title.font.hspacing);
|
||||||
var y = legend_y0 + leg_height_sum + mfh[heights_idx] / 2;
|
var y = legend_y0 + leg_height_sum + mfh[heights_idx] / 2 + s.title.height / 2;
|
||||||
|
|
||||||
// series title
|
// series title
|
||||||
chart.ctx.move_to (x + line_length, y + s.title.height / 2);
|
chart.ctx.move_to (x + line_length, y);
|
||||||
chart.color = s.title.color;
|
chart.color = s.title.color;
|
||||||
s.title.show();
|
s.title.show();
|
||||||
|
|
||||||
// series line style
|
// series line style
|
||||||
chart.ctx.move_to (x, y);
|
chart.ctx.move_to (x, y - s.title.height / 2);
|
||||||
s.line_style.apply(chart);
|
s.line_style.apply(chart);
|
||||||
chart.ctx.rel_line_to (line_length, 0);
|
chart.ctx.rel_line_to (line_length, 0);
|
||||||
chart.ctx.stroke();
|
chart.ctx.stroke();
|
||||||
s.marker.draw_at_pos (Point(x + line_length / 2, y));
|
s.marker.draw_at_pos (Point(x + line_length / 2, y - s.title.height / 2));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case Position.TOP:
|
case Position.TOP:
|
||||||
case Position.BOTTOM:
|
case Position.BOTTOM:
|
||||||
var ser_title_width = line_length + s.title.width + s.title.font.hspacing * 2;
|
var ser_title_width = s.title.width + line_length;
|
||||||
leg_width_sum += ser_title_width;
|
leg_width_sum += (leg_width_sum == 0 ? 0 : s.title.font.hspacing) + ser_title_width;
|
||||||
max_font_h = double.max (max_font_h, s.title.height + s.title.font.vspacing * 2);
|
max_font_h = double.max (max_font_h, s.title.height) + (leg_height_sum != 0 ? s.title.font.vspacing : 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Position.LEFT:
|
case Position.LEFT:
|
||||||
case Position.RIGHT:
|
case Position.RIGHT:
|
||||||
switch (process_type) {
|
switch (process_type) {
|
||||||
case ProcessType.CALC:
|
case ProcessType.CALC:
|
||||||
mfh += s.title.height + s.title.font.vspacing * 2;
|
mfh += s.title.height + (leg_height_sum != 0 ? s.title.font.vspacing : 0);
|
||||||
width = double.max (width, s.title.font.hspacing * 2 + line_length + s.title.width);
|
width = double.max (width, s.title.width + line_length);
|
||||||
break;
|
break;
|
||||||
case ProcessType.DRAW:
|
case ProcessType.DRAW:
|
||||||
heights_idx++;
|
heights_idx++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
leg_height_sum += s.title.height + s.title.font.vspacing * 2;
|
leg_height_sum += s.title.height + (leg_height_sum != 0 ? s.title.font.vspacing : 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,10 +261,10 @@ namespace CairoChart {
|
||||||
case ProcessType.CALC:
|
case ProcessType.CALC:
|
||||||
height = leg_height_sum;
|
height = leg_height_sum;
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case Position.TOP: chart.evarea.y0 += height + spacing; break;
|
case Position.TOP: chart.evarea.y0 += height; break;
|
||||||
case Position.BOTTOM: chart.evarea.y1 -= height + spacing; break;
|
case Position.BOTTOM: chart.evarea.y1 -= height; break;
|
||||||
case Position.LEFT: chart.evarea.x0 += width + spacing; break;
|
case Position.LEFT: chart.evarea.x0 += width; break;
|
||||||
case Position.RIGHT: chart.evarea.x1 -= width + spacing; break;
|
case Position.RIGHT: chart.evarea.x1 -= width; break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,9 +73,10 @@ namespace CairoChart {
|
||||||
line_style.color = value;
|
line_style.color = value;
|
||||||
axis_x.color = value;
|
axis_x.color = value;
|
||||||
axis_y.color = value;
|
axis_y.color = value;
|
||||||
axis_x.grid_style.color.red = axis_y.grid_style.color.red = value.red;
|
axis_x.grid_style.color = value;
|
||||||
axis_x.grid_style.color.green = axis_y.grid_style.color.green = value.green;
|
axis_x.grid_style.color.alpha = 0.5;
|
||||||
axis_x.grid_style.color.blue = axis_y.grid_style.color.blue = value.blue;
|
axis_y.grid_style.color = value;
|
||||||
|
axis_y.grid_style.color.alpha = 0.5;
|
||||||
}
|
}
|
||||||
default = Color (0, 0, 0, 1);
|
default = Color (0, 0, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,7 +287,6 @@ int main (string[] args) {
|
||||||
da.set_events ( Gdk.EventMask.BUTTON_PRESS_MASK
|
da.set_events ( Gdk.EventMask.BUTTON_PRESS_MASK
|
||||||
|Gdk.EventMask.BUTTON_RELEASE_MASK
|
|Gdk.EventMask.BUTTON_RELEASE_MASK
|
||||||
|Gdk.EventMask.POINTER_MOTION_MASK
|
|Gdk.EventMask.POINTER_MOTION_MASK
|
||||||
|Gdk.EventMask.SCROLL_MASK
|
|
||||||
);
|
);
|
||||||
|
|
||||||
var chart = chart1;
|
var chart = chart1;
|
||||||
|
@ -572,18 +571,11 @@ int main (string[] args) {
|
||||||
|
|
||||||
return true; // return ret;
|
return true; // return ret;
|
||||||
});
|
});
|
||||||
|
da.add_events(Gdk.EventMask.SCROLL_MASK);
|
||||||
da.scroll_event.connect((event) => {
|
da.scroll_event.connect((event) => {
|
||||||
switch (event.direction) {
|
|
||||||
case Gdk.ScrollDirection.UP:
|
|
||||||
chart.zoom_scroll_in(Point(event.x, event.y));
|
|
||||||
break;
|
|
||||||
case Gdk.ScrollDirection.DOWN:
|
|
||||||
chart.zoom_scroll_out(Point(event.x, event.y));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
da.queue_draw_area(0, 0, da.get_allocated_width(), da.get_allocated_height());
|
|
||||||
|
|
||||||
//var ret = chart.scroll_notify_event(event);
|
//var ret = chart.scroll_notify_event(event);
|
||||||
|
|
||||||
return true; // return ret;
|
return true; // return ret;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue