Nevron Forum

Possible bug with NChart.Refresh() after adding mesh surface ?

https://www.nevron.com/Forum/Topic9332.aspx

By Richard Aidley - Friday, August 21, 2015

Hi, we're trying out the latest Nevron and having the following problem;
After changing our surface in a mesh surface view, the screen does not update unless we 'resize' the view. We have tried .Refresh() on the chart, but this does not make any difference.
We can replicate the problem by modifying the Nevron example code in the following way;

to NMeshSurfaceUC.xaml.cs add

<Button Content="New Mesh" Name="NewMeshButton" Click="NewMeshButton_Click" />

to NMeshSurfaceUC.xaml.cs
modify

private void FillData(NMeshSurfaceSeries surface, double firstmod = 4.0, double secondmod = 3.0)
        {
            double x, y, z;
            int nCountX = surface.Data.GridSizeX;
            int nCountZ = surface.Data.GridSizeZ;

            for (int j = 0; j < nCountZ; j++)
            {
                for (int i = 0; i < nCountX; i++)
                {
                    x = 2 + i + Math.Sin(j / firstmod) * 2;
                    z = 1 + j + Math.Cos(i / firstmod);

                    y = Math.Sin(i / secondmod) * Math.Sin(j / secondmod);

                    if (y < 0)
                    {
                        y = Math.Abs(y / 2.0);
                    }

                    surface.Data.SetValue(i, j, y, x, z);
                }
            }
        }

And Add

  private void NewMeshButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            NChart chart = nChartControl1.Charts[0];

            NMeshSurfaceSeries surface = (NMeshSurfaceSeries)chart.Series.Add(SeriesType.MeshSurface);

            surface.Name = "Surface";
            surface.Legend.Mode = SeriesLegendMode.SeriesLogic;
            surface.FillMode = SurfaceFillMode.Zone;
            surface.PositionValue = 0.5;
            surface.Data.SetGridSize(20, 20);
            surface.SyncPaletteWithAxisScale = false;
            surface.PaletteSteps = 8;
            surface.ValueFormatter.FormatSpecifier = "0.00";
            surface.FillStyle = new NColorFillStyle(Color.YellowGreen);

            var firstmod = _rand.NextDouble() * 6.0 + 1.0;
            var secondmod = _rand.NextDouble() * 6.0 + 1.0;
            FillData(surface,firstmod,secondmod);

            chart.Refresh();
        }

        private Random _rand = new Random();

Are we doing something wrong, or is there a genuine problem ?
Thanks

By Nevron Support - Monday, August 24, 2015

Hi Richard,

The only problem with this code is that you need to call:

nChartControl1.Refresh();

otherwise you're refreshing the chart image map only. Let us know if you meet any problems or have any questions.