2

I am using a tchart in Delphi. It is a bar chart, and to add to each series, it requires 3 parameters like this:

chart1.series[0].add(123,'annoying',clred); 

The middle parameter, in this example the word "annoying" results in that string being displayed over the bar.

Is there a way to create a bar chart without having the string appear? The obvious thing was to use an empty value , like ...add(123,'',clred) but it still draws this over the bar with what looks like random numbers in each series.

LU RD
  • 34,438
  • 5
  • 88
  • 296
SteveL
  • 51
  • 7
  • I can't reproduce the problem showing random numbers in the marks. Could you please arrange an [mcve](http://stackoverflow.com/help/mcve)? – Yeray Jan 09 '17 at 09:34

1 Answers1

1

TBarSeries.Add has one-parameter overloaded version

Anyway, you can off showing of string labels:

In chart editor, in Object Inspector, in the code: Series-Marks-Visible

//Series1-General-BottomAxis-DataTime is set
var
  i: integer;
begin
  Series1.Marks.Visible := false;
  for i := -2 to 0 do
     Series1.AddXY(Now + 3 * i, i + 3);
MBo
  • 77,366
  • 5
  • 53
  • 86
  • I tried it and the label over the bar disappeared. I unchecked it and tried again, as reported above like ..series[0].add(amt,' ',clred) and the random numbers went away, and it is now displaying the numeric value of the variable "amt". But now I need to add a similar label below the bar, a string representation of a date in the mm/dd/yy format. – SteveL Jan 08 '17 at 01:56
  • continuaton. .... I could not find anything in reference on steema.com. I do not want to try to do this in the chart editor, because the dates are not known until runtime, as it is pulling the last 5 pay raise amount and dates fro a database. I am looking for something along the lines of chart1[0].bottom_label := raise_date but there is no such property like this, How, then, can you set this bottom label string at runtime, using Delphi code? – SteveL Jan 08 '17 at 02:04
  • I found a way to populate the bottom labels and it works, but in doing so , it also overwrites the top labels, wiping out the raise amount with the same date value that appears on the bottom. – SteveL Jan 08 '17 at 04:08
  • I am not sure that I fully understand your needs. Look at example – MBo Jan 08 '17 at 07:48
  • If you drop a Tchart on a Delphi form of a new projet, add 1 series of type Bar, and add 2 buttons, I think you will see the problem. – SteveL Jan 08 '17 at 16:11
  • continuation - Run the program and button 1 displays the amount over the top of each bar, and a sequential number under the bar. Button2 displays the Day of the week on the top and the bottom (the axis?). I want the amount on the top and the day under the bar. What am I missing? – SteveL Jan 08 '17 at 16:16
  • Do you believe that I use telepathy? Show your code. Anyway, your question has been answered, and perhaps you have to make new question with clear description. – MBo Jan 08 '17 at 19:13
  • @SteveL Please, when you are asked for additional information, edit your question (see the *edit* button just beneath the tags?). All relevant information must be added to the question itself. – Tom Brunberg Jan 11 '17 at 05:15