Can somebody please tell me how can i show the Total Collection on MSChart
You can use
chart.Annotations
[1] property to get a similar result.
For example with the following code (located after filling the chart):
var ann = new RectangleAnnotation();
ann.Text = "Total Collection" + Environment.NewLine + "250 Billion";
ann.IsMultiline = true;
ann.AxisX = this.chart1.ChartAreas[0].AxisX;
ann.AxisY = this.chart1.ChartAreas[0].AxisY;
ann.AnchorX = 9; // as you can see from the image below,
ann.AnchorY = 41; // these values are inside the range
// add the annotation to the chart annotations list
this.chart1.Annotations.Add(ann);
I got the following result:
N.B.:
there are a lot of annotations types (CalloutAnnotation
, EllipseAnnotation
...) and they have a lot of properties to change styles and behaviors. You can even set a property to allow annotation moving (i.e. AllowMoving=true
).
Have a look to annotation properties through intellisense or MSDN.
[1] http://msdn.microsoft.com/en-us/library/dd456725.aspxYou can set the property IsDockedInsideChartArea
to true
. You will also need to specify which ChartArea the legend is docked to, and set the position property to Auto
.
legend.IsDockedInsideChartArea = true;
legend.DockedToChartArea = "ChartArea1";
There are more information about this and other legend properties here [1].
[1] http://msdn.microsoft.com/en-CA/library/system.windows.forms.datavisualization.charting.legend.isdockedinsidechartarea.aspx