Is it possible to maintain a fixed ratio between X and Y axis extents? Or get the plot area size?

I have a situation where I need the aspect ratio of the axes to match the aspect ratio of the plot area so that, for instance, a horizontal line of length 1.0 is the same number of pixels wide as a vertical line of length 1.0 is tall. Say I have four FastLineBitmapSeries with 2 points each that describes a square, it should be a square on screen no matter how I resize the window or the chart control -- without having to change the underlying point values.

Consider how a lot of modern TVs deal with 4:3 SD and 16:9 HD content.  SD content displayed on an HD screen can be pillarboxed, so the height fits perfectly leaving blank space on the sides or it can be zoomed such that the width fits and the top and bottom are chopped off.  If you want to display HD on an SD screen, it can be letterboxed so the width fits leaving blank space above and below or it can be zoomed so the height fits but the left and right are chopped off.  In all of those cases, the pixel aspect ratio (1:1 on most digital displays) of the image remains constant.  This only makes sense if the X and Y axis units are the same or otherwise commensurate.  The default behavior of the SfChart is akin to the dreaded Stretch mode on TVs where the image is squished to fit the screen making everyone look short and fat (SD on HD) or tall and skinny (HD on SD).

To implement it myself, I'd need to be able to get the actual width and height of the plot area and adjust the axis minimum and maximums to match the aspect ratio on control resize.  Any scaling to fit or user zoom/pan would have to be handled manually in the same resize event.  I'm willing to resort to that if necessary but I have not found a way to get the size of the plot area.


3 Replies

MK Muneesh Kumar G Syncfusion Team April 3, 2018 09:39 AM UTC

Hi Jason, 
 
Thanks for using Syncfusion products.  
 
We have analyzed your query, we suspect that your query is related to below requirements.  
 
Query 1 : Is it possible to maintain a fixed ratio between X and Y axis extents. 
 
We can achieve your requirement by setting Height and Width property in chart as follows.  
 
Code snippet [XAML]: 
 
    <chart:SfChart  Height="400" Width="400"> 
    </chart:SfChart> 
 
 
Query 2 : Get the plot area size? 
 
We can get chart area size by getting ActualHeight and ActualWidth property value as follows.  
 
Code snippet [C#]: 
 
var height = chart.ActualHeight; 
var width = chart.ActualWidth; 
 
 
If your requirement is different from this means, please update more information about your requirement that would be useful for us to provide better solution.  
 
Thanks, 
Muneesh Kumar G. 
 



JS Jason S. Clary April 3, 2018 03:07 PM UTC

I do not want to fix the chart height and width to be the same.  I want the window to be freely resized.  Also, this won't work because the aspect ratio of the control and the plot area are not the same thing. At a minimum, the tick marks and their values make them a bit different.  If you have axis labels, a title, a key or split the chart area with rows and columns, things get much worse.

ActualHeight and ActualWidth suffer the same issue.  It's the plot area width and height that I need to be fixed relative to the x and y axis extents, not the entire control.






MK Muneesh Kumar G Syncfusion Team April 6, 2018 08:39 AM UTC

Hi Jason,  
  
We have achieved your requirement by extending axis range based on size. Please find the sample from the below location.   
 
   
Thanks,   
Muneesh Kumar G.   
 


Loader.
Up arrow icon