This is a migrated thread and some comments may be shown as answers.

not showing percentage value on StackedSplineArea100 chart

5 Answers 123 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
shunman
Top achievements
Rank 1
shunman asked on 29 Sep 2011, 02:38 AM
Hi. i'm trying to make StackedSplineArea100  chart.
i saw indicating Ycolumn convert numeric to Percentage at this hyperlink. and i want to show like this.
http://www.telerik.com/help/aspnet-ajax/radchart-types-stacked-spline-area-100.html

here is my code.
this code has a problem that all Ycolumn value is 0%.
<telerik:RadChart ID="RadChart1" runat="server" DefaultType="StackedSplineArea100 " Width="1000" Height="800">
</telerik:RadChart>
Imports Telerik.Web.UI
Imports Telerik.Charting
 
Partial Class _Default
    Inherits System.Web.UI.Page
 
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
 
        RadChart1.DataGroupColumn = "Year"
 
        RadChart1.DataSource = ChartData.GetGrouplData()
        RadChart1.DataBind()
 
        For i As Integer = 0 To RadChart1.Series.Count - 1
 
            RadChart1.Series(i).DataXColumn = "Month"
            RadChart1.Series(i).DataYColumn = "MonthCount"
            RadChart1.Series(i).DefaultLabelValue = "#%"
        Next
    End Sub
End Class
 
Public Class ChartData
    Public Shared Function GetGrouplData() As DataTable
        Dim dataTableGroupData As New DataTable()
        dataTableGroupData = New DataTable()
        dataTableGroupData.Columns.Add("Year")
        dataTableGroupData.Columns.Add("Month")
        dataTableGroupData.Columns.Add("MonthCount")
 
        dataTableGroupData.Rows.Add(New Object() {"2009", "1", "50"})
        dataTableGroupData.Rows.Add(New Object() {"2009", "2", "20"})
        dataTableGroupData.Rows.Add(New Object() {"2009", "3", "70"})
        dataTableGroupData.Rows.Add(New Object() {"2009", "4", "143"})
        dataTableGroupData.Rows.Add(New Object() {"2009", "5", "210"})
        dataTableGroupData.Rows.Add(New Object() {"2009", "6", "250"})
        dataTableGroupData.Rows.Add(New Object() {"2009", "7", "252"})
        dataTableGroupData.Rows.Add(New Object() {"2009", "8", "396"})
        dataTableGroupData.Rows.Add(New Object() {"2009", "9", "406"})
        dataTableGroupData.Rows.Add(New Object() {"2009", "10", "470"})
        dataTableGroupData.Rows.Add(New Object() {"2009", "11", "472"})
        dataTableGroupData.Rows.Add(New Object() {"2009", "12", "431"})
 
        dataTableGroupData.Rows.Add(New Object() {"2010", "1", "10"})
        dataTableGroupData.Rows.Add(New Object() {"2010", "2", "50"})
        dataTableGroupData.Rows.Add(New Object() {"2010", "3", "234"})
        dataTableGroupData.Rows.Add(New Object() {"2010", "4", "101"})
        dataTableGroupData.Rows.Add(New Object() {"2010", "5", "231"})
        dataTableGroupData.Rows.Add(New Object() {"2010", "6", "482"})
        dataTableGroupData.Rows.Add(New Object() {"2010", "7", "20"})
        dataTableGroupData.Rows.Add(New Object() {"2010", "8", "87"})
        dataTableGroupData.Rows.Add(New Object() {"2010", "9", "58"})
        dataTableGroupData.Rows.Add(New Object() {"2010", "10", "10"})
        dataTableGroupData.Rows.Add(New Object() {"2010", "11", "99"})
        dataTableGroupData.Rows.Add(New Object() {"2010", "12", "312"})
 
        GetGrouplData = dataTableGroupData
    End Function
End Class

how can i solve this problem? thanks you

5 Answers, 1 is accepted

Sort by
0
Missing User
answered on 03 Oct 2011, 03:28 PM
Hi Shunman,

In order to achieve the desired scenario you need to use StackedSplineArea chart and "#%" as DefaultLabelValue format. Please, find attached a small example, demonstrating this approach.

Kind regards,
Polina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
shunman
Top achievements
Rank 1
answered on 04 Oct 2011, 01:41 AM
Hi. Telerik. thank you for reply and attaching sample.
But i wanted chartt type is "StackedSplineArea100". "StackedSplineArea" type is works fine.
I have a same problem bewteen "StackedArea100" and "StackedSplineArea100". these chart types are still not working about indicating %.
could you more help for me?

i'm attaching screenshot of using StackedSplineArea100 chart.
0
Missing User
answered on 06 Oct 2011, 04:36 PM
Hello Shunman,

Indeed it seems this is an issue with StackedSplineArea100 chart type when using "#%" wildcard as DefaultLabelValue format. We will forward it to our developers. The workaround here would be to loop manually through all series, calculate the sum of their first items and then calculate the current series' first item percentage of that sum. Then - do the same for the second items etc. Here is one possible approach:
Private Sub RadChart1_BeforeLayout(sender As Object, e As EventArgs)
    Dim sum As Double = 0.0
    Dim seriesItemsCount As Integer = RadChart1.PlotArea.XAxis.Items.Count
    For i As Integer = 0 To seriesItemsCount - 1
        sum = RadChart1.Series.Sum(Function(series) series(i).YValue)
        For Each series As var In RadChart1.Series
            series(i).Label.TextBlock.Text = Math.Round(series(i).YValue / sum * 100) + " %"
        Next
    Next
End Sub

I hope this helps.

Greetings,
Polina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
shunman
Top achievements
Rank 1
answered on 07 Oct 2011, 02:12 AM
Hi. thank you for reply.
I understand your answer, and i hope to fix it soon.

And I had tried your code,
"sum = RadChart1.Series.Sum(Function(series) series(i).YValue)"

this line Sum() method has error, "Sum is not a memeber of Telerik.charting.ChartseriesCollection."

let me know how can i use your code corretcly?
0
Missing User
answered on 07 Oct 2011, 01:17 PM
Hello Shunman,

The Sum() method computes the sum of a sequence of numeric values and is part of the System.Linq namespace. In order to use it you need to include a reference to this namespace.

Regards,
Polina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Chart (Obsolete)
Asked by
shunman
Top achievements
Rank 1
Answers by
Missing User
shunman
Top achievements
Rank 1
Share this question
or