mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-19 00:19:26 +02:00
TAChart: Sort TChartListbox items according to Legend.Order
git-svn-id: trunk@31655 -
This commit is contained in:
parent
af52bce126
commit
56bfdb8e1a
@ -252,7 +252,6 @@ function TChartListbox.CreateLegendItems: TChartLegendItems;
|
|||||||
a single legend item is used }
|
a single legend item is used }
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
j: Integer = MaxInt;
|
|
||||||
begin
|
begin
|
||||||
Result := TChartLegendItems.Create;
|
Result := TChartLegendItems.Create;
|
||||||
try
|
try
|
||||||
@ -260,11 +259,6 @@ begin
|
|||||||
for i := 0 to FChart.SeriesCount - 1 do
|
for i := 0 to FChart.SeriesCount - 1 do
|
||||||
if FChart.Series[i] is TCustomChartSeries then
|
if FChart.Series[i] is TCustomChartSeries then
|
||||||
TCustomChartSeries(FChart.Series[i]).GetSingleLegendItem(Result);
|
TCustomChartSeries(FChart.Series[i]).GetSingleLegendItem(Result);
|
||||||
for i := Result.Count - 1 downto 0 do
|
|
||||||
if Result[i].Order = LEGEND_ITEM_ORDER_AS_ADDED then begin
|
|
||||||
Result[i].Order := j;
|
|
||||||
j -= 1;
|
|
||||||
end;
|
|
||||||
except
|
except
|
||||||
FreeAndNil(Result);
|
FreeAndNil(Result);
|
||||||
raise;
|
raise;
|
||||||
@ -458,10 +452,10 @@ begin
|
|||||||
if FChart = nil then exit;
|
if FChart = nil then exit;
|
||||||
FreeAndNil(FLegendItems);
|
FreeAndNil(FLegendItems);
|
||||||
FLegendItems := CreateLegendItems;
|
FLegendItems := CreateLegendItems;
|
||||||
|
Chart.Legend.SortItemsByOrder(FLegendItems);
|
||||||
for i := 0 to FLegendItems.Count - 1 do
|
for i := 0 to FLegendItems.Count - 1 do
|
||||||
// The caption is owner-drawn, but add it anyway for user convenience.
|
// The caption is owner-drawn, but add it anyway for user convenience.
|
||||||
Items.AddObject(FLegendItems[i].Text, FLegendItems[i]);
|
Items.AddObject(FLegendItems[i].Text, FLegendItems[i]);
|
||||||
|
|
||||||
if Assigned(OnPopulate) then
|
if Assigned(OnPopulate) then
|
||||||
OnPopulate(Self);
|
OnPopulate(Self);
|
||||||
finally
|
finally
|
||||||
|
Loading…
Reference in New Issue
Block a user