View Full Version : Heatmap refresh problem

09-27-2010, 07:19 AM

I need to write a code in C# where the IMSL heatmap should be refreshed every 1 second.

I successfully create a heatmap using:

Heatmap heatmap2 = new Heatmap(axis, xmin, xmax, ymin, ymax, zmin, zmax, data, cm);

where data is a matrix of numbers, but when I change data after one second, the heatmap does not refresh itself.

I also tried to use:


each second and than create a new heatmap, but it doesn't work eather.

All new ideas are welcome. Thank you.


09-27-2010, 09:05 AM
The Remove() method is the correct thing to be looking at, but there are a few gotchas in this case.

First, you may actually need to remove the axis that is the Heatmap's parent. If you just remove the heatmap, the axis will stay and get overdrawn. If the limits are the same with the new data, there's a subtle over-draw issue that could make the text look fuzzy. If the limits change, things will get very messy quickly.

Next, you will need to call Refresh() on the form to get any changes to update in the GUI. Your Remove might actually be working, but not displaying, if there's no Refresh done.

Finally, be aware of the scope. If you'll be doing things in a callback separate from a method that initializes/creates the chart you want the axis/heatmap object to have a larger scope so that you're reusing the same object each time.

For example, in a test case I wrote where a button click updates data in the heatmap, the key pieces are:

private void button1_Click(object sender, EventArgs e)
if (axis != null) axis.Remove();

/* new random color data created in here */

axis = new AxisXY(chart);
Heatmap heatmap = new Heatmap(axis, xmin, xmax, ymin, ymax, color);

09-28-2010, 04:16 AM
Thank you Ed,

Your advice helped me a lot.
I removed all I had in mind: axis, labels, heatmap, and important - chart.
Then adding new ones really worked. :)

Thanks again.