Profile Picture

Adding and positioning multiple charts

Posted By Devin Ellis 6 Years Ago
Author
Message
Devin Ellis
Posted 6 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: Forum Members
Last Active: Last Month
Posts: 9, Visits: 78
We have some graph where one graph is on top of another graph and one that has four graphs.
I had thought that positioning and adding was done through NChartControl Panels member but in the
examples I see it being used to add charts. For the two graph case we want to add one graph above another.
We call ChartControl.Panels.Add but the graphs appear one on top of the other. Do we have to add a chart to an 
NDockPanel then add dock panel to NChartControl, or can we use a docking enum and add a chart to NChartControl.
And how is this done for four graph case?




Nevron Support
Posted 6 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
Hi Devin,
Generally you have two options when positioning panels:
1. Location / Size in this case DockMode is set to None and the Location / Size parameters of the panel (chart, label, legend etc.) determine where its location - for example:
NCartesianChart chart1 = new NCartesianChart();
nChartControl1.Panels.Add(chart1);
chart1.BoundsMode = BoundsMode.Stretch;
chart1.Location = new NPointL(new NLength(5, NRelativeUnit.ParentPercentage), new NLength(5, NRelativeUnit.ParentPercentage));
chart1.Size = new NSizeL(new NLength(90, NRelativeUnit.ParentPercentage), new NLength(40, NRelativeUnit.ParentPercentage));
NBarSeries bar1 = new NBarSeries();
bar1.Values.Add(10);
bar1.Values.Add(20);
bar1.Values.Add(30);
chart1.Series.Add(bar1);

NCartesianChart chart2 = new NCartesianChart();
nChartControl1.Panels.Add(chart2);
chart2.BoundsMode = BoundsMode.Stretch;
chart2.Location = new NPointL(new NLength(5, NRelativeUnit.ParentPercentage), new NLength(55, NRelativeUnit.ParentPercentage));
chart2.Size = new NSizeL(new NLength(90, NRelativeUnit.ParentPercentage), new NLength(40, NRelativeUnit.ParentPercentage));
NBarSeries bar2 = new NBarSeries();
bar2.Values.Add(10);
bar2.Values.Add(20);
bar2.Values.Add(30);
chart2.Series.Add(bar2);
2. Using docking - this approach is useful when you want to have a label / legend that are hard to measure initially and you want the control to measure them automatically - for example:
nChartControl1.Panels.Clear();

NLabel label = new NLabel("Some Header");
label.DockMode = PanelDockMode.Top;
label.Margins = new NMarginsL(10);
nChartControl1.Panels.Add(label);

NDockPanel dockFill = new NDockPanel();
dockFill.DockMode = PanelDockMode.Fill;
nChartControl1.Panels.Add(dockFill);

NCartesianChart chart1 = new NCartesianChart();
dockFill.ChildPanels.Add(chart1);
chart1.BoundsMode = BoundsMode.Stretch;
chart1.Margins = new NMarginsL(10);
chart1.DockMode = PanelDockMode.Top;
chart1.Size = new NSizeL(new NLength(100, NRelativeUnit.ParentPercentage), new NLength(50, NRelativeUnit.ParentPercentage));
NBarSeries bar1 = new NBarSeries();
bar1.Values.Add(10);
bar1.Values.Add(20);
bar1.Values.Add(30);
chart1.Series.Add(bar1);

NCartesianChart chart2 = new NCartesianChart();
dockFill.ChildPanels.Add(chart2);
chart2.Margins = new NMarginsL(10);
chart2.DockMode = PanelDockMode.Fill;
chart2.BoundsMode = BoundsMode.Stretch;
chart1.Size = new NSizeL(new NLength(100, NRelativeUnit.ParentPercentage), new NLength(50, NRelativeUnit.ParentPercentage));
NBarSeries bar2 = new NBarSeries();
bar2.Values.Add(10);
bar2.Values.Add(20);
bar2.Values.Add(30);
chart2.Series.Add(bar2);

You can also check out the Users Guide \ Layout topics which explain this in detail. Hope this helps - let us know if you meet any problems or have any questions.

Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic