PivotGrid to HTMLChart

2 posts, 0 answers
  1. Hani
    Hani avatar
    3 posts
    Member since:
    Jun 2012

    Posted 06 Jul 2015 Link to this post



    First i don't know if this is the correct place to post or i should have posted in the HTMLChart section,


    Anyways I'm binding RadHTML Chart to a PivotGrid and everything is working perfectly excepts that the series names of the htmlchart are in an incorrect order, for example:


    If i have the below pivot:


       Name   :   Col1   |    Col2   |   Col3   |   Col4   

       A          :      1      |      4      |      5     |      2

       B          :      7      |      3      |      2     |      1

       C          :      5      |      1      |      4     |      2


    I get it in the HTML Chart as follows:


    X Axis name of Col3 with Series and Y value of Col2 and so on for the rest


    The ASP code is:


    <telerik:RadPivotGrid ID="RadPivotGrid1" runat="server" DataSourceID="SqlDataSource1" OnCellDataBound="RadPivotGrid1_CellDataBound">
                                            <telerik:PivotGridColumnField UniqueName="column" DataField="ProjectName" Caption="Project"></telerik:PivotGridColumnField>
                                            <telerik:PivotGridRowField UniqueName="column1" DataField="DisplayName" Caption="Name"></telerik:PivotGridRowField>
                                            <telerik:PivotGridAggregateField GrandTotalAggregateFormatString="" CalculationExpression="" UniqueName="column2" DataField="Duration" Caption="Duration">
                                                <TotalFormat Level="0" Axis="Rows" TotalFunction="NoCalculation" SortOrder="Ascending"></TotalFormat>
                                        <ConfigurationPanelSettings DefaultDeferedLayoutUpdate="True"></ConfigurationPanelSettings>
                                    <telerik:RadHtmlChart ID="RadHtmlChart1" runat="server" DataSourceID="SqlDataSource1">
                                            <Appearance Position="Bottom">

    I have SQLDataSource which is populated from Code behind, The code behind as follows:

        Private columnNames As New HashSet(Of String)()
        Private columnSeriesByRowName As New Dictionary(Of String, ColumnSeries)()
        Protected Sub RadPivotGrid1_CellDataBound(sender As Object, e As PivotGridCellDataBoundEventArgs)
            Dim dataCell As PivotGridDataCell = TryCast(e.Cell, PivotGridDataCell)
            If columnNames.Count = 0 Then
            End If
            If dataCell IsNot Nothing AndAlso dataCell.CellType = PivotGridDataCellType.DataCell Then
                Dim rowName As String = GetName(dataCell.ParentRowIndexes)
                Dim columnName As String = GetName(dataCell.ParentColumnIndexes)
                columnName = columnName.Replace("'", " ")
                If columnNames.Add(columnName) Then
                    Dim axisItem As New AxisItem(columnName)
                End If
                RadHtmlChart1.PlotArea.XAxis.LabelsAppearance.RotationAngle = 45
                Dim columnSeries As ColumnSeries = Nothing
                If columnSeriesByRowName.ContainsKey(rowName) Then
                    columnSeries = columnSeriesByRowName(rowName)
                    columnSeries = New ColumnSeries()
                    columnSeriesByRowName.Add(rowName, columnSeries)
                    columnSeries.Name = rowName
                    ' columnSeries.LabelsAppearance.DataFormatString = "C"
                    columnSeries.LabelsAppearance.Visible = False
                    columnSeries.LabelsAppearance.RotationAngle = 45
                    columnSeries.TooltipsAppearance.DataFormatString = "{0} " & rowName
                    columnSeries.Stacked = True
                End If
                Dim item As New CategorySeriesItem()
                Dim value As Decimal = 0
                If e.Cell.DataItem IsNot Nothing AndAlso Decimal.TryParse(e.Cell.DataItem.ToString(), value) Then
                    item.Y = value
                    item.Y = Nothing
                End If
            End If
        End Sub
        Private Function GetName(indexes As Object()) As String
            Dim builder As New StringBuilder()
            For Each index As Object In indexes
                builder.Append(" / ")
            builder.Remove(builder.Length - 3, 3)
            Return builder.ToString()
        End Function
        Private Sub PopulateSQLDataSource()
            SqlDataSource1.SelectCommand = "SELECT Project.ProjectName, SUM( DATEDIFF(HOUR, DbProvider_Classes.Start, DbProvider_Classes.[End])) AS Duration, Users.DisplayName
    FROM     Project INNER JOIN
                      DbProvider_Classes ON Project.ProjectID = DbProvider_Classes.ProjectID INNER JOIN
                      Users ON DbProvider_Classes.UserID = Users.UserID
                      INNER JOIN Tasks ON DbProvider_Classes.TaskID = Tasks.TaskID
                      WHERE Tasks.DepartmentID <> 6
                      GROUP BY Project.ProjectName , Users.DisplayName ORDER BY Project.ProjectName ASC"
        End Sub
    Private Sub btnViewAll_Click(sender As Object, e As EventArgs) Handles btnViewAll.Click
            lblReportDate.Text = "Report Date: Until " & Today.Date.ToString
        End Sub


    If i create the same report with report designer everything works fine and i can load the generated report file from report viewer within my page but i want the client side capabilities of the HTMLChart






  2. Maria Ilieva
    Maria Ilieva avatar
    4017 posts

    Posted 09 Jul 2015 Link to this post

    Hello Hani,

    The provided code looks absolutely correct to me and there is no obvious reason for the described issue to appear. The chart integration works properly in a sample application on my end.
    See the demo below:

    In this case it will be best if you can open a regular support ticket and send us sample runnable version of your application that demonstrates the issue. Thus we will be able to inspect it locally and advise you further.

    Maria Ilieva
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
Back to Top