DateTime for TChart Bottom Axis lazarus / 55-TAChart ---------------------------------------------------------------------- Tom · 2010-05-06 10:54 I want to display float values versus DateTime using TChart. Delphi has the property XValues.DateTime for the ChartSeries and setting it to true gives the desired effect. I found out, that the label text for the Axis gets created in "tatypes.pas" -> MarkToText() and I can simply edit the implementation to display DateTime values. However, this affects all axes, so I would like to find a proper way to implement such a datetime axis. I would like to derive a new class from TChart that allows me to override DrawAxis() in order to carefully change the labelling of one axis only to display DateTime values. I think I need to add a new property to TChartAxis like "DateTime" : Boolean and then check for this when I generate the text. My problem is, I can only make these changes by either copying the TAChart component into my project folder or directly editing it in the lazarus/components/tachart folder. Is there a way to derive from TChart and implement the changes this way? All the properties and members are either private or protected, so I cannot override them in another unit... Best regards, Tom ---------------------------------------------------------------------- Ask · 2010-05-07 06:45 If you use the SVN version, Date/Time axis values are already possible. Look at components/tachart/demo/axis/axisdemo, "Customized marks" page. ---------------------------------------------------------------------- Tom · 2010-05-09 19:54 Ah, ok - I'll give it a try... Thanks! ---------------------------------------------------------------------- pacific2 · 2010-07-31 10:52 Dear all Is there something new in this topic ? I try to use Tachart with time series (in chartlineseries) and I need to have a bottom axis as (dd/mm/yyy) for all points of the serie. For the moment I did not find solution. Thanks in advance ---------------------------------------------------------------------- Ask · 2010-07-31 16:07 Did you look at components/tachart/demo/axis/axisdemo, "Customized marks" page? ---------------------------------------------------------------------- pacific2 · 2010-07-31 19:37 I did, but this demo use the source property of the ChartCustomerBarSeries objet in order to enter manualy the datapoint as a list, as below: 1|18000|?|January 2|35000|?|February 3|31000|?|March 4|26000|?|April 5|37000|?|May 6|22000|?|June I would like to enter directly the data set (in lineseries with addxy) and not manualy as in the demo. I tryed tu use the delphi teechart operating mode but this do not work. For exemple to set the date format: s1.XValues.DateTime := True; Chart3.BottomAxis.DateTimeFormat:='dd/mm/yyyy'; by the way I use the Typhon code version of lazarus. But I think this does not matter regards ---------------------------------------------------------------------- Ask · 2010-07-31 23:34 The key here is that you can assign arbitrary source to axis marks. After that, you can set Marks.Style = smsLabel and use Code: [Select]LineSeries.AddXY(x, y, FormatDateTime('dd/mm/yyyy', x)); Or, alternatively, assign OnMarkToText event handler to format labels on the fly, which may be slightly more efficient if you have very long series. ---------------------------------------------------------------------- Ask · 2010-08-01 03:18 Also, since r26951 you can use TDateTimeIntervalChartSource for simplified datetime formatting. See "Date and Time" page in the axisdemo. ---------------------------------------------------------------------- pacific2 · 2010-08-01 09:05 Thanks To avoid mistake, I started a new project with a basic chart. I added the folowing code: chart1lineseries1.AddXY(2, 2, FormatDateTime('dd/mm/yyyy', strtodate('01/01/2010')),1);   chart1lineseries1.AddXY(3, 3, FormatDateTime('dd/mm/yyyy', strtodate('10/01/2010')),1);          Then I put the Marks style to smslabel (through the object inspector). The programme compile and run with a line on the chart  but no date on the axis. The bottom axis is empty. I olso tryed to put smslabel in the code (chart1.BottomAxis.Marks.Style:=smslabel; ) but this does not compile because the word smslabel is not recognized) I installed my code typhon lazarus version few weeks ago but mybe the tachart package is not up to date. Do yo know the link to the latest version ? I had a look on sourceforge but the version date is very old (2006). ! thanks again ---------------------------------------------------------------------- Ask · 2010-08-01 09:23 QuoteThen I put the Marks style to smslabel (through the object inspector). The programme compile and run with a line on the chart  but no date on the axis. The bottom axis is empty. Did you set Marks.Source property? QuoteI also tried to put smsLabel in the code (chart1.BottomAxis.Marks.Style:=smslabel; ) but this does not compile because the word smsLabel is not recognized) You have to add TAChartUtils unit to uses clause. QuoteI installed my code typhon lazarus version few weeks ago but mybe the tachart package is not up to date. Sourceforge package is very outdated, do not use it. TAChart is a part of Lazarus for a few years already. So, TAChart version is equal to the Lazarus version. You can look at the Lazarus version in Help/About Lazarus dialog. If you want to get latest changes, use either SVN or daily snapshots (see links on the left panel of the forum). ---------------------------------------------------------------------- pacific2 · 2010-08-01 09:49 The marks.source property is empty in the object inspector. How can I set it ? ok for TAChartUtils chart1.BottomAxis.Marks.Style:=smslabel; compile now. ---------------------------------------------------------------------- Ask · 2010-08-01 10:02 QuoteThe marks.source property is empty in the object inspector. How can I set it ? Did you look at components/tachart/demo/axis/axisdemo, "Customized marks" page? In particular, note lcsMarks component. Alternatively, you may assign Code: [Select]Marks.Source := LineSeries1.Source, but that can be done at run-time only. ---------------------------------------------------------------------- pacific2 · 2010-08-01 10:27 ok Ask, I added in the code of my basic example: chart1.BottomAxis.Marks.Source := chart1lineseries1.Source; that works now. many thanks