ViewXY - making room for scrollbars with autoplacement

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
greggorob64
Posts: 183
Joined: Tue Mar 18, 2014 2:55 pm

ViewXY - making room for scrollbars with autoplacement

Post by greggorob64 » Wed May 11, 2016 5:40 pm

I'm working towards enabling a clean implementation of allowing multiple Y axis.

Something I really liek is the automatic Y axis placement, using as little hozontal space as possible.

I have a graph that looks liek this:

Image

However, when I draw my scroll bars in, it draws them right on top of the axis I had drawn:

Image

Im in kind of a "have my cake and eat it too" situation. I'd like for the autoviewxy layout stuff to work, but I always want to "hard code" in a 12px padding so I can place my scroll bars there.

How would you approach this issue?

Thanks!

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: ViewXY - making room for scrollbars with autoplacement

Post by ArctionPasi » Thu May 12, 2016 5:29 am

LightningChart Support Team, PT

greggorob64
Posts: 183
Joined: Tue Mar 18, 2014 2:55 pm

Re: ViewXY - making room for scrollbars with autoplacement

Post by greggorob64 » Thu May 12, 2016 7:43 pm

That method is VERY hard to use, i've spent all day tinkering with it, and i feel like im farther away than i was frmo the very start.

Here is my goal: I want all the benefits of autoformatting the axis, but with the addition of padding the bottom and left side 15px for a scrollbar. The code sample below is a pretty simple example, i havent even accounted for the 15px scrollbar.

Using this logic for laying out my axis already breaks when I use multiple Y axis. It does not shrink the chart space to accomidate the additional axis (screenshot below).

How do I use this logic to achieve my goal?

Code: Select all

chart.BeginUpdate();

               //Special tweak: Let the rendering code run, but don't render 
               chart.TweakDisablePresent();
               chart.ViewXY.AxisLayout.AutoAdjustMargins = true;
               chart.EndUpdate();


               Rectangle r = chart.ViewXY.GetMarginsRect();

               chart.BeginUpdate();
               chart.ViewXY.AxisLayout.AutoAdjustMargins = false;

               //User left, top and bottom as they were measured by contents of axis labels, but change right margin
               //chart.ViewXY.Margins = new Padding(
               //   r.Left + ScrollbarVerticalWidth,
               //   r.Top,
               //   chart.ClientSize.Width - r.Right,
               //   chart.ClientSize.Height - r.Bottom + ScrollbarHorizontalHeight);
               chart.ViewXY.Margins = new Padding(
                  r.Left, // + ScrollbarVerticalWidth,
                  r.Top,
                  //r.Right,
                  //r.Bottom);
                  chart.ClientSize.Width - r.Right,
                  chart.ClientSize.Height - r.Bottom);// + ScrollbarHorizontalHeight);

               //Special tweak: enable rendering. 
               chart.TweakEnablePresent();

               chart.EndUpdate();
Screenshot of what happens after i call the previous margin code every time after I add an axis
Image

Post Reply