Barchart, datetime on x-axis
Posted: Thu Nov 19, 2009 9:26 am
Hello, When i want to show a datetime object on the x-axis, it starts at 1899.
See the attachment how it looks.
Source code looks like this.
ObservableCollection<Gensys.Widget.ObjectsAndMessages.ObjectsAndMessagesModel.MessageData> col = new ObservableCollection<ObjectsAndMessagesModel.MessageData>();
Steema.TeeChart.WPF.Styles.Bar barSeries;
tchart.Chart.Series.Add(barSeries = new Steema.TeeChart.WPF.Styles.Bar());
barSeries.XValues.DateTime = true;
barSeries.XValues.DataMember = "Date";
barSeries.YValues.DataMember = "TotalTickets";
int counter = 0;
List<MessageData> messageData = _objectsAndMessagesModel.MessageList.Where(m => m.Date == time).ToList();
foreach (MessageData data in messageData)
{
barSeries.Add(data.TotalTickets);
barSeries[counter].Color = GetMessageTypeColor(data.MessageType);
counter++;
col.Add(data);
}
barSeries.DataSource = col;
barSeries.XValues.DataMember = "Date";
I bind to the date property that is located inan other class, but the datacontext is set to an instance of that class and the datasource is set to the observablecollection where data is located.
How can i fix this?
the barchart is selfstacked btw.
See the attachment how it looks.
Source code looks like this.
ObservableCollection<Gensys.Widget.ObjectsAndMessages.ObjectsAndMessagesModel.MessageData> col = new ObservableCollection<ObjectsAndMessagesModel.MessageData>();
Steema.TeeChart.WPF.Styles.Bar barSeries;
tchart.Chart.Series.Add(barSeries = new Steema.TeeChart.WPF.Styles.Bar());
barSeries.XValues.DateTime = true;
barSeries.XValues.DataMember = "Date";
barSeries.YValues.DataMember = "TotalTickets";
int counter = 0;
List<MessageData> messageData = _objectsAndMessagesModel.MessageList.Where(m => m.Date == time).ToList();
foreach (MessageData data in messageData)
{
barSeries.Add(data.TotalTickets);
barSeries[counter].Color = GetMessageTypeColor(data.MessageType);
counter++;
col.Add(data);
}
barSeries.DataSource = col;
barSeries.XValues.DataMember = "Date";
I bind to the date property that is located inan other class, but the datacontext is set to an instance of that class and the datasource is set to the observablecollection where data is located.
How can i fix this?
the barchart is selfstacked btw.