Jump to content
Software FX Community

icipeliuc

Members
  • Posts

    1
  • Joined

  • Last visited

icipeliuc's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hello guys, Rly sry if u r alrdy bored by this subject, but i'm alrdy bored of trying to find a way not to show datagrid headers as datetime.tooadate() (as numbers, which look pretty cool as u can imagine )) ) but to show them as actual dates, i mean.... humanly meaningful please just dont tell me there is no workaround, other than c.DataGrid.ShowHeader = false any kind of help will be deeply appreciated, best regards & thx in advance p.s. here is the code i used, if a test is required using System; using System.Collections.Generic; using System.Data; using System.Windows.Forms; using ChartFX.WinForms; namespace chart { public partial class dataTable : UserControl { public dataTable() { InitializeComponent(); this._SetDefaultFieldUsage(maps, string.Empty, chart1); chart1.ToolBar.Visible = true; this._BindData(); } void __resetChart(Chart c) { c.Reset(); c.Data.InterpolateHidden = true; c.DataSourceSettings.Style |= DataSourceStyles.DatesAsLabels; c.ToolBar.Visible = true; c.DataGrid.Visible = true; c.AxisX.DataFormat.Decimals = 10; c.AxisX.LabelsFormat.Format = AxisFormat.DateTime; c.AxisX.LabelsFormat.CustomFormat = "m/d/yy h:mm"; c.AxisY.DataFormat.Decimals = 10; } string[] maps = new string[] { "AVG_KN2", "DELTA_KN2", "HD_KN_BATCH2", "HD_KN_BATCH3" }; private void _SetDefaultFieldUsage(string[] distinctKNNames, string defaultKeyValueField, ChartFX.WinForms.Chart c) { __resetChart©; FieldMap fm = null; foreach (string s in distinctKNNames) { fm = new FieldMap(s, FieldUsage.Value); c.DataSourceSettings.Fields.Add(fm); } c.DataSourceSettings.Fields.Add(new FieldMap("KNV_START_TIMESTAMP", FieldUsage.XValue)); } private void _BindData() { DataTable t = new DataTable("tabeledData"); //reference for data to be inserted in the rows object[] values; t.Columns.Add("KNV_START_TIMESTAMP", typeof(DateTime)); IList<_DTDO> _list = _DTDO.GetCollectionOfData(40); foreach (_DTDO kn in _list) { //fill the table //create the columns if (!t.Columns.Contains(kn.KND_NAME)) t.Columns.Add(kn.KND_NAME, kn.KNV_VALUE.GetType()); //create the array for inserting values values = new object[t.Columns.Count]; values[0] = kn.KNV_START_TIMESTAMP; int colNo = t.Columns.IndexOf(t.Columns[kn.KND_NAME]); //create the values array for (int i = 1; i < t.Columns.Count; i++) { //put on the kn col if (i == colNo) values = kn.KNV_VALUE; else values = null; } //insert data into table t.Rows.Add(values); } //clear references values = null; chart1.DataSource = t; } #region unused public class _DTDO { public string KND_NAME { get; set; } public decimal KNV_VALUE { get; set; } public DateTime KNV_START_TIMESTAMP { get; set; } public static IList<_DTDO> GetCollectionOfData(int nrOfItems) { string[] nks = new string[] { "AVG_KN2", "DELTA_KN2", "HD_KN_BATCH2", "HD_KN_BATCH3" }; IList<_DTDO> toReturn = new _DTDO[nrOfItems]; _DTDO rec; DateTime? dt = DateTime.Now; Random r = new Random(); int rem = -1; for (int i = 0; i < nrOfItems; i++) { rec = new _DTDO(); rem = i % 2; // rem = i % 4; rec.KND_NAME = nks[rem]; rec.KNV_VALUE = (decimal)(r.NextDouble() * 100); rec.KNV_START_TIMESTAMP = (DateTime)(dt.Value.Add(new TimeSpan(00, i * 5, i * 10))); toReturn = rec; } dt = null; r = null; rec = null; return (IList<_DTDO>)toReturn; } } #endregion } }
×
×
  • Create New...