r038tmp5
r038tmp5

Reputation: 115

TPieSeries and Legend with null label

I use DBChart to show pie series, but I have a problem when the value is set to NULL, the legend show the total and not an empty label.

for exemple with this code

with Chart1.AddSeries(TPieSeries.Create(Self)) do
  begin
    AddXY(1, 5, 'ttt');
    AddXY(1, 10, '');
  end;

The legend show 10 but not ''.

I have found nothing in the documentation.

Thank you

Upvotes: 0

Views: 484

Answers (3)

r038tmp5
r038tmp5

Reputation: 115

My example is not good. In fact I use a TDBChart, so I use a SQL request to load the graphic and I have a record with a null value (some lines in the database contain null).

In my searches, I have found that using "AddXY(1, 10, '')" have the same effect. In quick solution, I have change the SQL request, but I search if exists a parameter (like TreatNulls).

Upvotes: 0

LU RD
LU RD

Reputation: 34919

I'm not sure what you are expecting, but this code removes the label:

with Chart1.AddSeries(TPieSeries.Create(Self)) do
  begin
    AddXY(1, 5, 'ttt');
    AddNullXY(1, 10, '');
  end;

enter image description here

Upvotes: 1

Yeray
Yeray

Reputation: 5039

Try changing the Legend.TextStyle to ltsPlain:

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
begin
  with Chart1.AddSeries(TPieSeries.Create(Self)) do
  begin
    AddXY(1, 5, 'ttt');
    AddXY(1, 10, '');
  end;

  Chart1.Legend.TextStyle:=ltsPlain;
end;

Upvotes: 1

Related Questions