Page 1 of 1

chart1GetLegendText(): Need to know format for LegendText

Posted: Fri Dec 02, 2005 5:16 pm
by 8438518
online help does not tell me what format(s) LegendText will come in such that I can massage the strings as needed. Can anyone point me to doc on this?
Thanks!

Posted: Mon Dec 05, 2005 9:19 am
by narcis
Hi Jeff S,

LegendText will be a string in the format you set at TChart.Legend.LegendStyle property. Also notice that this property is available at GetLegendText event as an argument. Its full help information is:
property LegendStyle: TLegendStyle;

Unit
Chart

Description
Default Value: lsAuto

The LegendStyle property defines which items are to be displayed in the Chart Legend.

lsSeries style shows the TChartSeries.Title of all active Series in a Chart. Whenever a Series Title is empty, the Series Name property is used.

lsValues style shows a text representation of all the points of the first active Series in a Chart.

lsLastValues style shows the last point value and the TChartSeries.Title of all active Series in a Chart. It is useful for real-time charting, where new points are being added at the end of each Series.

lsAuto style (the default) means LegendStyle will be lsSeries when there's more than one Active Series, and lsValues when there's only one Series in a Chart.

The TextStyle property determines how the Series point values are formatted.

no doc for how LegendText is formatted -- HELP please

Posted: Tue Dec 06, 2005 4:48 pm
by 8438518
Narcis,
Thanks for the info, it helps, but, and I appoligize for not being more explicit in my original request, what I'm seeing is that the LegendText will sometimes have the following VARIOUS formats but I have no idea how to code to expect when tchart will send them to me or what the complete list of potential formats is/are!

"xxx.yyy\x06xxx.yyy" e.g. 4.3\x069.999 (has a hex character as a separator I guess)
or
'string' e.g. when data is grouped, can get a string representing which column the data was grouped by.
or
'string,string' e.g. might get a value (seems like a high water mark in the data but I have no idea what tchart uses to determine what it's putting there) then A COMMA as a separator and another value)
OR
'string,string;string' e.g. I can get it to generate a legend that has three strings, separated by a comma THEN a semicolon.
OR
a few other formats. The point being, I have a LARGE customer that wants us to have the legends be consistent - they are displaying these on a LARGE screen in the operations center. Currently, the only doc I have is the online TeeChart Help and I can see the doc you provided but NO WHERE do I see anything on LegendText ** DOES NOT EVEN SEEM TO be a property of TChartLegend!!!!!!!!!!!!!!!!! ***
So I'm unable currently to control the legends as I need to.... and looking for HELP :-}
Thanks!

Posted: Fri Dec 09, 2005 3:37 pm
by Pep
Hi Jeff,

there a FormattedLegend function which returns the text string corresponding to a Legend position.
function FormattedLegend(SeriesOrValueIndex: Integer): String;

Values are formatted accordingly to the Legend.TextStyle property.
The list of textStyles are :
type TLegendTextStyle = (ltsPlain, ltsLeftValue, ltsRightValue, ltsLeftPercent, ltsRightPercent, ltsXValue, ltsValue, ltsPercent, ltsXAndValue, ltsXAndPercent);

From the Help :
Description
Default Value: ltsLeftValue

The TextStyle property stipulates how Legend text items are formatted.

- ltsPlain shows the point Label only.
- ltsLeftValue shows the point Value and the point Label.
- ltsRightValue shows the point Label and the point Value.
- ltsLeftPercent shows the percent the point represents and the point Label.
- ltsRightPercent shows the point Label and the percent the points represent.

- ltsXValue shows the point's X value. It applies only to Series with X (horizontal) values.

Values are pre-formatted using the Series ValueFormat property. Percents are pre-formatted using the Series PercentFormat property.

You can also use the TChart.OnGetLegendText event to supply customized Legend texts.

Example

These are examples of different Legend's TextStyle values:

ltsPlain Summer
ltsLeftValue 1234 Summer
ltsRightValue Summer 1234

ltsLeftPercent 5.1 % Summer
ltsRightPercent Summer 5.1 %
**ltsXValue 4321

**Applies only to Series with X values. See TChartSeries.AddXY method.

chart1GetLegendText() - what formats can legendText come in

Posted: Fri Dec 16, 2005 9:13 pm
by 8438518
Arg. sorry, once again, I was not clear.
Thanks Pep for your response.
The critical detail I keep omitting is I'm trying to parse the legendText
I get in the callback char1GetLegendText(). As I indicate, the LegendText can come to the routine formatted a number of ways and the variable LegendStyle seems to not be all the only factor.

Posted: Thu Nov 20, 2008 1:49 am
by 9337917
I hope my jumping in here isn't considered poor form, but I may help to answer the question for you, Jeff (or others).

If I understand your question, you're asking about the actual formatting of the legend items, and what controls that.

From what I've seen, the answer is it's controlled by:
1) just as Pep indicates, Legend.TextStyle (e.g., ltsLeftValue, ltsRightValue, ltsLeftPercent, etc).

2) Legend.LegendStyle, which should be lsValues (or it can be lsAuto if there's only one series in the chart)

3) and lastly, the one that I'm guessing made the format seem "random" to you, the Series itself, in:
o its ValueFormat (e.g., '#,##0.###') and/or
o its PercentFormat string string or ##0%).

This fact took me a while to realize.

If the Legend item involves percents, it will use the Series' PercentFormat string. If the legend involves instead, or ALSO, values, it will use the ValueFormat defined for the Series.

Change the series' formatting of values or percents, and the legend items suddenly change right along with that formatting change!
Forgive any misrepresentations or over-simplifications, but I hope this helps steer you in the right direction! Although I assume by now you've long ago figured it out, I thought this might be useful to others in the TeeChart community..:)

Regards,
richard diamond