In This Topic
Nevron Chart for .NET has an advanced built-in WYSIWYG layout support. The following topics will tecah you how to use the fatures of this layout engine.
Each object in the control (Chart, Legend, Label, Watermark, Annotation etc.) derives directly or indirectly from the NPanel class. Each panel has the following core features:
Parent Panel
When you add panels to the chart control they are either children of the root panel (which is hidden because you cannot directly modify it) or children of the children of the root panel and so on. You can access the panel parent from the ParentPanel property:
C# |
Copy Code
|
NPanel parentPanel = somePanel.ParentPanel;
|
Visual Basic |
Copy Code
|
Dim parentPanel As NPanel = somePanel.ParentPanel
|
Child Panels
The panel's structure represents a tree where each node is a panel and nodes can have child nodes. This provides powerful support for building complex nested and scalable layouts. You access the child panels of the panels from the ChildPanels property. The following code adds a child label to the chart:
C# |
Copy Code
|
NChart chart = chartControl.Charts[0];
NLabel label = new NLabel();
label.Text = "Label Child Panel";
label.Location = new NPointL(0, 0);
label.ContentAlignment = ContentAlignment.BottomRight;
label.TextStyle.FontStyle.EmSize = new NLength(22, NGraphicsUnit.Point);
chart.ChildPanels.Add(label);
|
Visual Basic |
Copy Code
|
Dim chart As NChart = chartControl.Charts(0)
Dim label As New NLabel
label.Text = "Label Child Panel"
label.Location = New NPointL(0, 0)
label.ContentAlignment = ContentAlignment.BottomRight
label.TextStyle.FontStyle.EmSize = New NLength(22, NGraphicsUnit.Point)
chart.ChildPanels.Add(label)
|
Panel Z Order
The Z order for each panel is automatically generated based on its position in the panels tree. To move a panel to the top of the Z order in it's parent you can use the
BringToFront method:
C# |
Copy Code
|
somePanel.BringToFront();
|
Visual Basic |
Copy Code
|
somePanel.BringToFront()
|
similarly to move the panel at the bottom of the Z order in it's parent you can call SendToBack():
C# |
Copy Code
|
somePanel.SendToBack();
|
Visual Basic |
Copy Code
|
somePanel.SendToBack()
|
Panel Bounds
The bounds of the panel are automatically calculated by the layout manager and you can access them when you perform custom painting or other tasks from the Bounds property.
These foundations are very powerful and allow you to build complex layouts like the ones shown on the following pictures:
Layout with Docking (demonstrates docking panels, ContentAlignment, Orientation for labels) |
|
|
Layout with Anchor Panels and Annotations (demonstrates annotations attached to different chart elements) |
|
|
The following topics will guide you trough the structure of the layout in Nevron Chart for .NET.