Nevron Forum

Add Cursot to a surface chart

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

By Giulio Certo - Wednesday, January 23, 2013

I've a surface chart with one serie of data; I try to add a cursor tool following your example but I'm not able to show anything. What is wrong?
Thank you very much
This is my code snippet:

// setup Y axis
chart.Axis(StandardAxis.PrimaryY).Visible = false;

// setup X axis
NAxis axisX = chart.Axis(StandardAxis.PrimaryX);
axisX.Anchor =
new NDockAxisAnchor(AxisDockZone.FrontTop);
NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator();
scaleX.InnerMajorTickStyle.Visible =
false;
scaleX.RoundToTickMin =
false;
scaleX.RoundToTickMax =
false;
axisX.ScaleConfigurator = scaleX;

// setup Z axis
NAxis axisZ = chart.Axis(StandardAxis.Depth);
axisZ.Anchor =
new NDockAxisAnchor(AxisDockZone.TopLeft);
NLinearScaleConfigurator scaleZ = new NLinearScaleConfigurator();
scaleZ.InnerMajorTickStyle.Visible =
false;
scaleZ.MajorGridStyle.ShowAtWalls =
new ChartWallType[0];
scaleZ.RoundToTickMin = false;
scaleZ.RoundToTickMax =
false;
axisZ.ScaleConfigurator = scaleZ;

// add a surface series
surface = (NGridSurfaceSeries)chart.Series.Add(SeriesType.GridSurface);
surface.Name =
"Contour";
surface.Legend.Mode = SeriesLegendMode.SeriesLogic;
surface.ValueFormatter =
new NNumericValueFormatter("0.000");
surface.FillMode =
SurfaceFillMode.Zone;
surface.FrameMode =
SurfaceFrameMode.Contour;
surface.ShadingMode =
ShadingMode.Flat;
surface.DrawFlat =
true;

//add cursor
NInteractivityStyle curStyle = new NInteractivityStyle();
curStyle.Cursor =
new NCursorAttribute(CursorType.Cross);
m_HorizontalAxisCursor =
new NAxisCursor();
m_HorizontalAxisCursor.BeginEndAxis = (
int)StandardAxis.PrimaryX;
m_HorizontalAxisCursor.ValueChanged +=
new EventHandler(OnValueChanged);
m_HorizontalAxisCursor.SynchronizeOnMouseAction |=
MouseAction.Down;
m_HorizontalAxisCursor.InteractivityStyle = curStyle;
chart.Axis(
StandardAxis.PrimaryX).Cursors.Add(m_HorizontalAxisCursor);
m_VerticalAxisCursor =
new NAxisCursor();
m_VerticalAxisCursor.BeginEndAxis = (
int)StandardAxis.Depth;
m_VerticalAxisCursor.ValueChanged +=
new EventHandler(OnValueChanged);
m_VerticalAxisCursor.SynchronizeOnMouseAction |=
MouseAction.Down;
m_VerticalAxisCursor.InteractivityStyle = curStyle;
chart.Axis(StandardAxis.Depth).Cursors.Add(m_VerticalAxisCursor);

// add selector and data cursor tool
nChart.Controller.Tools.Add(new NSelectorTool());
nChart.Controller.Tools.Add(new NDataCursorTool());

By Nevron Support - Wednesday, January 23, 2013

Hi Giulio,

By default the chart is in 2D mode and surface charts require 3D mode. You have to add the following code:

chart.Enable3D = true;

Also you'll probably have to adjust the chart dimensions (Width, Height, Depth) as the default values are not appropriate for surface charts.