Is there a way to format to the text in piechart's legend? Like, I would like to have the Item_label to be aligned to the left while the data_value to be aligned to the right. Currently, the only way I could achieve this is by using 'Courier new' font. But I would like to use 'Arial' font and still achieve the same results. Any ideas on how to do this?
Hi,
You can customize legend changing its location, margins and format text to change its font, color. For more information you can refer to our online documentation here. For quick reference have a look following code:
this.UltraChart1.Legend.BackgroundColor = System.Drawing.Color.Yellow;
this.UltraChart1.Legend.FontColor = System.Drawing.Color.DarkSeaGreen;
this.UltraChart1.Legend.BorderColor = System.Drawing.Color.Red;
this.UltraChart1.Legend.BorderStyle = LineDrawStyle.Dash;
this.UltraChart1.Legend.BorderThickness = 3;
this.UltraChart1.Legend.AlphaLevel = 25;
this.UltraChart1.Legend.Font = new System.Drawing.Font("Arial", 20);
The problem I is with the alignment of the text inside the legends. All the text in each legend is not getting properly aligned. How do I align the text in the legend, like left middle or right?
by default they should be aligned left and there isn't a property which can be used to change this. however, you can handle the ChartDrawItem event and change it there:
void ultraChart1_ChartDrawItem(object sender, ChartDrawItemEventArgs e) { Text t = e.Primitive as Text; if (t != null && t.Path != null && t.Path.Contains("Legend")) { t.labelStyle.HorizontalAlign = StringAlignment.Far; } }