Jump to content
Software FX Community

isaac

Members
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

0 Neutral

About isaac

  • Rank
    Newbie
  1. 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; }
  2. Hello, I'm trying to show some event with bar chart. [Im trying to] X-Axis format is DateTime. Each bar is a event that occured at bar's X-Axis time. Each series is a event's type (there is many series) But bar's x-axis location doesn't match up it's x-value. [for example] In Code: chart.Data.X[0.0] = Convert.ToString("2020-05-20 16:00:00").ToOADate(); In Chart: bar's x-axis location looks like "2020-05-15 02:00:00"; All bar's locations seems to be moved to right; how can I solve this problem? help me please.
  3. Hello, I have a problem using AxisSection with DateTime. I don't know how to parse DateTime into Double so that I can set AxisSection's "From", "To". I tried to use DateTime.Ticks but it doesn't work. Anyone please help me.
×
×
  • Create New...