Manually fill in Chart in ASPX

0

I am trying to fill in a Chart with manual data, the code I have tried is the following:

int[,] horas = new int[,] { { 0, 1 },{ 1, 1 }, { 2, 0 }, { 3, 1 }, { 4, 0 }, { 5, 1 } };

protected void Page_Load(object sender, EventArgs e)
{
    Chart1.Series.Clear();
    Chart1.DataSource = horas;
    var series1 = new Series
    {
        Name = "Prueba1",
        Color = System.Drawing.Color.Green,
        IsVisibleInLegend = true,
        IsXValueIndexed = true,
        ChartType = SeriesChartType.Line           
    };
    series1.AxisLabel = "Axis";        


    for (int i = 0; i < horas.GetLength(0); i++)
    {
        series1.Points.AddXY(horas[i,0],horas[i,1]);
    }

    Chart1.DataBind();

}

However, nothing comes out on the page, thank you.

    
asked by U. Busto 28.09.2017 в 11:52
source

1 answer

1

You must add the series to the graphic:

Chart1.Series.Add(series1);
    
answered by 28.09.2017 / 12:02
source