0
我有我想要設置包含系列標題和條的實際值的標記樣式的小節系列。這裏是我的代碼:TChart:獲取帶有系列標題的標記樣式及其值
procedure TFRDept.PopulateDeptChart;
var
Loop ,YearIndex: integer;
DeptKey: String;
StartBar, TotalBar, EndBar : TBarSeries;
begin
for Loop := 0 to FDeptList.Count -1 do
begin
DeptKey := FDeptList.ValueFromIndex[Loop];
StartBar := GetInsertedBarSeries(DeptKey+'Start', 'Start', clGreen);
TotalBar := GetInsertedBarSeries(DeptKey+'Total', 'Total', clBlue);
EndBar := GetInsertedBarSeries(DeptKey+'End', 'End', clRed);
with Dataset do
begin
if Locate('o_deptaddressno',DeptKey,[]) then
begin
While (FieldByName('o_deptaddressno').AsString = DeptKey) and not eof do
begin
StartBar.AddXY(FieldByName('o_year').AsInteger,
FieldByName('o_totalstart').AsInteger,
FieldByName('o_year').AsString,
StartBar.Color);
{when adding series per year for each department - the bars are not one after the other}
//TotalBar := GetInsertedBarSeries(DeptKey+'Total'+FieldByName('o_year').AsString, siLang.GetTextOrDefault('IDS_TOTAL'), clBlue);
TotalBar.AddXY(FieldByName('o_year').AsInteger,
FieldByName('o_total').AsInteger,
FieldByName('o_year').AsString,
TotalBar.Color);
TotalBar.Title := FieldByName('o_total').AsString + ': '+ FDeptList.Names[Loop];
TotalBar.Marks.Style := smsSeriesTitle;
TotalBar.Marks.ArrowLength := 50;
TotalBar.Marks.Callout.ArrowHead := ahSolid;
EndBar.AddXY(FieldByName('o_year').AsInteger,
FieldByName('o_totalEnd').AsInteger,
FieldByName('o_year').AsString,
EndBar.Color);
Next;
end;
end;
end;
end;
SetSeriesLegendProperties;
end;
function TFRDept.GetInsertedBarSeries(aName, aTitle: String;
aColor: TColor): TBarSeries;
begin
Result := TBarSeries.Create(Self);
with Result do
begin
Name := 'Series' + aName;
Title := aTitle;
Color := aColor;
Marks.Style := smsValue;
end;
Chart1.AddSeries(Result);
end;
我的代碼生成以下欄但是對於藍條的數值未在商標獲得適當的值。
其實,我的目標是顯示每個系列酒吧(紅色,綠色和藍色)上方的各個部門。我甚至選擇了一種替代方法,試圖用'抽籤符號'來修改圖例,但事件沒有觸發。是否有可能在帶有複選框的樣式lsSeriesGroups的圖例中顯示符號?然後我還可以設置Totalbar:
Marks.Symbol.Visible := True;
是。感謝負載。有用。我添加了第二張圖片來解釋我試圖顯示部門(系列組) – Veela
@Veela ok的第二種可能性。恐怕這不可能。我已經回覆了一點點。 –