Title: Cartesian XY Chart β 2-D array binding: "Element to use" enumerates the wrong dimension; documented example (Dialog: XY Chart Configuration, "Two-dimensional array of base type REAL") appears transposed
Product / version: CODESYS Development System V3.5 SP21 Patch 40 (3.5.21.40). Cartesian XY Chart visualization element (System_VisuElemXYChart / VisuElemXYChart).
Summary:
When a curve's Data X/Data Y is bound to a two-dimensional array, the element treats the last array dimension as the per-point record (the one selected by "Element to use") and iterates the first dimension as the sequence of curve points. The online documentation's worked example has the dimensions in the opposite order, so following it produces a non-functional curve and a nonsensical "Element to use" list.
Steps to reproduce (fails β matches the documented layout):
1. Declare aData : ARRAY[0..1, 0..4095] OF LREAL; (2 data sets Γ 4096 points, i.e. first dimension = set, second = point).
2. In XY Chart Configuration, bind a curve's Data X (and Y) Variable to this array.
3. Observe the "Element to use" combobox.
Actual result: The "Element to use" combobox lists 4096 entries (the indices of the second dimension) instead of 2 (the data sets in the first dimension). Selecting a row does not produce the expected curve; at most a single/degenerate point is plotted.
Steps to reproduce (works β transposed):
1. Declare aData : ARRAY[0..4095, 0..1] OF LREAL; (points first, set second).
2. Bind Data X/Y to this array; "Element to use" now correctly lists [0] and [1].
3. Populate aData[point, set] and the curve plots as expected.
Expected result: Either the documented example should select the data set from the first dimension (as its [1]/[2] "Element to use" implies), or the documentation should state that the last dimension is the record dimension (stride) and the first dimension is the point sequence β consistent with how the element actually behaves.
Analysis:
The behavior is self-consistent if the element always walks a single array by a fixed byte stride, reading one element per point β the same mechanism as the documented "one-dimensional array of a DUT" case, where it strides by SIZEOF(DUT) and "Element to use" picks the member offset. For a 2-D array the record is the last dimension: to plot column/set c it starts at [0, c] and strides by the last-dimension length to reach [1, c], [2, c], β¦ (row-major layout makes this a contiguous column walk). Under that rule, ARRAY[0..N, 0..1] is correct (record length 2 β "Element to use" [0]/[1]), and the documented ARRAY[1..2, 1..50] with "Element to use" [1]/[2] is transposed.
Documentation reference:
Dialog: XY Chart Configuration β Data X / Data Y β "Example: Two-dimensional array of the base type REAL" (ARRAY[1..2, 1..50], Element to use [1]/[2], "100 array values are displayed"). This example does not plot as described in 3.5.21.40; transposing to ARRAY[1..50, 1..2] does.
Request: Please confirm whether this is (a) a documentation error (example dimensions reversed) or (b) an element defect (combobox enumerates the wrong dimension). Either way, a corrected example plus an explicit statement of which dimension is the point sequence vs. the record/stride dimension would prevent others from hitting this. Two separate 1-D arrays for Data X and Data Y work correctly and are unaffected.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Title: Cartesian XY Chart β 2-D array binding: "Element to use" enumerates the wrong dimension; documented example (Dialog: XY Chart Configuration, "Two-dimensional array of base type REAL") appears transposed
Product / version: CODESYS Development System V3.5 SP21 Patch 40 (3.5.21.40). Cartesian XY Chart visualization element (System_VisuElemXYChart / VisuElemXYChart).
Summary:
When a curve's Data X/Data Y is bound to a two-dimensional array, the element treats the last array dimension as the per-point record (the one selected by "Element to use") and iterates the first dimension as the sequence of curve points. The online documentation's worked example has the dimensions in the opposite order, so following it produces a non-functional curve and a nonsensical "Element to use" list.
Steps to reproduce (fails β matches the documented layout):
1. Declare
aData : ARRAY[0..1, 0..4095] OF LREAL;(2 data sets Γ 4096 points, i.e. first dimension = set, second = point).2. In XY Chart Configuration, bind a curve's Data X (and Y) Variable to this array.
3. Observe the "Element to use" combobox.
Actual result: The "Element to use" combobox lists 4096 entries (the indices of the second dimension) instead of 2 (the data sets in the first dimension). Selecting a row does not produce the expected curve; at most a single/degenerate point is plotted.
Steps to reproduce (works β transposed):
1. Declare
aData : ARRAY[0..4095, 0..1] OF LREAL;(points first, set second).2. Bind Data X/Y to this array; "Element to use" now correctly lists
[0]and[1].3. Populate
aData[point, set]and the curve plots as expected.Expected result: Either the documented example should select the data set from the first dimension (as its
[1]/[2]"Element to use" implies), or the documentation should state that the last dimension is the record dimension (stride) and the first dimension is the point sequence β consistent with how the element actually behaves.Analysis:
The behavior is self-consistent if the element always walks a single array by a fixed byte stride, reading one element per point β the same mechanism as the documented "one-dimensional array of a DUT" case, where it strides by
SIZEOF(DUT)and "Element to use" picks the member offset. For a 2-D array the record is the last dimension: to plot column/setcit starts at[0, c]and strides by the last-dimension length to reach[1, c],[2, c], β¦ (row-major layout makes this a contiguous column walk). Under that rule,ARRAY[0..N, 0..1]is correct (record length 2 β "Element to use"[0]/[1]), and the documentedARRAY[1..2, 1..50]with "Element to use"[1]/[2]is transposed.Documentation reference:
Dialog: XY Chart Configuration β Data X / Data Y β "Example: Two-dimensional array of the base type REAL" (
ARRAY[1..2, 1..50], Element to use[1]/[2], "100 array values are displayed"). This example does not plot as described in 3.5.21.40; transposing toARRAY[1..50, 1..2]does.Request: Please confirm whether this is (a) a documentation error (example dimensions reversed) or (b) an element defect (combobox enumerates the wrong dimension). Either way, a corrected example plus an explicit statement of which dimension is the point sequence vs. the record/stride dimension would prevent others from hitting this. Two separate 1-D arrays for Data X and Data Y work correctly and are unaffected.