I have a table with following records
Where Status
A for All Applicaion,
V for Valid Applicaion
and
I for Invalid Applicaion
<pre><table>
<tr>
<td>
StateName
</td>
<td>
AppType
</td>
<td>
Count
</td>
<td>
AppStatus
</td>
</tr>
<tr>
<td>UP</td>
<td>IND</td>
<td>10</td>
<td>V</td>
</tr>
<tr>
<td>UP</td>
<td>IND</td>
<td>20</td>
<td>I</td>
</tr>
<tr>
<td>UP</td>
<td>IND</td>
<td>30</td>
<td>A</td>
</tr>
<tr>
<td>UP</td>
<td>INF</td>
<td>5</td>
<td>V</td>
</tr>
<tr>
<td>UP</td>
<td>INF</td>
<td>15</td>
<td>I</td>
</tr>
<tr>
<td>UP</td>
<td>INF</td>
<td>20</td>
<td>A</td>
</tr>
<tr>
<td>UP</td>
<td>MIN</td>
<td>6</td>
<td>V</td>
</tr>
<tr>
<td>UP</td>
<td>MIN</td>
<td>16</td>
<td>I</td>
</tr>
<tr>
<td>UP</td>
<td>MIN</td>
<td>22</td>
<td>A</td>
</tr>
<tr>
<td>MP</td>
<td>IND</td>
<td>10</td>
<td>V</td>
</tr>
<tr>
<td>MP</td>
<td>IND</td>
<td>20</td>
<td>I</td>
</tr>
<tr>
<td>MP</td>
<td>IND</td>
<td>30</td>
<td>A</td>
</tr>
<tr>
<td>MP</td>
<td>INF</td>
<td>5</td>
<td>V</td>
</tr>
<tr>
<td>MP</td>
<td>INF</td>
<td>15</td>
<td>I</td>
</tr>
<tr>
<td>MP</td>
<td>INF</td>
<td>20</td>
<td>A</td>
</tr>
<tr>
<td>MP</td>
<td>MIN</td>
<td>100</td>
<td>V</td>
</tr>
<tr>
<td>MP</td>
<td>MIN</td>
<td>100</td>
<td>I</td>
</tr>
<tr>
<td>MP</td>
<td>MIN</td>
<td>200</td>
<td>A</td>
</tr>
</table>
I want to make high charts like following
Basic bar | Highcharts[
^]
What I have tried:
In c#
private void GetMainChartStateWiseAppCountForAll()
{
public StringBuilder Str_StateWiseAppCountINDA = new StringBuilder();
public StringBuilder Str_StateWiseAppCountINFA = new StringBuilder();
public StringBuilder Str_StateWiseAppCountMINA = new StringBuilder();
public StringBuilder Str_StateWiseAppCountINDV = new StringBuilder();
public StringBuilder Str_StateWiseAppCountINFV = new StringBuilder();
public StringBuilder Str_StateWiseAppCountMINV = new StringBuilder();
public StringBuilder Str_StateWiseAppCountINDI = new StringBuilder();
public StringBuilder Str_StateWiseAppCountINFI = new StringBuilder();
public StringBuilder Str_StateWiseAppCountMINI = new StringBuilder();
public string Str_StateWiseAppCountINDColor = "rgb(255, 144, 80)";
public string Str_StateWiseAppCountINFColor = "rgb(9, 78, 127)";
public string Str_StateWiseAppCountMINColor = "rgb(9, 78, 0)";
public StringBuilder Str_Category = new StringBuilder();
try
{
StateWiseAppCountForAll obj_stateWiseAppCount = new StateWiseAppCountForAll();
List<StateWiseAppCountForAll> list_tempStateWiseAppCountBLL = null;
list_tempStateWiseAppCountBLL = obj_stateWiseAppCount.GetAll();
if (list_tempStateWiseAppCountBLL != null)
{
List<string> tempString = new List<string>();
for (int i = 0; i < list_tempStateWiseAppCountBLL.Count; i++)
{
if(tempString.Contains(list_tempStateWiseAppCountBLL[i].categories))
tempString.Add(list_tempStateWiseAppCountBLL[i].categories);
}
StringBuilder sb = new StringBuilder();
sb.Append("<script>");
sb.Append("var testArray = new Array;");
foreach (string str in tempString)
{
sb.Append("testArray.push('" + str + "');");
}
sb.Append("</script>");
ClientScript.RegisterStartupScript(this.GetType(), "TestArrayScript", sb.ToString());
Str_StateWiseAppCountINDA.Append(new JavaScriptSerializer().Serialize(list_tempStateWiseAppCountBLL.Where(c => c.AppTypeCode == Convert.ToInt32(ApplicationTypeOption.IND) && c.Flage == 'A').ToList()));
if (Str_StateWiseAppCountINDA.ToString() == "")
Str_StateWiseAppCountINDA.Append("''");
Str_StateWiseAppCountINFA.Append(new JavaScriptSerializer().Serialize(list_tempStateWiseAppCountBLL.Where(c => c.AppTypeCode == Convert.ToInt32(ApplicationTypeOption.INF) && c.Flage == 'A').ToList()));
if (Str_StateWiseAppCountINFA.ToString() == "")
Str_StateWiseAppCountINFA.Append("''");
Str_StateWiseAppCountMINA.Append(new JavaScriptSerializer().Serialize(list_tempStateWiseAppCountBLL.Where(c => c.AppTypeCode == Convert.ToInt32(ApplicationTypeOption.MIN) && c.Flage == 'A').ToList()));
if (Str_StateWiseAppCountMINA.ToString() == "")
Str_StateWiseAppCountMINA.Append("''");
Str_StateWiseAppCountINDV.Append(new JavaScriptSerializer().Serialize(list_tempStateWiseAppCountBLL.Where(c => c.AppTypeCode == Convert.ToInt32(ApplicationTypeOption.IND) && c.Flage == 'V').ToList()));
if (Str_StateWiseAppCountINDV.ToString() == "")
Str_StateWiseAppCountINDV.Append("''");
Str_StateWiseAppCountINFV.Append(new JavaScriptSerializer().Serialize(list_tempStateWiseAppCountBLL.Where(c => c.AppTypeCode == Convert.ToInt32(ApplicationTypeOption.INF) && c.Flage == 'V').ToList()));
if (Str_StateWiseAppCountINFV.ToString() == "")
Str_StateWiseAppCountINFV.Append("''");
Str_StateWiseAppCountMINV.Append(new JavaScriptSerializer().Serialize(list_tempStateWiseAppCountBLL.Where(c => c.AppTypeCode == Convert.ToInt32(ApplicationTypeOption.MIN) && c.Flage == 'V').ToList()));
if (Str_StateWiseAppCountMINV.ToString() == "")
Str_StateWiseAppCountMINV.Append("''");
Str_StateWiseAppCountINDI.Append(new JavaScriptSerializer().Serialize(list_tempStateWiseAppCountBLL.Where(c => c.AppTypeCode == Convert.ToInt32(ApplicationTypeOption.IND) && c.Flage == 'I').ToList()));
if (Str_StateWiseAppCountINDI.ToString() == "")
Str_StateWiseAppCountINDI.Append("''");
Str_StateWiseAppCountINFI.Append(new JavaScriptSerializer().Serialize(list_tempStateWiseAppCountBLL.Where(c => c.AppTypeCode == Convert.ToInt32(ApplicationTypeOption.INF) && c.Flage == 'I').ToList()));
if (Str_StateWiseAppCountINFI.ToString() == "")
Str_StateWiseAppCountINFI.Append("''");
Str_StateWiseAppCountMINI.Append(new JavaScriptSerializer().Serialize(list_tempStateWiseAppCountBLL.Where(c => c.AppTypeCode == Convert.ToInt32(ApplicationTypeOption.MIN) && c.Flage == 'I').ToList()));
if (Str_StateWiseAppCountMINI.ToString() == "")
Str_StateWiseAppCountMINI.Append("''");
}
}
catch (Exception ex)
{
}
}
In aspx page
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<script src="jquery.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="../../../css/Chart/bootstrap.min.css" />
<link href="jquery-ui.css" rel="stylesheet" type="text/css" />
<link href="keen-dashboards.css" rel="stylesheet" type="text/css" />
<script src="HighChart/jquery-1.11.1.min.js" type="text/javascript"></script>
<script type="text/javascript" src="bootstrap.min.js"></script>
<script type="text/javascript" src="Scripts/holder.js"></script>
<script type="text/javascript">
Holder.add_theme("white", { background: "#fff", foreground: "#a7a7a7", size: 10 });
</script>
<script src="highcharts.js" type="text/javascript"></script>
<script src="highcharts-more.js" type="text/javascript"></script>
<script src="highcharts-3d.js" type="text/javascript"></script>
<script src="exporting.js" type="text/javascript"></script>
<script src="drilldown.js" type="text/javascript"></script>
<script src="data.js" type="text/javascript"></script>
<script src="jquery-ui.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
Highcharts.setOptions(
{
colors: ['#094e7f ', '#D92525', '#63A01F', '#FCB711', '#FD5E1E', '#6460AA', '#677300', '#CC004C', '#005391', '#8A1525', '#3C4C00', '#0E3D59']
});
MainChartStateWiseAppCountHori();
});
function MainChartStateWiseAppCountHori() {
if (testArray)
{
var cat = [];
var data=testArray ;
data.forEach(function(item) {
cat.push(item);
});
}
Highcharts.chart('MainChartStateWiseAppCount', {
chart: {
type: 'bar',
},
title: {
align: 'center',
text: 'State Wise Application Count For New NOC',
style: '{ "color": "#214900" }'
}
, xAxis: {
type:'categories',
categories:cat,
title: {
text: 'States Name'
}
}
,
yAxis: {
min: 0,
title: {
text: 'Total Application'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold', color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
}
,
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -40,
y: 80,
floating: true,
borderWidth: 1,
backgroundColor:
Highcharts.defaultOptions.legend.backgroundColor || '#FFFFFF',
shadow: true
},
tooltip: {
animation: true,
shadow: true,
headerFormat: '', pointFormat: '{point.FullName}<br/>{series.name}: {point.y}<br/>Total: {point.stackTotal}'
},
credits: {
enabled: false
},
plotOptions: {
bar: {
dataLabels: {
enabled: true
}
},
series: {
animation: {
duration: 2000
},
stacking:'normal'
}
}
,series: [
{ name: 'Industrial',color:'<%= Str_StateWiseAppCountINDColor.ToString() %>',
data: <%= Str_StateWiseAppCountINDA.ToString() %>
,stack:'ALL'
}
,{
name: 'Infrastructure', color:'<%= Str_StateWiseAppCountINFColor.ToString() %>',
data: <%= Str_StateWiseAppCountINFA.ToString() %>
,stack:'ALL'
}
,{
name: 'Mining', color:'<%= Str_StateWiseAppCountMINColor.ToString() %>',
data: <%= Str_StateWiseAppCountMINA.ToString() %>
,stack:'ALL'
}
, { name: 'BeforeExpire',color:'<%= Str_StateWiseAppCountINDColor.ToString() %>',
data: <%= Str_StateWiseAppCountINDV.ToString() %>
,stack:'BeforeExpire'
}
,{
name: 'BeforeExpire', color:'<%= Str_StateWiseAppCountINFColor.ToString() %>',
data: <%= Str_StateWiseAppCountINFV.ToString() %>
,stack:'BeforeExpire'
}
,{
name: 'BeforeExpire', color:'<%= Str_StateWiseAppCountMINColor.ToString() %>',
data: <%= Str_StateWiseAppCountMINV.ToString() %>
,stack:'BeforeExpire'
}
, { name: 'AfterExpire',color:'<%= Str_StateWiseAppCountINDColor.ToString() %>',
data: <%= Str_StateWiseAppCountINDI.ToString() %>
,stack:'AfterExpire'
}
,{
name: 'AfterExpire', color:'<%= Str_StateWiseAppCountINFColor.ToString() %>',
data: <%= Str_StateWiseAppCountINFI.ToString() %>
,stack:'AfterExpire'
}
,{
name: 'AfterExpire', color:'<%= Str_StateWiseAppCountMINColor.ToString() %>',
data: <%= Str_StateWiseAppCountMINI.ToString() %>
,stack:'AfterExpire'
}
]
});
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<table width="100%" style="line-height: 25px">
<tr>
<td colspan="2">
<div id="MainChartStateWiseAppCount">
</div>
</td>
</tr>
</table>
</asp:Content>