Profile Picture

HeatMap problems when values pass 0

Posted By Lennart Bossér 7 Years Ago

HeatMap problems when values pass 0

Author
Message
Nevron Support
Posted 7 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Yesterday @ 4:39 AM
Posts: 3,054, Visits: 4,018
Hi Lennart,

Just a short note that we found/fixed the problem. It was related to double precision after the 8 decimal digit so it was kind of difficult to spot at first. Thank you for sending the code that reproduces it. We'll upload a SP fixing this later today.

Best Regards,
Nevron Support Team



Lennart Bossér
Posted 7 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 7 Years Ago
Posts: 5, Visits: 37
Version as reported in Visual studio C# 2013
Nevron.Chart.Wpf version 17.2.14.12,  Runtime version v4.0.30319.

The application is the example code supplied with the Nevron charts installation eg.
C:\Program Files (x86)\Nevron Software\Nevron .NET Vision 2016.1 for VS2013\Examples\Chart\Wpf\Nevron.Examples.Chart.Wpf.VS2013.sln

In file NHeatMapContourUC.xaml.cs change line 115
from
    y = 10 - Math.Sqrt((x * x) + (z * z) + 2);

to
     y = 1 - Math.Sqrt((x * x) + (z * z) + 2);


Then rebuild and run the application and select Chart Gallery -> Heat Map -> Heat Map Contour

Notice the change in behaviour between unmodified and modified application. Notice that also the chart shown for selection Chart Gallery -> Heat Map -> Heat Map get corrrupted if you select that option afterwards (reset by selecting other chart type in between).

I have noted the exact same behaviour for my own application, both with the exact data as above from your demo with the change on line 115 and also for some of my own data sets. My conclusions so far:
  • If the data set has values both below and over zero this behaviour often, but not always, occurs. This might make it hard to reproduce with random data, but you have the case above where it always occurs.
  • If all points in the data set have the same sign I have not seen this error so far.

Happy hunting,
Lennart




Nevron Support
Posted 7 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Yesterday @ 4:39 AM
Posts: 3,054, Visits: 4,018
Hi Lennart,
We were unable to reproduce the problem - we tested using the following code:

  private void Form1_Load(object sender, EventArgs e)
  {
   // set a chart title
   NLabel title = new NLabel("Heat Map Contour");
   title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
   title.TextStyle.FillStyle = new NColorFillStyle(Color.Gray);

   NChart chart = nChartControl1.Charts[0];

   chart.BoundsMode = BoundsMode.Stretch;
   chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator();

   // create the heat map
   NHeatMapSeries heatMap = new NHeatMapSeries();
   chart.Series.Add(heatMap);

   heatMap.Palette.Mode = PaletteMode.AutoMinMaxColor;
   heatMap.Palette.NegativeColor = Color.Blue;
   heatMap.Palette.PositiveColor = Color.Red;
   heatMap.Palette.ZeroColor = Color.White;
   heatMap.Palette.SmoothPalette = true;
   heatMap.XValuesMode = HeatMapValuesMode.OriginAndStep;
   heatMap.YValuesMode = HeatMapValuesMode.OriginAndStep;

   heatMap.ContourDisplayMode = ContourDisplayMode.None;
   heatMap.Legend.Mode = SeriesLegendMode.SeriesLogic;
   heatMap.Legend.Format = "<zone_value>";

   GenerateData(heatMap);
  }

  private void GenerateData(NHeatMapSeries heatMap)
  {
   int gridSize = 1000;

   double x = 0;
   double z = 0;
   double dIncrementX = 1.0;
   double dIncrementY = 1.0;

   heatMap.Data.SetGridSize(gridSize, gridSize);
   Random rand = new Random();


   for (int col = 0; col < gridSize; col++, x += dIncrementX)
   {
    for (int row = 0; row < gridSize; row++, z += dIncrementY)
    {
     double y = 1 - Math.Sqrt((x * x) + (z * z) + 2);
     y += 3.0 * Math.Sin(x) * Math.Cos(y);
     double value = y;

     if (value < 0)
     {
      heatMap.Data.SetValue(row, col, value);
     }
     else
     {
      heatMap.Data.SetValue(row, col, value);
     }

     heatMap.Data.SetValue(row, col, rand.Next(200000000) - 100000000);
    }
   }

   nChartControl1.Refresh();
  }

We also tested with dynamically changing random data but again there were no problems. What is the version of the control you're currently using? Also can you send us an app that replicates the problem?


Best Regards,
Nevron Support Team



Lennart Bossér
Posted 7 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 7 Years Ago
Posts: 5, Visits: 37
Hi again,
I have the same problem with NHeatMapSeries for other datasets as well.
When values pass through zero there is often (but not always) trouble.
When I pass in only positive values e.g. data.SetValue(row, col, Math.Abs(value) ) it always works for the same datasets.

best regards,
Lennart


Lennart Bossér
Problem Posted 7 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 7 Years Ago
Posts: 5, Visits: 37
Hello,
There seems to be some instability which leads to strange behaviour when the values in a NHeatMapSeries has both positive and negative values.
example from the Nevron example code in NHeatMapContourUC.xaml.cs lines 113 - 121


Original code (Works)

                for (int row = 0; row < GridStepY; row++, x += dIncrementX)
                {
                    y = 10 - Math.Sqrt((x * x) + (z * z) + 2);
                    y += 3.0 * Math.Sin(x) * Math.Cos(z);

                    double value = y;

                    data.SetValue(row, col, value);
                }


Slightly altered code (Fails). Note change in line 3 below

               for (int row = 0; row < GridStepY; row++, x += dIncrementX)
                {
                    y = 1 - Math.Sqrt((x * x) + (z * z) + 2);
                    y += 3.0 * Math.Sin(x) * Math.Cos(z);

                    double value = y;

                    data.SetValue(row, col, value);
                }


Best regards,
Lennart








Similar Topics


Reading This Topic

1 active, 1 guest, 0 members, 0 anonymous.
No members currently viewing this topic!