Hi Errol,
Errol wrote:Thanks for your suggestions. However my situation is a little different from your example. I use a single series while you appear to use a series for each bar in the chart.
No, if you look at the code in my last post, you'll see I'm creating a unique TBarSeries in all the examples. Concretely, the line of code where the series is created is this one, and as you'll see it's out of any loop:
Code: Select all
with Chart1.AddSeries(TBarSeries) as TBarSeries do
Errol wrote:I also have a number of fields in my data set, and I believe the field used in the Marks is specified by XLabelsSource, and this is somehow auto-added to the legend text.
I can't assure it without the complete project here to know what are you exactly doing, but yes, you can populate the labels array through XLabelsSource. However, the series and the legend should behave the same way either populating the labels array through this XLabelsSource property than through the Add() method as I did in the examples above:
Code: Select all
for i:=0 to 4 do
Add(25+random*75, 'label ' + IntToStr(i));
Errol wrote:Possibly because of these differences, your GetLegendText suggestion did not work - it removed both legend components, the Depth and the Rock Type Code.
To assure what differences between your project and the examples I posted above are making my suggestions invalid in your project, we should compare your project and mine. I understand your project may be huge, but to know what exact property or combination of settings is making the difference, we'd need you to minimize your project to the minimum expression that still reproduces this or any problem in general.
Errol wrote:However, I was successful when I used the attached code - I observed that Delphi flyover hints reported the LegendText as '100'#6'TUF' (although the Watch tool reported it as 100-TUF). Clearly ASCII character 6 is used as a delimiter in the TeeChart legend in this case.
This may be particular to the way you exactly populate the series and the format of the strings in your XLabelsSource.
Anyway, I'm glad to hear you found a way to make it work as you want.
Errol wrote:By the way, the Legend.Items suggestion also failed, but I think this is because there are some issues with refreshing the data at this point in my code.
Note after each data update, the chart needs to be repainted so the Legend.Items list can also be internally updated. So you may need to force a chart repaint between updating the data and modifying the Legend.Items list.