Nevron Forum

How to dynamically set chart size based on parent container

https://www.nevron.com/Forum/Topic2732.aspx

By Randy Michak 1 - Friday, November 6, 2009

I'm looking for an example or some ideas on how I can determine the chart size based on the parent container.  I really want a way to set a chart as 100% and 100% height.  However, I understand that since this is an image, this is not built in.  Seems like a common task a developer would want to do.  Is there an example floating around for how to do this?

Thanks, Randy

By Blagovest Milanov 1 - Friday, November 6, 2009

Hi Randy,

There are two ways to set the chart size to 100% of its parent panel:

1. By using docking:

NChart chart = nChartControl1.Charts[0];
chart.BoundsMode =
BoundsMode.Stretch;
chart.Dock =
DockStyle.Fill;

(that is provided that there are no other panels using docking before the chart panel in it's container)

2. By using Location/Size

NChart chart = nChartControl1.Charts[0];
chart.BoundsMode =
BoundsMode.Stretch;
chart.Size =
new NSizeL(new NLength(100, NRelativeUnit.ParentPercentage),
new NLength(100, NRelativeUnit.ParentPercentage));
chart.Size = new NPointL(new NLength(0),new NLength(0));

Hope I helped - let me know if you have any questions or comments.

Best regards,
Bob

By Randy Michak 1 - Friday, November 6, 2009

This binds it to 100% of the chart control.  How can I set the size of the ChartControl itself to take up 100% of the area on the webpage?   Assuming this is in a html table that is set 100%, can I have the parent ChartControl take the entire area and then bind an individual chart inside to also be 100%? 

 

Randy