Hello,
I would like to put 4 categories (fixed) on my chart (example: 1,2,3,4 quarter on the x-axis) and display data from the database in the right category.
// AVG correspond à moyenne et on multiplie par 100 puisque à la base la colonne est de type Decimal
string query = string.Format("select Entite, AVG(AvancementQuantitatifT1 * 100) FROM reponse WHERE ObjectifStrategique = '{0}' GROUP BY Entite", Objectif_strategique.SelectedItem.Value);
// On récupére les données grâce à la méthode GetData
DataTable dt = GetData(query);
//On récupère les noms des entités et on les positionne sur l'axe des abcisses
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]);
}
LineChart1.Series.Add(new AjaxControlToolkit.LineChartSeries { Data = y });
//
LineChart1.CategoriesAxis = string.Join(",", x);
// Titre du graphique
LineChart1.ChartTitle = "Graphique";
if (x.Length > 3)
{
LineChart1.ChartWidth = (x.Length * 75).ToString();
}
LineChart1.Visible = true;
For example I want to do something like that : select Progressquarter1, Progressquarter2,Progressquarter3, Progressquarter4 and put respectively in quarter 1 quarter 2 quarter 3 and quarter 4.
Do you have a solution for this ?
Thank you