[Lazarus] TAChart Date Axis Remove Weekends

"Leonardo M. Ramé" l.rame at griensu.com
Sun Sep 14 15:00:02 CEST 2014


On 14/09/14 08:35, "Leonardo M. Ramé" wrote:
> On 14/09/14 06:57, Werner Pamler wrote:
>> Don't use the real date as x value. Instead, use a counter value that is
>> incremented every time you add a value to the series. Don't add data if
>> the "DayOfWeek" of their date is 6 (Friday) or 7 (Saturday). In the data
>> you posted in your previous message the weekends are already messing,
>> therefore you can simply use the line index I for the x coordinate of
>> the data point.
>>
>> The problem left is the display of the axis labels. Your code in the
>> other posting already adds a data label to each series point (last
>> parameter of AddXOHLC shown). To activate it set the Style of the
>> Chart.BottomAxis.Marks to smsLabel, and don't forget to link the
>> ListSource of the series (that's where your AddXOHLC data go to) to the
>> Source of the BottomAxis.Marks.
>>
>> However, the x labels will be quite crowded and overlapping. There are
>> several ways to get rid of that: Use some logics in creating the data
>> labels - for example, if you want labels only for Monday set the
>> DateToStr(lDate) to the data label only if the DayOfWeek(lDate) is 2
>> (Monday), and use an empty string otherwise. Or you can play with the
>> Intervals property of the BottomAxis to increase the distance of the
>> labels, e.g. Intervals.MinLength=100, Intervals.MaxLength=200. Or you
>> can rotate the label by 90 degrees
>> (BottomAxis.Marks.LabelFont.Orientation = 900)
>>
>>
>
> Thanks! Werner, the chart is starting to look very good.
>
> Now, I need to define the range of left axis. By default it starts on 0
> (bottom left) and ends in the highest value of my data. How can I change
> the starting value, to the minimum value of the data source?.
>
> Currently all the data poins are displayed at the top part of the chart,
> and from 0 to 70 is empty.
>
>

Please forget about this, solved by setting Chart1.Extent.UseYMax and 
UseYMin.

Regards,

-- 
Leonardo M. Ramé
http://leonardorame.blogspot.com




More information about the Lazarus mailing list