Chart series color

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
Noemie23
Posts: 5
Joined: Thu Sep 12, 2013 2:31 pm

Chart series color

Post by Noemie23 »

Dear All,

Is is possible to manage the color of each bar of a Excel Bart Chart created with "MakeBarChart"?

Thank you for your answer

Noémie
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Chart series color

Post by larsa »

Hello

Here is a sample. You can add this to the end of MakeChart in the CreateChartsSample sample.

Code: Select all

var
  Props     : TXLSDrwShapeProperies;
  DTp       : TCT_DPt;
begin
  ChartSpace.Chart.PlotArea.BarChart.Shared.Series[0].Create_DPtXpgList;
  for i := 0 to sgData.RowCount - 1 do begin
    Props := TXLSDrwShapeProperies.Create(DTp.Create_SpPr);
    try
      DTp := ChartSpace.Chart.PlotArea.BarChart.Shared.Series[0].DPtXpgList.Add;
      DTp.Create_Idx;
      DTp.Idx.Val := i;

      Props.Fill.FillType := xdftSolid;

      Props.Fill.AsSolid.Color.AsRGB := RGB(Random(256),Random(256),Random(256));;
    finally
      Props.Free;
    end;
  end;
end;
Lars Arvidsson, Axolot Data
Post Reply