Because of company policy of Information Security, I can't append a Image File.
But I could post sample code that I'd tried to.
Here is code (I want for bar to be located exactly what bar's x-value points):
public Form1()
{
InitializeComponent();
DataTable valueDT = new DataTable();
valueDT.Columns.Add("time", typeof(DateTime));
valueDT.Columns.Add("value", typeof(int));
valueDT.Rows.Add(Convert.ToDateTime("2020-05-21 01:00:00"), 1);
valueDT.Rows.Add(Convert.ToDateTime("2020-05-21 02:00:00"), 2);
valueDT.Rows.Add(Convert.ToDateTime("2020-05-21 03:00:00"), 6);
valueDT.Rows.Add(Convert.ToDateTime("2020-05-21 04:00:00"), 4);
valueDT.Rows.Add(Convert.ToDateTime("2020-05-21 05:00:00"), 2);
valueDT.Rows.Add(Convert.ToDateTime("2020-05-21 06:00:00"), 3);
DataTable eventDT = new DataTable();
eventDT.Columns.Add("time", typeof(DateTime));
eventDT.Rows.Add(Convert.ToDateTime("2020-05-21 01:00:00"));
eventDT.Rows.Add(Convert.ToDateTime("2020-05-21 02:00:00"));
eventDT.Rows.Add(Convert.ToDateTime("2020-05-21 03:00:00"));
eventDT.Rows.Add(Convert.ToDateTime("2020-05-21 04:00:00"));
eventDT.Rows.Add(Convert.ToDateTime("2020-05-21 05:00:00"));
eventDT.Rows.Add(Convert.ToDateTime("2020-05-21 06:00:00"));
this.Controls.Add(GetChart(valueDT, eventDT));
}
public ChartFX.WinForms.Chart GetChart(DataTable valueDT, DataTable eventDT)
{
ChartFX.WinForms.Chart chart = new ChartFX.WinForms.Chart();
chart.Data.Series = 2;
chart.Series[0].Text = "value";
for(int i = 0; i < valueDT.Rows.Count; i++)
{
DataRow r = valueDT.Rows; chart.Data.X[0, i] = Convert.ToDateTime(r["time"]).ToOADate(); chart.Data.Y[0, i] = Convert.ToInt32(r["value"]); }
chart.Series[1].Text = "event"; for(int i = 0; i < eventDT.Rows.Count; i++) { DataRow r = eventDT.Rows; chart.Data.X[1, i] = Convert.ToDateTime(r["time"]).ToOADate(); chart.Data.Y[1, i] = 10; }
chart.AllSeries.Gallery = ChartFX.WinForms.Gallery.Bar; ((ChartFX.WinForms.Galleries.Bar)chart.GalleryAttributes).Overlap = true; chart.AllSeries.Gallery = ChartFX.WinForms.Gallery.Lines;
chart.AxisY.Max = 10; chart.AxisY.Min = 0;
chart.AxisX.LabelsFormat.CustomFormat = "MM-dd HH:mm"; chart.AxisX.LabelsFormat.Format = ChartFX.WinForms.AxisFormat.DateTime;
chart.Series[1].Gallery = ChartFX.WinForms.Gallery.Bar; chart.Series[1].Volume = 1;
chart.Dock = DockStyle.Fill; return chart; }