You've already forked lazarus-ccr
jvcllaz: Provide setter methods for a variaty of TJvChart properties. Update JvChartDemo.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7176 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -54,6 +54,13 @@
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="StatsClasses"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="jvpeneditor.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="PenEditorForm"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="jvPenEditor"/>
|
||||
</Unit>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
@ -6,7 +6,7 @@ uses
|
||||
Interfaces,
|
||||
Forms, printer4lazarus,
|
||||
JvChartDemoFm in 'JvChartDemoFm.pas' {JvChartDemoForm},
|
||||
StatsClasses in 'StatsClasses.pas';
|
||||
StatsClasses in 'StatsClasses.pas', jvPenEditor;
|
||||
|
||||
{$R *.res}
|
||||
|
||||
|
@ -18,7 +18,6 @@ object JvChartDemoForm: TJvChartDemoForm
|
||||
Height = 398
|
||||
Top = 35
|
||||
Width = 625
|
||||
Font.Height = -19
|
||||
Align = alClient
|
||||
Options.XAxisValuesPerDivision = 10
|
||||
Options.XAxisLabelAlignment = taLeftJustify
|
||||
@ -29,6 +28,7 @@ object JvChartDemoForm: TJvChartDemoForm
|
||||
Options.XGap = 0
|
||||
Options.XOrigin = 0
|
||||
Options.YOrigin = 0
|
||||
Options.XStartOffset = 60
|
||||
Options.YStartOffset = 42
|
||||
Options.PrimaryYAxis.YMax = 20
|
||||
Options.PrimaryYAxis.YMin = 0
|
||||
@ -47,11 +47,13 @@ object JvChartDemoForm: TJvChartDemoForm
|
||||
Options.HeaderFont.Color = clWindowText
|
||||
Options.LegendFont.Color = clWindowText
|
||||
Options.AxisFont.Color = clWindowText
|
||||
Options.AxisTitleFont.Height = -16
|
||||
Options.AxisTitleFont.Orientation = 900
|
||||
Options.AxisTitleFont.Style = [fsBold]
|
||||
Options.PaperColor = clWhite
|
||||
Options.AxisLineColor = clBlack
|
||||
Options.CursorColor = clBlack
|
||||
Options.CursorStyle = psDot
|
||||
OnChartPaint = ChartChartPaint
|
||||
OnBeginFloatingMarkerDrag = ChartBeginFloatingMarkerDrag
|
||||
OnEndFloatingMarkerDrag = ChartEndFloatingMarkerDrag
|
||||
end
|
||||
@ -186,7 +188,7 @@ object JvChartDemoForm: TJvChartDemoForm
|
||||
ParentShowHint = False
|
||||
end
|
||||
object ButtonBarAve: TSpeedButton
|
||||
Left = 31
|
||||
Left = 32
|
||||
Height = 25
|
||||
Hint = 'Bar Chart with Average Line'
|
||||
Top = 5
|
||||
@ -354,6 +356,15 @@ object JvChartDemoForm: TJvChartDemoForm
|
||||
ShowHint = True
|
||||
ParentShowHint = False
|
||||
end
|
||||
object SpinEdit1: TSpinEdit
|
||||
Left = 656
|
||||
Height = 24
|
||||
Top = 6
|
||||
Width = 66
|
||||
MaxValue = 1000
|
||||
OnChange = SpinEdit1Change
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
object ListBox1: TListBox
|
||||
Left = 0
|
||||
@ -417,21 +428,84 @@ object JvChartDemoForm: TJvChartDemoForm
|
||||
top = 48
|
||||
object Demo1: TMenuItem
|
||||
Caption = '&Demo'
|
||||
object mnuSetHeaderFont: TMenuItem
|
||||
Caption = 'Set Header Font...'
|
||||
OnClick = mnuSetHeaderFontClick
|
||||
object MenuItem2: TMenuItem
|
||||
Caption = '-'
|
||||
end
|
||||
object mnuSetAxisTitlefont: TMenuItem
|
||||
Caption = 'Set Axis Title Font...'
|
||||
OnClick = mnuSetAxisTitlefontClick
|
||||
object mnuSetXAxisHeader: TMenuItem
|
||||
Caption = 'Set X Axis Header...'
|
||||
OnClick = mnuSetXAxisHeaderClick
|
||||
end
|
||||
object mnuSetAxisFont: TMenuItem
|
||||
Caption = 'Set Axis Label Font...'
|
||||
OnClick = mnuSetAxisFontClick
|
||||
object mnuSetYAxisHeader: TMenuItem
|
||||
Caption = 'Set Y Axis Header...'
|
||||
OnClick = mnuSetYAxisHeaderClick
|
||||
end
|
||||
object mnuSetLegendFont: TMenuItem
|
||||
Caption = 'Set Legend Font...'
|
||||
OnClick = mnuSetLegendFontClick
|
||||
object mnuSetMarkerSize: TMenuItem
|
||||
Caption = 'Set Marker Size...'
|
||||
OnClick = mnuSetMarkerSizeClick
|
||||
end
|
||||
object MenuItem3: TMenuItem
|
||||
Caption = '-'
|
||||
end
|
||||
object mnuFonts: TMenuItem
|
||||
Caption = 'Fonts'
|
||||
object mnuSetHeaderFont: TMenuItem
|
||||
Caption = 'Set Header Font...'
|
||||
OnClick = mnuSetHeaderFontClick
|
||||
end
|
||||
object mnuSetAxisTitlefont: TMenuItem
|
||||
Caption = 'Set Axis Title Font...'
|
||||
OnClick = mnuSetAxisTitlefontClick
|
||||
end
|
||||
object mnuSetAxisFont: TMenuItem
|
||||
Caption = 'Set Axis Label Font...'
|
||||
OnClick = mnuSetAxisFontClick
|
||||
end
|
||||
object mnuSetLegendFont: TMenuItem
|
||||
Caption = 'Set Legend Font...'
|
||||
OnClick = mnuSetLegendFontClick
|
||||
end
|
||||
end
|
||||
object mnuColors: TMenuItem
|
||||
Caption = 'Colors'
|
||||
object mnuSetPaperColor: TMenuItem
|
||||
Caption = 'Set Paper Color...'
|
||||
OnClick = mnuSetPaperColorClick
|
||||
end
|
||||
object mnuSetDivisionLineColor: TMenuItem
|
||||
Caption = 'Set Division Line Color...'
|
||||
OnClick = mnuSetDivisionLineColorClick
|
||||
end
|
||||
object mnuSetShadowColor: TMenuItem
|
||||
Caption = 'Set Shadow Color..'
|
||||
OnClick = mnuSetShadowColorClick
|
||||
end
|
||||
object mnuSetCursorColor: TMenuItem
|
||||
Caption = 'Set Cursor Color...'
|
||||
OnClick = mnuSetCursorColorClick
|
||||
end
|
||||
object mnuSetHintColor: TMenuItem
|
||||
Caption = 'Set Hint Color...'
|
||||
OnClick = mnuSetHintColorClick
|
||||
end
|
||||
end
|
||||
object mnuSetLineWidths: TMenuItem
|
||||
Caption = 'Line Widths'
|
||||
object mnuSetAxisLineWidth: TMenuItem
|
||||
Caption = 'Set Axis Line Width...'
|
||||
OnClick = mnuSetAxisLineWidthClick
|
||||
end
|
||||
object mnuSetPenLineWidth: TMenuItem
|
||||
Caption = 'Set Pen Line Width...'
|
||||
OnClick = mnuSetPenLineWidthClick
|
||||
end
|
||||
end
|
||||
object mnuPens: TMenuItem
|
||||
Caption = 'Pens...'
|
||||
OnClick = mnuPensClick
|
||||
end
|
||||
object mnuSetXStartOffset: TMenuItem
|
||||
Caption = 'X Start Offset...'
|
||||
OnClick = mnuSetXStartOffsetClick
|
||||
end
|
||||
object N2: TMenuItem
|
||||
Caption = '-'
|
||||
|
@ -46,6 +46,23 @@ type
|
||||
{ TJvChartDemoForm }
|
||||
|
||||
TJvChartDemoForm = class(TForm)
|
||||
mnuSetXStartOffset: TMenuItem;
|
||||
mnuSetPenLineWidth: TMenuItem;
|
||||
mnuSetAxisLineWidth: TMenuItem;
|
||||
mnuSetLineWidths: TMenuItem;
|
||||
mnuSetHintColor: TMenuItem;
|
||||
mnuSetCursorColor: TMenuItem;
|
||||
mnuPens: TMenuItem;
|
||||
mnuSetPaperColor: TMenuItem;
|
||||
mnuSetShadowColor: TMenuItem;
|
||||
mnuFonts: TMenuItem;
|
||||
mnuSetDivisionLineColor: TMenuItem;
|
||||
mnuColors: TMenuItem;
|
||||
MenuItem3: TMenuItem;
|
||||
mnuSetMarkerSize: TMenuItem;
|
||||
mnuSetYAxisHeader: TMenuItem;
|
||||
mnuSetXAxisHeader: TMenuItem;
|
||||
MenuItem2: TMenuItem;
|
||||
mnuSetAxisTitlefont: TMenuItem;
|
||||
mnuSetLegendFont: TMenuItem;
|
||||
mnuSetHeaderFont: TMenuItem;
|
||||
@ -76,6 +93,7 @@ type
|
||||
mnuSetAxisFont: TMenuItem;
|
||||
mnuScrolling: TMenuItem;
|
||||
ListBox1: TListBox;
|
||||
SpinEdit1: TSpinEdit;
|
||||
Splitter1: TSplitter;
|
||||
Timer1: TTimer;
|
||||
ShowDataInListbox1: TMenuItem;
|
||||
@ -94,6 +112,11 @@ type
|
||||
procedure ButtonBarChartClick(Sender: TObject);
|
||||
procedure ButtonStackedBarAveClick(Sender: TObject);
|
||||
procedure ButtonStackedBarClick(Sender: TObject);
|
||||
procedure mnuSetAxisLineWidthClick(Sender: TObject);
|
||||
procedure mnuSetCursorColorClick(Sender: TObject);
|
||||
procedure mnuSetHintColorClick(Sender: TObject);
|
||||
procedure mnuSetPenLineWidthClick(Sender: TObject);
|
||||
procedure mnuSetXStartOffsetClick(Sender: TObject);
|
||||
procedure SpeedButton7Click(Sender: TObject);
|
||||
procedure ButtonBarAveClick(Sender: TObject);
|
||||
procedure SpinEdit1Change(Sender: TObject);
|
||||
@ -120,6 +143,7 @@ type
|
||||
|
||||
procedure PrintOptions1Click(Sender: TObject);
|
||||
procedure MenuSecondaryAxisModeClick(Sender: TObject);
|
||||
|
||||
procedure ListBox1Click(Sender: TObject);
|
||||
procedure ListBox1DblClick(Sender: TObject);
|
||||
|
||||
@ -127,6 +151,15 @@ type
|
||||
procedure mnuSetAxisTitlefontClick(Sender: TObject);
|
||||
procedure mnuSetHeaderFontClick(Sender: TObject);
|
||||
procedure mnuSetLegendFontClick(Sender: TObject);
|
||||
procedure mnuSetMarkerSizeClick(Sender: TObject);
|
||||
procedure mnuSetPaperColorClick(Sender: TObject);
|
||||
procedure mnuPensClick(Sender: TObject);
|
||||
procedure mnuSetShadowColorClick(Sender: TObject);
|
||||
procedure mnuSetXAxisHeaderClick(Sender: TObject);
|
||||
procedure mnuSetYAxisHeaderClick(Sender: TObject);
|
||||
|
||||
procedure mnuSetDivisionLineColorClick(Sender: TObject);
|
||||
procedure mnuSetPenCountClick(Sender: TObject);
|
||||
|
||||
procedure MenuNegValueTestClick(Sender: TObject);
|
||||
procedure SpeedButtonTestMouseOverClick(Sender: TObject);
|
||||
@ -134,7 +167,6 @@ type
|
||||
FloatingMarker: TJvChartFloatingMarker);
|
||||
procedure ChartBeginFloatingMarkerDrag(Sender: TJvChart;
|
||||
FloatingMarker: TJvChartFloatingMarker);
|
||||
procedure ChartChartPaint(Sender: TJvChart; aCanvas: TCanvas);
|
||||
procedure NewFeaturesfor20071Click(Sender: TObject);
|
||||
private
|
||||
|
||||
@ -150,6 +182,7 @@ type
|
||||
procedure _Generate;
|
||||
procedure _StoreValue(I: integer);
|
||||
function _QAProblemScatter: Integer;
|
||||
procedure MakePensMenu;
|
||||
|
||||
public
|
||||
procedure NewValues;
|
||||
@ -161,12 +194,17 @@ var
|
||||
implementation
|
||||
|
||||
uses
|
||||
LCLIntf, // OpenURL
|
||||
LCLType, // MB_OK
|
||||
Math; // Math:NaN handling, function isNan in D6 and higher.
|
||||
Math, // Math:NaN handling, function isNan in D6 and higher.
|
||||
JvPenEditor;
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
const
|
||||
TAG_PENCOLORS = 991;
|
||||
MAX_PEN = 100;
|
||||
|
||||
|
||||
{ Bogus vageuly sinusoidal signal generator }
|
||||
|
||||
procedure TJvChartDemoForm._Generate;
|
||||
@ -472,7 +510,6 @@ procedure TJvChartDemoForm.ButtonBarChartClick(Sender: TObject);
|
||||
begin
|
||||
Chart.Options.ChartKind := ckChartBar;
|
||||
NewValues;
|
||||
//Chart.PlotGraph;
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.ButtonLineClick(Sender: TObject);
|
||||
@ -523,7 +560,6 @@ begin
|
||||
Chart.Options.ChartKind := ckChartBarAverage;
|
||||
|
||||
NewValues;
|
||||
//Chart.Plo
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.ButtonPieClick(Sender: TObject);
|
||||
@ -540,6 +576,9 @@ end;
|
||||
|
||||
procedure TJvChartDemoForm.SpinEdit1Change(Sender: TObject);
|
||||
begin
|
||||
// Chart.Options.PrimaryYAxis.YPixelGap := SpinEdit1.Value;
|
||||
// Chart.Options.YStartOffset := SpinEdit1.Value;
|
||||
Chart.Options.XStartOffset := SpinEdit1.Value;
|
||||
// Chart.Options.ColorScheme := SpinEdit1.Value;
|
||||
// Chart.PlotGraph;
|
||||
end;
|
||||
@ -562,6 +601,8 @@ end;
|
||||
|
||||
procedure TJvChartDemoForm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
MakePensMenu;
|
||||
|
||||
FStatHgt := TStatArray.Create(10); // Initialize for rolling average of last 10 samples.
|
||||
FStatHg0 := TStatArray.Create(10);
|
||||
|
||||
@ -600,6 +641,28 @@ begin
|
||||
Chart.GraphToClipboard;
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.MakePensMenu;
|
||||
var
|
||||
i: Integer;
|
||||
mnu: TMenuItem;
|
||||
begin
|
||||
for i := mnuPens.Count-1 downto 0 do begin
|
||||
mnu := mnuPens.Items[i];
|
||||
if (mnu <> nil) and (mnu.Tag >= TAG_PENCOLORS) and (mnu.tag < TAG_PENCOLORS + MAX_PEN) then
|
||||
mnuPens.Delete(i);
|
||||
end;
|
||||
(*
|
||||
for i:=0 to Chart.Options.PenCount - 1do
|
||||
begin
|
||||
mnu := TMenuItem.Create(mnuPens);
|
||||
mnu.Caption := 'Set Pen ' + IntToStr(i + 1);
|
||||
mnu.Tag := TAG_PENCOLORS + i;
|
||||
mnu.OnClick := @mnuSetPen;
|
||||
mnuPens.Add(mnu);
|
||||
end;
|
||||
*)
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.mnuSetAxisFontClick(Sender: TObject);
|
||||
begin
|
||||
{Get the current font for the axis label texts...}
|
||||
@ -609,19 +672,43 @@ begin
|
||||
{Set the font for the Header text...}
|
||||
Chart.Options.AxisFont := FontDialog1.Font;
|
||||
Chart.PlotGraph;
|
||||
// Chart.Invalidate;
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.mnuSetAxisTitlefontClick(Sender: TObject);
|
||||
procedure TJvChartDemoForm.mnuSetAxisLineWidthClick(Sender: TObject);
|
||||
var
|
||||
s: String;
|
||||
w: Integer;
|
||||
begin
|
||||
s := InputBox('Set Axis Linewidth', 'Value:', IntToStr(Chart.Options.AxisLineWidth));
|
||||
if TryStrToInt(s, w) and (w > 0) then
|
||||
Chart.Options.AxisLineWidth := w
|
||||
else
|
||||
MessageDlg('No valid number for axis linewidth', mtError, [mbOk], 0);
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.mnuSetAxisTitleFontClick(Sender: TObject);
|
||||
begin
|
||||
{Get the current font for the axis titles...}
|
||||
FontDialog1.Font.Assign(Chart.Font);
|
||||
FontDialog1.Font.Assign(Chart.Options.AxisTitleFont);
|
||||
|
||||
if FontDialog1.Execute then
|
||||
{Set the font for the Header text...}
|
||||
Chart.Font := FontDialog1.Font;
|
||||
Chart.PlotGraph;
|
||||
Chart.Invalidate;
|
||||
if FontDialog1.Execute then
|
||||
{Set the font for the Header text...}
|
||||
Chart.Options.AxisTitleFont := FontDialog1.Font;
|
||||
Chart.PlotGraph;
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.mnuSetCursorColorClick(Sender: TObject);
|
||||
begin
|
||||
ColorDialog1.Color := Chart.Options.CursorColor;
|
||||
if ColorDialog1.Execute then
|
||||
Chart.Options.CursorColor := ColorDialog1.Color;
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.mnuSetDivisionLineColorClick(Sender: TObject);
|
||||
begin
|
||||
ColorDialog1.Color := Chart.Options.DivisionLineColor;
|
||||
if ColorDialog1.Execute then
|
||||
Chart.Options.DivisionLineColor := ColorDialog1.Color;
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.mnuSetHeaderFontClick(Sender: TObject);
|
||||
@ -633,7 +720,13 @@ begin
|
||||
{Set the font for the Header text...}
|
||||
Chart.Options.HeaderFont := FontDialog1.Font;
|
||||
Chart.PlotGraph;
|
||||
// Chart.Invalidate;
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.mnuSetHintColorClick(Sender: TObject);
|
||||
begin
|
||||
ColorDialog1.Color := Chart.Options.HintColor;
|
||||
if ColorDialog1.Execute then
|
||||
Chart.Options.HintColor := ColorDialog1.Color;
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.mnuSetLegendFontClick(Sender: TObject);
|
||||
@ -645,7 +738,84 @@ begin
|
||||
{Set the font for the Header text...}
|
||||
Chart.Options.LegendFont := FontDialog1.Font;
|
||||
Chart.PlotGraph;
|
||||
// Chart.Invalidate;
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.mnuSetMarkerSizeClick(Sender: TObject);
|
||||
var
|
||||
s: String;
|
||||
begin
|
||||
s := InputBox('Set Marker Size', 'Value:', IntToStr(Chart.Options.MarkerSize));
|
||||
Chart.Options.MarkerSize := StrToInt(s);
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.mnuSetPaperColorClick(Sender: TObject);
|
||||
begin
|
||||
ColorDialog1.Color := Chart.Options.PaperColor;
|
||||
if ColorDialog1.Execute then
|
||||
Chart.Options.PaperColor := ColorDialog1.Color;
|
||||
end;
|
||||
|
||||
|
||||
procedure TJvChartDemoForm.mnuSetPenCountClick(Sender: TObject);
|
||||
var
|
||||
s: String;
|
||||
n: Integer;
|
||||
begin
|
||||
s := InputBox('Set pen count', 'Value:', IntToStr(Chart.Options.PenCount));
|
||||
if TryStrToInt(s, n) then
|
||||
begin
|
||||
Chart.Options.PenCount := n;
|
||||
//MakePenColorMenu;
|
||||
end else
|
||||
MessageDlg('No valid number of pens.', mtError, [mbOK], 0);
|
||||
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.mnuSetPenLineWidthClick(Sender: TObject);
|
||||
var
|
||||
s: String;
|
||||
w: Integer;
|
||||
begin
|
||||
s := InputBox('Set Pen Linewidth', 'Value:', IntToStr(Chart.Options.PenLineWidth));
|
||||
if TryStrToInt(s, w) and (w > 0) then
|
||||
Chart.Options.PenLineWidth := w
|
||||
else
|
||||
MessageDlg('No valid number for pen linewidth', mtError, [mbOk], 0);
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.mnuSetShadowColorClick(Sender: TObject);
|
||||
begin
|
||||
ColorDialog1.Color := Chart.Options.ShadowColor;
|
||||
if ColorDialog1.Execute then
|
||||
Chart.Options.ShadowColor := ColorDialog1.Color;
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.mnuSetXAxisHeaderClick(Sender: TObject);
|
||||
var
|
||||
s: String;
|
||||
begin
|
||||
s := InputBox('Set X Axis Title', 'Text:', Chart.Options.XAxisHeader);
|
||||
Chart.Options.XAxisHeader := s;
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.mnuSetXStartOffsetClick(Sender: TObject);
|
||||
var
|
||||
s: String;
|
||||
x: Integer;
|
||||
begin
|
||||
s := InputBox('Set X Axis Start Offset', 'Value:', IntToStr(Chart.Options.XStartOffset));
|
||||
if TryStrToInt(s, x) and (x >= 0) then
|
||||
Chart.Options.XStartOffset := x
|
||||
else
|
||||
MessageDlg('No valid number for X Start Offset.', mtError, [mbOK], 0);
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.mnuSetYAxisHeaderClick(Sender: TObject);
|
||||
var
|
||||
s: String;
|
||||
begin
|
||||
s := InputBox('Set Y Axis Title', 'Text:', Chart.Options.YAxisHeader);
|
||||
Chart.Options.YAxisHeader := s;
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.About1Click(Sender: TObject);
|
||||
@ -725,6 +895,20 @@ begin
|
||||
NewValues;
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.mnuPensClick(Sender: TObject);
|
||||
var
|
||||
F: TPenEditorForm;
|
||||
begin
|
||||
F := TPenEditorForm.Create(nil);
|
||||
try
|
||||
F.UseChart(Chart);
|
||||
if F.ShowModal = mrOK then
|
||||
F.ApplyToChart(Chart);
|
||||
finally
|
||||
F.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.ListBox1DblClick(Sender: TObject);
|
||||
begin
|
||||
Chart.CursorPosition := ListBox1.ItemIndex; // Highlight one sample.
|
||||
@ -812,14 +996,7 @@ begin
|
||||
draggableCursor.Caption := FloatToStrF( Chart.Data.Value[0,draggableCursor.XPosition], ffFixed, 6,4 );
|
||||
draggableCursor.Visible := true;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Chart.PlotGraph;
|
||||
|
||||
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.ChartEndFloatingMarkerDrag(Sender: TJvChart;
|
||||
@ -830,25 +1007,13 @@ begin
|
||||
FloatingMarker.YPosition := Chart.Data.Value[0, FloatingMarker.XPosition]
|
||||
else // update caption
|
||||
FloatingMarker.Caption := FloatToStrF( Chart.Data.Value[0,FloatingMarker.XPosition],ffFixed,6,4 );
|
||||
|
||||
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.ChartBeginFloatingMarkerDrag(Sender: TJvChart;
|
||||
FloatingMarker: TJvChartFloatingMarker);
|
||||
begin
|
||||
if FloatingMarker.Index=2 then
|
||||
FloatingMarker.Caption := '?';
|
||||
|
||||
end;
|
||||
|
||||
procedure TJvChartDemoForm.ChartChartPaint(Sender: TJvChart;
|
||||
aCanvas: TCanvas);
|
||||
begin
|
||||
aCanvas.Pen.Color := clRed;
|
||||
aCanvas.Pen.Style := psSolid;
|
||||
aCanvas.MoveTo(0,0);
|
||||
aCanvas.LineTo(100,100);
|
||||
if FloatingMarker.Index = 2 then
|
||||
FloatingMarker.Caption := '?';
|
||||
end;
|
||||
|
||||
end.
|
||||
|
156
components/jvcllaz/examples/JvChartDemo/jvpeneditor.lfm
Normal file
156
components/jvcllaz/examples/JvChartDemo/jvpeneditor.lfm
Normal file
@ -0,0 +1,156 @@
|
||||
object PenEditorForm: TPenEditorForm
|
||||
Left = 347
|
||||
Height = 291
|
||||
Top = 128
|
||||
Width = 505
|
||||
Caption = 'PenEditorForm'
|
||||
ClientHeight = 291
|
||||
ClientWidth = 505
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
LCLVersion = '2.1.0.0'
|
||||
object btnPenColor: TButton
|
||||
Left = 224
|
||||
Height = 25
|
||||
Top = 128
|
||||
Width = 64
|
||||
AutoSize = True
|
||||
Caption = 'Color...'
|
||||
OnClick = btnPenColorClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object rgPenStyle: TRadioGroup
|
||||
Left = 224
|
||||
Height = 80
|
||||
Top = 40
|
||||
Width = 265
|
||||
AutoFill = True
|
||||
Caption = 'Style'
|
||||
ChildSizing.LeftRightSpacing = 6
|
||||
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
|
||||
ChildSizing.EnlargeVertical = crsHomogenousChildResize
|
||||
ChildSizing.ShrinkHorizontal = crsScaleChilds
|
||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||
ChildSizing.ControlsPerLine = 3
|
||||
ClientHeight = 60
|
||||
ClientWidth = 261
|
||||
Columns = 3
|
||||
Items.Strings = (
|
||||
'Solid'
|
||||
'Dash'
|
||||
'Dot'
|
||||
'Dash-dot'
|
||||
'Dash-dot-dot'
|
||||
'Clear'
|
||||
)
|
||||
OnClick = rgPenStyleClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object ButtonPanel1: TButtonPanel
|
||||
Left = 6
|
||||
Height = 34
|
||||
Top = 251
|
||||
Width = 493
|
||||
OKButton.Name = 'OKButton'
|
||||
OKButton.DefaultCaption = True
|
||||
HelpButton.Name = 'HelpButton'
|
||||
HelpButton.DefaultCaption = True
|
||||
CloseButton.Name = 'CloseButton'
|
||||
CloseButton.DefaultCaption = True
|
||||
CancelButton.Name = 'CancelButton'
|
||||
CancelButton.DefaultCaption = True
|
||||
TabOrder = 2
|
||||
ShowButtons = [pbOK, pbCancel]
|
||||
end
|
||||
object lbPens: TListBox
|
||||
Left = 8
|
||||
Height = 200
|
||||
Top = 8
|
||||
Width = 200
|
||||
ItemHeight = 0
|
||||
OnDrawItem = lbPensDrawItem
|
||||
OnSelectionChange = lbPensSelectionChange
|
||||
Style = lbOwnerDrawFixed
|
||||
TabOrder = 3
|
||||
end
|
||||
object btnAdd: TButton
|
||||
Left = 11
|
||||
Height = 25
|
||||
Top = 216
|
||||
Width = 48
|
||||
AutoSize = True
|
||||
Caption = 'Add'
|
||||
OnClick = btnAddClick
|
||||
TabOrder = 4
|
||||
end
|
||||
object btnDelete: TButton
|
||||
Left = 64
|
||||
Height = 25
|
||||
Top = 216
|
||||
Width = 59
|
||||
AutoSize = True
|
||||
Caption = 'Delete'
|
||||
OnClick = btnDeleteClick
|
||||
TabOrder = 5
|
||||
end
|
||||
object edPenLegend: TEdit
|
||||
Left = 304
|
||||
Height = 23
|
||||
Top = 8
|
||||
Width = 185
|
||||
OnEditingDone = edPenLegendEditingDone
|
||||
TabOrder = 6
|
||||
end
|
||||
object btnClear: TButton
|
||||
Left = 128
|
||||
Height = 25
|
||||
Top = 216
|
||||
Width = 53
|
||||
AutoSize = True
|
||||
Caption = 'Clear'
|
||||
OnClick = btnClearClick
|
||||
TabOrder = 7
|
||||
end
|
||||
object lblLegend: TLabel
|
||||
Left = 224
|
||||
Height = 15
|
||||
Top = 8
|
||||
Width = 39
|
||||
Caption = 'Legend'
|
||||
ParentColor = False
|
||||
end
|
||||
object ColorSample: TShape
|
||||
Left = 304
|
||||
Height = 25
|
||||
Top = 128
|
||||
Width = 25
|
||||
end
|
||||
object ColorDialog: TColorDialog
|
||||
Color = clBlack
|
||||
CustomColors.Strings = (
|
||||
'ColorA=000000'
|
||||
'ColorB=000080'
|
||||
'ColorC=008000'
|
||||
'ColorD=008080'
|
||||
'ColorE=800000'
|
||||
'ColorF=800080'
|
||||
'ColorG=808000'
|
||||
'ColorH=808080'
|
||||
'ColorI=C0C0C0'
|
||||
'ColorJ=0000FF'
|
||||
'ColorK=00FF00'
|
||||
'ColorL=00FFFF'
|
||||
'ColorM=FF0000'
|
||||
'ColorN=FF00FF'
|
||||
'ColorO=FFFF00'
|
||||
'ColorP=FFFFFF'
|
||||
'ColorQ=C0DCC0'
|
||||
'ColorR=F0CAA6'
|
||||
'ColorS=F0FBFF'
|
||||
'ColorT=A4A0A0'
|
||||
)
|
||||
left = 243
|
||||
top = 168
|
||||
end
|
||||
end
|
265
components/jvcllaz/examples/JvChartDemo/jvpeneditor.pas
Normal file
265
components/jvcllaz/examples/JvChartDemo/jvpeneditor.pas
Normal file
@ -0,0 +1,265 @@
|
||||
unit jvPenEditor;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
|
||||
Spin, ButtonPanel,Contnrs,
|
||||
JvChart, Types;
|
||||
|
||||
type
|
||||
TPenObj = class
|
||||
Legend: String;
|
||||
Color: TColor;
|
||||
Style: TPenStyle;
|
||||
end;
|
||||
|
||||
{ TPenEditorForm }
|
||||
|
||||
TPenEditorForm = class(TForm)
|
||||
btnPenColor: TButton;
|
||||
btnAdd: TButton;
|
||||
btnDelete: TButton;
|
||||
btnClear: TButton;
|
||||
ButtonPanel1: TButtonPanel;
|
||||
ColorDialog: TColorDialog;
|
||||
edPenLegend: TEdit;
|
||||
lblLegend: TLabel;
|
||||
lbPens: TListBox;
|
||||
rgPenStyle: TRadioGroup;
|
||||
ColorSample: TShape;
|
||||
procedure btnAddClick(Sender: TObject);
|
||||
procedure btnClearClick(Sender: TObject);
|
||||
procedure btnDeleteClick(Sender: TObject);
|
||||
procedure btnPenColorClick(Sender: TObject);
|
||||
procedure edPenLegendEditingDone(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure lbPensDrawItem(Control: TWinControl; Index: Integer;
|
||||
ARect: TRect; State: TOwnerDrawState);
|
||||
procedure lbPensSelectionChange(Sender: TObject; User: boolean);
|
||||
procedure rgPenStyleClick(Sender: TObject);
|
||||
private
|
||||
FPens: TObjectList;
|
||||
procedure ControlsToPen(AIndex: Integer);
|
||||
procedure PenToControls(AIndex: Integer);
|
||||
function GetCurrentPen: TPenObj;
|
||||
|
||||
public
|
||||
procedure ApplyToChart(AChart: TJvChart);
|
||||
procedure UseChart(AChart: TJvChart);
|
||||
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
LCLType;
|
||||
|
||||
|
||||
{ TPenEditorForm }
|
||||
|
||||
procedure TPenEditorForm.ApplyToChart(AChart: TJvChart);
|
||||
var
|
||||
i: Integer;
|
||||
pen: TPenObj;
|
||||
begin
|
||||
Assert(AChart <> nil);
|
||||
AChart.Options.PenCount := FPens.Count;
|
||||
AChart.Options.PenLegends.Clear;
|
||||
for i := 0 to FPens.Count - 1 do
|
||||
begin
|
||||
pen := TPenObj(FPens[i]);
|
||||
AChart.Options.PenLegends.Add(pen.Legend);
|
||||
AChart.Options.PenColor[i] := pen.Color;
|
||||
AChart.Options.PenStyle[i] := pen.Style;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPenEditorForm.btnAddClick(Sender: TObject);
|
||||
var
|
||||
pen: TPenObj;
|
||||
begin
|
||||
pen := TPenObj.Create;
|
||||
pen.Legend := '';
|
||||
pen.Style := psSolid;
|
||||
pen.Color := clBlack;
|
||||
FPens.Add(pen);
|
||||
lbPens.Items.Add('');
|
||||
end;
|
||||
|
||||
procedure TPenEditorForm.btnClearClick(Sender: TObject);
|
||||
begin
|
||||
FPens.Clear;
|
||||
lbPens.Items.Clear;
|
||||
end;
|
||||
|
||||
procedure TPenEditorForm.btnDeleteClick(Sender: TObject);
|
||||
begin
|
||||
if lbPens.ItemIndex = -1 then
|
||||
exit;
|
||||
FPens.Delete(lbPens.ItemIndex);
|
||||
lbPens.Items.Delete(lbPens.ItemIndex);
|
||||
end;
|
||||
|
||||
procedure TPenEditorForm.btnPenColorClick(Sender: TObject);
|
||||
var
|
||||
pen: TPenObj;
|
||||
begin
|
||||
pen := GetCurrentPen;
|
||||
if pen = nil then
|
||||
exit;
|
||||
|
||||
ColorDialog.Color := pen.Color;
|
||||
if ColorDialog.Execute then begin
|
||||
pen.Color := ColorDialog.Color;
|
||||
lbPens.Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPenEditorForm.ControlsToPen(AIndex: Integer);
|
||||
var
|
||||
pen: TPenObj;
|
||||
begin
|
||||
if AIndex = -1 then
|
||||
exit;
|
||||
pen := TPenObj(FPens[AIndex]);
|
||||
pen.Legend := edPenLegend.Text;
|
||||
if rgPenStyle.ItemIndex = rgPenStyle.Items.Count-1 then
|
||||
pen.Style := psClear
|
||||
else
|
||||
pen.Style := TPenStyle(rgPenStyle.ItemIndex);
|
||||
pen.Color := ColorSample.Brush.Color;
|
||||
end;
|
||||
|
||||
procedure TPenEditorForm.edPenLegendEditingDone(Sender: TObject);
|
||||
var
|
||||
pen: TPenObj;
|
||||
begin
|
||||
pen := GetCurrentPen;
|
||||
if pen = nil then
|
||||
exit;
|
||||
pen.Legend := edPenLegend.Text;
|
||||
lbPens.Invalidate;
|
||||
end;
|
||||
|
||||
procedure TPenEditorForm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
FPens := TObjectList.Create;
|
||||
end;
|
||||
|
||||
procedure TPenEditorForm.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
FPens.Free;
|
||||
end;
|
||||
|
||||
function TPenEditorForm.GetCurrentPen: TPenObj;
|
||||
begin
|
||||
if lbPens.ItemIndex = -1 then
|
||||
Result := nil
|
||||
else
|
||||
Result := TPenObj(FPens[lbPens.ItemIndex]);
|
||||
end;
|
||||
|
||||
procedure TPenEditorForm.lbPensDrawItem(Control: TWinControl; Index: Integer;
|
||||
ARect: TRect; State: TOwnerDrawState);
|
||||
var
|
||||
R: TRect;
|
||||
pen: TPenObj;
|
||||
begin
|
||||
pen := TPenObj(FPens[Index]);
|
||||
lbPens.Canvas.Font.Assign(lbPens.Font);
|
||||
if [odSelected, odFocused] * State <> [] then
|
||||
begin
|
||||
lbPens.Canvas.Brush.Color := clHighlight;
|
||||
lbPens.Canvas.Font.Color := clHighlightText;
|
||||
end else
|
||||
begin
|
||||
lbPens.Canvas.Brush.Color := lbPens.Color;
|
||||
lbPens.Canvas.Font.Color := lbPens.Font.Color;
|
||||
end;
|
||||
lbPens.Canvas.FillRect(ARect);
|
||||
R := ARect;
|
||||
R.Right := R.Left + 50;
|
||||
InflateRect(R, -2, 0);
|
||||
lbPens.Canvas.Pen.Style := pen.Style;
|
||||
lbPens.Canvas.Pen.Color := pen.Color;
|
||||
lbPens.Canvas.Line(R.Left, (R.Top + R.Bottom) div 2, R.Right, (R.Top + R.Bottom) div 2);
|
||||
lbPens.Canvas.TextOut(R.Right + 2, (R.Top + R.Bottom - lbPens.Canvas.TextHeight('Rg')) div 2, pen.Legend);
|
||||
if odFocused in State then
|
||||
lbPens.Canvas.DrawFocusRect(ARect);
|
||||
end;
|
||||
|
||||
procedure TPenEditorForm.lbPensSelectionChange(Sender: TObject; User: boolean);
|
||||
begin
|
||||
PenToControls(lbPens.ItemIndex);
|
||||
end;
|
||||
|
||||
procedure TPenEditorForm.PenToControls(AIndex: Integer);
|
||||
var
|
||||
pen: TPenObj;
|
||||
begin
|
||||
if AIndex = -1 then
|
||||
exit;
|
||||
|
||||
pen := TPenObj(FPens[AIndex]);
|
||||
edPenLegend.Text := pen.Legend;
|
||||
if pen.Style = psClear then
|
||||
rgPenStyle.ItemIndex := rgPenStyle.Items.Count-1
|
||||
else
|
||||
rgPenStyle.ItemIndex := ord(pen.Style);
|
||||
ColorSample.Brush.Color := pen.Color;
|
||||
|
||||
edPenLegend.Enabled := true;
|
||||
rgPenStyle.Enabled := true;
|
||||
btnPenColor.Enabled := true;
|
||||
ColorSample.Visible := true;
|
||||
end;
|
||||
|
||||
procedure TPenEditorForm.rgPenStyleClick(Sender: TObject);
|
||||
var
|
||||
pen: TPenObj;
|
||||
begin
|
||||
pen := GetCurrentPen;
|
||||
if pen = nil then
|
||||
exit;
|
||||
|
||||
if rgPenStyle.itemIndex = rgPenStyle.Items.Count -1 then
|
||||
pen.Style := psClear
|
||||
else
|
||||
pen.Style := TPenStyle(rgPenStyle.ItemIndex);
|
||||
lbPens.Invalidate;
|
||||
end;
|
||||
|
||||
procedure TPenEditorForm.UseChart(AChart: TJvChart);
|
||||
var
|
||||
i: Integer;
|
||||
pen: TPenObj;
|
||||
begin
|
||||
Assert(AChart <> nil);
|
||||
|
||||
FPens.Clear;
|
||||
lbPens.Items.Clear;
|
||||
for i := 0 to AChart.Options.PenLegends.Count - 1 do
|
||||
begin
|
||||
pen := TPenObj.Create;
|
||||
pen.Legend := AChart.Options.PenLegends[i];
|
||||
pen.Color := AChart.Options.PenColor[i];
|
||||
pen.Style := AChart.Options.PenStyle[i];
|
||||
FPens.Add(pen);
|
||||
lbPens.Items.Add('');
|
||||
end;
|
||||
|
||||
edPenLegend.Enabled := false;
|
||||
rgpenStyle.Enabled := false;
|
||||
btnPenColor.Enabled := false;
|
||||
ColorSample.Visible := false;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -112,6 +112,7 @@ const
|
||||
JvDefaultAvgLineColor = TColor($00EEDDDD);
|
||||
JvDefaultDivisionLineColor = clLtGray; //NEW!
|
||||
JvDefaultShadowColor = clLtGray; //NEW!
|
||||
JvDefaultPaperColor = clWhite;
|
||||
|
||||
JvDefaultYLegends = 20;
|
||||
MaxShowXValueInLegends = 10;
|
||||
@ -391,6 +392,7 @@ type
|
||||
function GetYLegends: TStrings;
|
||||
procedure SetYLegends(Value: TStrings);
|
||||
procedure SetYDivisions(AValue: Integer);
|
||||
procedure SetYPixelGap(AValue: Double);
|
||||
public
|
||||
constructor Create(Owner: TJvChartOptions); virtual;
|
||||
destructor Destroy; override;
|
||||
@ -398,7 +400,7 @@ type
|
||||
procedure Normalize;
|
||||
procedure Clear;
|
||||
// runtime only properties
|
||||
property YPixelGap: Double read FYPixelGap write FYPixelGap;
|
||||
property YPixelGap: Double read FYPixelGap write SetYPixelGap;
|
||||
property Active: Boolean read FActive;
|
||||
property YGap: Double read FYGap;
|
||||
property YGap1: Double read FYGap1; // Gap multiplication factor for value scaling.
|
||||
@ -424,21 +426,15 @@ type
|
||||
function GetAverageValue(Index: Integer): Double;
|
||||
procedure SetAverageValue(Index: Integer; AValue: Double);
|
||||
function GetPenColor(Index: Integer): TColor;
|
||||
procedure SetPenColor(Index: Integer; AColor: TColor);
|
||||
function GetPenStyle(Index: Integer): TPenStyle;
|
||||
procedure SetPenStyle(Index: Integer; APenStyle: TPenStyle);
|
||||
function GetPenMarkerKind(Index: Integer): TJvChartPenMarkerKind;
|
||||
procedure SetPenMarkerKind(Index: Integer; AMarkKind: TJvChartPenMarkerKind);
|
||||
procedure SetXStartOffset(Offset: Integer);
|
||||
function GetPenSecondaryAxisFlag(Index: Integer): Boolean;
|
||||
procedure SetPenSecondaryAxisFlag(Index: Integer; NewValue: Boolean);
|
||||
function GetPenValueLabels(Index: Integer): Boolean;
|
||||
procedure SetPenValueLabels(Index: Integer; NewValue: Boolean);
|
||||
procedure SetPenCount(Count: Integer);
|
||||
procedure SetChartKind(AKind: TJvChartKind);
|
||||
// TStrings<->TStringList transmogrifiers
|
||||
function GetPenLegends: TStrings;
|
||||
procedure SetPenLegends(Value: TStrings);
|
||||
function GetPenUnit: TStrings;
|
||||
procedure SetPenUnit(Value: TStrings);
|
||||
function GetXLegends: TStrings;
|
||||
@ -446,13 +442,29 @@ type
|
||||
procedure SetHeaderFont(AFont: TFont);
|
||||
procedure SetLegendFont(AFont: TFont);
|
||||
procedure SetAxisFont(AFont: TFont);
|
||||
procedure SetPaperColor(AColor: TColor);
|
||||
procedure SetPrimaryYAxis(AssignFrom: TJvChartYAxisOptions);
|
||||
procedure SetSecondaryYAxis(AssignFrom: TJvChartYAxisOptions);
|
||||
// Each pen can be associated with either the primary or secondary axis,
|
||||
// this function decides which axis to return depending on the pen configuration:
|
||||
function GetPenAxis(Index: Integer): TJvChartYAxisOptions;
|
||||
|
||||
procedure SetAxisLineWidth(const Value: Integer);
|
||||
procedure SetAxisTitleFont(const Value: TFont);
|
||||
procedure SetChartKind(AKind: TJvChartKind);
|
||||
procedure SetDivisionLineColor(const AColor: TColor);
|
||||
procedure SetMarkerSize(const Value: Integer);
|
||||
procedure SetPaperColor(const AColor: TColor);
|
||||
procedure SetPenColor(Index: Integer; AColor: TColor);
|
||||
procedure SetPenCount(Count: Integer);
|
||||
procedure SetPenLegends(Value: TStrings);
|
||||
procedure SetPenLineWidth(const Value: Integer);
|
||||
procedure SetPenStyle(Index: Integer; APenStyle: TPenStyle);
|
||||
procedure SetShadowColor(const AColor: TColor);
|
||||
procedure SetXAxisDateTimeDivision(const Value: Double);
|
||||
procedure SetXAxisHeader(const Value: String);
|
||||
procedure SetXStartOffset(Offset: Integer);
|
||||
procedure SetYAxisHeader(const Value: String);
|
||||
procedure SetYStartOffset(Offset: Integer);
|
||||
protected
|
||||
FChartKind: TJvChartKind; // default JvChartLine
|
||||
{runtime pixel spacing multipliers}
|
||||
@ -461,6 +473,7 @@ type
|
||||
FHeaderFont: TFont;
|
||||
FLegendFont: TFont;
|
||||
FAxisFont: TFont;
|
||||
FAxisTitleFont: TFont;
|
||||
FTitle: string;
|
||||
FNoDataMessage: string;
|
||||
FYAxisHeader: string;
|
||||
@ -570,8 +583,6 @@ type
|
||||
//NEW! NOV 2004. Optionally display this instead of fixed resource string rsNoData
|
||||
|
||||
{ X Axis Properties }
|
||||
property YAxisHeader: string read FYAxisHeader write FYAxisHeader;
|
||||
property YAxisDivisionMarkers: Boolean read FYAxisDivisionMarkers write FYAxisDivisionMarkers default True;
|
||||
// Do you want grid-paper look?
|
||||
{ X Axis Properties }
|
||||
property XAxisDivisionMarkers: Boolean read FXAxisDivisionMarkers write FXAxisDivisionMarkers default True;
|
||||
@ -580,15 +591,14 @@ type
|
||||
// Number of Values (aka samples) in each vertical dotted lines that are divisision marker.
|
||||
property XAxisLabelAlignment: TAlignment read FXAxisLabelAlignment write FXAxisLabelAlignment;
|
||||
// New: Text alignment for X axis labels. Default is left alignment.
|
||||
|
||||
property XAxisDateTimeMode: Boolean read FXAxisDateTimeMode write FXAxisDateTimeMode;
|
||||
// REWORKED LOGIC NEW IN 2007! See GraphXAxisDivisionMarkers
|
||||
property XAxisDateTimeDivision: Double read FXAxisDateTimeDivision write SetXAxisDateTimeDivision;
|
||||
// NEW 2007 : What is the nominal date/time division (1.0=day, 1.0/24=1 hour)
|
||||
|
||||
property XAxisDateTimeFormat: string read FXAxisDateTimeFormat write FXAxisDateTimeFormat;
|
||||
property XAxisHeader: string read FXAxisHeader write FXAxisHeader;
|
||||
property XAxisHeader: string read FXAxisHeader write SetXAxisHeader;
|
||||
property XAxisLegendSkipBy: Integer read FXAxisLegendSkipBy write FXAxisLegendSkipBy default 1;
|
||||
|
||||
property DateTimeFormat: string read FDateTimeFormat write FDateTimeFormat;
|
||||
// Usually a long date-time label, ISO standard yyyy-mm-dd hh:nn:ss is fine, as is Windows locale defaults.
|
||||
property PenCount: Integer read FPenCount write SetPenCount default 1;
|
||||
@ -596,10 +606,15 @@ type
|
||||
property XOrigin: Integer read FXOrigin write FXOrigin;
|
||||
property YOrigin: Integer read FYOrigin write FYOrigin; // Position of bottom of chart (not always the zero origin)
|
||||
property XStartOffset: Longint read FXStartOffset write SetXStartOffset default 45;
|
||||
property YStartOffset: Longint read FYStartOffset write FYStartOffset default 10;
|
||||
property YStartOffset: Longint read FYStartOffset write SetYStartOffset default 10;
|
||||
|
||||
{ Y Axis Properties }
|
||||
property YAxisHeader: string read FYAxisHeader write SetYAxisHeader;
|
||||
property YAxisDivisionMarkers: Boolean read FYAxisDivisionMarkers write FYAxisDivisionMarkers default True;
|
||||
|
||||
{ Y Range }
|
||||
{ plotting markers }
|
||||
property MarkerSize: Integer read FMarkerSize write FMarkerSize default JvChartDefaultMarkerSize;
|
||||
property MarkerSize: Integer read FMarkerSize write SetMarkerSize default JvChartDefaultMarkerSize;
|
||||
property FillUnderLine : Boolean read FFillUnderLine write FFillUnderLine default False;
|
||||
{ !! New: Primary (left side) Y axis, and Secondary (right side) Y Axis !!}
|
||||
property PrimaryYAxis: TJvChartYAxisOptions read FPrimaryYAxis write SetPrimaryYAxis;
|
||||
@ -617,20 +632,21 @@ type
|
||||
property Legend: TJvChartLegend read FLegend write FLegend default clChartLegendNone;
|
||||
property LegendRowCount: Integer read FLegendRowCount write FLegendRowCount;
|
||||
property LegendWidth: Integer read FLegendWidth write FLegendWidth default 150;
|
||||
property PenLineWidth: Integer read FPenLineWidth write FPenLineWidth default 1;
|
||||
property AxisLineWidth: Integer read FAxisLineWidth write FAxisLineWidth default 2;
|
||||
property PenLineWidth: Integer read FPenLineWidth write SetPenLineWidth default 1;
|
||||
property AxisLineWidth: Integer read FAxisLineWidth write SetAxisLineWidth default 2;
|
||||
{ more and more design time. these ones not sure about whether they are designtime or not.}
|
||||
property XValueCount: Integer read FXValueCount write FXValueCount default 10;
|
||||
{Font properties}
|
||||
property HeaderFont: TFont read FHeaderFont write SetHeaderFont;
|
||||
property LegendFont: TFont read FLegendFont write SetLegendFont;
|
||||
property AxisFont: TFont read FAxisFont write SetAxisFont;
|
||||
property AxisTitleFont: TFont read FAxisTitleFont write SetAxisTitleFont;
|
||||
{ Color properties}
|
||||
property DivisionLineColor: TColor read FDivisionLineColor write FDivisionLineColor default
|
||||
property DivisionLineColor: TColor read FDivisionLineColor write SetDivisionLineColor default
|
||||
JvDefaultDivisionLineColor; // NEW! Division line
|
||||
property ShadowColor: TColor read FShadowColor write FShadowColor default JvDefaultShadowColor; // NEW! Shadow color
|
||||
property ShadowColor: TColor read FShadowColor write SetShadowColor default JvDefaultShadowColor; // NEW! Shadow color
|
||||
|
||||
property PaperColor: TColor read FPaperColor write SetPaperColor;
|
||||
property PaperColor: TColor read FPaperColor write SetPaperColor default clWhite;
|
||||
property AxisLineColor: TColor read FAxisLineColor write FAxisLineColor;
|
||||
property HintColor: TColor read FHintColor write FHintColor default JvDefaultHintColor;
|
||||
property AverageLineColor: TColor read FAverageLineColor write FAverageLineColor default JvDefaultAvgLineColor;
|
||||
@ -690,7 +706,7 @@ type
|
||||
FMouseDownY: Longint;
|
||||
FMouseValue: Integer;
|
||||
FMousePen: Integer;
|
||||
FYFont: TFont; // Delphi Font object wrapper.
|
||||
// FYFont: TFont; // Delphi Font object wrapper.
|
||||
//NEW:
|
||||
FXOrigin: Double; {was in TJvChart.PlotGraph}
|
||||
FYOrigin: Double; {was in TJvChart.PlotGraph}
|
||||
@ -703,10 +719,10 @@ type
|
||||
// over top of the TImage, so that we can just restore the TImage
|
||||
// without replotting the whole chart.
|
||||
// Y Axis Vertical Font
|
||||
FYFontHandle: HFONT; // Y AXIS VERTICAL TEXT: Vertical Font Handle (remember to DeleteObject)
|
||||
FYLogFont: TLogFont; // Y AXIS VERTICAL TEXT: Logical Font Options Record
|
||||
procedure MakeVerticalFont; // Call GDI calls to get the Y Axis Vertical Font handle
|
||||
procedure MyGraphVertFont(ACanvas: TCanvas); // vertical font handle
|
||||
// FYFontHandle: HFONT; // Y AXIS VERTICAL TEXT: Vertical Font Handle (remember to DeleteObject)
|
||||
// FYLogFont: TLogFont; // Y AXIS VERTICAL TEXT: Logical Font Options Record
|
||||
// procedure MakeVerticalFont; // Call GDI calls to get the Y Axis Vertical Font handle
|
||||
// procedure MyGraphVertFont(ACanvas: TCanvas); // vertical font handle
|
||||
procedure PaintCursor; // called from Paint iif a Cursor is visible. does NOT modify FPicture!
|
||||
protected
|
||||
procedure DrawFloatingMarkers;
|
||||
@ -1776,6 +1792,14 @@ begin
|
||||
FOwner.NotifyOptionsChange;
|
||||
end;
|
||||
|
||||
procedure TJvchartYAxisOptions.SetYPixelGap(AValue: Double);
|
||||
begin
|
||||
if FYPixelGap = AValue then exit;
|
||||
FYPixelGap := AValue;
|
||||
FOwner.NotifyOptionsChange;
|
||||
end;
|
||||
|
||||
|
||||
//=== { TJvChartOptions } ====================================================
|
||||
|
||||
constructor TJvChartOptions.Create(Owner: TJvChart);
|
||||
@ -1832,24 +1856,27 @@ begin
|
||||
FAverageLineColor := JvDefaultAvgLineColor;
|
||||
FDivisionLineColor := JvDefaultDivisionLineColor; // NEW!
|
||||
FShadowColor := JvDefaultShadowColor; //NEW!
|
||||
FPaperColor := JvDefaultPaperColor;
|
||||
FHintColor := JvDefaultHintColor;
|
||||
|
||||
FHeaderFont := TFont.Create;
|
||||
FLegendFont := TFont.Create;
|
||||
FAxisFont := TFont.Create;
|
||||
FAxisTitleFont := TFont.Create;
|
||||
FAxisTitleFont.Orientation := 900;
|
||||
|
||||
//FShowLegend := True;
|
||||
FMouseEdit := True;
|
||||
FMouseInfo := True;
|
||||
FLegendWidth := 150;
|
||||
FPenLineWidth := 1;
|
||||
FAxisLineWidth := 3;
|
||||
FAxisLineWidth := 2;
|
||||
|
||||
FXValueCount := 10;
|
||||
|
||||
FXAxisLegendSkipBy := 1;
|
||||
FXLegendHoriz := 0;
|
||||
|
||||
FHintColor := JvDefaultHintColor;
|
||||
end;
|
||||
|
||||
destructor TJvChartOptions.Destroy;
|
||||
@ -1864,6 +1891,7 @@ begin
|
||||
FreeAndNil(FHeaderFont);
|
||||
FreeAndNil(FLegendFont);
|
||||
FreeAndNil(FAxisFont);
|
||||
FreeAndNil(FAxisTitleFont);
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
@ -1884,6 +1912,7 @@ begin
|
||||
FHeaderFont.Assign(src.HeaderFont);
|
||||
FLegendFont.Assign(src.LegendFont);
|
||||
FAxisFont.Assign(src.AxisFont);
|
||||
FAxisTitleFont.Assign(src.AxisTitleFont);
|
||||
FPenLegends.Assign(src.PenLegends);
|
||||
FPenUnit.Assign(src.PenUnit);
|
||||
FXLegends.Assign(src.XLegends);
|
||||
@ -2002,12 +2031,6 @@ begin
|
||||
Result := FPrimaryYAxis; // default
|
||||
end;
|
||||
|
||||
procedure TJvChartOptions.SetChartKind(AKind: TJvChartKind);
|
||||
begin
|
||||
if AKind <> FChartKind then
|
||||
FChartKind := AKind;
|
||||
end;
|
||||
|
||||
function TJvChartOptions.GetPenMarkerKind(Index: Integer): TJvChartPenMarkerKind;
|
||||
begin
|
||||
if (Index >= 0) and (Index < Length(FPenMarkerKind)) then
|
||||
@ -2061,7 +2084,10 @@ begin
|
||||
|
||||
if Index >= Length(FPenColors) then
|
||||
SetLength(FPenColors, Index + 1);
|
||||
|
||||
FPenColors[Index] := AColor;
|
||||
if Assigned(FOwner) then
|
||||
FOwner.Invalidate;
|
||||
end;
|
||||
|
||||
procedure TJvChartOptions.SetPenStyle(Index: Integer; APenStyle: TPenStyle);
|
||||
@ -2072,6 +2098,8 @@ begin
|
||||
if Index >= Length(FPenStyles) then
|
||||
SetLength(FPenStyles, Index + 1);
|
||||
FPenStyles[Index] := APenStyle;
|
||||
if Assigned(FOwner) then
|
||||
FOwner.Invalidate;
|
||||
end;
|
||||
|
||||
function TJvChartOptions.GetPenStyle(Index: Integer): TPenStyle;
|
||||
@ -2151,11 +2179,6 @@ begin
|
||||
Result := TStrings(FPenLegends);
|
||||
end;
|
||||
|
||||
procedure TJvChartOptions.SetPenLegends(Value: TStrings);
|
||||
begin
|
||||
FPenLegends.Assign(Value);
|
||||
end;
|
||||
|
||||
function TJvChartOptions.GetPenUnit: TStrings;
|
||||
begin
|
||||
Result := TStrings(FPenUnit);
|
||||
@ -2171,16 +2194,98 @@ begin
|
||||
Result := TStrings(FXLegends);
|
||||
end;
|
||||
|
||||
procedure TJvChartOptions.SetAxisLineWidth(const Value: Integer);
|
||||
begin
|
||||
if FAxisLineWidth = Value then exit;
|
||||
FAxisLineWidth := Value;
|
||||
NotifyOptionsChange;
|
||||
end;
|
||||
|
||||
procedure TJvChartOptions.SetAxisTitleFont(const Value: TFont);
|
||||
begin
|
||||
FAxisTitleFont.Assign(Value);
|
||||
FAxisTitleFont.Orientation := 900;
|
||||
NotifyOptionsChange;
|
||||
end;
|
||||
|
||||
procedure TJvChartOptions.SetChartKind(AKind: TJvChartKind);
|
||||
begin
|
||||
if AKind = FChartKind then exit;
|
||||
|
||||
FChartKind := AKind;
|
||||
NotifyOptionsChange;
|
||||
end;
|
||||
|
||||
procedure TJvChartOptions.SetDivisionLinecolor(const AColor: TColor);
|
||||
begin
|
||||
if FDivisionLineColor = AColor then exit;
|
||||
FDivisionLineColor := AColor;
|
||||
if Assigned(FOwner) then
|
||||
FOwner.Invalidate;
|
||||
end;
|
||||
|
||||
procedure TJvChartOptions.SetMarkerSize(const Value: Integer);
|
||||
begin
|
||||
if FMarkerSize = Value then exit;
|
||||
FMarkerSize := Value;
|
||||
NotifyOptionsChange;
|
||||
end;
|
||||
|
||||
procedure TJvChartOptions.SetPaperColor(const AColor: TColor);
|
||||
begin
|
||||
if AColor <> FPaperColor then
|
||||
begin
|
||||
FPaperColor := AColor;
|
||||
if Assigned(FOwner) then
|
||||
FOwner.Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TJvChartOptions.SetPenLegends(Value: TStrings);
|
||||
begin
|
||||
FPenLegends.Assign(Value);
|
||||
NotifyOptionsChange;
|
||||
end;
|
||||
|
||||
procedure TJvChartOptions.SetPenLineWidth(const Value: Integer);
|
||||
begin
|
||||
if FPenLineWidth = Value then exit;
|
||||
FPenLineWidth := Value;
|
||||
NotifyOptionsChange;
|
||||
end;
|
||||
|
||||
procedure TJvChartOptions.SetShadowColor(const AColor: TColor);
|
||||
begin
|
||||
if FShadowColor = AColor then exit;
|
||||
FShadowColor := AColor;
|
||||
if Assigned(FOwner) then
|
||||
FOwner.Invalidate;
|
||||
end;
|
||||
|
||||
procedure TJvChartOptions.SetXAxisDateTimeDivision(const Value: Double);
|
||||
begin
|
||||
FXAxisDateTimeDivision := Value;
|
||||
end;
|
||||
|
||||
procedure TJvChartOptions.SetXAxisHeader(const Value: String);
|
||||
begin
|
||||
if FXAxisHeader = Value then exit;
|
||||
FXAxisHeader := Value;
|
||||
NotifyOptionsChange;
|
||||
end;
|
||||
|
||||
procedure TJvChartOptions.SetXLegends(Value: TStrings);
|
||||
begin
|
||||
FXLegends.Assign(Value);
|
||||
end;
|
||||
|
||||
procedure TJvChartOptions.SetYAxisHeader(const Value: String);
|
||||
begin
|
||||
if FYAxisHeader = Value then exit;
|
||||
FYAxisHeader := Value;
|
||||
NotifyOptionsChange;
|
||||
end;
|
||||
|
||||
procedure TJvChartOptions.SetHeaderFont(AFont: TFont);
|
||||
begin
|
||||
FHeaderFont.Assign(AFont);
|
||||
@ -2206,24 +2311,26 @@ begin
|
||||
FSecondaryYAxis.Assign(AssignFrom);
|
||||
end;
|
||||
|
||||
procedure TJvChartOptions.SetPaperColor(AColor: TColor);
|
||||
begin
|
||||
if AColor <> FPaperColor then
|
||||
begin
|
||||
FPaperColor := AColor;
|
||||
if Assigned(FOwner) then
|
||||
FOwner.Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TJvChartOptions.SetXStartOffset(Offset: Integer);
|
||||
begin
|
||||
//if not PrintInSession then
|
||||
// if (Offset < 10) or (Offset > (FOwner.Width div 2)) then
|
||||
// raise ERangeError.CreateRes(@RsEChartOptionsXStartOffsetValueOutO);
|
||||
if FXStartOffset = Offset then
|
||||
exit;
|
||||
FXStartOffset := Offset;
|
||||
NotifyOptionsChange;
|
||||
end;
|
||||
|
||||
procedure TJvChartOptions.SetYStartOffset(Offset: Integer);
|
||||
begin
|
||||
if FYStartOffset = Offset then
|
||||
exit;
|
||||
FYStartOffset := Offset;
|
||||
NotifyOptionsChange;
|
||||
end;
|
||||
|
||||
|
||||
//=== { TJvChart } ===========================================================
|
||||
|
||||
{ GRAPH }
|
||||
@ -2292,10 +2399,11 @@ destructor TJvChart.Destroy;
|
||||
begin
|
||||
{Add code for destroying my own data...here}
|
||||
FBitmap.Free;
|
||||
{
|
||||
if Ord(FYFontHandle) <> 0 then
|
||||
DeleteObject(FYFontHandle); // vertical font object
|
||||
FreeAndNil(FYFont);
|
||||
|
||||
}
|
||||
FreeAndNil(FPicture);
|
||||
FreeAndNil(FAverageData);
|
||||
FreeAndNil(FOptions);
|
||||
@ -3198,7 +3306,9 @@ var
|
||||
if Options.PenStyle[I] <> psClear then
|
||||
begin
|
||||
if Options.XPixelGap < 3.0 then
|
||||
ACanvas.Pen.Color := Options.PenColor[I]; // greek-out the borders
|
||||
ACanvas.Pen.Color := Options.PenColor[I] // greek-out the borders
|
||||
else
|
||||
ACanvas.Pen.Color := clBlack;
|
||||
MyColorRectangle(ACanvas, I,
|
||||
Round((XOrigin + J * Options.XPixelGap) + (Options.XPixelGap / 6)),
|
||||
Round(YOrigin - YOldOrigin),
|
||||
@ -4461,7 +4571,8 @@ begin
|
||||
Exit;
|
||||
ACanvas.Brush.Color := Color;
|
||||
{ !!warning: uses Win32 only font-handle stuff!!}
|
||||
MyGraphVertFont(ACanvas); // Select Vertical Font Output.
|
||||
ACanvas.Font.Assign(FOptions.AxisTitleFont);
|
||||
// MyGraphVertFont(ACanvas); // Select Vertical Font Output.
|
||||
if Options.XStartOffset > 10 then
|
||||
begin
|
||||
{ht := MyTextHeight(StrText); }// not used (ahuser)
|
||||
@ -4884,8 +4995,8 @@ begin
|
||||
StrWidth := ACanvas.TextWidth(RsNoValuesHere);
|
||||
if StrWidth > nWidth then
|
||||
nWidth := StrWidth;
|
||||
MyColorRectangle(ACanvas, jvChartHintColorIndex, X + 3, Y + 3, X + nWidth + 3 + 5, Y + nLineH + 3);
|
||||
MyColorRectangle(ACanvas, jvChartPaperColorIndex, X, Y, X + nWidth + 5, Y + nLineH);
|
||||
MyColorRectangle(ACanvas, jvChartShadowColorIndex, X + 3, Y + 3, X + nWidth + 3, Y + nLineH + 3);
|
||||
MyColorRectangle(ACanvas, jvChartHintColorIndex, X, Y, X + nWidth, Y + nLineH);
|
||||
ACanvas.Font.Color := Self.Font.Color;
|
||||
MyLeftTextOutHint(ACanvas, X + 2, Y, RsNoValuesHere);
|
||||
FMouseLegend := True;
|
||||
@ -4903,7 +5014,7 @@ begin
|
||||
X := (Self.Width - nWidth);
|
||||
|
||||
// Draw hint box:
|
||||
MyColorRectangle(ACanvas, jvChartPaperColorIndex, X + 3, Y + 3, X + nWidth + 3, Y + nHeight + 3);
|
||||
MyColorRectangle(ACanvas, jvChartShadowColorIndex, X + 3, Y + 3, X + nWidth + 3, Y + nHeight + 3);
|
||||
MyColorRectangle(ACanvas, jvChartHintColorIndex, X, Y, X + nWidth, Y + nHeight);
|
||||
|
||||
//MyLeftTextOut( ACanvas, X + 3, Y + 3, 'Foo');
|
||||
@ -5227,7 +5338,7 @@ end;
|
||||
{ or check for metafile output! }
|
||||
{****************************************************************************}
|
||||
|
||||
|
||||
(*
|
||||
{ !!warning: uses Win32 only font-handle stuff!!}
|
||||
procedure TJvChart.MakeVerticalFont;
|
||||
begin
|
||||
@ -5270,6 +5381,7 @@ begin
|
||||
FYFont.Color := Options.AxisFont.Color;
|
||||
FYFont.Handle := FYFontHandle;
|
||||
end;
|
||||
*)
|
||||
|
||||
|
||||
procedure TJvChart.MyHeader(ACanvas: TCanvas; StrText: string);
|
||||
@ -5301,6 +5413,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
(*
|
||||
{ !!warning: uses Win32 only font-handle stuff!!}
|
||||
procedure TJvChart.MyGraphVertFont(ACanvas: TCanvas);
|
||||
begin
|
||||
@ -5313,7 +5426,7 @@ begin
|
||||
if not PrintInSession then
|
||||
Assert(ACanvas.Font.Handle = FYFontHandle);
|
||||
end;
|
||||
|
||||
*)
|
||||
|
||||
procedure TJvChart.MyHeaderFont(ACanvas: TCanvas);
|
||||
begin
|
||||
@ -5813,9 +5926,7 @@ begin
|
||||
if (Options.FGradientDirection = grNone) or (Options.PaperColor = Options.FGradientColor) then
|
||||
Exit;
|
||||
ACanvas := GetChartCanvas(false);
|
||||
VC := Options.XValueCount;
|
||||
if VC < 1 then
|
||||
VC := 1;
|
||||
VC := Max(1, Options.XValueCount);
|
||||
RawRect.Top := FOptions.YStartOffset;
|
||||
RawRect.Bottom := Trunc(YOrigin);
|
||||
RawRect.Left := Round(XOrigin);
|
||||
|
Reference in New Issue
Block a user