Profile Picture

using data cursor tool

Posted By Daniel Csimszi 11 Years Ago
Author
Message
Daniel Csimszi
questionmark Posted 11 Years Ago
View Quick Profile
Forum Guru

Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)

Group: Forum Members
Last Active: 8 Years Ago
Posts: 61, Visits: 35
Hi,

I am trying to set an X axis data cursor tool on my graph.

I am using this code, but it does not seems to be working, could you please tell me what I am missing?

//data cursor tool
NDataCursorTool m_DataCursorTool = new NDataCursorTool();

m_VerticalAxisCursor = new NAxisCursor();
m_VerticalAxisCursor.BeginEndAxis = (int)StandardAxis.PrimaryX;
m_VerticalAxisCursor.ValueChanged += new EventHandler(OnValueChanged);


m_VerticalAxisCursor.ValueSnapper = new NAxisMinorTickSnapper();
m_Chart.Axis(StandardAxis.PrimaryX).Cursors.Clear();
m_Chart.Axis(StandardAxis.PrimaryX).Cursors.Add(m_VerticalAxisCursor);


m_VerticalAxisCursor.SynchronizeOnMouseAction = MouseAction.None;
m_VerticalAxisCursor.SynchronizeOnMouseAction |= MouseAction.Move;

nChartControl1.Controller.Tools.Add(m_DataCursorTool);

My class which is handling the graph and the graph object in to separate classes, I do not know if thtat makes any difference or not because of the mouse move event.

Regards
Daniel

Nevron Support
Posted 11 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: Last Week
Posts: 3,054, Visits: 4,009
Hi Daniel,

Probably you don't have a selected chart - you can achieve this in two ways:

1. Add a NSelectorTool which will automatically select a chart when the user clicks on it.
2. Select a chart from code:

NChart chart = nChartControl1.Charts[0];
nChartControl1.Controller.Selection.SelectedObjects.Add(chart);

Hope this helps - let us know if you meet any problems.

Best Regards,
Nevron Support Team



Daniel Csimszi
Posted 11 Years Ago
View Quick Profile
Forum Guru

Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)

Group: Forum Members
Last Active: 8 Years Ago
Posts: 61, Visits: 35
Hi,

I changed my code regarding your answer to this:

NDataCursorTool m_DataCursorTool = new NDataCursorTool();

m_VerticalAxisCursor = new NAxisCursor();
m_VerticalAxisCursor.BeginEndAxis = (int)StandardAxis.PrimaryX;
m_VerticalAxisCursor.ValueChanged += new EventHandler(OnValueChanged);


m_VerticalAxisCursor.ValueSnapper = new NAxisMinorTickSnapper();
m_Chart.Axis(StandardAxis.PrimaryX).Cursors.Clear();
m_Chart.Axis(StandardAxis.PrimaryX).Cursors.Add(m_VerticalAxisCursor);


m_VerticalAxisCursor.SynchronizeOnMouseAction = MouseAction.None;
m_VerticalAxisCursor.SynchronizeOnMouseAction |= MouseAction.Move;

NChart chart = nChartControl1.Charts[0];
nChartControl1.Controller.Selection.SelectedObjects.Add(chart);
nChartControl1.Controller.Tools.Add(m_DataCursorTool);

Unfortunately it still does not show anything.

Regards
Daniel

Nevron Support
Posted 11 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: Last Week
Posts: 3,054, Visits: 4,009
Hi Daniel,

The begin end axis should the primary Y (or another vertical axis) as you add the cursor to the x axis:

verticalAxisCursor.BeginEndAxis = (int)StandardAxis.PrimaryY;

Also make sure that m_Chart and nChartControl1.Charts[0] actually refer to the same chart.

We tested with the following code:

      private void Form1_Load(object sender, EventArgs e)
      {
         NDataCursorTool dataCursorTool = new NDataCursorTool();

         NAxisCursor verticalAxisCursor = new NAxisCursor();
         verticalAxisCursor.BeginEndAxis = (int)StandardAxis.PrimaryY;

         verticalAxisCursor.ValueSnapper = new NAxisMinorTickSnapper();

         NChart chart = nChartControl1.Charts[0];
         chart.Axis(StandardAxis.PrimaryX).Cursors.Clear();
         chart.Axis(StandardAxis.PrimaryX).Cursors.Add(verticalAxisCursor);

         verticalAxisCursor.SynchronizeOnMouseAction = MouseAction.None;
         verticalAxisCursor.SynchronizeOnMouseAction |= MouseAction.Move;

         NBarSeries bar = new NBarSeries();
         bar.Values.Add(10);
         bar.Values.Add(20);
         bar.Values.Add(30);
         chart.Series.Add(bar);

         nChartControl1.Controller.Selection.SelectedObjects.Add(chart);
         nChartControl1.Controller.Tools.Add(dataCursorTool);
      }

and it was working OK.

Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic