We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Complete example of auto scale y axis when x axis is zoomed

Thread ID:

Created:

Updated:

Platform:

Replies:

118291 Feb 20,2015 02:48 PM UTC Mar 13,2015 12:49 PM UTC WPF 7
loading
Tags: SfChart
Steven Michael
Asked On February 20, 2015 02:48 PM UTC

Hello,

I am new to Syncfusion. I love the product, but I am an inexperienced programmer. I have a scatter SfChart and I would like to auto scale y axis when x axis is zoomed. I have seen the code snippet http://help.syncfusion.com/ug/wpf/default.htm#!documents/howtoautoscaleyaxisw.htm

 

But I still don’t know how to use it. Here are some of my problems:

 

I am unable to find the VisibleRangeChanged event associated with the chart or axis.

Your code includes the class RecordFilterDescriptor but I can't seem to find it in the overall program.

 

I would greatly appreciate it if you could provide a more complete example so that I could see how to implement auto scale y axis when x axis is zoomed.

 

Thank you.


Rachel A [Syncfusion]
Replied On February 23, 2015 12:47 PM UTC

Hi Steven,

Thanks for your interest in using Syncfuion products.

When set the ZoomMode as “XY” by default both axis will be scaled automatically. However, we can auto scale any of the axis (say Y-axis) while zooming another axis (say X-Axis, if we set ZoomMode=”X”) as reported old chart help link by using ZoomChanged Event. Please refer the below code snippet.

Code Snippet:

 private void sfchart_ZoomChanged(object sender, ZoomChangedEventArgs e)

  {

  

   }

We have prepared the sample based on this and please find the sample in the below location.

Sample: AutoScaleYAxis.zip

Please refer the below documentation for your more information about SfChart zoom and pan behavior.

Link: http://help.syncfusion.com/ug/wpf/default.htm#!documents/zoomingandpanning.htm

Note: There is no VisibleRangeChanged event and RecordFilterDescriptor class in our SfChart control.

Please let us know if you require any further assistance.

Thanks,

Rachel. A



Steven Michael
Replied On February 28, 2015 01:53 PM UTC

Hello Rachel,

Thank you for your rapid response and detailed example.

I’m sorry but I guess didn’t explain my problem very well. When I ran your example with zoom on x only, the y axis did not auto-scale.

In order to achieve zoom on x only, I had to change one line in your example to the following:

 

<chart:ChartZoomPanBehavior EnableSelectionZooming="True" ZoomMode="X" />

 

The y axis did not auto-scale. I would greatly appreciate your advice on how to get the y axis to auto-scale when I use EnableSelectionZooming="True" ZoomMode="X"

Thank you for your help,

Steven


Rachel A [Syncfusion]
Replied On March 2, 2015 01:43 PM UTC

Hi Steven,

Thank you for your response.

When you are using selection zooming, we can auto scale the y axis using SelectionZoomingEnd event as shown in the below code snippet.

Code Snippet:

private void SfChart_SelectionZoomingEnd(object sender, Syncfusion.UI.Xaml.Charts.SelectionZoomingEndEventArgs e)

        {

                }

We have modified the sample based on your requirement and please find the sample in the below location.

Sample: AutoScale_SelctionZooming.zip

Note: If this is not your requirement, please let us know your auto scaling functionality. It would be helpful for us to serve you better.

Please let us know if you require any further assistance.

Thanks,

Rachel. A



Steven Michael
Replied On March 3, 2015 12:36 PM UTC

Thank you for your response.

I am trying to build a stock chart, where I can selection zoom on the x-axis and have the y-axis autoscale. This is some of the functionality I need:

 

1. A two pane stock chart with OHLC on the top pane and volume on the bottom pane.

2. The x-axis is a DateTimeCategoryAxis.

3. Only the x-axis for the volume pane is visible. The x-axis for the price pane in not visible so that the top pane can sit directly on the volume pane.

4. The cursor is a crosshairs that goes across both panes, and shows the date only on the x-axis of the bottom volume pane.

