How can I do to show percentage in a ColumnChart3d in the same way we show percentage in a pie chart?
See images.
Thanks.
Hello Dariogs,
Maybe one possible approach to achieve this behavior is to handle ultraChart1_FillSceneGraph() event and include the code below:
private void ultraChart1_FillSceneGraph(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs e) { TextList.Clear(); string IsAddedKey = null; foreach (Primitive pr in e.SceneGraph) { if (pr.Row != -1 && pr.Column != -1 && IsAddedKey != (pr.Row.ToString() + "-" + pr.Column.ToString())) { decimal tempPercent= (Convert.ToDecimal(pr.Value) / CalcSum(dt.Rows[pr.Row]))*100; Text textLable = new Text(new Point((int)((Infragistics.UltraChart.Core.Primitives.Path)(pr)).GraphicsPath.PathPoints[0].X, (int)((Infragistics.UltraChart.Core.Primitives.Path)(pr)).GraphicsPath.PathPoints[0].Y), tempPercent.ToString("0.00") + " %"); textLable.PE.Fill = Color.Black; IsAddedKey = pr.Row.ToString() + "-" + pr.Column.ToString(); TextList.Add(textLable); } } foreach (var item in TextList.Distinct()) e.SceneGraph.Add(item); }
private void ultraChart1_FillSceneGraph(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs e)
{
TextList.Clear();
string IsAddedKey = null;
foreach (Primitive pr in e.SceneGraph)
if (pr.Row != -1 && pr.Column != -1 && IsAddedKey != (pr.Row.ToString() + "-" + pr.Column.ToString()))
decimal tempPercent= (Convert.ToDecimal(pr.Value) / CalcSum(dt.Rows[pr.Row]))*100;
Text textLable = new Text(new Point((int)((Infragistics.UltraChart.Core.Primitives.Path)(pr)).GraphicsPath.PathPoints[0].X, (int)((Infragistics.UltraChart.Core.Primitives.Path)(pr)).GraphicsPath.PathPoints[0].Y), tempPercent.ToString("0.00") + " %");
textLable.PE.Fill = Color.Black;
IsAddedKey = pr.Row.ToString() + "-" + pr.Column.ToString();
TextList.Add(textLable);
}
foreach (var item in TextList.Distinct())
e.SceneGraph.Add(item);
Please take a look at the attached sample for more details. Please let me know if you have any questions.
Regards
Have you been able to resolve your issue ? Did you have a time to take a look at the attached sample. Please let me know if you have any questions.
could you post similar example for vb.net
Hello Anandraj,
anandraj said:could you post similar example for vb.net
Private Sub UltraChart1_FillSceneGraph(sender As System.Object, e As Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs) Handles UltraChart1.FillSceneGraph TextList.Clear() Dim IsAddedKey As String = Nothing For Each pr As Primitive In e.SceneGraph If pr.Row <> -1 AndAlso pr.Column <> -1 AndAlso IsAddedKey <> (pr.Row.ToString() + "-" + pr.Column.ToString()) Then Dim tempPercent As Decimal = (Convert.ToDecimal(pr.Value) / CalcSum(dt.Rows(pr.Row))) * 100 Dim textLable As New Text(New Point(CInt(DirectCast(pr, Infragistics.UltraChart.Core.Primitives.Path).GraphicsPath.PathPoints(0).X), CInt(DirectCast(pr, Infragistics.UltraChart.Core.Primitives.Path).GraphicsPath.PathPoints(0).Y)), tempPercent.ToString("0.00") + " %") textLable.PE.Fill = Color.Black IsAddedKey = pr.Row.ToString() + "-" + pr.Column.ToString() TextList.Add(textLable) End If Next For Each item As Text In TextList.Distinct() e.SceneGraph.Add(item) Next End Sub
Private Sub UltraChart1_FillSceneGraph(sender As System.Object, e As Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs) Handles UltraChart1.FillSceneGraph
TextList.Clear()
Dim IsAddedKey As String = Nothing
For Each pr As Primitive In e.SceneGraph
If pr.Row <> -1 AndAlso pr.Column <> -1 AndAlso IsAddedKey <> (pr.Row.ToString() + "-" + pr.Column.ToString()) Then
Dim tempPercent As Decimal = (Convert.ToDecimal(pr.Value) / CalcSum(dt.Rows(pr.Row))) * 100
Dim textLable As New Text(New Point(CInt(DirectCast(pr, Infragistics.UltraChart.Core.Primitives.Path).GraphicsPath.PathPoints(0).X), CInt(DirectCast(pr, Infragistics.UltraChart.Core.Primitives.Path).GraphicsPath.PathPoints(0).Y)), tempPercent.ToString("0.00") + " %")
textLable.PE.Fill = Color.Black
IsAddedKey = pr.Row.ToString() + "-" + pr.Column.ToString()
TextList.Add(textLable)
End If
Next
For Each item As Text In TextList.Distinct()
e.SceneGraph.Add(item)
End Sub