HeatMapSeries Update Bug

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

BenInCOSprings wrote at 2014-04-25 06:31:
I believe there is either a bug in the HeatMapSeries.cs class or an ambiguity in the documentation pertaining to updates to the Series Data structure. When elements in HeatMapSeries..Model.Series.Data are updated and HeatMapSeries..Model.InvalidatePlot() is called, the image is not updated. That is because the following logic is used to determine if the image should be updated (starting at line 201 of HeatMapSeries.cs):
<code> var currentDataHash = this.Data.GetHashCode(); // Hashes the this.Data // reference, and NOT the // contents of this.Data var currentColorAxisHash = this.ColorAxis.GetElementHashCode(); if (this.image == null || currentDataHash != this.dataHash || currentColorAxisHash != this.colorAxisHash) { this.UpdateImage(); this.dataHash = currentDataHash; this.colorAxisHash = currentColorAxisHash; } The currentDataHash is a hash of the this.Data reference, not of the contents of this.Data itself. So if the contents of this.Data are updated and the changes don't result in a change to this.ColorAxis.GetElementHashCode(), then the image will not be updated.

I am happy to help fix this, but want to be sure that my interpretation of this is correct before proceeding. So, question for OxyPlot developers:
  1. Do you agree this is a bug?
  2. If so, suggested approach for fixing (I can think of a few)?
  3. If not, do you agree that the HeadMapSeries documentation could at least be updated to reflect this information?
BTW, OxyPlot is a great framework and you guys have done an awesome job. Thank you for your efforts!

objo wrote at 2014-04-25 11:36:

Thanks for bringing up this issue! I agree it should be possible to force an update of the heatmap image without changing the Data reference. I also think the actual update of the image should be done during the update of the model (some refactoring may be needed to do this), not during rendering. But we must ensure the update of the image is not called when it is not needed, since it is an expensive operation. Could we add a HeatMapSeries.Invalidate method to invalidate the image? Let us know if you have other ideas!

Documentation is high priority, but it may still take some time before it is complete and up to date. Please contribute :-)

BenInCOSprings wrote at 2014-04-25 17:12:
HeatMapSeries already has an invalidate method. It could be as simple is making sure that when that method is called, the UpdateImage() method always gets called as a result. Agree with this approach?

objo wrote at 2014-04-25 22:02:
I forgot this was already implemented. Right, when the image = null the image will be regenerated next time the heatmapseries is rendered. Does this solve your problem? Remember to invalidate both the HeatMapSeries and the PlotModel.