Today I'm going to talk about LabVIEW for a change, this here is a clever lil trick to make your fat tables etc dynamic and responsive.
I've got masses of data and I want to put it in a Table or List box. I want to colour in the background colour for the cells if they are within the ROI (region of interest). I want to switch in an out sub-sets of the data and summary info. Our example table here has 6100 readings in 19 channels, that's 115900 cells not excluding headers etc.
LabVIEW can handle this, but it's beginning to make my laptop grunt a bit. Here's the easiest and gruntiest way to do it. Load the multi-column listbox with all the data and check the ROI set the cell colours accordingly. This is slow and unpleasant.
Next use Defer Panel Updates... This speeds things up a lot!
But it's still a but clunky and is sucking a lot of CPU, time to roll up our sleeves and get tricksy on this!
Here's the thing with UIs, the user is only looking at a finite amount of data at a time...
A graph is only x pixels wide and a table is only x columns by y rows. In the case of the one in this project it is only 39 rows by 19 columns (I'm going to leave columns as is because I'm lazy.
If we could fool the user into thinking that they are seeing an entire data-set when they are only seeing 0.6% of it we'll be winning and grinning.
The first thing we will need for our sleight of hand is a scrollbar control and we then need to tell it some important info.
I've shifted the scrollbar over so you can see my little white lie.
The page size tells it the amount of increments in a page (in our case rows=39). When you click on the slider part it will go up and down a page worth (or 39 rows).
The increment property is set to 1 and this tells it that when you press the Up,Down arrows it goes up down 1/39 per press.
These are all fixed on start-up, leaving only one thing left, the maximum value for the scrollbar and this is dynamic depending on the size of the record set loaded. In this case it will be 6100 or the number of rows.
You should now check that you scrollbar acts similarly to the fully loaded table scrollbar.
You may have noticed that I use a constant vi to set the page size, this is because this number is important and I only want it to change in one place.
Now all I need to do is select blocks of 39 rows based on the scrollbar number. Nice and easy.
The next technique is very useful for colouring an entire row of a table.
Notice that I have set column to -2, this colours the entire row (pink or white), also notice I then set it to -1, this is just setting the row header to grey again.
I use the row header to decide the Cell BackGround colours, again pretty simple.. If it's a character it's white, if it's the word "Data" it's grey, if it's a digit it's pink or white depending on whether it's in the ROI or not.
Very responsive and CPU usage is now negligible.
How very splendid.
Once again thank-you to James Powell for demoing this many years back at CSLUG, it's saved my ass a few times now.