<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent posts to Cartesian XY Chart — 2-D array binding: "Element to use" enumerates the wrong dimension</title><link>https://forge.codesys.com/forge/talk/Visualization/thread/85ca36cff4/</link><description>Recent posts to Cartesian XY Chart — 2-D array binding: "Element to use" enumerates the wrong dimension</description><language>en</language><lastBuildDate>Fri, 14 Aug 2026 07:11:49 -0000</lastBuildDate><atom:link href="https://forge.codesys.com/forge/talk/Visualization/thread/85ca36cff4/feed.rss" rel="self" type="application/rss+xml"></atom:link><item><title>Cartesian XY Chart — 2-D array binding: "Element to use" enumerates the wrong dimension</title><link>https://forge.codesys.com/forge/talk/Visualization/thread/85ca36cff4/?limit=25#5e92</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;strong&gt;Title:&lt;/strong&gt; 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&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Product / version:&lt;/strong&gt; CODESYS Development System V3.5 SP21 Patch 40 (3.5.21.40). Cartesian XY Chart visualization element (System_VisuElemXYChart / VisuElemXYChart).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Summary:&lt;/strong&gt;&lt;br/&gt;
When a curve's Data X/Data Y is bound to a two-dimensional array, the element treats the &lt;strong&gt;last&lt;/strong&gt; array dimension as the per-point record (the one selected by "Element to use") and iterates the &lt;strong&gt;first&lt;/strong&gt; 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.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Steps to reproduce (fails — matches the documented layout):&lt;/strong&gt;&lt;br/&gt;
1. Declare &lt;code&gt;aData : ARRAY[0..1, 0..4095] OF LREAL;&lt;/code&gt; (2 data sets × 4096 points, i.e. first dimension = set, second = point).&lt;br/&gt;
2. In XY Chart Configuration, bind a curve's Data X (and Y) Variable to this array.&lt;br/&gt;
3. Observe the "Element to use" combobox.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Actual result:&lt;/strong&gt; The "Element to use" combobox lists 4096 entries (the indices of the &lt;strong&gt;second&lt;/strong&gt; 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.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Steps to reproduce (works — transposed):&lt;/strong&gt;&lt;br/&gt;
1. Declare &lt;code&gt;aData : ARRAY[0..4095, 0..1] OF LREAL;&lt;/code&gt; (points first, set second).&lt;br/&gt;
2. Bind Data X/Y to this array; "Element to use" now correctly lists &lt;code&gt;[0]&lt;/code&gt; and &lt;code&gt;[1]&lt;/code&gt;.&lt;br/&gt;
3. Populate &lt;code&gt;aData[point, set]&lt;/code&gt; and the curve plots as expected.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Expected result:&lt;/strong&gt; Either the documented example should select the data set from the &lt;strong&gt;first&lt;/strong&gt; dimension (as its &lt;code&gt;[1]&lt;/code&gt;/&lt;code&gt;[2]&lt;/code&gt; "Element to use" implies), or the documentation should state that the &lt;strong&gt;last&lt;/strong&gt; dimension is the record dimension (stride) and the first dimension is the point sequence — consistent with how the element actually behaves.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Analysis:&lt;/strong&gt;&lt;br/&gt;
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 &lt;code&gt;SIZEOF(DUT)&lt;/code&gt; and "Element to use" picks the member offset. For a 2-D array the record is the &lt;strong&gt;last&lt;/strong&gt; dimension: to plot column/set &lt;code&gt;c&lt;/code&gt; it starts at &lt;code&gt;[0, c]&lt;/code&gt; and strides by the last-dimension length to reach &lt;code&gt;[1, c]&lt;/code&gt;, &lt;code&gt;[2, c]&lt;/code&gt;, … (row-major layout makes this a contiguous column walk). Under that rule, &lt;code&gt;ARRAY[0..N, 0..1]&lt;/code&gt; is correct (record length 2 → "Element to use" &lt;code&gt;[0]&lt;/code&gt;/&lt;code&gt;[1]&lt;/code&gt;), and the documented &lt;code&gt;ARRAY[1..2, 1..50]&lt;/code&gt; with "Element to use" &lt;code&gt;[1]&lt;/code&gt;/&lt;code&gt;[2]&lt;/code&gt; is transposed.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Documentation reference:&lt;/strong&gt;&lt;br/&gt;
Dialog: XY Chart Configuration → Data X / Data Y → "Example: Two-dimensional array of the base type REAL" (&lt;code&gt;ARRAY[1..2, 1..50]&lt;/code&gt;, Element to use &lt;code&gt;[1]&lt;/code&gt;/&lt;code&gt;[2]&lt;/code&gt;, "100 array values are displayed"). This example does not plot as described in 3.5.21.40; transposing to &lt;code&gt;ARRAY[1..50, 1..2]&lt;/code&gt; does.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Request:&lt;/strong&gt; 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.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">hammer</dc:creator><pubDate>Fri, 14 Aug 2026 07:11:49 -0000</pubDate><guid isPermaLink="false">https://forge.codesys.com4cfa90a7f0f883c863c3b8251422d0c547a2d5b5</guid></item></channel></rss>