How do I change the legend of a chart?

6

I'm developing an application in C # using the Windows Form chart. I would like to know how to put the x-axis values as the caption 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;
     }
}
    
asked by anonymous 30.11.2015 / 00:09

1 answer

0

This way you can rename the Chart legend.

this.ChartLinhas.Series[0].Name = tiposLinhas.ToString();
            this.ChartLinhas.Legends[0].Name = tiposLinhas.ToString();
            this.ChartLinhas.Series[0].Legend = tiposLinhas.ToString();
    
13.05.2016 / 04:47