NHeatMapSeries with negative X / Y values

Print Topic | Close Window

By joern kunze - 5 Years Ago
Hi Experts,

I want to display data in a NHeatMapSeries. If X and Y data is positive, it is working nice. But when I have negative X-values, only the values with positive X / Y values are displayed:

Data is feed to the Chart like:
nevSeries.Data.SetValue(iX, iY, fValue);

when I change the Origin:
      nevSeries.XValuesMode = HeatMapValuesMode.OriginAndStep;
       nevSeries.OriginX = - 40; // -0.5; fXMinMax[0]
       nevSeries.StepX = 1;
It looks like that:
But it should look like a full circle. Are there any special settings to be made for negative X-Values ?

Thanks for the help,
Best regards,

By Nevron Support - 5 Years Ago

Hi Joern,
You cannot pass negative values to the heatMapSeries.Data.SetValue function - the x/y values passed there must always be in the range [0, gridSize). We just tested the control with the following code:

// set a chart title
   NLabel title = new NLabel("Wafer Chart");
   title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
   title.TextStyle.FillStyle = new NColorFillStyle(Color.AliceBlue);

   // configure chart
   NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];

   NHeatMapSeries heatMap = new NHeatMapSeries();

   NHeatMapData data = heatMap.Data;

   heatMap.Palette.Mode = PaletteMode.AutoFixedEntryCount;
   heatMap.Palette.AutoPaletteColors = new NArgbColorValue[] { new NArgbColorValue(Color.Green), new NArgbColorValue(Color.Red) };
   heatMap.Palette.SmoothPalette = true;

   int gridSizeX = 100;
   int gridSizeY = 100;
   data.SetGridSize(gridSizeX, gridSizeY);

   int centerX = gridSizeX / 2;
   int centerY = gridSizeY / 2;

   int radius = gridSizeX / 2;
   Random rand = new Random();

   for (int y = 0; y < gridSizeY; y++)
    for (int x = 0; x < gridSizeX; x++)
     int dx = x - centerX;
     int dy = y - centerY;

     double pointDistance = Math.Sqrt(dx * dx + dy * dy);

     if (pointDistance < radius)
      // assign value
      data.SetValue(x, y, pointDistance + rand.Next(20));
      data.SetValue(x, y, double.NaN);

   heatMap.XValuesMode = HeatMapValuesMode.OriginAndStep;
   heatMap.OriginX = -40;
   heatMap.StepX = 1;

and the control was working properly. What is the version you're testing with?

By joern kunze - 5 Years Ago
... thanks a lot for the detailed example. Now I added a manual offset for negative coordinate values and with this work-around all is displayed properly.

May be it would be a good enhancement for a future Nevron Chart version if the heatMapSeries would also support negative coordinate values so that no manual offset is necessary?

Thanks again & best regards,