我想在ms图表中使用条件构建图形不同的颜色,当我使用此代码时,没有任何反应。这是我的代码。
if (metroComboBox3.Text == "Temperature")
{
chart1.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
// chart1.Series["Series1"].Points[0].Color = Color.Green;
chart1.Series[0].Color = Color.Green;
}
if (metroComboBox3.Text == "Relative Humidity")
{
chart1.Series[1].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
// chart1.Series["Series1"].Points[0].Color = Color.Green;
chart1.Series[1].Color = Color.Red;
}
答案 0 :(得分:-1)
chart1.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
chart1.Series[1].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
chart1.Series[2].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
if (metroComboBox1.Text == "Text 1")
{
for (int i = 0; i < metroGrid1.Rows.Count - 1; i++)
{
foreach (DataGridViewRow row in metroGrid1.Rows)
{
int x = 0;
Int32.TryParse(metroGrid1.Rows[i].Cells[4].Value.ToString(), out x);
DateTime dt;
DateTime.TryParse(metroGrid1.Rows[i].Cells[5].Value.ToString(), out dt);
chart1.Series[0].Points.AddXY(metroGrid1.Rows[i].Cells[5].Value.ToString(), metroGrid1.Rows[i].Cells[4].Value.ToString());
//Console.WriteLine(chart1.Series[0].Points.AddXY(metroGrid1.Rows[i].Cells[5].Value.ToString(), metroGrid1.Rows[i].Cells[4].Value.ToString()));
}
}
}
if (metroComboBox1.Text == "Text 2")
{........