[Lazarus] TAChart question

José Mejuto joshyfun at gmail.com
Sun Oct 3 17:38:00 CEST 2010


Hello Alexander,

Sunday, October 3, 2010, 6:07:54 AM, you wrote:

>>  DataPoints.Strings = (
>>    'January|18000|?|January'
>>    'June|22000|?|June'
AK> As a separate note, I'd like to point out that using DataPoints property
AK> in not an efficient way to fill the ListChartSource at run-time.
AK> Use ListChartSource.Add instead.
AK> This property is primarily intended to allow design-time editing,
AK> mostly for demonstration purposes.

I had used just here only to show my data structure in the "natural"
format at design time ;)

>> But I do not like to modify standard components. Thank you.
AK> Do you use ListChartSource or DbChartSource as a primary source for
AK> your data? If first, then you can easily generate "index" for X values
AK> like this:
AK> for i := 1 to NumPoints do
AK>   ListSource.Add(i, YValue[i], 'text label', clTAChart);

I'm using DbChartSource (which present many stability bugs) and I
whish to stay, as much as possible, away from coding to generate the
charts.

AK> If, however, your data comes directly from the database via DbChartSource,
AK> then I believe you are right, lack of record index may be inconvenient.
AK> Btw, how do you display the series itself? It should suffer from the
AK> exact same problem.

I'm a bit lost with the terminology of the chart. I'm using a bar
series with the above "patch" and the only problem is that axis text
are a "mess" because if I allow them to overlay it is impossible to
read most of them, if hide neightbor only some of them can be read,
and in this case the legend can not be used as all data points share
the same "color". It would be great, at least for bar series, to be
possible to generate something like this (using countries):

100%|  *            * United States Of America 100%
    |  *       #    @ Portugal 50%
 50%|  *   @   #    # Italy 75%
    |  *   @   #
  0%|  *   @   #
    --------------
      USA POR ITA

So the axis text is different than the legend text. I'm using
something like this and my database data is:

COUNTRY3C    3 char
COUNTRYNAME  VARCHAR
PERCENT      Float

In SQL is quite difficult to return a row number to act as an index.

Also for the BottomAxis at least I whish to suggest a new mode to
write, so using Ignore, Hide neightbor and the new one, "scattered" or
"intercaled" or "shuffled". Something like:

100%|  *
    |  *       #
 50%|  *   @   #
    |  *   @   #   $
  0%|  *   @   #   $
    -----------------
      USA     ITA
          POR    OTHER

Which will double the possibilities of display complete texts.
          
AK> Anyway, I think your idea to return record index in case of
AK> empty FieldX makes a lot of sense, so I applied your patch in r27551

Thank you, but maybe it would be better to use a "faked" field name
like:

if FieldX=':recno' then
  FCurItem.X := ds.RecNo;
else if FieldX=':reccount' then
  FCurItem.X := ds.RecCount;

This is just a possibility for future expansions, anyway using empty
field to a default to recno looks fine to me.

I'll try to take a look at a bug that is bringing down the IDE when in
a connected data source to a chart you write a wrong field name and
press enter, the sucession of access violations bring down the IDE
(Windows/32 at least).

-- 
Best regards,
 José





More information about the Lazarus mailing list