Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
Aspect ratio of ultra chart
posted

 Hi,

 Is there a way to maintain aspect ratio of the ultra chart, i.e, the ratio between Y-axis and X-axis,  when the control is resized?

 

Thanks in advance. 

Parents
No Data
Reply
  • 200
    posted

     Hi bakidost,

    I'm not really sure that I understand what exactly You need but if you need to keep drawn chart not resizable I beleive the snippet below will help you. Firstly, You should set each axis' Extent property. Note that Extent property will take an effect only if current axis is visibe. But You may not need to have all axises displayed. That is why You should set the LineColor property of the axis to Color.Transparent. After setuping this You need to handle Resize event of the control in order to be able to reset axises' Extent property.

    Public Cass MyForm

        ' drawn chart width
        Dim chartWidth As Integer
        ' drawn chart height
        Dim chartHeight As Integer
        Dim intialExtend As Integer = 200

        Private Sub MarginsOn3DBarChartForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            UltraChart1.Axis.Y.Extent = intialExtend
            UltraChart1.Axis.X.Extent = intialExtend
            UltraChart1.Axis.Y2.Visible = True
            UltraChart1.Axis.Y2.LineColor = Color.Transparent
            UltraChart1.Axis.Y2.Extent = intialExtend
            UltraChart1.Axis.X2.Visible = True
            UltraChart1.Axis.X2.LineColor = Color.Transparent
            UltraChart1.Axis.X2.Extent = intialExtend
            chartWidth = UltraChart1.Width - intialExtend * 2
            chartHeight = UltraChart1.Height - intialExtend * 2
        End Sub

        Private Sub UltraChart1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UltraChart1.Resize

            Dim currentYExtent As Integer = (UltraChart1.Width - chartWidth) / 2
            Dim currentXExtent As Integer = (UltraChart1.Height - chartHeight) / 2

            If currentYExtent > 0 Then
                UltraChart1.Axis.Y.Extent = currentYExtent
                UltraChart1.Axis.Y2.Extent = currentYExtent
            End If

            If currentXExtent > 0 Then
                UltraChart1.Axis.X.Extent = currentXExtent
                UltraChart1.Axis.X2.Extent = currentXExtent
            End If

        End Sub

    End Class

Children
No Data