如何在teechart中创建多行图例?

时间:2014-05-28 08:26:25

标签: legend multiline teechart

有人知道是否有办法编写图表的多行图例? 我试过添加TeeLineSeparator或#13,但它不起作用?

非常感谢

1 个答案:

答案 0 :(得分:0)

我害怕不在当前的传说中。替代方案是使用TeeChart Pro提供的CustomLegend工具,或使用自定义绘图技术直接在OnAfterDraw事件中绘制形状和字符串。即:

uses Series, TeCanvas;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.Legend.Visible:=false;
  Chart1.MarginRight:=22;

  for i:=0 to 4 do
    with Chart1.AddSeries(TBarSeries) as TBarSeries do
    begin
      Title:='Long title in Series number ' + IntToStr(i);
      FillSampleValues;
      Marks.Visible:=false;
      MultiBar:=mbStacked;
    end;
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
var tmpHeight, i: Integer;
begin
  tmpHeight:=Chart1.SeriesCount*33;

  with Chart1.Canvas do
  begin
    Rectangle(Chart1.Width-130, 50, Chart1.Width-10, 50+tmpHeight);

    for i:=0 to Chart1.SeriesCount-1 do
    begin
      Brush.Color:=Chart1[i].Color;
      Rectangle(Chart1.Width-120, 65+i*30, Chart1.Width-120+15, 65+i*30+15);

      TextOut(Chart1.Width-100, 60+i*30, WrapText(Chart1[i].Title, #13#10, ['.',' ',#9,'-'], 15));
    end;
  end;
end;

legend manually drawn