--- a/svghmi/widget_xygraph.ysl2 Wed Jun 01 11:12:26 2022 +0200
+++ b/svghmi/widget_xygraph.ysl2 Fri Jun 03 11:49:13 2022 +0200
@@ -111,7 +111,7 @@
curve.setAttribute("clip-path", "url(#" + clipPath.id + ")");
- this.curves_data = this.curves.map(_unused => []);
dispatch(value,oldval, index) {
@@ -122,6 +122,9 @@
// data is updated only when graph is visible
// TODO: replace with separate recording
+ if(this.curves_data[index] === undefined){ + this.curves_data[index] = []; this.curves_data[index].push([time, value]);
let data_length = this.curves_data[index].length;
let ymin_damaged = false;
@@ -226,6 +229,22 @@
+def "func:check_curves_label_consistency" { + param "number_to_check"; + when "$curve_elts[@inkscape:label = concat('curve_', string($number_to_check))]"{ + if "$number_to_check > 0"{ + value "func:check_curves_label_consistency($curve_elts, $number_to_check - 1)"; + value "concat('missing curve_', string($number_to_check))"; labels("/x_interval_minor_mark /x_axis_line /x_interval_major_mark /x_axis_label");
labels("/y_interval_minor_mark /y_axis_line /y_interval_major_mark /y_axis_label");
@@ -233,15 +252,15 @@
// collect all curve_n labelled children
- foreach "$hmi_element/*[regexp:test(@inkscape:label,'^curve_[0-9]+$')]" {
+ const "curves","$hmi_element/*[regexp:test(@inkscape:label,'^curve_[0-9]+$')]"; + const "curves_error", "func:check_curves_label_consistency($curves,count($curves)-1)"; + if "string-length($curves_error)" + error > XYGraph id="«@id»", label="«@inkscape:label»" : «$curves_error» const "label","@inkscape:label";
- // detect non-unique names
- if "$hmi_element/*[not($id = @id) and @inkscape:label=$label]"{
- error > XYGraph id="«$id»", label="«$label»" : elements with data_n label must be unique.
- | this.curves[«substring(@inkscape:label, 7)»] = id("«@id»"); /* «@inkscape:label» */
+ const "curve_num", "substring(@inkscape:label, 7)"; + | this.curves[«$curve_num»] = id("«@id»"); /* «@inkscape:label» */