Hello,
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"> <Fields> <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> </telerik:PivotGridAggregateField> </Fields> <ConfigurationPanelSettings DefaultDeferedLayoutUpdate="True"></ConfigurationPanelSettings> </telerik:RadPivotGrid> <telerik:RadHtmlChart ID="RadHtmlChart1" runat="server" DataSourceID="SqlDataSource1"> <Legend> <Appearance Position="Bottom"> </Appearance> </Legend> </telerik:RadHtmlChart>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 Me.RadHtmlChart1.PlotArea.XAxis.Items.Clear() Me.RadHtmlChart1.PlotArea.Series.Clear() 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) RadHtmlChart1.PlotArea.XAxis.Items.Add(axisItem) End If RadHtmlChart1.PlotArea.XAxis.LabelsAppearance.RotationAngle = 45 Dim columnSeries As ColumnSeries = Nothing If columnSeriesByRowName.ContainsKey(rowName) Then columnSeries = columnSeriesByRowName(rowName) Else 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 Me.RadHtmlChart1.PlotArea.Series.Add(columnSeries) 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 Else item.Y = Nothing End If columnSeries.SeriesItems.Add(item) 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(index.ToString()) builder.Append(" / ") Next 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.DisplayNameFROM 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" SqlDataSource1.Select(DataSourceSelectArguments.Empty) SqlDataSource1.DataBind() RadPivotGrid1.DataBind() End SubPrivate Sub btnViewAll_Click(sender As Object, e As EventArgs) Handles btnViewAll.Click PopulateSQLDataSource() 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
Thanks