not showing percentage value on StackedSplineArea100 chart

Thread is closed for posting
6 posts, 0 answers
  1. shunman
    shunman avatar
    77 posts
    Member since:
    Jul 2011

    Posted 28 Sep 2011 Link to this post

    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
  2. Missing user
    Missing user avatar

    Posted 03 Oct 2011 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. shunman
    shunman avatar
    77 posts
    Member since:
    Jul 2011

    Posted 03 Oct 2011 Link to this post

    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.
  5. Missing user
    Missing user avatar

    Posted 06 Oct 2011 Link to this post

    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
  6. shunman
    shunman avatar
    77 posts
    Member since:
    Jul 2011

    Posted 06 Oct 2011 Link to this post

    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?
  7. Missing user
    Missing user avatar

    Posted 07 Oct 2011 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017