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. Image for the cookie policy date

Modify series properties by user

Hi,

I have a chart with several series, with millions of points.
I want to be able to modify the series properties at runtime.

I found a way to do it for ShowTrackballInfo, Strockethickness, Interior, YAxis.visibility, serie.isVisible, zoomfactor but not for YAxis range minimum and maximum (YAxis.Minimum or Maximum are not available).

1) The way I do the modifications of series properties works but doesn't look conventional for me. Is it the right way or is there a better method?
example (tracesParams is a list where I store user properties for each serie):

     foreach (var ser in FastLine.Series)
            {
                    if (ser is FastLineBitmapSeries)
                    {
                        FastLineBitmapSeries fastLineBitmap = ser as FastLineBitmapSeries;

                        fastLineBitmap.ShowTrackballInfo = (from s in tracesParams
                                                            where s.tag == fastLineBitmap.Label
                                                            select s.isOnSlider).Single();

                        if ((from s in tracesParams
                             where s.tag == fastLineBitmap.Label
                             select s.blockZoomFactor).Single())
                        {
                            fastLineBitmap.YAxis.ZoomFactor = 1;
                            fastLineBitmap.YAxis.ZoomPosition = 1;
                        }
                        else
                        {
                            fastLineBitmap.YAxis.ZoomFactor = FastLine.SecondaryAxis.ZoomFactor;
                            fastLineBitmap.YAxis.ZoomPosition = FastLine.SecondaryAxis.ZoomPosition;
                        }

                        if ((from s in tracesParams
                             where s.tag == fastLineBitmap.Label
                             select s.isAxisVisible).Single())
                        {
                            fastLineBitmap.YAxis.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            fastLineBitmap.YAxis.Visibility = Visibility.Collapsed;
                        }
                    }
             }

Note: I use this method because in the example above, ser.ShowTrackballInfo or ser.YAxis are not available.

2) using this method, for some reason I have to recall the procedure for zoomfactor and zoomposition everytime I zoom or the serie disappear. It works but seems not normal for me as I don't need to do it for ShowTrackballInfo or axis.visibility. Is it normal or not ?  

3) How can I force Yaxis range minimum and maximum to values from my list (yMinVal and yMaxVal) when user enters new values?

Thank you in advance
Best regards
Nicolas



1 Reply

HM Hemalatha Marikumar Syncfusion Team January 21, 2020 04:41 PM UTC

Hi Nicolas, 
  
Greetings from Syncfusion. 
  
Query 1: The way I do the modifications of series properties works but doesn't look conventional for me. Is it the right way or is there a better method?example (tracesParams is a list where I store user properties for each series) 
  
We have validated your code snippet and we suggest you to set binding the ViewModel properties from the corresponding DataContext to series ShowTrackball, ZoomPosition properties, when you need to set same values (ShowTrackball, ZoomPosition) for all the series. 
  
Note: I use this method because in the example above, ser.ShowTrackballInfo or ser.YAxis are not available. 
  
We would like to let you know that ShowTrackballInfo and YAxis properties are available in Cartesian series only. You can get these properties by converting the series to Cartesian series as per in the below code snippet. 
  
Code Snippet [C#]: 
if (series is CartesianSeries) 
{ 
               CartesianSeries cartesianSeries = series as CartesianSeries; 
               bool isshowtrackball = cartesianSeries.ShowTrackballInfo; 
               var axis = cartesianSeries.YAxis; 
  }    
  
  
Query 2: using this method, for some reason I have to recall the procedure for zoomfactor and zoomposition everytime I zoom or the serie disappear. It works but seems not normal for me as I don't need to do it for ShowTrackballInfo or axis.visibility. Is it normal or not ?  
  
Yes, you can split up your methods based on your requirement to avoid unnecessary changes. You can call the corresponding methods based on your requirement as per in the below code snippet. 
  
Code Snippet [C#]: 
  
private void UpdateZoomFactor() 
{ 
            foreach (var ser in FastLine.Series) 
            { 
                if (ser is FastLineBitmapSeries) 
                { 
                    FastLineBitmapSeries fastLineBitmap = ser as FastLineBitmapSeries; 
  
                    if ((from s in tracesParams 
                         where s.tag == fastLineBitmap.Label 
                         select s.blockZoomFactor).Single()) 
                    { 
                        fastLineBitmap.YAxis.ZoomFactor = 1; 
                        fastLineBitmap.YAxis.ZoomPosition = 1; 
                    } 
                    else 
                    { 
                        fastLineBitmap.YAxis.ZoomFactor = FastLine.SecondaryAxis.ZoomFactor; 
                        fastLineBitmap.YAxis.ZoomPosition = FastLine.SecondaryAxis.ZoomPosition; 
                    } 
                } 
            } 
        } 
  
private void UpdateTrackballAndAxis() 
  { 
            foreach (var ser in FastLine.Series) 
            { 
                if (ser is FastLineBitmapSeries) 
                { 
                    FastLineBitmapSeries fastLineBitmap = ser as FastLineBitmapSeries; 
  
                    fastLineBitmap.ShowTrackballInfo = (from s in tracesParams 
                                                        where s.tag == fastLineBitmap.Label 
                                                        select s.isOnSlider).Single(); 
                     
  
                    fastLineBitmap.YAxis.Visibility = (from s in tracesParams 
                                                       where s.tag == fastLineBitmap.Label 
                                                       select s.isAxisVisible).Single() ? Visibility.Visible : Visibility.Collapsed; 
                } 
            } 
        } 
  
  
Query 3: How can I force Yaxis range minimum and maximum to values from my list (yMinVal and yMaxVal) when user enters new values?  
  
You can achieve this requirement by setting the values to the Minimum and Maximum properties of the corresponding series Y-axis as per in the below code snippet. 
  
Code Snippet [C#]: 
  
if (fastLineBitmap.YAxis is NumericalAxis) 
{ 
             (fastLineBitmap.YAxis as NumericalAxis).Minimum = 100; 
             (fastLineBitmap.YAxis as NumericalAxis).Maximum = 500; 
  } 
  
  
Since we can't know your exact application scenario, please let us explain your exact requirement or application details to provide a better solution earlier. 
 
Regards, 
Hemalatha M. 


Loader.
Up arrow icon