TExportChartBars

TExportDrawingTExportChart → [...] → TExportChartBars

Description

TExportChartBars is the bar and column chart class.

Please note that Excel has some problems reading ODS charts (it can read most features, but not all)! ODS charts are correctly displayed in Calc and XLSX charts are correctly displayed in Excel.

Properties

NameTypeDescription
GroupingTExportChartGroupingGrouping of the chart.
FormTExportChartBarsFormForm of the chart:
  • ecfRectangle2D: 2D rectangles
  • ecfBox3D: 3D boxes
  • ecfCylinder3D: 3D cylinders
  • ecfCone3D: 3D cones
  • ecfConeToMax3D: 3D cones, smaller are cutted-off. Supported only by Excel, for Calc same as ecfCone3D
  • ecfPyramid3D: 3D pyramides
  • ecfPyramidToMax3D: 3D pyramides, smaller are cutted-off. Supported only by Excel, for Calc same as ecfPyramid3D
OrientationTExportChartBarsOrientationOrientation of the chart:
  • ecoVertical: vertical (column chart)
  • ecoHorizontal: horizontal (bar chart)
Please see TExportChart for inherited properties.

Code snippet

This code generates a clustered bar chart:

procedure TForm1.BtnTestClick(Sender: TObject);
var
  xExport: TOExport;
  I: Integer;
begin
  xExport := TOExport.Create;
  try
    with xExport.AddWorkSheet('Bar chart') do begin
      AddRow.AddCellString('Sales in €').SetFontSize(20);

      with AddRow do begin
        AddCellString('Products');
        AddCellString('January');
        AddCellString('February');
        AddCellString('March');

        AddCellString('');
        AddCellString('');
        with AddCellString('').AddChart(TExportChartBars, 0, 0, 500, 300) do
        with TExportChartBars(Drawing) do begin
          Title := 'Sales in €';
          Fill.Color := clWhite;
          Border.Color := clBlue;
          Shadow.FillStyle := edfColor;
          Grouping := ecClustered;//TRY DIFFERENT SETTINGS
          Orientation := ecoVertical;//TRY DIFFERENT SETTINGS
          Form := ecfBox3D;//TRY DIFFERENT SETTINGS
          Legend := eclRight;//TRY DIFFERENT SETTINGS
          YAxis.TickSkip := 10;//TRY DIFFERENT SETTINGS
          XTicsRange.SetRange(0, Rows.Count, 1, 4);//x-axis description
          for I := 1 to 3 do
          with AddData(I, Rows.Count, 1, 4) do begin//y-axis data
            DataTitle.SetRange(I, Rows.Count-1, 1, 1);//legend entry title
            Border.FillStyle := edfNone;
            ShowLabels := False;
          end;
        end;
      end;
      with AddRow do begin
        AddCellString('Bubble gums');
        AddCellNumber(15);
        AddCellNumber(12);
        AddCellNumber(8);
      end;
      with AddRow do begin
        AddCellString('Doughnuts');
        AddCellNumber(30);
        AddCellNumber(40);
        AddCellNumber(25);
      end;
      with AddRow do begin
        AddCellString('Soups');
        AddCellNumber(10);
        AddCellNumber(18);
        AddCellNumber(12);
      end;
      with AddRow do begin
        AddCellString('Drinks');
        AddCellNumber(50);
        AddCellNumber(47);
        AddCellNumber(61);
      end;
    end;

    xExport.SaveToFileWithDialog;
  finally
    xExport.Free;
  end;
end;
Categories