Hi,
I'm trying to put on some custom labels on my chart, and I've been succeeding in parts..
I've gotten the custom label on the items using
Dim cta As Infragistics.UltraChart.Resources.Appearance.ChartTextAppearance
cta = New Infragistics.UltraChart.Resources.Appearance.ChartTextAppearance()cta.ChartTextFont = New Font("Arial", 7)cta.ItemFormatString = "<DATA_VALUE_ITEM:00.00>"cta.FontColor = Color.Whitecta.Visible = Truecta.Row = -2cta.Column = -2cta.PositionFromRadius = 100cta.HorizontalAlign = StringAlignment.Centercta.VerticalAlign = StringAlignment.NearchrtData.ColumnChart.ChartText.Add(cta)
but I want to succeed in adding a total ABOVE the columns.
Any ideas? Thanks in advance for the time spent.
What I got..
What I Want..
The chart doesn't have this built-in, so you will have to add these labels manually. I suggest using FillSceneGraph event for this. For example:private void ultraChart1_FillSceneGraph(object sender, FillSceneGraphEventArgs e){ if (e.Grid.Count <= 0) return;
List<string> labels = new List<string>(); IAdvanceAxis xAxis = (IAdvanceAxis)e.Grid["X"]; IAdvanceAxis yAxis = (IAdvanceAxis)e.Grid["Y"];
IChartData chartData = e.ChartCore.GetCurrentDataRef(); int rowCount = chartData.GetRowCount(); int columnCount = chartData.GetColumnCount();
for (int i=0; i<rowCount; i++) { double value = 0.0;
for (int j = 0; j < columnCount; j++) { value += chartData.GetValue(i, j); }
Point location = new Point((int)xAxis.Map(i + 0.5), (int)yAxis.Map(value)); Text label = new Text();
SizeF labelSize = Platform.GetStringSizePixels(value.ToString(), label.labelStyle.Font); location.X -= (int)labelSize.Width / 2; location.Y -= (int)labelSize.Height;
label.SetTextString(value.ToString()); label.bounds = new Rectangle(location, new Size((int)labelSize.Width, (int)labelSize.Height));
e.SceneGraph.Add(label); }}
Hi Max,
Thanks a lot for the post above. It works like a charm. I could space my X and Y labels neatly in the center of my axis for my Heatmap chart.
Could you guide me how to rotate my labels created as above, by a certain degree? I need my labels to be aligned by some degree (eg 30 degrees).
Thanka a lot.
after having it converted to vb.NET I succeeded in adding the wanted labels. Thanks for the help.