Barchart, datetime on x-axis

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
SPS
Newbie
Newbie
Posts: 27
Joined: Tue May 26, 2009 12:00 am

Barchart, datetime on x-axis

Post by SPS » 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.
Attachments
screenieBarChart.png
screenieBarChart.png (29.14 KiB) Viewed 5892 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Barchart, datetime on x-axis

Post by Sandra » Thu Nov 19, 2009 12:43 pm

Hello SPS,


I recommend that see on Tutorial number 4 Axis Control.,specifically see in Increment, Where you can find some examples of when to use date times. If it isn't don't hesitate to let us know.


I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

SPS
Newbie
Newbie
Posts: 27
Joined: Tue May 26, 2009 12:00 am

Re: Barchart, datetime on x-axis

Post by SPS » Thu Nov 19, 2009 1:29 pm

Hello,

thank you for your reply, but i dont think thats the answer, because when i change the multibar to stacked or something else then selfstack, then the x-axis will show the correct dates. But i want i to be set at selfstack. I think it is a bug when using the selfstack option

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Barchart, datetime on x-axis

Post by Yeray » Thu Nov 19, 2009 3:41 pm

Hi SPS,

I've tried to reproduce it with the following code but coudln't:

Code: Select all

        private void InitializeChart()
        {
            //tChart1.Aspect.View3D = false;

            for (int i = 0; i < 5; i++)
			{
                new Steema.TeeChart.WPF.Styles.Bar(tChart1.Chart);
                tChart1[i].XValues.DateTime = true;
                tChart1[i].FillSampleValues(5);
			}
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Steema.TeeChart.WPF.Styles.Bar bar1 = tChart1[0] as Steema.TeeChart.WPF.Styles.Bar;
            if (bar1.MultiBar == Steema.TeeChart.WPF.Styles.MultiBars.Stacked)
                bar1.MultiBar = Steema.TeeChart.WPF.Styles.MultiBars.Side;
            else
                bar1.MultiBar = Steema.TeeChart.WPF.Styles.MultiBars.Stacked;
        }
Could you please modify it until the problem can be reproduced? Or could you send us a simple example project we can run as-is to reproduce the problem here?
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply