Generating Stacked Bar series automatically

8 posts, 0 answers
  1. Derek
    Derek avatar
    118 posts
    Member since:
    Oct 2008

    Posted 20 Aug 2013 Link to this post

    Is there any way to create a stacked bar chart without explicitly creating different series? We have a table that returns three columns; Category, Status, and a numeric value. We'd like to have the chart show each category as a stacked bar, with the status items stacked together; however, we don't know up front how many different status values will exist in the result set. The original RadChart control supported this, but we can't figure out any way to do it within the RadHTMLChart.
  2. Barbaros Saglamtimur
    Barbaros Saglamtimur avatar
    110 posts
    Member since:
    Jul 2012

    Posted 21 Aug 2013 Link to this post

    If I understand correctly you need to define series at runtime. So something like this may solve your problem

    RadHtmlChart1.PlotArea.Series.Clear();
    RadHtmlChart1.PlotArea.XAxis.Items.Clear();
    foreach (var item in yourDesiredData)
    {
        BarSeries newSeries = new BarSeries();
        //Series properties goes here like
        newSeries.Name = item.NameValue;
        newSeries.Stacked = true;
        RadHtmlChart1.PlotArea.Series.Add(newSeries);
    }
    I have not got detailed/working code on hand but if you search "RadHtmlChart.PlotArea.Series.Add" you will find more detailed samples like adding DataFieldY etc. Hope this will be a guide.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Derek
    Derek avatar
    118 posts
    Member since:
    Oct 2008

    Posted 04 Aug 2014 in reply to Barbaros Saglamtimur Link to this post

    I'm not sure I explained myself clearly enough. Let's say I have a dataset that has values such as

    "Category A", "Status 1", 7
    "Category A", "Status 2", 5
    "Category B", "Status 1", 11
    "Category B", "Status 2", 3
    "Category B", "Status 3", 4

    What I'd like to do is show each category as a single bar, with stacked values for each Status. I could do this by denormalizing the data and returning a column for each status, but i don't want to take that approach since the status values are dynamic and the list will change.

    Is there a way to generate stacked bar elements automatically from the data set? As I said, this feature is available in the original RadChart control, but has disappeared in the RadHTMLChart.
  5. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1492 posts

    Posted 06 Aug 2014 Link to this post

    Hi Derek,

    Data source grouping functionality is not supported out of the box by the RadHtmlChart and must be done manually. You can find such an example in the Group RadHtmlChart Data Source code library.

    Regards,
    Danail Vasilev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Derek
    Derek avatar
    118 posts
    Member since:
    Oct 2008

    Posted 06 Aug 2014 in reply to Danail Vasilev Link to this post

    Thank you for the code library reference. That should get our developers around the bump for this specific chart.

    What I find surprising is that this represents a downgrade in functionality from the component it replaces (RadChart), which was able to provide data grouping automatically. As well, the need to include all rows means that source data needs to change to include some kind of cross-product union to pad out the values with zeros; a performance hit, plus in many cases it means creating an alternate version of the source data object.

    I'd encourage Telerik to consider this as a feature upgrade; I'd suggest modifying it so that the user can specify a GroupBy column, and dealing with missing values automatically.
  7. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1492 posts

    Posted 11 Aug 2014 Link to this post

    Hello Derek,

    Thank you for sharing your feedback regarding our products.

    Generally the purpose of a charting control is to visualize data in different shapes and not to perform custom data source manipulations which is an entirely different domain. This may be the case, however, with a grid control because it displays data only in a tabular view and has actions like grouping, filtering, etc.

    As for the functionality parity between RadChart and RadHtmlChart I can suggest that you refer to this blog post and Migrating Functionalities - Features and Series Types Parity help article. Generally the newer RadHtmlChart control has reached almost all of the features of the obsolete RadChart and has only few lacks like intelligent labels, scale breaks, built in data source grouping, etc. RadHtmlChart has also many advantages over the older control like performance, client-side rendering, animations, many chart types, etc.

    Regarding the embedded grouping functionality of the RadChart it also has some limitations like the provided example - if the number for data rows for each series is not equal the data is not plotted properly. Yes, there isn't an exception to be thrown but the plotted data is misaligned. You can make a test with the example from this help article, by simply deleting the second row.

    Regards,
    Danail Vasilev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  8. Derek
    Derek avatar
    118 posts
    Member since:
    Oct 2008

    Posted 13 Oct 2014 in reply to Danail Vasilev Link to this post

    I respectfully disagree that a charting control should not be expected to perform data source manipulation. Pivoting and visualizing data is a common requirement; it's prevalent throughout Telerik's UI and reporting tools, and was present in the previous chart object (and is still present in the Reporting charting object). 

    Good database design will often result in linear data that needs to be grouped or pivoted before it can be charted. From a developer's perspective, the ideal place to have that happen would be in the chart control itself, rather than having to do it manually each time. Hopefully that feature will be added to the RadHtmlChart in the near future; I'm sure I'm not alone in requesting it.

    I note your comment about missing values; while it would also be nice to have a component that can account for missing values (as the pivotgrid and pivottables can do), but that's easier to work around.
  9. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1492 posts

    Posted 16 Oct 2014 Link to this post

    Hello Derek,

    The RadHtmlChart control is actually an ASP.NET server-side wrapper of the Kendo UI charting widget and that is why there are many differences with the older RadChart in the performance, UI and functionality. Fortunately the advantages of the RadHtmlChart prevail the ones in the older control and they are constantly increasing with each Q. See details in the release notes and in make a test of the new functionality in our Q3 2014 beta online demos.

    Currently our efforts are put mainly on developing the chart's UI for data visualizing, the client-side functionality as well as the server-side wrapper rather than implementing custom server-side functionality. As already stated data source grouping is a separate functionality that is not directly related to the charting domain. This is not so, however, with controls that display data only in tabular view because they must manipulate with the data itself through operations like filtering, paging, sorting, grouping, etc.

    Note also that the data base design is different for the particular project requirements and needs and also the performance of the grouping is the same for an embedded or a custom functionality.

    Regards,
    Danail Vasilev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017