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
I’m trying the following code and it displays the texts in the middle of the columns:
DataTable table = new DataTable();
table.Columns.Add("name", typeof(string));
table.Columns.Add("value", typeof(double));
table.Rows.Add("a", 9);
table.Rows.Add("b", 4);
this.UltraChart1.ChartType = ChartType.StackColumnChart;
this.UltraChart1.DataSource = table;
this.UltraChart1.DataBind();
ChartTextAppearance app = new ChartTextAppearance();
app.Visible = true;
app.Column = -2;
app.Row = -2;
this.UltraChart1.ColumnChart.ChartText.Add(app);
Thanks! it's right, I have a composite char with un columnlayer and various series, so the stackcolumn don't fit this situation, I need use a column chart because I need show all the columns right each other and not stacked.
There's a way of doing this with a column chart?
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);
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.
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.
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?
Thanks! it work perfectly