📄 teelegendpalette.pas
字号:
ParentChart.CancelMouse:=True;
end;
procedure TLegendPaletteTool.SetParentChart(const Value: TCustomAxisPanel);
begin
inherited;
if Assigned(FChart) then
TPaletteChart(FChart).IParent:=ParentChart;
end;
procedure TLegendPaletteTool.SetSmooth(const Value: Boolean);
begin
SetBooleanProperty(FSmooth,Value);
end;
procedure TLegendPaletteTool.SetVertical(const Value: Boolean);
var tmp : Integer;
begin
if FVertical<>Value then
begin
FVertical:=Value;
tmp:=Width;
Width:=Height;
Height:=tmp;
with FChart.Axes do
begin
Bottom.Visible:=not Vertical;
Top.Visible:=not Vertical;
Left.Visible:=Vertical;
Right.Visible:=Vertical;
end;
end;
end;
function TLegendPaletteTool.GetInverted: Boolean;
begin
result:=FChart.Axes.Left.Inverted;
end;
procedure TLegendPaletteTool.SetInverted(const Value: Boolean);
begin
with FChart.Axes do
begin
Left.Inverted:=Value;
Right.Inverted:=Value;
Top.Inverted:=Value;
Bottom.Inverted:=Value;
end;
end;
procedure TLegendPaletteTool.SetPositionUnits(const Value: TTeeUnits);
begin
if FPositionUnits<>Value then
begin
FPositionUnits:=Value;
Repaint;
end;
end;
procedure TLegendPaletteTool.SetHeight(const Value: Integer);
begin
SetIntegerProperty(FHeight,Value);
end;
procedure TLegendPaletteTool.SetLeft(const Value: Integer);
begin
SetIntegerProperty(FLeft,Value);
end;
procedure TLegendPaletteTool.SetTop(const Value: Integer);
begin
SetIntegerProperty(FTop,Value);
end;
procedure TLegendPaletteTool.SetWidth(const Value: Integer);
begin
SetIntegerProperty(FWidth,Value);
end;
procedure TLegendPaletteTool.SetSeries(const Value: TChartSeries);
begin
inherited;
Repaint;
end;
function TLegendPaletteTool.GetTransp: Boolean;
begin
result:=Chart.Color=clNone
end;
procedure TLegendPaletteTool.SetTransp(const Value: Boolean);
begin
if GetTransp<>Value then
if Value then
Chart.Color:=clNone
else
Chart.Color:=DefaultPanelColor;
end;
function TLegendPaletteTool.GetBorder: TChartHiddenPen;
begin
result:=Chart.Border;
end;
procedure TLegendPaletteTool.SetBorder(const Value: TChartHiddenPen);
begin
Chart.Border:=Value;
end;
function TLegendPaletteTool.GetAxis: TLegendPaletteAxis;
begin
case Chart[0].VertAxis of
aLeftAxis : result:=laDefault;
aRightAxis : result:=laOther;
else
result:=laBoth;
end;
end;
procedure TLegendPaletteTool.SetAxis(const Value: TLegendPaletteAxis);
begin
with Chart[0] do
case Value of
laDefault : begin
VertAxis:=aLeftAxis;
HorizAxis:=aBottomAxis;
end;
laOther : begin
VertAxis:=aRightAxis;
HorizAxis:=aTopAxis;
end;
else
begin
VertAxis:=aBothVertAxis;
HorizAxis:=aBothHorizAxis;
end;
end;
Repaint;
end;
function TLegendPaletteTool.GetColor: TColor;
begin
result:=FChart.Color;
end;
procedure TLegendPaletteTool.SetColor(const Value: TColor);
begin
FChart.Color:=Value;
end;
function TLegendPaletteTool.GetGradient: TChartGradient;
begin
result:=FChart.Gradient;
end;
procedure TLegendPaletteTool.SetGradient(const Value: TChartGradient);
begin
FChart.Gradient:=Value;
end;
function TLegendPaletteTool.GetShadow: TTeeShadow;
begin
result:=FChart.Shadow;
end;
procedure TLegendPaletteTool.SetShadow(const Value: TTeeShadow);
begin
FChart.Shadow:=Value;
end;
{ TPaletteSeries }
procedure TPaletteSeries.DrawValue(ValueIndex: Integer);
var R : TRect;
begin
if ValueIndex>0 then
begin
if ITool.Vertical then
begin
R.Left:=GetHorizAxis.IStartPos;
if VertAxis<>aRightAxis then
Inc(R.Left,ParentChart.Axes.Left.Axis.Width);
R.Right:=GetHorizAxis.IEndPos;
R.Top:=CalcYPos(ValueIndex);
if ValueIndex=Count-1 then
if GetVertAxis.Inverted then Dec(R.Bottom)
else Inc(R.Top);
R.Bottom:=CalcYPos(ValueIndex-1);
if ValueIndex=1 then
if GetVertAxis.Inverted then
Inc(R.Bottom);
end
else
begin
R.Top:=GetVertAxis.IStartPos;
if HorizAxis<>aBottomAxis then
Inc(R.Top,ParentChart.Axes.Bottom.Axis.Width);
R.Bottom:=GetVertAxis.IEndPos;
R.Left:=CalcXPos(ValueIndex);
R.Right:=CalcXPos(ValueIndex-1);
end;
with ParentChart.Canvas do
begin
Pen.Style:=psClear;
Brush.Color:=ValueColor[ValueIndex];
if ITool.Smooth then
begin
IGradient:=TTeeGradient.Create(nil);
try
if not ITool.Vertical then
IGradient.Direction:=gdRightLeft;
IGradient.EndColor:=ValueColor[ValueIndex];
if ValueIndex>0 then
IGradient.StartColor:=ValueColor[ValueIndex-1]
else
IGradient.StartColor:=IGradient.EndColor;
IGradient.Draw(ParentChart.Canvas,R);
finally
IGradient.Free;
end;
end
else
FillRect(R);
if Self.Pen.Visible then
begin
AssignVisiblePen(Self.Pen);
if ITool.Vertical then
begin
DoHorizLine(R.Left,R.Right,R.Top);
if ValueIndex=1 then
DoHorizLine(R.Left,R.Right,R.Bottom);
if VertAxis=aLeftAxis then
DoVertLine(R.Right,R.Top,R.Bottom)
else
if VertAxis=aRightAxis then
DoVertLine(R.Left,R.Top,R.Bottom);
end
else
begin
DoVertLine(R.Right,R.Top,R.Bottom);
if ValueIndex=1 then
DoVertLine(R.Left,R.Top,R.Bottom);
if HorizAxis=aTopAxis then
DoHorizLine(R.Left,R.Right,R.Top)
else
if HorizAxis=aBottomAxis then
DoHorizLine(R.Left,R.Right,R.Bottom);
end;
end;
end;
end;
end;
procedure TLegendPaletteEditor.FormShow(Sender: TObject);
begin
inherited;
if Assigned(Tool) then
with LegendTool do
begin
FillSeries(CBSeries,TCustom3DPaletteSeries,Series);
FillSeries(CBSeries,TPolarGridSeries,Series,False);
ButtonPen1.LinkPen(Pen);
RGAxis.ItemIndex:=Ord(Axis);
CBSmooth.Checked:=Smooth;
CBVertical.Checked:=Vertical;
CBTransp.Checked:=Chart.Color=clNone;
CBInverted.Checked:=Inverted;
if PositionUnits=muPercent then CBUnits.ItemIndex:=0
else CBUnits.ItemIndex:=1;
UDLeft.Position:=Left;
ECustLeft.Text:=IntToStr(Left);
UDTop.Position:=Top;
ECustTop.Text:=IntToStr(Top);
UDWidth.Position:=Width;
ECustWidth.Text:=IntToStr(Width);
UDHeight.Position:=Height;
ECustHeight.Text:=IntToStr(Height);
BBorder.LinkPen(Border);
end;
CreatingForm:=False;
end;
procedure TLegendPaletteEditor.RGAxisClick(Sender: TObject);
begin
if not CreatingForm then
LegendTool.Axis:=TLegendPaletteAxis(RGAxis.ItemIndex);
end;
procedure TLegendPaletteEditor.CBTranspClick(Sender: TObject);
begin
LegendTool.Transparent:=CBTransp.Checked;
end;
procedure TLegendPaletteEditor.CBSmoothClick(Sender: TObject);
begin
LegendTool.Smooth:=CBSmooth.Checked;
end;
procedure TLegendPaletteEditor.CBVerticalClick(Sender: TObject);
begin
LegendTool.Vertical:=CBVertical.Checked;
end;
procedure TLegendPaletteEditor.CBInvertedClick(Sender: TObject);
begin
LegendTool.Inverted:=CBInverted.Checked;
end;
procedure TLegendPaletteEditor.ECustLeftChange(Sender: TObject);
begin
if Showing then
LegendTool.Left:=UDLeft.Position;
end;
procedure TLegendPaletteEditor.ECustTopChange(Sender: TObject);
begin
if Showing then
LegendTool.Top:=UDTop.Position
end;
procedure TLegendPaletteEditor.CBUnitsChange(Sender: TObject);
begin
if CBUnits.ItemIndex=0 then
begin
LegendTool.PositionUnits:=muPercent;
if UDLeft.Position>100 then UDLeft.Position:=100;
if UDTop.Position>100 then UDTop.Position:=100;
end
else
LegendTool.PositionUnits:=muPixels;
end;
procedure TLegendPaletteEditor.ECustWidthChange(Sender: TObject);
begin
if Showing then
LegendTool.Width:=UDWidth.Position
end;
procedure TLegendPaletteEditor.ECustHeightChange(Sender: TObject);
begin
if Showing then
LegendTool.Height:=UDHeight.Position
end;
function TLegendPaletteEditor.LegendTool:TLegendPaletteTool;
begin
result:=TLegendPaletteTool(Tool);
end;
procedure TLegendPaletteEditor.PageControl1Change(Sender: TObject);
begin
if PageControl1.ActivePage=TabAxes then
begin
if TabAxes.ControlCount=0 then
begin
IAxes:=TFormTeeAxis.CreateAxis(nil,LegendTool.Chart.LeftAxis);
AddFormTo(IAxes,TabAxes);
end;
end
else
if PageControl1.ActivePage=TabPanel then
begin
if TabPanel.ControlCount=0 then
IPanel:=TFormTeePanel.InsertAt(nil,TabPanel,LegendTool.Chart);
end;
end;
procedure TLegendPaletteEditor.FormCreate(Sender: TObject);
begin
inherited;
CreatingForm:=True;
end;
initialization
RegisterClass(TLegendPaletteEditor);
RegisterTeeTools([TLegendPaletteTool]);
finalization
UnRegisterTeeTools([TLegendPaletteTool]);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -