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

Bind RadPivotGrid to RadHtmlChart

10 Answers 163 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
systems
Top achievements
Rank 1
systems asked on 24 Dec 2015, 07:56 AM

Hello,

I have  a page with RadPivotGrid along with RadHtmlChart.

RadPivotGrid is getting populated programmatically with additional PivotGridColumnFields & PivotGridAggregateFields. (see attached)

Now, I need to generate an charts based on the RadPivotGrids data, however I am unable to set the binding to Chart with PivotGrid as source.

Does anybody have tried this before and can explain how shall I move ahead with this?

Thanks,

Chetan

10 Answers, 1 is accepted

Sort by
0
Hristo Valyavicharski
Telerik team
answered on 25 Dec 2015, 11:55 AM
Hi Chetan,

It all depends on your data and what you need. If might be possible. If is needed you may create additional object that work with both controls.

Regards,
Hristo Valyavicharski
Telerik
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
0
systems
Top achievements
Rank 1
answered on 28 Dec 2015, 03:21 AM

Hello Histro,

The issue I am currently struggling with is to bind the same Chart from RadPivotGrid's columns. 

I am binding the RadPivit with a data source with 5 columns and rendering a pivot with 8 columns (additional 3 columns are being added programatically as PivotGridColumnFields & PivotGridAggregateFields.

Now , I wish to assign these additional columns as data source to my Charts. 

Is there any blog/article/demo available for such bindings, as I did not found any?

Appreciate your comments.

Thanks,

Chetan

0
Konstantin Dikov
Telerik team
answered on 28 Dec 2015, 09:22 AM
Hello Chetan,

An online example for retrieving value from RadPivotGrid and displaying them in a chart is available in the following link:
As you will notice, the cell values are retrieved within the OnCellDataBound event of the RadPivotGrid.

Hope this helps.


Regards,
Konstantin Dikov
Telerik
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
0
systems
Top achievements
Rank 1
answered on 28 Dec 2015, 09:51 AM

Hi Konstatine,
I have already checked this demo, the difference here is you are binding the original plain data source as it is to Pivot without any additional Aggregate columns in it.
This works well if we Bind the chart with original datasource with column series.

In my case (see attached) the chart binding is required on row level against the specific column(in this case Type as Online / Reservation / Walk-In).

Could you pls explain more on row-series binding against a specific column only?
I can not change the Rad Pivot rendering as its been finalize as standard export format in excel, hence the struggle to get the chart working.

Awaiting your response.

Thanks,

Chetan


0
systems
Top achievements
Rank 1
answered on 30 Dec 2015, 04:00 AM

Is there any workaround pls, any help is appreciable.

-Chetan

0
Konstantin Dikov
Telerik team
answered on 30 Dec 2015, 02:35 PM
Hi Chetan,

You could use the same principal for retrieving the relevant columns and rows for each data cell, but you may need to modify the logic for binding to the chart as per your exact requirements:
protected void RadPivotGrid1_CellDataBound(object sender, PivotGridCellDataBoundEventArgs e)
{
    PivotGridDataCell dataCell = e.Cell as PivotGridDataCell;
         
        if (dataCell != null && dataCell.CellType == PivotGridDataCellType.DataCell)
        {
            string rowName = GetName(dataCell.ParentRowIndexes);
            string columnName = GetName(dataCell.ParentColumnIndexes);
            // your custom logic
        }
}
 
private string GetName(object[] indexes)
{
    StringBuilder builder = new StringBuilder();
    foreach (object index in indexes)
    {
        builder.Append(index.ToString());
        builder.Append(" / ");
    }
    builder.Remove(builder.Length - 3, 3);
    return builder.ToString();
}

Please note that rowName and columnName will hold the nested rows and columns, separated by " / ".


Kind Regards,
Konstantin Dikov
Telerik
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
0
systems
Top achievements
Rank 1
answered on 31 Dec 2015, 11:09 AM

Hi Konstantine,
This logic is already been tried & works well for scenario where single rows are considered. 
See my earlier attachement where in our case Pivot having multiple rows of Countries, now in this case binding grand total against each country rows 
is the challenge.
More over, with above code snippet we can not reterive Grand Total rows/columns count ( or am I not cognizant on how to retrive those).

Attached is the sample project with dummy data for your kind reference .As you can see per Pivot Cell Bound event the Chart binding is not as expected. 
We need to bind 2 charts as - 
Chart 1 : Brand wise Total Count  (See attached )
Chart 2 : Within single brand HOtel wise Total counts ( see attached)

Code location : https://www.dropbox.com/s/ax4h4i8darqm8so/RadPivotGridSample.zip?dl=0

Pls advise how do we achieve to retrieve specific rows/columns as highlighted.

Thank You,
Chetan

0
systems
Top achievements
Rank 1
answered on 04 Jan 2016, 03:17 AM

Hello Konstantine, 

Did you manage to look at this piece of thread pls. Yet we are not able to find a way to bind the chart as desired.

Looking for any workaround if possible

Chetan

0
systems
Top achievements
Rank 1
answered on 08 Jan 2016, 01:13 PM
Does anybody has any suggestions on this pls?
0
Konstantin Dikov
Telerik team
answered on 13 Jan 2016, 07:52 AM
Hi Chetan,

The OnCellDataBound event will fire for all cells and it is all a matter of custom handling. If you need to retrieve only the main level totals you could use the dataCell.ParentRowIndexes when the count of the objects equals 2 (for aloft and The Ritz-Carlton totals).

Please note that the ParentRowIndexes will contain all nested rows values, so you can retrieve the information that you need based on them.


Regards,
Konstantin Dikov
Telerik
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
Tags
Chart (HTML5)
Asked by
systems
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
systems
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or