Page 1 of 1

How to set layout the legendbox?

Posted: Mon Aug 22, 2016 9:02 am
by ehdrnsep
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?

Re: How to set layout the legendbox?

Posted: Mon Aug 22, 2016 10:05 am
by ArctionNikolai
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

Re: How to set layout the legendbox?

Posted: Tue Aug 23, 2016 12:49 am
by ehdrnsep
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

Re: How to set layout the legendbox?

Posted: Tue Aug 23, 2016 5:02 am
by ArctionNikolai
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 13286 times
I hope it will help.

Best regards and have a good day,

Nikolai

Re: How to set layout the legendbox?

Posted: Thu Aug 25, 2016 7:51 am
by ehdrnsep
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.

Re: How to set layout the legendbox?

Posted: Thu Aug 25, 2016 8:09 am
by ehdrnsep
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();

Re: How to set layout the legendbox?

Posted: Thu Aug 25, 2016 8:17 am
by ArctionNikolai
Always welcome.
Enjoy your coding with LightningChart ;)