9
I’m developing a c# application using the Windows Form chart. I would like to know how to put the values of the x-axis as the legend of it.
string[] nomes = { "eduardo", "jorge", "chris", "matheus" };
int[] idades = { 23, 10, 70, 80 };
List<int> numeros = new List<int>();
numeros.Add(23);
numeros.Add(10);
numeros.Add(70);
numeros.Add(100);
int maior = numeros.Max();
int menor = numeros.Min();
chart1.Titles.Add("Idades");
for (int i = 0; i < nomes.Length; i++)
{
//chart1.Series["Idades"]["PointWidth"] = "0.6";
//chart1.Series.Add(nomes[i]);
chart1.Legends.Add(new Legend(nomes[i]));
chart1.Series["Idades"].Points.AddXY(nomes[i], idades[i]);
if(numeros.ElementAt(i)==maior){
chart1.Series["Idades"].Points[i].Color = Color.Red;
}else if (numeros.ElementAt(i) == menor) {
chart1.Series["Idades"].Points[i].Color = Color.Yellow;
}
else
{
chart1.Series["Idades"].Points[i].Color = Color.Blue;
}
}
Put your code in too, so it’s better for the community to help you.
– gato
Yes, probably what you have to do is use Legends.add for each X-axis vector value.
– KhaosDoctor
I tried this: chart1.Series["Ages"]. Legendtext = "#VALX", but it didn’t work
– Matheus Barros