Bind RadPivotGrid to RadHtmlChart

11 posts, 0 answers
  1. systems
    systems avatar
    70 posts
    Member since:
    Dec 2013

    Posted 24 Dec 2015 Link to this post

    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

  2. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 25 Dec 2015 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. systems
    systems avatar
    70 posts
    Member since:
    Dec 2013

    Posted 27 Dec 2015 in reply to Hristo Valyavicharski Link to this post

    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

  5. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 28 Dec 2015 Link to this post

    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
  6. systems
    systems avatar
    70 posts
    Member since:
    Dec 2013

    Posted 28 Dec 2015 in reply to Konstantin Dikov Link to this post

    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


  7. systems
    systems avatar
    70 posts
    Member since:
    Dec 2013

    Posted 29 Dec 2015 in reply to systems Link to this post

    Is there any workaround pls, any help is appreciable.

    -Chetan

  8. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 30 Dec 2015 Link to this post

    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
  9. systems
    systems avatar
    70 posts
    Member since:
    Dec 2013

    Posted 31 Dec 2015 in reply to Konstantin Dikov Link to this post

    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

  10. systems
    systems avatar
    70 posts
    Member since:
    Dec 2013

    Posted 03 Jan in reply to systems Link to this post

    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

  11. systems
    systems avatar
    70 posts
    Member since:
    Dec 2013

    Posted 08 Jan Link to this post

    Does anybody has any suggestions on this pls?
  12. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 13 Jan Link to this post

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