mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 06:29:29 +02:00
TAChart: Fix TChartColorMapSeries legend items when BuiltinPalette is used: Add new properties BuiltInPaletteMax and BuildInPaletteMin, remove property AutoMapColors. Update "func" demo.
git-svn-id: trunk@58900 -
This commit is contained in:
parent
0c95cf6607
commit
813b5366b2
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<CONFIG>
|
<CONFIG>
|
||||||
<ProjectOptions>
|
<ProjectOptions>
|
||||||
<Version Value="10"/>
|
<Version Value="11"/>
|
||||||
<PathDelim Value="\"/>
|
<PathDelim Value="\"/>
|
||||||
<General>
|
<General>
|
||||||
<Flags>
|
<Flags>
|
||||||
@ -18,15 +18,19 @@
|
|||||||
</BuildModes>
|
</BuildModes>
|
||||||
<PublishOptions>
|
<PublishOptions>
|
||||||
<Version Value="2"/>
|
<Version Value="2"/>
|
||||||
<IgnoreBinaries Value="False"/>
|
|
||||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
|
||||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
|
||||||
</PublishOptions>
|
</PublishOptions>
|
||||||
<RunParams>
|
<RunParams>
|
||||||
<local>
|
<local>
|
||||||
<FormatVersion Value="1"/>
|
|
||||||
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
|
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
|
||||||
</local>
|
</local>
|
||||||
|
<FormatVersion Value="2"/>
|
||||||
|
<Modes Count="1">
|
||||||
|
<Mode0 Name="default">
|
||||||
|
<local>
|
||||||
|
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
|
||||||
|
</local>
|
||||||
|
</Mode0>
|
||||||
|
</Modes>
|
||||||
</RunParams>
|
</RunParams>
|
||||||
<RequiredPackages Count="4">
|
<RequiredPackages Count="4">
|
||||||
<Item1>
|
<Item1>
|
||||||
|
@ -32,14 +32,18 @@ object Form1: TForm1
|
|||||||
item
|
item
|
||||||
Grid.Color = clGray
|
Grid.Color = clGray
|
||||||
TickLength = 0
|
TickLength = 0
|
||||||
|
Marks.LabelBrush.Style = bsClear
|
||||||
Minors = <>
|
Minors = <>
|
||||||
Title.LabelFont.Orientation = 900
|
Title.LabelFont.Orientation = 900
|
||||||
|
Title.LabelBrush.Style = bsClear
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
Grid.Color = clGray
|
Grid.Color = clGray
|
||||||
TickLength = 0
|
TickLength = 0
|
||||||
Alignment = calBottom
|
Alignment = calBottom
|
||||||
|
Marks.LabelBrush.Style = bsClear
|
||||||
Minors = <>
|
Minors = <>
|
||||||
|
Title.LabelBrush.Style = bsClear
|
||||||
end>
|
end>
|
||||||
ExpandPercentage = 5
|
ExpandPercentage = 5
|
||||||
Extent.UseYMax = True
|
Extent.UseYMax = True
|
||||||
@ -97,9 +101,9 @@ object Form1: TForm1
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
object cbDomain: TCheckBox
|
object cbDomain: TCheckBox
|
||||||
Left = 470
|
Left = 464
|
||||||
Height = 19
|
Height = 19
|
||||||
Top = 391
|
Top = 392
|
||||||
Width = 62
|
Width = 62
|
||||||
Anchors = [akRight, akBottom]
|
Anchors = [akRight, akBottom]
|
||||||
Caption = 'Domain'
|
Caption = 'Domain'
|
||||||
@ -107,7 +111,7 @@ object Form1: TForm1
|
|||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
object cbRotate: TCheckBox
|
object cbRotate: TCheckBox
|
||||||
Left = 470
|
Left = 464
|
||||||
Height = 19
|
Height = 19
|
||||||
Top = 367
|
Top = 367
|
||||||
Width = 54
|
Width = 54
|
||||||
@ -129,14 +133,18 @@ object Form1: TForm1
|
|||||||
AxisList = <
|
AxisList = <
|
||||||
item
|
item
|
||||||
MarginsForMarks = False
|
MarginsForMarks = False
|
||||||
|
Marks.LabelBrush.Style = bsClear
|
||||||
Minors = <>
|
Minors = <>
|
||||||
Title.LabelFont.Orientation = 900
|
Title.LabelFont.Orientation = 900
|
||||||
|
Title.LabelBrush.Style = bsClear
|
||||||
ZPosition = 1
|
ZPosition = 1
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
Alignment = calBottom
|
Alignment = calBottom
|
||||||
MarginsForMarks = False
|
MarginsForMarks = False
|
||||||
|
Marks.LabelBrush.Style = bsClear
|
||||||
Minors = <>
|
Minors = <>
|
||||||
|
Title.LabelBrush.Style = bsClear
|
||||||
ZPosition = 1
|
ZPosition = 1
|
||||||
end>
|
end>
|
||||||
Extent.UseXMax = True
|
Extent.UseXMax = True
|
||||||
@ -161,6 +169,8 @@ object Form1: TForm1
|
|||||||
Extent.XMax = 0.5
|
Extent.XMax = 0.5
|
||||||
Extent.XMin = -0.5
|
Extent.XMin = -0.5
|
||||||
Title = 'sin(10x + 17y)'
|
Title = 'sin(10x + 17y)'
|
||||||
|
BuiltInPaletteMax = 1
|
||||||
|
BuiltInPaletteMin = -1
|
||||||
ColorSource = ListChartSource1
|
ColorSource = ListChartSource1
|
||||||
OnCalculate = ChartColorMapColorMapSeries1Calculate
|
OnCalculate = ChartColorMapColorMapSeries1Calculate
|
||||||
end
|
end
|
||||||
@ -184,25 +194,75 @@ object Form1: TForm1
|
|||||||
Align = alTop
|
Align = alTop
|
||||||
end
|
end
|
||||||
object cbInterpolate: TCheckBox
|
object cbInterpolate: TCheckBox
|
||||||
|
AnchorSideLeft.Control = Panel1
|
||||||
|
AnchorSideBottom.Control = lblPalette
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 19
|
Height = 19
|
||||||
Top = 399
|
Top = 354
|
||||||
Width = 77
|
Width = 77
|
||||||
Anchors = [akLeft, akBottom]
|
Anchors = [akLeft, akBottom]
|
||||||
|
BorderSpacing.Left = 8
|
||||||
|
BorderSpacing.Bottom = 8
|
||||||
Caption = 'Interpolate'
|
Caption = 'Interpolate'
|
||||||
OnChange = cbInterpolateChange
|
OnChange = cbInterpolateChange
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
object cbMultLegend: TCheckBox
|
object cbMultLegend: TCheckBox
|
||||||
|
AnchorSideLeft.Control = Panel1
|
||||||
|
AnchorSideBottom.Control = cbInterpolate
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 19
|
Height = 19
|
||||||
Top = 371
|
Top = 327
|
||||||
Width = 97
|
Width = 97
|
||||||
Anchors = [akLeft, akBottom]
|
Anchors = [akLeft, akBottom]
|
||||||
|
BorderSpacing.Left = 8
|
||||||
|
BorderSpacing.Bottom = 8
|
||||||
Caption = 'Expand legend'
|
Caption = 'Expand legend'
|
||||||
OnChange = cbMultLegendChange
|
OnChange = cbMultLegendChange
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
end
|
end
|
||||||
|
object cmbPalette: TComboBox
|
||||||
|
AnchorSideLeft.Control = Panel1
|
||||||
|
AnchorSideRight.Control = Panel1
|
||||||
|
AnchorSideRight.Side = asrBottom
|
||||||
|
AnchorSideBottom.Control = Panel1
|
||||||
|
AnchorSideBottom.Side = asrBottom
|
||||||
|
Left = 8
|
||||||
|
Height = 23
|
||||||
|
Top = 400
|
||||||
|
Width = 105
|
||||||
|
Anchors = [akLeft, akRight, akBottom]
|
||||||
|
BorderSpacing.Left = 8
|
||||||
|
BorderSpacing.Right = 8
|
||||||
|
BorderSpacing.Bottom = 8
|
||||||
|
ItemHeight = 15
|
||||||
|
ItemIndex = 4
|
||||||
|
Items.Strings = (
|
||||||
|
'cmpHot'
|
||||||
|
'cmpCold'
|
||||||
|
'cmpRainbow'
|
||||||
|
'cmpMonochrome'
|
||||||
|
'(ColorSource)'
|
||||||
|
)
|
||||||
|
OnChange = cmbPaletteChange
|
||||||
|
Style = csDropDownList
|
||||||
|
TabOrder = 3
|
||||||
|
Text = '(ColorSource)'
|
||||||
|
end
|
||||||
|
object lblPalette: TLabel
|
||||||
|
AnchorSideLeft.Control = Panel1
|
||||||
|
AnchorSideBottom.Control = cmbPalette
|
||||||
|
Left = 8
|
||||||
|
Height = 15
|
||||||
|
Top = 381
|
||||||
|
Width = 36
|
||||||
|
Anchors = [akLeft, akBottom]
|
||||||
|
BorderSpacing.Left = 8
|
||||||
|
BorderSpacing.Bottom = 4
|
||||||
|
Caption = 'Palette'
|
||||||
|
FocusControl = cmbPalette
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
end
|
end
|
||||||
object Splitter1: TSplitter
|
object Splitter1: TSplitter
|
||||||
Left = 416
|
Left = 416
|
||||||
@ -228,15 +288,19 @@ object Form1: TForm1
|
|||||||
Grid.Cosmetic = False
|
Grid.Cosmetic = False
|
||||||
Intervals.Options = [aipGraphCoords, aipUseCount, aipUseMinLength, aipUseNiceSteps]
|
Intervals.Options = [aipGraphCoords, aipUseCount, aipUseMinLength, aipUseNiceSteps]
|
||||||
Intervals.Tolerance = 2
|
Intervals.Tolerance = 2
|
||||||
|
Marks.LabelBrush.Style = bsClear
|
||||||
Minors = <>
|
Minors = <>
|
||||||
Title.LabelFont.Orientation = 900
|
Title.LabelFont.Orientation = 900
|
||||||
|
Title.LabelBrush.Style = bsClear
|
||||||
Transformations = catSpline
|
Transformations = catSpline
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
Grid.Color = clGray
|
Grid.Color = clGray
|
||||||
Grid.Cosmetic = False
|
Grid.Cosmetic = False
|
||||||
Alignment = calBottom
|
Alignment = calBottom
|
||||||
|
Marks.LabelBrush.Style = bsClear
|
||||||
Minors = <>
|
Minors = <>
|
||||||
|
Title.LabelBrush.Style = bsClear
|
||||||
end>
|
end>
|
||||||
ExpandPercentage = 5
|
ExpandPercentage = 5
|
||||||
Foot.Brush.Color = clBtnFace
|
Foot.Brush.Color = clBtnFace
|
||||||
@ -269,7 +333,7 @@ object Form1: TForm1
|
|||||||
AxisIndexY = 0
|
AxisIndexY = 0
|
||||||
Pointer.Brush.Color = clAqua
|
Pointer.Brush.Color = clAqua
|
||||||
Source = RandomChartSource1
|
Source = RandomChartSource1
|
||||||
Options = [csoDrawFewPoints, csoDrawUnorderedX]
|
Options = [csoDrawUnorderedX]
|
||||||
Pen.Color = clAqua
|
Pen.Color = clAqua
|
||||||
Pen.Width = 2
|
Pen.Width = 2
|
||||||
end
|
end
|
||||||
@ -396,12 +460,16 @@ object Form1: TForm1
|
|||||||
Width = 542
|
Width = 542
|
||||||
AxisList = <
|
AxisList = <
|
||||||
item
|
item
|
||||||
|
Marks.LabelBrush.Style = bsClear
|
||||||
Minors = <>
|
Minors = <>
|
||||||
Title.LabelFont.Orientation = 900
|
Title.LabelFont.Orientation = 900
|
||||||
|
Title.LabelBrush.Style = bsClear
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
Alignment = calBottom
|
Alignment = calBottom
|
||||||
|
Marks.LabelBrush.Style = bsClear
|
||||||
Minors = <>
|
Minors = <>
|
||||||
|
Title.LabelBrush.Style = bsClear
|
||||||
end>
|
end>
|
||||||
Foot.Brush.Color = clBtnFace
|
Foot.Brush.Color = clBtnFace
|
||||||
Foot.Font.Color = clBlue
|
Foot.Font.Color = clBlue
|
||||||
@ -462,12 +530,16 @@ object Form1: TForm1
|
|||||||
Width = 412
|
Width = 412
|
||||||
AxisList = <
|
AxisList = <
|
||||||
item
|
item
|
||||||
|
Marks.LabelBrush.Style = bsClear
|
||||||
Minors = <>
|
Minors = <>
|
||||||
Title.LabelFont.Orientation = 900
|
Title.LabelFont.Orientation = 900
|
||||||
|
Title.LabelBrush.Style = bsClear
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
Alignment = calBottom
|
Alignment = calBottom
|
||||||
|
Marks.LabelBrush.Style = bsClear
|
||||||
Minors = <>
|
Minors = <>
|
||||||
|
Title.LabelBrush.Style = bsClear
|
||||||
end>
|
end>
|
||||||
Foot.Brush.Color = clBtnFace
|
Foot.Brush.Color = clBtnFace
|
||||||
Foot.Font.Color = clBlue
|
Foot.Font.Color = clBlue
|
||||||
@ -777,16 +849,20 @@ object Form1: TForm1
|
|||||||
Width = 542
|
Width = 542
|
||||||
AxisList = <
|
AxisList = <
|
||||||
item
|
item
|
||||||
|
Marks.LabelBrush.Style = bsClear
|
||||||
Minors = <>
|
Minors = <>
|
||||||
Title.LabelFont.Orientation = 900
|
Title.LabelFont.Orientation = 900
|
||||||
Title.Visible = True
|
Title.Visible = True
|
||||||
Title.Caption = 'y'
|
Title.Caption = 'y'
|
||||||
|
Title.LabelBrush.Style = bsClear
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
Alignment = calBottom
|
Alignment = calBottom
|
||||||
|
Marks.LabelBrush.Style = bsClear
|
||||||
Minors = <>
|
Minors = <>
|
||||||
Title.Visible = True
|
Title.Visible = True
|
||||||
Title.Caption = 'x'
|
Title.Caption = 'x'
|
||||||
|
Title.LabelBrush.Style = bsClear
|
||||||
end>
|
end>
|
||||||
Foot.Brush.Color = clBtnFace
|
Foot.Brush.Color = clBtnFace
|
||||||
Foot.Font.Color = clBlue
|
Foot.Font.Color = clBlue
|
||||||
@ -842,6 +918,7 @@ object Form1: TForm1
|
|||||||
top = 180
|
top = 180
|
||||||
object chtsColorMapZoomDragTool1: TZoomDragTool
|
object chtsColorMapZoomDragTool1: TZoomDragTool
|
||||||
Shift = [ssLeft]
|
Shift = [ssLeft]
|
||||||
|
Brush.Style = bsClear
|
||||||
end
|
end
|
||||||
object chtsColorMapPanDragTool1: TPanDragTool
|
object chtsColorMapPanDragTool1: TPanDragTool
|
||||||
Shift = [ssRight]
|
Shift = [ssRight]
|
||||||
@ -868,7 +945,7 @@ object Form1: TForm1
|
|||||||
object Timer1: TTimer
|
object Timer1: TTimer
|
||||||
Interval = 200
|
Interval = 200
|
||||||
OnTimer = Timer1Timer
|
OnTimer = Timer1Timer
|
||||||
left = 448
|
left = 440
|
||||||
top = 296
|
top = 248
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -28,6 +28,7 @@ type
|
|||||||
Chart1YAxis: TConstantLine;
|
Chart1YAxis: TConstantLine;
|
||||||
catSpline: TChartAxisTransformations;
|
catSpline: TChartAxisTransformations;
|
||||||
catSplineLogarithmAxisTransform: TLogarithmAxisTransform;
|
catSplineLogarithmAxisTransform: TLogarithmAxisTransform;
|
||||||
|
cmbPalette: TComboBox;
|
||||||
ExpressionChart: TChart;
|
ExpressionChart: TChart;
|
||||||
ExpressionSeries: TExpressionSeries;
|
ExpressionSeries: TExpressionSeries;
|
||||||
chParametric: TChart;
|
chParametric: TChart;
|
||||||
@ -49,6 +50,7 @@ type
|
|||||||
EdExprDomain: TEdit;
|
EdExprDomain: TEdit;
|
||||||
EdExprParamA: TEdit;
|
EdExprParamA: TEdit;
|
||||||
EdExprParamB: TEdit;
|
EdExprParamB: TEdit;
|
||||||
|
lblPalette: TLabel;
|
||||||
LblExpression: TLabel;
|
LblExpression: TLabel;
|
||||||
LblExprDomain: TLabel;
|
LblExprDomain: TLabel;
|
||||||
LblExprParamA: TLabel;
|
LblExprParamA: TLabel;
|
||||||
@ -100,6 +102,7 @@ type
|
|||||||
AY: Double);
|
AY: Double);
|
||||||
procedure chParametricParametricCurveSeries1Calculate(const AT: Double; out
|
procedure chParametricParametricCurveSeries1Calculate(const AT: Double; out
|
||||||
AX, AY: Double);
|
AX, AY: Double);
|
||||||
|
procedure cmbPaletteChange(Sender: TObject);
|
||||||
procedure EdExprDomainEditingDone(Sender: TObject);
|
procedure EdExprDomainEditingDone(Sender: TObject);
|
||||||
procedure EdExpressionEditingDone(Sender: TObject);
|
procedure EdExpressionEditingDone(Sender: TObject);
|
||||||
procedure EdExprParamAEditingDone(Sender: TObject);
|
procedure EdExprParamAEditingDone(Sender: TObject);
|
||||||
@ -219,6 +222,15 @@ begin
|
|||||||
AY := Sin(c * AT) - IntPower(Sin(d * AT), seK.Value);
|
AY := Sin(c * AT) - IntPower(Sin(d * AT), seK.Value);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.cmbPaletteChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if cmbPalette.ItemIndex < cmbPalette.Items.Count-1 then begin
|
||||||
|
ChartColorMapColorMapSeries1.ColorSource := nil;
|
||||||
|
ChartColorMapColorMapSeries1.BuiltinPalette := TColorMapPalette(cmbPalette.ItemIndex);
|
||||||
|
end else
|
||||||
|
ChartColorMapColorMapSeries1.ColorSource := ListChartSource1;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TForm1.EdExprDomainEditingDone(Sender: TObject);
|
procedure TForm1.EdExprDomainEditingDone(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
ExpressionSeries.Domain := EdExprDomain.Text;
|
ExpressionSeries.Domain := EdExprDomain.Text;
|
||||||
|
@ -412,17 +412,21 @@ type
|
|||||||
FStepX: TFuncSeriesStep;
|
FStepX: TFuncSeriesStep;
|
||||||
FStepY: TFuncSeriesStep;
|
FStepY: TFuncSeriesStep;
|
||||||
FUseImage: TUseImage;
|
FUseImage: TUseImage;
|
||||||
FAutoMapColors: Boolean;
|
|
||||||
FColorExtentMin, FColorExtentMax: Double;
|
FColorExtentMin, FColorExtentMax: Double;
|
||||||
FBuiltinColorSource: TCustomChartSource;
|
FBuiltinColorSource: TCustomChartSource;
|
||||||
FBuiltinPalette: TColormapPalette;
|
FBuiltinPalette: TColormapPalette;
|
||||||
|
FPaletteMax: Double;
|
||||||
|
FPaletteMin: Double;
|
||||||
function GetColorSource: TCustomChartSource;
|
function GetColorSource: TCustomChartSource;
|
||||||
function IsColorSourceStored: boolean;
|
function IsColorSourceStored: boolean;
|
||||||
procedure SetAutoMapColors(AValue: Boolean);
|
function IsPaletteMaxStored: Boolean;
|
||||||
|
function IsPaletteMinStored: Boolean;
|
||||||
procedure SetBrush(AValue: TBrush);
|
procedure SetBrush(AValue: TBrush);
|
||||||
procedure SetBuiltinPalette(AValue: TColorMapPalette);
|
procedure SetBuiltinPalette(AValue: TColorMapPalette);
|
||||||
procedure SetColorSource(AValue: TCustomChartSource);
|
procedure SetColorSource(AValue: TCustomChartSource);
|
||||||
procedure SetInterpolate(AValue: Boolean);
|
procedure SetInterpolate(AValue: Boolean);
|
||||||
|
procedure SetPaletteMax(AValue: Double);
|
||||||
|
procedure SetPaletteMin(AValue: Double);
|
||||||
procedure SetStepX(AValue: TFuncSeriesStep);
|
procedure SetStepX(AValue: TFuncSeriesStep);
|
||||||
procedure SetStepY(AValue: TFuncSeriesStep);
|
procedure SetStepY(AValue: TFuncSeriesStep);
|
||||||
procedure SetUseImage(AValue: TUseImage);
|
procedure SetUseImage(AValue: TUseImage);
|
||||||
@ -431,6 +435,7 @@ type
|
|||||||
procedure BuildPalette(APalette: TColorMapPalette);
|
procedure BuildPalette(APalette: TColorMapPalette);
|
||||||
procedure GetLegendItems(AItems: TChartLegendItems); override;
|
procedure GetLegendItems(AItems: TChartLegendItems); override;
|
||||||
procedure GetZRange(ARect: TRect; dx, dy: Integer);
|
procedure GetZRange(ARect: TRect; dx, dy: Integer);
|
||||||
|
procedure UpdateColorExtent;
|
||||||
|
|
||||||
public
|
public
|
||||||
procedure Assign(ASource: TPersistent); override;
|
procedure Assign(ASource: TPersistent); override;
|
||||||
@ -443,13 +448,15 @@ type
|
|||||||
procedure Draw(ADrawer: IChartDrawer); override;
|
procedure Draw(ADrawer: IChartDrawer); override;
|
||||||
function IsEmpty: Boolean; override;
|
function IsEmpty: Boolean; override;
|
||||||
published
|
published
|
||||||
property AutoMapColors: Boolean
|
|
||||||
read FAutoMapColors write SetAutoMapColors default false;
|
|
||||||
property AxisIndexX;
|
property AxisIndexX;
|
||||||
property AxisIndexY;
|
property AxisIndexY;
|
||||||
property Brush: TBrush read FBrush write SetBrush;
|
property Brush: TBrush read FBrush write SetBrush;
|
||||||
property BuiltInPalette: TColorMapPalette
|
property BuiltInPalette: TColorMapPalette
|
||||||
read FBuiltinPalette write SetBuiltinPalette default cmpHot;
|
read FBuiltinPalette write SetBuiltinPalette default cmpHot;
|
||||||
|
property BuiltInPaletteMax: Double
|
||||||
|
read FPaletteMax write SetPaletteMax stored IsPaletteMaxStored;
|
||||||
|
property BuiltInPaletteMin: Double
|
||||||
|
read FPaletteMin write SetPaletteMin stored IsPaletteMinStored;
|
||||||
property ColorSource: TCustomChartSource
|
property ColorSource: TCustomChartSource
|
||||||
read GetColorSource write SetColorSource stored IsColorSourceStored;
|
read GetColorSource write SetColorSource stored IsColorSourceStored;
|
||||||
property Interpolate: Boolean
|
property Interpolate: Boolean
|
||||||
@ -2079,9 +2086,10 @@ procedure TCustomColorMapSeries.Assign(ASource: TPersistent);
|
|||||||
begin
|
begin
|
||||||
if ASource is TCustomColorMapSeries then
|
if ASource is TCustomColorMapSeries then
|
||||||
with TCustomColorMapSeries(ASource) do begin
|
with TCustomColorMapSeries(ASource) do begin
|
||||||
Self.AutoMapColors := FAutoMapColors;
|
|
||||||
Self.Brush := FBrush;
|
Self.Brush := FBrush;
|
||||||
Self.BuiltinPalette := FBuiltinPalette;
|
Self.BuiltinPalette := FBuiltinPalette;
|
||||||
|
Self.BuiltinPaletteMax := FPaletteMax;
|
||||||
|
Self.BuiltinPaletteMin := FPaletteMin;
|
||||||
Self.ColorSource := FColorSource;
|
Self.ColorSource := FColorSource;
|
||||||
Self.FInterpolate := FInterpolate;
|
Self.FInterpolate := FInterpolate;
|
||||||
Self.FStepX := FStepX;
|
Self.FStepX := FStepX;
|
||||||
@ -2093,7 +2101,9 @@ end;
|
|||||||
procedure TCustomColorMapSeries.BuildPalette(APalette: TColorMapPalette);
|
procedure TCustomColorMapSeries.BuildPalette(APalette: TColorMapPalette);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
h,s,l: Byte;
|
h, s, l: Byte;
|
||||||
|
cmax, cmin, factor: Double;
|
||||||
|
ex: TDoubleRect;
|
||||||
begin
|
begin
|
||||||
with FBuiltinColorSource as TListChartSource do begin
|
with FBuiltinColorSource as TListChartSource do begin
|
||||||
BeginUpdate;
|
BeginUpdate;
|
||||||
@ -2138,6 +2148,29 @@ begin
|
|||||||
else
|
else
|
||||||
raise Exception.Create('Palette not supported');
|
raise Exception.Create('Palette not supported');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if FPaletteMin < FPaletteMax then begin
|
||||||
|
cmin := FPaletteMin;
|
||||||
|
cmax := FPaletteMax;
|
||||||
|
end else
|
||||||
|
if FPaletteMax < FPaletteMin then begin
|
||||||
|
cmin := FPaletteMax;
|
||||||
|
cmax := FPaletteMin;
|
||||||
|
end else
|
||||||
|
exit;
|
||||||
|
|
||||||
|
with FBuiltInColorSource do begin
|
||||||
|
ex := Extent;
|
||||||
|
if (ex.a.x = ex.b.x) then
|
||||||
|
exit;
|
||||||
|
factor := (cmax - cmin) / (ex.b.x - ex.a.x);
|
||||||
|
for i:=0 to Count-1 do
|
||||||
|
Item[i]^.X := (Item[i]^.X - ex.a.x) * factor + cmin;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if FColorSource = nil then
|
||||||
|
UpdateColorExtent;
|
||||||
|
|
||||||
finally
|
finally
|
||||||
EndUpdate;
|
EndUpdate;
|
||||||
end;
|
end;
|
||||||
@ -2151,16 +2184,6 @@ var
|
|||||||
v1, v2: Double;
|
v1, v2: Double;
|
||||||
begin
|
begin
|
||||||
if (ColorSource = nil) or (ColorSource.Count = 0) then exit(clTAColor);
|
if (ColorSource = nil) or (ColorSource.Count = 0) then exit(clTAColor);
|
||||||
|
|
||||||
if FAutoMapColors then begin
|
|
||||||
// Transform data value to the values assigned to the colorsource
|
|
||||||
if FMinZ <> FMaxZ then begin
|
|
||||||
AValue := (AValue - FMinZ) / (FMaxZ - FMinZ);
|
|
||||||
AValue := AValue * (FColorExtentMax - FColorExtentMin) + FColorExtentMin;
|
|
||||||
end else
|
|
||||||
AValue := FColorExtentMin;
|
|
||||||
end;
|
|
||||||
|
|
||||||
ColorSource.FindBounds(AValue, SafeInfinity, lb, ub);
|
ColorSource.FindBounds(AValue, SafeInfinity, lb, ub);
|
||||||
if Interpolate and InRange(lb, 1, ColorSource.Count - 1) then begin
|
if Interpolate and InRange(lb, 1, ColorSource.Count - 1) then begin
|
||||||
with ColorSource[lb - 1]^ do begin
|
with ColorSource[lb - 1]^ do begin
|
||||||
@ -2207,6 +2230,7 @@ end;
|
|||||||
procedure TCustomColorMapSeries.Draw(ADrawer: IChartDrawer);
|
procedure TCustomColorMapSeries.Draw(ADrawer: IChartDrawer);
|
||||||
var
|
var
|
||||||
ext: TDoubleRect;
|
ext: TDoubleRect;
|
||||||
|
// cext: TDoubleRect;
|
||||||
bounds: TDoubleRect;
|
bounds: TDoubleRect;
|
||||||
r, cell: TRect;
|
r, cell: TRect;
|
||||||
pt, next, offset: TPoint;
|
pt, next, offset: TPoint;
|
||||||
@ -2251,6 +2275,11 @@ begin
|
|||||||
|
|
||||||
GetZRange(r, scaled_stepX, scaled_stepY);
|
GetZRange(r, scaled_stepX, scaled_stepY);
|
||||||
|
|
||||||
|
if FColorExtentMin = FColorExtentMax then begin
|
||||||
|
ADrawer.FillRect(r.Left, r.Top, r.Right, r.Bottom);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
try
|
try
|
||||||
pt.Y := (r.Top div scaled_stepY - 1) * scaled_stepY + offset.Y mod scaled_stepY;
|
pt.Y := (r.Top div scaled_stepY - 1) * scaled_stepY + offset.Y mod scaled_stepY;
|
||||||
while pt.Y <= r.Bottom do begin
|
while pt.Y <= r.Bottom do begin
|
||||||
@ -2429,11 +2458,14 @@ begin
|
|||||||
Result := FColorSource <> nil;
|
Result := FColorSource <> nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomColorMapSeries.SetAutoMapColors(AValue: Boolean);
|
function TCustomColorMapSeries.IsPaletteMaxStored: Boolean;
|
||||||
begin
|
begin
|
||||||
if FAutoMapColors = AValue then exit;
|
Result := FPaletteMax <> 0;
|
||||||
FAutoMapColors := AValue;
|
end;
|
||||||
UpdateParentChart;
|
|
||||||
|
function TCustomColorMapSeries.IsPaletteMinStored: Boolean;
|
||||||
|
begin
|
||||||
|
Result := FPaletteMin <> 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomColorMapSeries.SetBrush(AValue: TBrush);
|
procedure TCustomColorMapSeries.SetBrush(AValue: TBrush);
|
||||||
@ -2444,32 +2476,20 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomColorMapSeries.SetBuiltinPalette(AValue: TColorMapPalette);
|
procedure TCustomColorMapSeries.SetBuiltinPalette(AValue: TColorMapPalette);
|
||||||
var
|
|
||||||
ex: TDoubleRect;
|
|
||||||
begin
|
begin
|
||||||
// if FBuiltinPalette = AValue then exit;
|
|
||||||
FBuiltinPalette := AValue;
|
FBuiltinPalette := AValue;
|
||||||
BuildPalette(FBuiltinPalette);
|
BuildPalette(FBuiltinPalette);
|
||||||
if FColorSource = nil then begin
|
UpdateParentChart;
|
||||||
ex := FBuiltinColorSource.Extent;
|
|
||||||
FColorExtentMin := ex.a.x;
|
|
||||||
FColorExtentMax := ex.b.x;
|
|
||||||
UpdateParentChart;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomColorMapSeries.SetColorSource(AValue: TCustomChartSource);
|
procedure TCustomColorMapSeries.SetColorSource(AValue: TCustomChartSource);
|
||||||
var
|
|
||||||
ex: TDoubleRect;
|
|
||||||
begin
|
begin
|
||||||
if FColorSource = AValue then exit;
|
if FColorSource = AValue then exit;
|
||||||
if FColorSourceListener.IsListening then
|
if FColorSourceListener.IsListening then
|
||||||
ColorSource.Broadcaster.Unsubscribe(FColorSourceListener);
|
ColorSource.Broadcaster.Unsubscribe(FColorSourceListener);
|
||||||
FColorSource := AValue;
|
FColorSource := AValue;
|
||||||
ColorSource.Broadcaster.Subscribe(FColorSourceListener);
|
ColorSource.Broadcaster.Subscribe(FColorSourceListener);
|
||||||
ex := ColorSource.Extent;
|
UpdateColorExtent;
|
||||||
FColorExtentMin := ex.a.x;
|
|
||||||
FColorExtentMax := ex.b.x;
|
|
||||||
UpdateParentChart;
|
UpdateParentChart;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2480,6 +2500,22 @@ begin
|
|||||||
UpdateParentChart;
|
UpdateParentChart;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomColorMapSeries.SetPaletteMax(AValue: Double);
|
||||||
|
begin
|
||||||
|
if AValue = FPaletteMax then exit;
|
||||||
|
FPaletteMax := AValue;
|
||||||
|
BuildPalette(FBuiltinPalette);
|
||||||
|
UpdateParentChart;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomColorMapSeries.SetPaletteMin(AValue: Double);
|
||||||
|
begin
|
||||||
|
if AValue = FPaletteMin then exit;
|
||||||
|
FPaletteMin := AValue;
|
||||||
|
BuildPalette(FBuiltinPalette);
|
||||||
|
UpdateParentChart;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomColorMapSeries.SetStepX(AValue: TFuncSeriesStep);
|
procedure TCustomColorMapSeries.SetStepX(AValue: TFuncSeriesStep);
|
||||||
begin
|
begin
|
||||||
if FStepX = AValue then exit;
|
if FStepX = AValue then exit;
|
||||||
@ -2501,6 +2537,15 @@ begin
|
|||||||
UpdateParentChart;
|
UpdateParentChart;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomColorMapSeries.UpdateColorExtent;
|
||||||
|
var
|
||||||
|
ext: TDoubleRect;
|
||||||
|
begin
|
||||||
|
ext := ColorSource.Extent;
|
||||||
|
FColorExtentMin := ext.a.x;
|
||||||
|
FColorExtentMax := ext.b.x;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TColorMapSeries }
|
{ TColorMapSeries }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user