Not a bug

Last Index issues on a Bar Graph

mgoutier 2 years ago updated by Ulrik Zakariasson (Software development) 2 years ago 3 and

Maybe I am misunderstanding what the "Last Index" should do on a bar graph, but I have an Array size of 48, and the first 24 contain the data I would like to show on a bar graph. I am basically using the other 24 for math functions. I figured if I set my last index to 24 I would be all set. But this doesn't seem to do anything. Can someone either tell me I am misunderstanding the intent, or the software has glitches? 



Satisfaction mark by mgoutier 2 years ago

The hint of the last index property says: "Index in the array channel that corresponds to the rightmost value in the graph."

The bar graph always draws all the values in the array. But it does not have to start from index 0 to the left and index 47 to the right. By setting the last index you can determine which value is drawn as the last (rightmost) bar. This is useful if the array contains historic data and is used as a circular buffer, i.e. you store the latest value at an index that is increased with every value (restarting at 0 when reaching the length of the array).

In your example setting last index to 24 means that the value at index 24 is drawn to the right, then 23, 22, 21 and so on down to 0. After reaching 0 the drawing will continue at index 47, 46, 45 ... 25 until all values has been drawn (index 25 will be the leftmost value).

Thank you, great example. I should have thought of that.