Chart with dates on bottom axis: understanding behaviour...

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
NoName
Newbie
Newbie
Posts: 34
Joined: Fri Nov 15, 2002 12:00 am
Location: Italy

Chart with dates on bottom axis: understanding behaviour...

Post by NoName » Thu Mar 11, 2004 9:42 am

Hello,
I use TeeChartPro 6.01 and Delphi 6.

I can't manage a BottomAxis to display dates "as is".
To have a visual representation of my problem, please copy & paste on a new Delphi form the code at the end of my message.

This is a bar chart, with 2 series, side by side.
X values are end-of-year dates, Y values are numbers.

Well, the chart displays dates from january 1st, instead of december 31st. I set BottomAxis.increment=365, and BottomAxis.ExactDateTime=true.
I can understand, the ExactDateTime rounds to the 1st day of the year, but if I set BottomAxis.ExactDateTime=false, the chart displays dates starting from current date.

In conclusion, question is: how can I display the exact date I have in my datas? Have I to put my date values as "Text" instead of "X values"?

Regards

Code: Select all

      object Chart2: TChart
        Left = 0
        Top = 33
        Width = 725
        Height = 393
        Legend.ColorWidth = 10
        Legend.Font.Charset = ANSI_CHARSET
        Legend.Font.Name = 'Tahoma'
        Legend.Gradient.Direction = gdBottomTop
        Legend.Gradient.EndColor = 14737368
        Legend.Gradient.MidColor = clWhite
        Legend.Gradient.StartColor = 14737368
        Legend.Gradient.Visible = True
        Legend.Shadow.HorizSize = 1
        Legend.Shadow.VertSize = 1
        Legend.Symbol.Width = 10
        Legend.TopPos = 9
        Legend.VertSpacing = 3
        MarginRight = 5
        Title.Font.Charset = ANSI_CHARSET
        Title.Font.Color = clNavy
        Title.Font.Height = -12
        Title.Font.Name = 'Tahoma'
        Title.Font.Style = [fsBold]
        Title.Text.Strings = (
          'Grafico dell''andamento della performance annua:')
        Title.Visible = False
        BottomAxis.Grid.Color = clSilver
        BottomAxis.Increment = 365
        BottomAxis.MinorTickCount = 0
        LeftAxis.Grid.Color = clSilver
        LeftAxis.MinorTickCount = 0
        View3D = False
        Align = alClient
        Color = clWhite
        TabOrder = 0
        object Series4: TBarSeries
          BarPen.Visible = False
          Marks.Arrow.Visible = False
          Marks.ArrowLength = 0
          Marks.Callout.Brush.Color = clBlack
          Marks.Callout.Arrow.Visible = False
          Marks.Callout.Length = 0
          Marks.BackColor = 14740222
          Marks.Color = 14740222
          Marks.Frame.Visible = False
          Marks.Shadow.HorizSize = 0
          Marks.Shadow.VertSize = 0
          Marks.Style = smsValue
          Marks.Visible = True
          SeriesColor = clRed
          Title = 'Benchmark (%)'
          AutoMarkPosition = False
          BarWidthPercent = 60
          Dark3D = False
          Gradient.Direction = gdTopBottom
          OffsetPercent = 1
          SideMargins = False
          XValues.DateTime = True
          XValues.Name = 'X'
          XValues.Order = loAscending
          YValues.Name = 'Barre'
          Data = {
            010500000000000000607AE14000000000000000000000000000A8E140333333
            333333234000000000A0D5E1400000000000404140000000006003E240CDCCCC
            CCCCCC30C0000000000031E24066666666666637C0}
        end
        object Series5: TBarSeries
          BarPen.Visible = False
          Marks.Arrow.Visible = False
          Marks.ArrowLength = 0
          Marks.Callout.Brush.Color = clBlack
          Marks.Callout.Arrow.Visible = False
          Marks.Callout.Length = 0
          Marks.BackColor = 15531993
          Marks.Color = 15531993
          Marks.Font.Charset = ANSI_CHARSET
          Marks.Font.Name = 'Tahoma'
          Marks.Frame.Visible = False
          Marks.Shadow.HorizSize = 0
          Marks.Shadow.VertSize = 0
          Marks.Visible = True
          SeriesColor = clGreen
          Title = 'Performance (%)'
          AutoMarkPosition = False
          BarWidthPercent = 60
          Dark3D = False
          Gradient.Direction = gdTopBottom
          OffsetPercent = 1
          SideMargins = False
          XValues.DateTime = True
          XValues.Name = 'X'
          XValues.Order = loAscending
          YValues.Name = 'Barre'
          Data = {
            010500000000000000607AE140CDCCCCCCCC4C3F400000000000A8E140CDCCCC
            CCCC4C3F4000000000A0D5E140CDCCCCCCCC4C3F40000000006003E240CDCCCC
            CCCC4C3F40000000000031E240CDCCCCCCCC4C3F40}
        end
      end
      object TeeCommander2: TTeeCommander
        Left = 0
        Top = 0
        Width = 725
        Height = 33
        Panel = Chart2
        Align = alTop
        ParentShowHint = False
        TabOrder = 1
      end

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Thu Mar 11, 2004 1:05 pm

Hi.
my date values as "Text" instead of "X values"?
Actually, in both (but only in this case). Use XValues to correctly position values and Text to force the display of all point labels. If you don't specify values for Text field, TeeChart internal algorithm will ignore point labels and calculate axis labels. This works fine in most cases, but occasionally (as in your case), it's not the best solution.

An alternative solution: manually set axis range by specifying axis minimum, maximum and increment properties. Also, try changing other axis properties like RoundFirstLabel and LabelsOnAxis.
Marjan Slatinek,
http://www.steema.com

NoName
Newbie
Newbie
Posts: 34
Joined: Fri Nov 15, 2002 12:00 am
Location: Italy

Post by NoName » Tue Mar 16, 2004 9:26 am

Hello Marjan,
thank you for your reply.

Just one question: how can I, programmatically, add text, X and Y values?

That is, to set values of my bars, I actually use:

Code: Select all

DBchart1.series[0].AddXY(mydate,value1);
DBchart1.series[1].AddXY(mydate,value2);
What have I to write to set the "text" of the date in the bottom axis, at each point value?

Thank you

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Tue Mar 16, 2004 4:16 pm

Hi.

If you're adding points manually then you can simply include the text label as 3rd parameter in AddXY method call. Something like this:

Code: Select all

DBchart1.series[0].AddXY(mydate,value1,DateToStr(mydate)); 
DBchart1.series[1].AddXY(mydate,value2,DateToStr(mydate)); 
Marjan Slatinek,
http://www.steema.com

Post Reply