문제

내가 유지하고있는 tchart를 사용하는 보고서가 있습니다. 추가되는 tlineseries 중 하나는 자동으로 Clwhite 색상이 배정되며, 이는 배경 (Clbtnface)에 너무 가깝습니다.

내가 변경하면 추가 된 다음 시리즈는 Clwhite를 가져옵니다. 다른 모든 시리즈가 만들어진 후에 돌아가서 변경하지 못한 것은 Tchart에게 내 시리즈 중 어느 것도 Clwhite가되기를 원하지 않는다고 말할 수있는 방법이 있습니까?

Tchart에 시리즈가 추가되면 Tchart는 색상을 할당합니다. 나는 그것이 Clwhite를 할당하지 않기를 원합니다.

도움이 되었습니까?

해결책

OK not one to give up easily, I did some more searching. There is a unit variable called ColorPalette of type TColorArray in the TeeProcs unit. If I find and replace white with a different color that fixes it. There may be an instance copy of it. I'll keep looking since that would be preferred.

To revert the ColorPalette back just call the unit method SetDefaultColorPalette in the same unit.

SetDefaultColorPalette; // Make sure we start with the default
ColorPalette[4] := $007FFF; // Change White to Orange
try
  // add series to the chart
finally
  SetDefaultColorPalette;  // Set it back to Default
end;

BTW, I can't accept as answer because I asked the question too, but I tested it and it works.

다른 팁

Near as I can tell from the TeeCharts module; no you can't specify a color that it should not be as it ships.
You can programatically walk through all the TLineSeries entries making sure at run-time that they don't use clWhite. Say you have an array of acceptable colors clArray, you can use the following code to set the colors of each of the tLineSeries entries at run time.

procedure TForm1.setColors(aChart: TChart; aColorArray: array of TColor);
var
  chi : Integer;
  coi : Integer;
begin
  coi := low(aColorArray);
  for chi := 0 to aChart.SeriesList.Count - 1 do begin
    aChart.SeriesList[chi].Color := aColorArray[coi];
    inc(coi);
    if coi > high(aColorArray) then
      coi := low(aColorArray);
  end;
end;

procedure TForm1.FormShow(Sender: TObject);
var
  ca : array of TColor;
begin
  setLength(ca, 3);
  ca[0] := clRed;
  ca[1] := clBlue;
  ca[2] := clGreen;
  setColors(Chart1, ca);
end;

You can use the series methods ClearPalette then AddPalette to create your custom palette.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top