mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-10-31 01:04:50 +01:00 
			
		
		
		
	TAChart: Update financial demo
git-svn-id: trunk@53935 -
This commit is contained in:
		
							parent
							
								
									12987e232a
								
							
						
					
					
						commit
						5e8135f59a
					
				| @ -1,7 +1,7 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <CONFIG> | ||||
|   <ProjectOptions> | ||||
|     <Version Value="9"/> | ||||
|     <Version Value="10"/> | ||||
|     <PathDelim Value="\"/> | ||||
|     <General> | ||||
|       <SessionStorage Value="InProjectDir"/> | ||||
| @ -13,9 +13,6 @@ | ||||
|     <i18n> | ||||
|       <EnableI18N LFM="False"/> | ||||
|     </i18n> | ||||
|     <VersionInfo> | ||||
|       <StringTable ProductVersion=""/> | ||||
|     </VersionInfo> | ||||
|     <BuildModes Count="1"> | ||||
|       <Item1 Name="Default" Default="True"/> | ||||
|     </BuildModes> | ||||
| @ -46,7 +43,6 @@ | ||||
|         <ComponentName Value="MainForm"/> | ||||
|         <HasResources Value="True"/> | ||||
|         <ResourceBaseClass Value="Form"/> | ||||
|         <UnitName Value="main"/> | ||||
|       </Unit1> | ||||
|       <Unit2> | ||||
|         <Filename Value="data.txt"/> | ||||
|  | ||||
| @ -7,7 +7,7 @@ object MainForm: TMainForm | ||||
|   ClientHeight = 466 | ||||
|   ClientWidth = 891 | ||||
|   OnCreate = FormCreate | ||||
|   LCLVersion = '1.3' | ||||
|   LCLVersion = '1.7' | ||||
|   object FinancialChart: TChart | ||||
|     Left = 0 | ||||
|     Height = 382 | ||||
| @ -45,7 +45,6 @@ object MainForm: TMainForm | ||||
|     ) | ||||
|     Toolset = ChartToolset1 | ||||
|     Align = alClient | ||||
|     ParentColor = False | ||||
|     object ohlcSeries: TOpenHighLowCloseSeries | ||||
|       CandlestickDownBrush.Color = clRed | ||||
|       CandlestickLinePen.Color = clDefault | ||||
| @ -64,8 +63,20 @@ object MainForm: TMainForm | ||||
|     Width = 891 | ||||
|     Align = alBottom | ||||
|     BevelOuter = bvNone | ||||
|     Caption = 'Hold the left mouse button down to see a hint window with the stock prices above each data point.' | ||||
|     ClientHeight = 42 | ||||
|     ClientWidth = 891 | ||||
|     TabOrder = 1 | ||||
|     object Label1: TLabel | ||||
|       Left = 0 | ||||
|       Height = 42 | ||||
|       Top = 0 | ||||
|       Width = 891 | ||||
|       Align = alClient | ||||
|       Alignment = taCenter | ||||
|       Caption = 'Hold down the left mouse button to see a hint window with the open/high/low/close stock prices above each data point.'#13#10'Hold down the left mouse button - together with CTRL - to see a hint window with the clicked stock price above each data point.' | ||||
|       Layout = tlCenter | ||||
|       ParentColor = False | ||||
|     end | ||||
|   end | ||||
|   object TopPanel: TPanel | ||||
|     Left = 0 | ||||
| @ -79,10 +90,10 @@ object MainForm: TMainForm | ||||
|     TabOrder = 2 | ||||
|     object cbSeriesType: TComboBox | ||||
|       Left = 8 | ||||
|       Height = 28 | ||||
|       Height = 23 | ||||
|       Top = 8 | ||||
|       Width = 242 | ||||
|       ItemHeight = 20 | ||||
|       ItemHeight = 15 | ||||
|       ItemIndex = 0 | ||||
|       Items.Strings = ( | ||||
|         'OHLC series' | ||||
| @ -95,9 +106,9 @@ object MainForm: TMainForm | ||||
|     end | ||||
|     object cbCandleStickSameColor: TCheckBox | ||||
|       Left = 600 | ||||
|       Height = 24 | ||||
|       Height = 19 | ||||
|       Top = 10 | ||||
|       Width = 218 | ||||
|       Width = 173 | ||||
|       Caption = 'same color for tails and body' | ||||
|       Checked = True | ||||
|       OnChange = cbCandleStickSameColorChange | ||||
| @ -118,7 +129,7 @@ object MainForm: TMainForm | ||||
|     end | ||||
|     object cbDownColor: TColorBox | ||||
|       Left = 464 | ||||
|       Height = 28 | ||||
|       Height = 26 | ||||
|       Top = 8 | ||||
|       Width = 100 | ||||
|       Selected = clRed | ||||
| @ -129,18 +140,18 @@ object MainForm: TMainForm | ||||
|     end | ||||
|     object LblUp: TLabel | ||||
|       Left = 264 | ||||
|       Height = 20 | ||||
|       Height = 15 | ||||
|       Top = 12 | ||||
|       Width = 19 | ||||
|       Width = 15 | ||||
|       Caption = 'Up' | ||||
|       FocusControl = cbUpColor | ||||
|       ParentColor = False | ||||
|     end | ||||
|     object LblDown: TLabel | ||||
|       Left = 413 | ||||
|       Height = 20 | ||||
|       Height = 15 | ||||
|       Top = 12 | ||||
|       Width = 39 | ||||
|       Width = 31 | ||||
|       Caption = 'Down' | ||||
|       FocusControl = cbDownColor | ||||
|       ParentColor = False | ||||
| @ -149,11 +160,17 @@ object MainForm: TMainForm | ||||
|   object ChartToolset1: TChartToolset | ||||
|     left = 160 | ||||
|     top = 111 | ||||
|     object DataPointHintTool: TDataPointHintTool | ||||
|     object DataPointHintTool_All: TDataPointHintTool | ||||
|       Shift = [ssLeft] | ||||
|       DistanceMode = cdmOnlyX | ||||
|       GrabRadius = 8 | ||||
|       OnHint = DataPointHintToolHint | ||||
|       OnHint = DataPointHintTool_AllHint | ||||
|       OnHintLocation = DataPointHintToolHintLocation | ||||
|     end | ||||
|     object DataPointHintTool_Details: TDataPointHintTool | ||||
|       Shift = [ssCtrl, ssLeft] | ||||
|       GrabRadius = 8 | ||||
|       Targets = [nptPoint, nptXList, nptYList] | ||||
|       OnHint = DataPointHintTool_DetailsHint | ||||
|       OnHintLocation = DataPointHintToolHintLocation | ||||
|     end | ||||
|   end | ||||
|  | ||||
| @ -18,8 +18,10 @@ type | ||||
|     ChartToolset1: TChartToolset; | ||||
|     cbUpColor: TColorBox; | ||||
|     cbDownColor: TColorBox; | ||||
|     DataPointHintTool: TDataPointHintTool; | ||||
|     DataPointHintTool_Details: TDataPointHintTool; | ||||
|     DataPointHintTool_All: TDataPointHintTool; | ||||
|     FinancialChart: TChart; | ||||
|     Label1: TLabel; | ||||
|     LblDown: TLabel; | ||||
|     LblUp: TLabel; | ||||
|     ohlcSeries: TOpenHighLowCloseSeries; | ||||
| @ -28,10 +30,12 @@ type | ||||
|     procedure cbCandleStickSameColorChange(Sender: TObject); | ||||
|     procedure cbSeriesTypeChange(Sender: TObject); | ||||
|     procedure cbColorChange(Sender: TObject); | ||||
|     procedure DataPointHintToolHint(ATool: TDataPointHintTool; | ||||
|     procedure DataPointHintTool_AllHint(ATool: TDataPointHintTool; | ||||
|       const APoint: TPoint; var AHint: String); | ||||
|     procedure DataPointHintToolHintLocation(ATool: TDataPointHintTool; | ||||
|       AHintSize: TSize; var APoint: TPoint); | ||||
|     procedure DataPointHintTool_DetailsHint(ATool: TDataPointHintTool; | ||||
|       const APoint: TPoint; var AHint: String); | ||||
|     procedure FormCreate(Sender: TObject); | ||||
|   private | ||||
|     { private declarations } | ||||
| @ -127,7 +131,7 @@ end; | ||||
| 
 | ||||
| { This event handler returns the text to be displayed as a mouse-over hint. | ||||
|   We construct the text from the date, and the open, high, low, close values. } | ||||
| procedure TMainForm.DataPointHintToolHint(ATool: TDataPointHintTool; | ||||
| procedure TMainForm.DataPointHintTool_AllHint(ATool: TDataPointHintTool; | ||||
|   const APoint: TPoint; var AHint: String); | ||||
| var | ||||
|   ser: TOpenHighLowCloseSeries; | ||||
| @ -135,10 +139,38 @@ begin | ||||
|   ser := ATool.Series as TOpenHighLowCloseSeries; | ||||
|   AHint := AnsiToUTF8(Format('Date: %s'#13'  Open: %.2m'#13'  High: %.2m'#13'  Low: %.2m'#13'  Close: %.2m', [ | ||||
|     FormatDateTime('dddddd', StrToDate(ser.ListSource[ATool.PointIndex]^.Text)), | ||||
|     ser.ListSource[ATool.PointIndex]^.YList[0], | ||||
|     ser.ListSource[ATool.PointIndex]^.YList[2], | ||||
|     ser.ListSource[ATool.PointIndex]^.Y, | ||||
|     ser.ListSource[ATool.PointIndex]^.YList[1] | ||||
|     ser.ListSource[ATool.PointIndex]^.GetY(ser.YIndexOpen), | ||||
|     ser.ListSource[ATool.PointIndex]^.GetY(ser.YIndexHigh), | ||||
|     ser.ListSource[ATool.PointIndex]^.GetY(ser.YIndexHigh), | ||||
|     ser.ListSource[ATool.PointIndex]^.GetY(ser.YIndexClose) | ||||
|   ])); | ||||
| end; | ||||
| 
 | ||||
| { Similar to the method above. Displays only the date and the value clicked } | ||||
| procedure TMainForm.DataPointHintTool_DetailsHint(ATool: TDataPointHintTool; | ||||
|   const APoint: TPoint; var AHint: String); | ||||
| var | ||||
|   ser: TOpenHighLowCloseSeries; | ||||
|   x, y: Integer; | ||||
|   idx: Integer; | ||||
|   yidx: Integer; | ||||
|   ohlcName: String; | ||||
| begin | ||||
|   ser := ATool.Series as TOpenHighLowCloseSeries; | ||||
|   idx := ATool.PointIndex; | ||||
|   yidx := ATool.YIndex; | ||||
|   if yidx = ohlcSeries.YIndexClose then | ||||
|     ohlcName := 'Close' | ||||
|   else if yidx = ohlcSeries.YIndexHigh then | ||||
|     ohlcName := 'High' | ||||
|   else if yidx = ohlcSeries.YIndexLow then | ||||
|     ohlcName := 'Low' | ||||
|   else if yidx = ohlcSeries.YIndexOpen then | ||||
|     ohlcName := 'Open'; | ||||
|   AHint := AnsiToUTF8(Format('Date: %s'#13'  %s: %.2m', [ | ||||
|     FormatDateTime('dddddd', StrToDate(ser.ListSource[idx]^.Text)), | ||||
|     ohlcName, | ||||
|     ser.ListSource[idx]^.GetY(yidx) | ||||
|   ])); | ||||
| end; | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 wp
						wp