| Samples > PieChart |
Merging values and labels
The Piechart is typically used to show how some total value is divided up, for example sales in two or more regions. It works best when there are only a few values, and they should be ranked in numerical order to facilitate comparison of the sector sizes.
Rather than drawing a separate legend, this example uses a special format string to merge the X-label text into the spider tags. The string XL is treated as an insertion point for the corresponding value from the array of labels.
The plain style simply omits the spider lines.
SharpPlot sp = new SharpPlot();
sp.SetMargins(12,0,18,0);
Party = new string[]{"Con","Lib","Lab"};
Votepc = new int[] {48,37,15};
sp.Heading = "Share of Votes Cast";
sp.HeadingStyle = HeadingStyles.Left;
sp.SetHeadingFont("ARB",14);
sp.PieChartStyle = PieChartStyles.ValueTags|PieChartStyles.Plain;
sp.SetEdgeStyle(Color.White,LineStyle.Solid,3);
sp.SetXLabels(Party);
sp.SetXLabelFont("ARB",12,Color.Navy);
sp.ValueTagFormat = "XL #0%";
sp.SetColors(new Color[]{Color.Navy,Color.Orange,Color.Red});
sp.DrawPieChart(Votepc);
See also
![]() |
![]() |
![]() |
![]() |




