Hi!
I'm working with a column chart and I want to know if there is a way to align the values in the center of each column.
I'm trying with StringAlignment but it only moves the values over the top of each column.
Thanks!
Hi,
Try using Stacked Column Chart. It displays the labels in the columns.
I tried the stacked column, but it don't show the value in the middle of each column.
The value is at the top of each column, there's a way to center the value vertically in each column?
Thanks
You can use this code:
this.ultraChart1.FillSceneGraph += new FillSceneGraphEventHandler(ultraChart1_FillSceneGraph);
…
private void ultraChart1_FillSceneGraph(object sender, FillSceneGraphEventArgs e)
{
List<Text> texts = new List<Text>();
foreach (Primitive prim in e.SceneGraph)
Box box = prim as Box;
if (box == null || box.DataPoint == null)
continue;
}
Text text = new Text();
text.labelStyle.HorizontalAlign = StringAlignment.Center;
text.labelStyle.VerticalAlign = StringAlignment.Center;
text.SetTextString(box.Value.ToString());
text.bounds = box.rect;
texts.Add(text);
foreach (Text text in texts)
e.SceneGraph.Add(text);
Thanks! it work perfectly
Hi
after convert it to vb.net i got the chart without text labels.(3D column chart)
this is my ucColumnChart_FillSceneGraph event
Dim texts As New List(Of Text)() For Each prim As Primitive In e.SceneGraph Dim box As Box = TryCast(prim, Box) If box Is Nothing OrElse box.DataPoint Is Nothing Then Continue For End If Dim text As New Text() text.labelStyle.HorizontalAlign = StringAlignment.Center text.labelStyle.VerticalAlign = StringAlignment.Center text.SetTextString(box.Value.ToString()) text.bounds = box.rect texts.Add(text) Next For Each text As Text In texts e.SceneGraph.Add(text) Next
after debugging i got the box is always nothing for all loop iterations.
is this statement is correct ? ; Dim box As Box = TryCast(prim, Box)
could you help me on this scenario?
I don’t think this logic from the 2D chart can be applied in the 3D charts, because of the complexity of the 3D rendering. In the 3D chart the rendered primitives are Path.
If you want to do any custom rendering in the chart, it is better to use 2D charts.
Dear Teodor,
After I follow your instruction, I can show value of column in center of column. However, I want to show this value outside of column and fill color in each bound of value (see in attach image). What Should I do?
Thank you.