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..
Hi Max,
Yup, dont know how I missed that!. Thanks a ton - it works beautifully.
You should create a single GraphicsContext for all the labels you want to rotate. You're adding a new one for each label, so each GraphicsContext is contained within another GraphicsContext, compounding the angle.
The label rotation can be done much simpler by using this: label.labelStyle.Orientation = TextOrientation.Custom; label.labelStyle.RotationAngle = 30;
I tried with the following code but it didn't work as expected: it rotates the first label correctly by 30 degrees, but the second label by 60 and third by 90 and so on. I have used the Matrix object's RotateAt method. I am rotating the Y axis labels.
for (int i = 0; i < columnCount; i++) { string value = chartData.GetColumnLabel(i).ToString();
GraphicsContext gc = new GraphicsContext(); Matrix m = new Matrix();
Point location = new Point((int)xAxis.Map(-.07), (int)yAxis.Map(i + 0.5)); Text label = new Text();
m.RotateAt(-30f, new PointF(location.X, location.Y)); gc.Transform = m;
//gc.SetClipBounds(e.ChartCore.GetChartLayer().GetOuterBounds());
e.SceneGraph.Add(gc);
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); }
Please let me know what I am missing here.
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.
Hello anandraj,
You can refer to the following forum thread that explains how this can be done - http://community.infragistics.com/forums/t/52899.aspx
I hope that this information will help you to implement your scenario.