Nevron Forum

Finding Value-Range of Slider

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

By praf daw - Monday, July 20, 2009

Hi,
I am developing an application with Nevron Chart.

I have implemented axis scroll feature in order to allow end user to navigate axis.

I have extracted current view range the scroll bar is showing by registering ScrollBar.EndValueChanged, ScrollBar.BeginValueChanged with suitable event handler.

whenever the position of slider button in the scrollbar changes,the event gets fired and I can obtain view range of the axis via scrollBar.BeginValue and scrollBar.EndValue.

Instead of finding view range of a scrollbar,I actually want to extract the value-range slider button has currently occupied in axes.

Can you please suggest me how can I do it?

Regards,
PND
By Blagovest Milanov 1 - Monday, July 20, 2009

Hi Praf,

 

I'm not quite sure what the problem is - as the BeginValue and EndValue properties of the scrollbar actually define the thumb range on the axis - I tested with the following code:

 

private void Form1_Load(object sender, EventArgs e)

{

    // configure chart

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

    chart.RangeSelections.Add(new NRangeSelection());

   

    // add dummy data

    NBarSeries bar = new NBarSeries();

    bar.Values.Add(10);

    bar.Values.Add(20);

    bar.Values.Add(30);

    

    chart.Series.Add(bar);

   

    // show scroll bars and intercept begin/value change

    chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true;

    chart.Axis(StandardAxis.PrimaryY).ScrollBar.Visible = true;

    chart.Axis(StandardAxis.PrimaryY).ScrollBar.ViewRangeChanged += new EventHandler(ScrollBar_ViewRangeChanged);

   

    // configure interactivity

    nChartControl1.Controller.Tools.Add(new NSelectorTool());

    nChartControl1.Controller.Tools.Add(new NAxisScrollTool());

    nChartControl1.Controller.Tools.Add(new NDataZoomTool());

}

 

void ScrollBar_ViewRangeChanged(object sender, EventArgs e)

{

    NChart chart = nChartControl1.Charts[0];

    label1.Text = chart.Axis(StandardAxis.PrimaryY).ScrollBar.BeginValue.ToString();

    label2.Text = chart.Axis(StandardAxis.PrimaryY).ScrollBar.EndValue.ToString();

}

 

Note that you can also handle Range changed event which is fired when either the begin or end of the scrollbar range is changed.

 

Hope this helps - let me know if you have any questions or comments.

 

Best regards,
Bob

By praf daw - Wednesday, July 22, 2009

Hi Bob,
Thank you for the reply.
I want to explain my problem as follows(Formatting is lost):


Slider Button |--------|
Jan---------Jul---------Sep-----------------------Dec Axes


In above axis scrolling tool, I want to extract the value of July to September i.e. the position the current slider has occupied in the axes.

I do not want to extract the value Jan to Dec which in fact is given by ScrollBar.BeginValue, ScrollBar.EndValue.

Can you please tell me how I can do this?

Regards,
PND
By Blagovest Milanov 1 - Wednesday, July 22, 2009

Hi Praf,

I see - there is no way to reproject the begin-end range again - it will also not be very accurate as at certain sizes the thumb distors the tranform in order to be draggable (this happens when the view range is very very small compared to the original range).

Why is it necessary?

Best regards,
Bob