I would like to have the X axis decrease in value on a 3D surface plot but I do not need (I think) to reverse the data.

I have the following grid information:

2D grid, YxX (Y rows, X Columns)

nX - number of points in X

nY - number of points in Y

dX - amount X increases

dY - amount Y increases

orgX - starting value of X at origin

orgY - starting value of Y at origin

On a 2D plot the origin is taken to be at the TOP LEFT.

The data values are stored in flat 1D array in column major format with origin at the top left, the array would would have values stored like:

[0,MaxY], [0,MaxY -1]...[0,MinY], [1,MaxY],[1,MaxY-1]...[1,MinY]... [MaxX,MaxY],[MaxX, MaxY -1]...[MaxX, MinY]

given

double[] datavalues;

datavalues[0] = [0,MaxY]

and

datavalues[end]=[MaxX,MinY]

The attached screen shot may help visualize this: Here is what I have it looking like in LighningChart, I'm using the values to set the LightningChart Y axis (passed as Z in the code): As you can see the LightningChart X axis starts at 2000000, I would like it to start at 2040000 and decrease to 2000000.

Here is my code:

Code: Select all

```
public void CreateChart(int nX, int nY, double dx, double dy, double orgX, double orgY, float[] Z)
{
//Create new chart
m_chart = new LightningChartUltimate(LicenseKeys.LicenseKeyStrings.LightningChartUltimate);
//Disable rendering, strongly recommended before updating chart properties
m_chart.BeginUpdate();
//Set 3D as active view
m_chart.ActiveView = ActiveView.View3D;
//Chart parent must be set
m_chart.Parent = this;
//Fill parent area with chart
m_chart.Dock = DockStyle.Fill;
//Chart name
m_chart.Name = "Simple surface grid 3D chart";
//Set x-rotation
m_chart.View3D.Camera.RotationX = 38;
//Set transparent walls
List<WallBase> walls = m_chart.View3D.GetWalls();
foreach (WallBase wall in walls)
{
wall.Material.DiffuseColor = Color.FromArgb(30, wall.Material.DiffuseColor);
wall.SetGridStripColor1(Color.FromArgb(60, wall.GetGridStripColor1()));
wall.SetGridStripColor2(Color.FromArgb(60, wall.GetGridStripColor2()));
}
//Lightning Chart coords, our X = their Z, our Y = their X, our Z = their Y on 3D plots
m_chart.View3D.XAxisPrimary3D.SetRange(orgY, orgY + nY * dy);
m_chart.View3D.ZAxisPrimary3D.SetRange(orgX, orgX + nX * dx);
float[] fz = Z.Where(z => !Double.IsNaN(z)).ToArray();//filter out NaNs before getting min/max
m_chart.View3D.YAxisPrimary3D.SetRange(fz.Min(), fz.Max());
m_chart.View3D.YAxisPrimary3D.Reversed = true;//depths are positive values "Below Sea Level", so reverse
//Add 3D surface grid
SurfaceGridSeries3D gridSeries = new SurfaceGridSeries3D(m_chart.View3D, Axis3DBinding.Primary, Axis3DBinding.Primary, Axis3DBinding.Primary);
gridSeries.ContourPalette = CreatePalette(gridSeries, fz.Min(), fz.Max());
gridSeries.ContourLineType = ContourLineType.ColorLine;
gridSeries.ContourLineWidth = 2;
gridSeries.WireframeType = SurfaceWireframeType.None;
gridSeries.Fill = SurfaceFillStyle.Paletted;
m_chart.View3D.SurfaceGridSeries3D.Add(gridSeries);
gridSeries.SmoothShading = true;
gridSeries.SetRangesXZ(orgY, orgY + nY * dy, orgX, orgX + nX * dx);
gridSeries.SetSize(nY, nX);
//Set Y values for nodes
//Lightning Chart coords, our X = their Z, our Y = their X, our Z = their Y on 3D plots
for (int iNodeX = 0; iNodeX < nY; iNodeX++)
{
for (int iNodeZ = 0; iNodeZ < nX; iNodeZ++)
{
gridSeries.Data[iNodeZ, iNodeX].Y = (Z[iNodeX*nY + iNodeZ]);//stored column major
}
}
//Notify new values are ready
gridSeries.InvalidateData();
//Allow chart rendering
m_chart.EndUpdate();
}
```

Thanks

Greg.