Page 1 of 1

How to distribute y-Axises equally in Left Margin

Posted: Fri Jul 07, 2017 3:47 am
by 15681001
Hi,
Our .NET Graph component Y-Axis label texts were clipping when Multiple Axises were available and label text has large numbers e.g. 100.000
To fix this issue we have provided option for user to increase Left Margin (Minimum by 3% & Maximum by 50%).
The issue we are facing is the - after the Left Margin size changes the Y-Axises are not getting positioned with equal distance in Left Margin. Instead they are getting aligned to right side with some width and left most area is blank.
We tried setting RelativePosition for Y-Axis but it didn't worked.

Kindly suggest us a way to handle the issue.
Let us know better way to align Y-Axises so that text don't get clipped or guide us to equally distribute Y-Axises in Left Margin so that text won't get clipped.

Thanks.

Re: How to distribute y-Axises equally in Left Margin

Posted: Fri Jul 07, 2017 11:21 am
by Christopher
Hello,

Custom axes do not automatically reposition on every Chart repaint, for example when you cause a repaint by resetting the MarginLeft property. This means that the custom axes positions have to be calculated for each repaint, something you can achieve in one of the Canvas paint events:
featuredemo.PNG
featuredemo.PNG (190.51 KiB) Viewed 12761 times

Re: How to distribute y-Axises equally in Left Margin

Posted: Mon Jul 10, 2017 10:19 am
by 15681001
Hi,
Thank you for your suggestion.
But we are not able to set Relative Position in any of the said events.
Thus we are trying to set it using some of our calculations as below. But it is not working accurately.

Code: Select all



            double leftMarginWidthInPixels = (tChart1.Chart.Width * tChart1.Panel.MarginLeft) / 100;
            double marginIntervalInPixels = leftMarginWidthInPixels / yAxisCount;
            double marginIntervalInPecent = (marginIntervalInPixels / leftMarginWidthInPixels) * tChart1.Panel.MarginLeft;           
           
            int index = 0;
            for (int i = 0; i < tChart1.Axes.Custom.Count; i++)
            {
                    tChart1.Axes.Custom[i].RelativePosition = marginIntervalInPecent * -(index) * (100 / tChart1.Panel.MarginLeft);
                    index++;
              }
                
          
we are worried about this calculation:

tChart1.Axes.Custom.RelativePosition = marginIntervalInPecent * -(index) * (100 / tChart1.Panel.MarginLeft);

Please suggest a way to set Relative Position properly.

Re: How to distribute y-Axises equally in Left Margin

Posted: Mon Jul 10, 2017 4:11 pm
by Christopher
Hello,

You might like to try the PlaceAxis code shown in this message here. If that does not fulfil your requirements, please let me know.

Re: How to distribute y-Axises equally in Left Margin

Posted: Tue Jul 11, 2017 11:49 am
by 15681001
HI,
Thank you for your reply.
But the suggested solution is not working for us.
We already have chart and allowing user to specify Left Margin using Numeric Up-Down and on this Numeric Up-Down value change want to set Relative position of each series.
Chart.Draw() we don't want to call.
Is it mandatory to call Chart.Draw()?

Please suggest some calculations with which we can achieve it.

Thanks.

Re: How to distribute y-Axises equally in Left Margin

Posted: Tue Jul 11, 2017 1:51 pm
by Christopher
YTI wrote: Please suggest some calculations with which we can achieve it.
I have already suggested some calculations to use, but without a much clearer idea of what you are trying to achieve I am unable to provide you with anything further. To that extent, would you please be so kind as to provide us with a a minimal, complete, verifiable example (definition here) of the code you have which clearly shows your difficulty?