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

Generating Stacked Bar series automatically

7 Answers 386 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Derek
Top achievements
Rank 1
Derek asked on 20 Aug 2013, 08:08 PM
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.

7 Answers, 1 is accepted

Sort by
0
Barbaros Saglamtimur
Top achievements
Rank 1
answered on 21 Aug 2013, 10:18 AM
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.
0
Derek
Top achievements
Rank 1
answered on 04 Aug 2014, 09:28 PM
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.
0
Danail Vasilev
Telerik team
answered on 06 Aug 2014, 10:58 AM
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.

 
0
Derek
Top achievements
Rank 1
answered on 06 Aug 2014, 11:35 AM
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.
0
Danail Vasilev
Telerik team
answered on 11 Aug 2014, 10:55 AM
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.

 
0
Derek
Top achievements
Rank 1
answered on 13 Oct 2014, 05:48 PM
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.
0
Danail Vasilev
Telerik team
answered on 16 Oct 2014, 04:44 PM
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.

 
Tags
Chart (HTML5)
Asked by
Derek
Top achievements
Rank 1
Answers by
Barbaros Saglamtimur
Top achievements
Rank 1
Derek
Top achievements
Rank 1
Danail Vasilev
Telerik team
Share this question
or