Page 1 of 1

Barchart, datetime on x-axis

Posted: Thu Nov 19, 2009 9:26 am
by 15653372
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.

Re: Barchart, datetime on x-axis

Posted: Thu Nov 19, 2009 12:43 pm
by 10050769
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,

Re: Barchart, datetime on x-axis

Posted: Thu Nov 19, 2009 1:29 pm
by 15653372
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

Re: Barchart, datetime on x-axis

Posted: Thu Nov 19, 2009 3:41 pm
by yeray
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?