The following table lists the built-in anchors of the control:
Anchor Type | Description |
---|---|
NPanelAnchor | Allows you to attach to a specific location within a panel. For example 10 pixels away from the top of the legend. |
NModelPointAnchor | Allows you to attach to a specific model coordinate in NChart panels. |
NScalePointAnchor | Allows you to attach to a specific scale coordinate (defined by the current axis scaling). |
NAxisAnchor | Allows you to attach to a specific axis value in scale coordinates. |
NDataPointAnchor | Allows you to attach to a specific data point. |
NPieDataPointAnchor | Allows you to attach to a specific data point of a pie chart. |
NLegendDataItemAnchor | Allows you to attach to a specific legend data item. |
The following code creates a rectangular callout panel and attaches is to the second data point of a bar series.
C# |
Copy Code
|
---|---|
NCartesianChart chart = (NCartesianChart)chartControl.Charts[0]; NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.Values.Add(10); bar.Values.Add(20); bar.Values.Add(30); NRectangularCallout rectangularCallout = new NRectangularCallout(); rectangularCallout.ArrowLength = new NLength(30, NRelativeUnit.ParentPercentage); rectangularCallout.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.CadetBlue)); rectangularCallout.UseAutomaticSize = true; rectangularCallout.Orientation = 120; rectangularCallout.Anchor = new NDataPointAnchor(bar, 1, ContentAlignment.MiddleCenter, StringAlignment.Center); rectangularCallout.Text = "Rectangular callout attached \r\nto the second bar"; chartControl.Panels.Add(rectangularCallout); chartControl.Refresh(); |
Visual Basic |
Copy Code
|
---|---|
Dim chart As NCartesianChart = chartControl.Charts(0) Dim bar As NBarSeries = chart.Series.Add(SeriesType.Bar) bar.Values.Add(10) bar.Values.Add(20) bar.Values.Add(30) Dim rectangularCallout As New NRectangularCallout rectangularCallout.ArrowLength = New NLength(30, NRelativeUnit.ParentPercentage) rectangularCallout.FillStyle = New NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.CadetBlue)) rectangularCallout.UseAutomaticSize = True rectangularCallout.Orientation = 120 rectangularCallout.Anchor = New NDataPointAnchor(bar, 1, ContentAlignment.MiddleCenter, StringAlignment.Center) rectangularCallout.Text = "Rectangular callout attached " + Environment.NewLine + "to the second bar" chartControl.Panels.Add(rectangularCallout) chartControl.Refresh() |