john kanyora

john kanyora

  • NA
  • 242
  • 46.3k

bar chart not displaying

Dec 8 2017 8:46 AM
Hi, kindly asking for help.Am using ajax toolkit to draw a bar chart from the database but once i run my web page it does not display..the problem is on the line code i have highlighted in red...help me wat to set to make it visible..
this is my code;
public void BindGrid()
{
string query = "select Customer, COUNT([Total Amount]) [Total Amount] from CustomerDebts group by Customer";
DataTable dt = GetData(query);

string[] x = new string[dt.Rows.Count];
decimal[] y = new decimal[dt.Rows.Count];
for (int i = 0; i < dt.Rows.Count; i++)
{
x[i] = dt.Rows[i][0].ToString();
y[i] = Convert.ToInt32(dt.Rows[i][1]);
}
BarChart1.Series.Add(new AjaxControlToolkit.BarChartSeries { Data = y });
BarChart1.CategoriesAxis = string.Join(",", x);
if (x.Length > 3)
{
BarChart1.ChartWidth = (x.Length * 150).ToString();
}
BarChart1.Visible=  


}
private static DataTable GetData(string query)
{
DataTable dt = new DataTable();
string constr = TraceBizCommon.Configuration.ConfigSettings.ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand(query))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
sda.SelectCommand = cmd;
sda.Fill(dt);
}
}
return dt;
}

Answers (1)