5. I can use the crosshairs cursor to selection zoom the x-axis, and the y-axis autoscales.

6. Finally, once I zoom the x-axis, a scrollbar appears.

7. When I use the scrollbar and scroll through the data, the y-axis autoscales to the data displayed.

 

I would greatly appreciate a sample program.

Kind regards

Steven


Sheik Syed Abthaheer M [Syncfusion]
Replied On March 4, 2015 01:53 PM UTC

Hi Steven,

Thanks for your update.


Requirement

Response

A two pane stock chart with OHLC on the top pane and volume on the bottom pane.

You can achieve multiple pane support by using Chart Row/Column Definition. For more information about Multiple Pane chart support please refer the below link:

Link: http://help.syncfusion.com/ug/wpf/documents/area.htm

The x-axis is a DateTimeCategoryAxis.

Please refer below link for DateTimeCategoryAxis

Link: http://help.syncfusion.com/ug/wpf/documents/datetimecategoryaxis.htm

 

Only the x-axis for the volume pane is visible. The x-axis for the price pane in not visible so that the top pane can sit directly on the volume pane.

By default  in chart Row definition, the ChartAxis will be placed in the bottom pane.

The cursor is a crosshairs that goes across both panes, and shows the date only on the x-axis of the bottom volume pane.

You are able show the cross hair value for chart axis by setting the ShowTrackBallInfo as true for specified chart axis.

I can use the crosshairs cursor to selection zoom the x-axis, and the y-axis autoscales.

Finally, once I zoom the x-axis, a scrollbar appears.

When I use the scrollbar and scroll through the data, the y-axis autoscales to the data displayed.

 

For more information about CrossHair and ZoomPan behavior please refer our UG documentation. You can enable the Scrollbar(ChartAxis’s EnableScrollBar as True)and auto scale the Y-axis by using  chart zooming events.

We have prepared the simple sample based on your requirement. Please find the sample in the below location.

Sample: ChartRequirement.zip

Please let us know if you have any queries.

Regards,

M.Sheik



Steven Michael
Replied On March 12, 2015 11:47 AM UTC


Thank you for your example M. Sheik.

I have a few questions. First, the example you provided does not seem to autoscale after zooming on the x-axis. I can’t see any logic in the method financialChart_SelectionZoomingEnd, which is supposed to autoscale the y-axis. Second, since this is supposed to be a stock chart the days cannot be consecutive. Weekend days must be skipped. Finally, the scrollbars on your example are on the y-axis. I would like to be able to scroll on the x-axis and have the y-axis autoscale.

Thank you for all you help so far.

Steven




Sheik Syed Abthaheer M [Syncfusion]
Replied On March 13, 2015 12:49 PM UTC

 Hi Steven,

Thanks for the update.

Query 1: the example you provided does not seem to autoscale after zooming on the x-axis. I can’t see any logic in the method financialChart_SelectionZoomingEnd.

We would like to let you know that, we have already provided the logic for auto scale the y-axis in AutoScale_SelctionZooming.zip sample. Also you can change the calculation based on your scenario in financialChart_SelectionZoomingEnd event. In last sample we have used financialChart_SelectionZoomingEnd event for enable the axis scroll bar while perform the select zooming action and not for auto scale the y-axis.

Query 2: since this is supposed to be a stock chart the days cannot be consecutive. Weekend days must be skipped.

In order to skip the weekends, you need to filter the data points as only for working days and use DateTimeCategoryAxis as shown in the below sample.

Query 3: the scrollbars on your example are on the y-axis. I would like to be able to scroll on the x-axis and have the y-axis autoscale.

As we informed in previous update you can apply the scroll bar in chart axis by setting EnableScrollbar as “True”. So you can set the scroll bar for X-Axis as shown in the below code snippet.

Code Snippet [Xaml]:

<chart:SfChart.PrimaryAxis>

          <chart:DateTimeCategoryAxis EnableScrollBar="True"/>

</chart:SfChart.PrimaryAxis>
Sample: Chart_WeekDays.zip

Please let us know if you have any queries.

Regards,
M. Sheik
 

 



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;