How to set layout the legendbox?

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
ehdrnsep
Posts: 48
Joined: Mon Jan 12, 2015 6:52 am

How to set layout the legendbox?

Post by ehdrnsep » Mon Aug 22, 2016 9:02 am

I want to set "want.jpg".
When the size of the chart changes.

example 1)
----------------------------------------------------------
Series1, Series2, Series3, Series4, Series5, Series6
Series7
----------------------------------------------------------

example 2)
----------------------------------------------------------
Series1, Series2, Series3, Series4, Series5
Series6, Series7
----------------------------------------------------------

How is it set?
Attachments
want.png
want.png (104.85 KiB) Viewed 13098 times
real.png
real.png (121.89 KiB) Viewed 13098 times

User avatar
ArctionNikolai
Posts: 38
Joined: Fri Feb 05, 2016 11:37 am
Location: Finland
Contact:

Re: How to set layout the legendbox?

Post by ArctionNikolai » Mon Aug 22, 2016 10:05 am

Hello,

My name is Nikolai and I am representative of Arction. Thank you for your question.

Each chart component is very flexible. I offer you to implement the following instructions to achieve the needed results:

- Сalculate LegendBox width. Get the width of the chart area.
- Increase margins to place legend box where you need. Set property chart.ViewXY.Margins. In your case, increase Margin.Top.
- Change LegendBox offset: X = 0; Y = 0. To place box in the top.

I hope it helps you in your projects. I am happy to answer all your further questions.

Best regards
Nikolai Arsenov
Software developer
Arction Ltd
Microkatu 1, 70210 Kuopio, Finland

ehdrnsep
Posts: 48
Joined: Mon Jan 12, 2015 6:52 am

Re: How to set layout the legendbox?

Post by ehdrnsep » Tue Aug 23, 2016 12:49 am

I'm sorry.
I am not so good at English.
So please be good to understand my awkward English.

It is not a question of margins.

I want to place the series in the legend box.

Series order of "real2.png" is shown below.
=====================================
series1, series2, series3
series4, series5, series6
series7
=====================================

but, i want ↓
=====================================
series1, series2, series3, series4, series5, series6
series7
=====================================


Thank you. T_T
Attachments
real2.png
real2.png (126.16 KiB) Viewed 13080 times

User avatar
ArctionNikolai
Posts: 38
Joined: Fri Feb 05, 2016 11:37 am
Location: Finland
Contact:

Re: How to set layout the legendbox?

Post by ArctionNikolai » Tue Aug 23, 2016 5:02 am

Oh no, your English is good.

Try to configure legend box in the code :
- Set LegendBox layout to HorizontalRowSpan

Code: Select all

chart.ViewXY.LegendBox.Layout = LegendBoxLayout.HorizontalRowSpan;
We have similar result what you want in demo application in Showcase examples: "Scrolling, layered axes".
Capture from Demo Application
Capture from Demo Application
Capture.PNG (9.1 KiB) Viewed 13078 times
I hope it will help.

Best regards and have a good day,

Nikolai
Nikolai Arsenov
Software developer
Arction Ltd
Microkatu 1, 70210 Kuopio, Finland

ehdrnsep
Posts: 48
Joined: Mon Jan 12, 2015 6:52 am

Re: How to set layout the legendbox?

Post by ehdrnsep » Thu Aug 25, 2016 7:51 am

Thank you for answer.

When I "YAxes Layout = YAxes Layout.Layered, AxisLayout.Auto Adjust Margins = false", I want to calculate the width of YAsixs.

Code: Select all

var r = chart.ViewXY.LegendBox.GetRenderedRect();
#warning How to calculate left margin?
chart.ViewXY.Margins = new Padding(80, r.Y + r.Height + 10, 30, 30);
Thank you.
Attachments
how to get yaxis width.png
how to get yaxis width.png (163.46 KiB) Viewed 13065 times

ehdrnsep
Posts: 48
Joined: Mon Jan 12, 2015 6:52 am

Re: How to set layout the legendbox?

Post by ehdrnsep » Thu Aug 25, 2016 8:09 am

Oh, i find it.

Thank you~~~~ :D

Code: Select all

chart.BeginUpdate();
chart.TweakDisablePresent();
chart.ViewXY.AxisLayout.AutoAdjustMargins = true;
chart.EndUpdate();

Rectangle r = chart.ViewXY.GetMarginsRect();

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

var ra = chart.ViewXY.LegendBox.GetRenderedRect();
chart.ViewXY.Margins = new Padding(r.Left, ra.Y + ra.Height + 10,
    chart.ClientSize.Width - r.Right,  
    chart.ClientSize.Height - r.Bottom);
            
chart.TweakEnablePresent();
chart.EndUpdate();

User avatar
ArctionNikolai
Posts: 38
Joined: Fri Feb 05, 2016 11:37 am
Location: Finland
Contact:

Re: How to set layout the legendbox?

Post by ArctionNikolai » Thu Aug 25, 2016 8:17 am

Always welcome.
Enjoy your coding with LightningChart ;)
Nikolai Arsenov
Software developer
Arction Ltd
Microkatu 1, 70210 Kuopio, Finland

Post Reply