Problem with the visual studio chart control in C #

1

I'm trying to make the values that are entered in a datagridview appear in a chart of the Chart control.

I have two problems:

  • What I want is to generate for each row that I have in the datagrridview a new series that must be painted on the graph, but it paints all the data on the same line instead of the coordinates that are passed.
  • Example:

    This is the code I use:

    for ( int i = 0; i < dataGridView1.RowCount; i++)
    {   
        nom_serie = dataGridView1.Rows[i].Cells[0].Value.ToString();
        chart1.Series.Add(nom_serie);//Creamos la nueva serie
        chart1.Series[nom_serie].ChartType = SeriesChartType.Bubble;
        chart1.Series[nom_serie].XValueType = ChartValueType.Double;
        chart1.Series[nom_serie].YValueType = ChartValueType.Double;
        chart1.Series[nom_serie].Points.Add(Convert.ToDouble (dataGridView1.Rows[i].Cells[1].Value.ToString()), Convert.ToDouble (dataGridView1.Rows[i].Cells[2].Value.ToString()));
    
    }
    
  • The second problem I have is that I want to be able to name the axes so they can be seen in the graph but I have not managed to get them written. I used this code:
  •   chart1.ChartAreas[0].AxisY.Name=nomEjeY;
      chart1.ChartAreas[0].AxisX.Title=nomEjeX;
    
  • And finally I would like to know if there is any way that the axes could appear in the center forming a cross like the image that I show next:
  • Example:

        
    asked by user112719 29.12.2018 в 17:36
    source

    0 answers