I am trying to create a timeline, and have been trying to use chart control. but it is not working out as i only need the X value and the chart series is like, only AddY or AddXY, there's no AddX/AddXX2.
I know there's like, questions like this before and stuff. There's this person that asked
How to create a timeline control?
like, 3 years ago but i'm not sure what exactly they are saying in the answers and comments..
My current code is:
DirectoryInfo dInfo = new DirectoryInfo(tbSelectFolder.Text);
FileInfo[] Files = dInfo.GetFiles("*.ts");
List<string> fileNames = new List<string>();
List<DateTime> fileDates = new List<DateTime>();
chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.White;
chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.White;
chart1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Solid;
chart1.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
chart1.ChartAreas[0].AxisX.LabelStyle.ForeColor = Color.White;
chart1.ChartAreas[0].AxisY.LabelStyle.ForeColor = Color.White;
chart1.ChartAreas[0].AxisX2.Enabled = AxisEnabled.True;
foreach (FileInfo file in Files)
{
string filename = Path.GetFileNameWithoutExtension(file.Name);
string[] fileNameSplit = filename.Split(' ');
fileNames.Add(fileNameSplit[0]);
DateTime date = DateTime.ParseExact(fileNameSplit[1], "yyMMdd",null);
fileDates.Add(date);
}
foreach (var value in fileNames)
{
foreach (var value1 in fileDates)
{
chart1.Series["US"].Points.AddXY(value1, value);
}
}
This basically gives me this
The timeline i'm trying to create is basically like a time table. So, is there a way to make it look something like this
Here is a possible solution:
I hope this fits your needs: unfortunately the axis-label aren't perfect, thats why you can remove them completely by uncommenting the first three line of code .