As per the image, I would like for the entries that are the same to be on the same line instead of being seperated. I think I need to create different series for each entry but being new at this, I have no idea on how to do this. So far, I have one series created as shown. If you could help me out with some code, it would be greatly appreciated. Here is the code I have:
private void LoadChartData()
{
var s = new Series();
s.ChartType = SeriesChartType.RangeBar;
chart1.Series.Clear();
chart1.Series.Add(s);
s.SetCustomProperty("PixelPointWidth", "25");
chart1.Series[0].YValueType = ChartValueType.DateTime;
chart1.ChartAreas[0].AxisY.LabelStyle.Format = "yyyy-MM-dd";
chart1.ChartAreas[0].AxisY.Interval = 1;
chart1.ChartAreas[0].AxisY.IntervalType = DateTimeIntervalType.Days;
chart1.ChartAreas[0].AxisY.IntervalOffset = 1;
chart1.Series[0].XValueType = ChartValueType.String;
chart1.ChartAreas[0].AxisY.Minimum = minDate.ToOADate();
chart1.ChartAreas[0].AxisY.Maximum = maxDate.ToOADate();
ConnectionStringSettings conSettings = ConfigurationManager.ConnectionStrings["shopmanagerConnectionString1"];
MySqlConnection con = new MySqlConnection(conSettings.ToString());
MySqlCommand cmd = new MySqlCommand(@"select * from shopmanager.planning;", con);
MySqlDataReader myReader;
try
{
con.Open();
myReader = cmd.ExecuteReader();
while (myReader.Read())
{
//check if machine is "en attente"
string notPlanned;
notPlanned = myReader.GetString("machine_name");
if(notPlanned == "En attente")
{
return;
}
else
{
s.LabelForeColor = Color.Black;
s.Font = new System.Drawing.Font("Arial", 10f);
var start_date = myReader.GetDateTime("predicted_start_date");
var predicted_finish_date = myReader.GetDateTime("predicted_delivery");
var machine = myReader.GetString("machine_name");
int pix = s.Points.AddXY(machine, start_date, predicted_finish_date);
s.Points[pix].Label = myReader.GetString("project_number") + " " + myReader.GetString("part_name");
}
}
cmd.Parameters.Clear();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
con.Close();
}