public partial class MainWindow : Window { TestingValuesCollection collection; ObservableCollection<TestingValues> selectedValue { get; set; } public MainWindow() { InitializeComponent(); collection = new TestingValuesCollection(); candle.ItemsSource = collection.TestingModel; //setting series items source selectedValue = new ObservableCollection<TestingValues>(); } private void SfChart_PanChanging(object sender, PanChangingEventArgs e) { if (selectedValue.Count > 0) selectedValue.Clear(); var primaryAxis = (sender as SfChart).PrimaryAxis as CategoryAxis; var start = Math.Round(primaryAxis.VisibleRange.Start); var end = Math.Round(primaryAxis.VisibleRange.End); for (int i = (int)start; i < (int)end; i++) selectedValue.Add(collection.TestingModel[i]); var max = (from values in selectedValue select values.Y).Max(); var min = (from values in selectedValue select values.Y1).Min(); yAxis.Minimum = min; // setting Minimum for SecondaryAxis yAxis.Maximum = max; //setting Maximum for SecondaryAxis } } |
private void SfChart_PanChanging(object sender, PanChangingEventArgs e) { if (selectedValue.Count > 0) selectedValue.Clear(); var primaryAxis = (sender as SfChart).PrimaryAxis as DateTimeAxis; var start = primaryAxis.VisibleRange.Start.FromOADate(); var end = primaryAxis.VisibleRange.End.FromOADate(); foreach(var item in collection.TestingModel) { if(item.Date >= start.Date && item.Date <= end.Date) selectedValue.Add(item); } var max = (from values in selectedValue select values.Y).Max(); var min = (from values in selectedValue select values.Y1).Min(); yAxis.Minimum = min; yAxis.Maximum = max; } |