lundi 17 novembre 2014

DotNet Highchart - Plot Grouped Bar - Fill Missing Combinations with Zero


Vote count:

0




from an SQL Query I get a result with a list of farmers


List allFarmers = getFarmers();


A Farmer Entry in this list has 3 properties.



String farmerName;
String mainCategory;
String subCategory;
int amount;


So the returned List might look like:


enter image description here


I want to plot the farmers dynamically with DotNet.highcharts in ASP.Net. The data should be grouped by mainCategory and subCategory (similar to http://ift.tt/1m51ckc). Basically I know how to plot grouped bar charts.


However there are combinations which must be shown with a value of zero. For example Framer A for Fruit and sub3.


A solution might be to complete the list with an amount of zero for the mainCategory/subCategoriy-combinations for each farmer that are not within the list and plot afterwards.


enter image description here


I can only think about many for loops to complete the data like in the second table but I do not like this solution very much. Particularly when the datasize gets bigger and there are more main/subCategory-combinations. What is an efficient way to display this data in an grouped bar chart?


Any suggestions?


Thank you very much!



asked 56 secs ago







DotNet Highchart - Plot Grouped Bar - Fill Missing Combinations with Zero

Aucun commentaire:

Enregistrer un commentaire