mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-11-04 07:43:13 +01:00 
			
		
		
		
	TAChart: Add errorbar demo.
git-svn-id: trunk@58612 -
This commit is contained in:
		
							parent
							
								
									eebc5bb077
								
							
						
					
					
						commit
						4eebc54703
					
				
							
								
								
									
										4
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							@ -4756,6 +4756,10 @@ components/tachart/demo/dragdrop/dragdropdemo.lpi svneol=native#text/plain
 | 
			
		||||
components/tachart/demo/dragdrop/dragdropdemo.lpr svneol=native#text/plain
 | 
			
		||||
components/tachart/demo/dragdrop/main.lfm svneol=native#text/plain
 | 
			
		||||
components/tachart/demo/dragdrop/main.pas svneol=native#text/pascal
 | 
			
		||||
components/tachart/demo/errorbars/errobarsdemo.lpi svneol=native#text/plain
 | 
			
		||||
components/tachart/demo/errorbars/errobarsdemo.lpr svneol=native#text/plain
 | 
			
		||||
components/tachart/demo/errorbars/main.lfm svneol=native#text/plain
 | 
			
		||||
components/tachart/demo/errorbars/main.pas svneol=native#text/plain
 | 
			
		||||
components/tachart/demo/events/Main.lfm svneol=native#text/plain
 | 
			
		||||
components/tachart/demo/events/Main.pas svneol=native#text/pascal
 | 
			
		||||
components/tachart/demo/events/eventsdemo.lpi svneol=native#text/plain
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										81
									
								
								components/tachart/demo/errorbars/errobarsdemo.lpi
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								components/tachart/demo/errorbars/errobarsdemo.lpi
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,81 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<CONFIG>
 | 
			
		||||
  <ProjectOptions>
 | 
			
		||||
    <Version Value="11"/>
 | 
			
		||||
    <PathDelim Value="\"/>
 | 
			
		||||
    <General>
 | 
			
		||||
      <SessionStorage Value="InProjectDir"/>
 | 
			
		||||
      <MainUnit Value="0"/>
 | 
			
		||||
      <Title Value="errobarsdemo"/>
 | 
			
		||||
      <Scaled Value="True"/>
 | 
			
		||||
      <ResourceType Value="res"/>
 | 
			
		||||
      <UseXPManifest Value="True"/>
 | 
			
		||||
      <XPManifest>
 | 
			
		||||
        <DpiAware Value="True"/>
 | 
			
		||||
      </XPManifest>
 | 
			
		||||
      <Icon Value="0"/>
 | 
			
		||||
    </General>
 | 
			
		||||
    <BuildModes Count="1">
 | 
			
		||||
      <Item1 Name="Default" Default="True"/>
 | 
			
		||||
    </BuildModes>
 | 
			
		||||
    <PublishOptions>
 | 
			
		||||
      <Version Value="2"/>
 | 
			
		||||
    </PublishOptions>
 | 
			
		||||
    <RunParams>
 | 
			
		||||
      <FormatVersion Value="2"/>
 | 
			
		||||
      <Modes Count="0"/>
 | 
			
		||||
    </RunParams>
 | 
			
		||||
    <RequiredPackages Count="2">
 | 
			
		||||
      <Item1>
 | 
			
		||||
        <PackageName Value="TAChartLazarusPkg"/>
 | 
			
		||||
      </Item1>
 | 
			
		||||
      <Item2>
 | 
			
		||||
        <PackageName Value="LCL"/>
 | 
			
		||||
      </Item2>
 | 
			
		||||
    </RequiredPackages>
 | 
			
		||||
    <Units Count="2">
 | 
			
		||||
      <Unit0>
 | 
			
		||||
        <Filename Value="errobarsdemo.lpr"/>
 | 
			
		||||
        <IsPartOfProject Value="True"/>
 | 
			
		||||
      </Unit0>
 | 
			
		||||
      <Unit1>
 | 
			
		||||
        <Filename Value="main.pas"/>
 | 
			
		||||
        <IsPartOfProject Value="True"/>
 | 
			
		||||
        <ComponentName Value="MainForm"/>
 | 
			
		||||
        <HasResources Value="True"/>
 | 
			
		||||
        <ResourceBaseClass Value="Form"/>
 | 
			
		||||
      </Unit1>
 | 
			
		||||
    </Units>
 | 
			
		||||
  </ProjectOptions>
 | 
			
		||||
  <CompilerOptions>
 | 
			
		||||
    <Version Value="11"/>
 | 
			
		||||
    <PathDelim Value="\"/>
 | 
			
		||||
    <Target>
 | 
			
		||||
      <Filename Value="errobarsdemo"/>
 | 
			
		||||
    </Target>
 | 
			
		||||
    <SearchPaths>
 | 
			
		||||
      <IncludeFiles Value="$(ProjOutDir)"/>
 | 
			
		||||
      <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
 | 
			
		||||
    </SearchPaths>
 | 
			
		||||
    <Linking>
 | 
			
		||||
      <Options>
 | 
			
		||||
        <Win32>
 | 
			
		||||
          <GraphicApplication Value="True"/>
 | 
			
		||||
        </Win32>
 | 
			
		||||
      </Options>
 | 
			
		||||
    </Linking>
 | 
			
		||||
  </CompilerOptions>
 | 
			
		||||
  <Debugging>
 | 
			
		||||
    <Exceptions Count="3">
 | 
			
		||||
      <Item1>
 | 
			
		||||
        <Name Value="EAbort"/>
 | 
			
		||||
      </Item1>
 | 
			
		||||
      <Item2>
 | 
			
		||||
        <Name Value="ECodetoolError"/>
 | 
			
		||||
      </Item2>
 | 
			
		||||
      <Item3>
 | 
			
		||||
        <Name Value="EFOpenError"/>
 | 
			
		||||
      </Item3>
 | 
			
		||||
    </Exceptions>
 | 
			
		||||
  </Debugging>
 | 
			
		||||
</CONFIG>
 | 
			
		||||
							
								
								
									
										22
									
								
								components/tachart/demo/errorbars/errobarsdemo.lpr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								components/tachart/demo/errorbars/errobarsdemo.lpr
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
			
		||||
program errobarsdemo;
 | 
			
		||||
 | 
			
		||||
{$mode objfpc}{$H+}
 | 
			
		||||
 | 
			
		||||
uses
 | 
			
		||||
  {$IFDEF UNIX}{$IFDEF UseCThreads}
 | 
			
		||||
  cthreads,
 | 
			
		||||
  {$ENDIF}{$ENDIF}
 | 
			
		||||
  Interfaces, // this includes the LCL widgetset
 | 
			
		||||
  Forms, Main
 | 
			
		||||
  { you can add units after this };
 | 
			
		||||
 | 
			
		||||
{$R *.res}
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
  RequireDerivedFormResource:=True;
 | 
			
		||||
  Application.Scaled:=True;
 | 
			
		||||
  Application.Initialize;
 | 
			
		||||
  Application.CreateForm(TMainForm, MainForm);
 | 
			
		||||
  Application.Run;
 | 
			
		||||
end.
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										585
									
								
								components/tachart/demo/errorbars/main.lfm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										585
									
								
								components/tachart/demo/errorbars/main.lfm
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,585 @@
 | 
			
		||||
object MainForm: TMainForm
 | 
			
		||||
  Left = 371
 | 
			
		||||
  Height = 601
 | 
			
		||||
  Top = 283
 | 
			
		||||
  Width = 1136
 | 
			
		||||
  Caption = 'MainForm'
 | 
			
		||||
  ClientHeight = 601
 | 
			
		||||
  ClientWidth = 1136
 | 
			
		||||
  OnCreate = FormCreate
 | 
			
		||||
  LCLVersion = '1.9.0.0'
 | 
			
		||||
  object Chart1: TChart
 | 
			
		||||
    Left = 208
 | 
			
		||||
    Height = 601
 | 
			
		||||
    Top = 0
 | 
			
		||||
    Width = 502
 | 
			
		||||
    AxisList = <    
 | 
			
		||||
      item
 | 
			
		||||
        Grid.Color = clSilver
 | 
			
		||||
        Marks.LabelBrush.Style = bsClear
 | 
			
		||||
        Minors = <>
 | 
			
		||||
        Title.LabelFont.Orientation = 900
 | 
			
		||||
        Title.LabelBrush.Style = bsClear
 | 
			
		||||
      end    
 | 
			
		||||
      item
 | 
			
		||||
        Grid.Color = clSilver
 | 
			
		||||
        Alignment = calBottom
 | 
			
		||||
        Marks.LabelBrush.Style = bsClear
 | 
			
		||||
        Minors = <>
 | 
			
		||||
        Title.LabelBrush.Style = bsClear
 | 
			
		||||
      end>
 | 
			
		||||
    BackColor = clWhite
 | 
			
		||||
    Foot.Brush.Color = clBtnFace
 | 
			
		||||
    Foot.Font.Color = clBlue
 | 
			
		||||
    Title.Brush.Color = clBtnFace
 | 
			
		||||
    Title.Font.Color = clBlue
 | 
			
		||||
    Title.Text.Strings = (
 | 
			
		||||
      'TAChart'
 | 
			
		||||
    )
 | 
			
		||||
    OnAfterPaint = Chart1AfterPaint
 | 
			
		||||
    Align = alClient
 | 
			
		||||
    object Chart1LineSeries1: TLineSeries
 | 
			
		||||
      Title = 'Line'
 | 
			
		||||
      ZPosition = 1
 | 
			
		||||
      AxisIndexX = 1
 | 
			
		||||
      AxisIndexY = 0
 | 
			
		||||
      LinePen.Color = clBlue
 | 
			
		||||
      Pointer.Brush.Color = clBlue
 | 
			
		||||
      Pointer.HorizSize = 6
 | 
			
		||||
      Pointer.Style = psCircle
 | 
			
		||||
      Pointer.VertSize = 6
 | 
			
		||||
      Pointer.Visible = True
 | 
			
		||||
      ShowPoints = True
 | 
			
		||||
      Stacked = True
 | 
			
		||||
      Source = RandomChartSource1
 | 
			
		||||
      XErrorBars.Pen.Color = clBlue
 | 
			
		||||
      XErrorBars.Visible = True
 | 
			
		||||
      YErrorBars.Pen.Color = clBlue
 | 
			
		||||
      YErrorBars.Visible = True
 | 
			
		||||
    end
 | 
			
		||||
    object Chart1BSplineSeries1: TBSplineSeries
 | 
			
		||||
      Active = False
 | 
			
		||||
      Title = 'BSpline'
 | 
			
		||||
      ZPosition = 2
 | 
			
		||||
      AxisIndexX = 1
 | 
			
		||||
      AxisIndexY = 0
 | 
			
		||||
      Source = RandomChartSource1
 | 
			
		||||
      Pen.Color = clRed
 | 
			
		||||
      Pointer.Brush.Color = clRed
 | 
			
		||||
      Pointer.HorizSize = 6
 | 
			
		||||
      Pointer.Style = psDiamond
 | 
			
		||||
      Pointer.VertSize = 6
 | 
			
		||||
      Pointer.Visible = True
 | 
			
		||||
      XErrorBars.Pen.Color = clRed
 | 
			
		||||
      XErrorBars.Visible = True
 | 
			
		||||
      YErrorBars.Pen.Color = clRed
 | 
			
		||||
      YErrorBars.Visible = True
 | 
			
		||||
    end
 | 
			
		||||
    object Chart1CubicSplineSeries1: TCubicSplineSeries
 | 
			
		||||
      Active = False
 | 
			
		||||
      Title = 'Cubic spline'
 | 
			
		||||
      ZPosition = 3
 | 
			
		||||
      AxisIndexX = 1
 | 
			
		||||
      AxisIndexY = 0
 | 
			
		||||
      Pointer.Brush.Color = clSilver
 | 
			
		||||
      Pointer.Visible = True
 | 
			
		||||
      Source = RandomChartSource1
 | 
			
		||||
      XErrorBars.Visible = True
 | 
			
		||||
      YErrorBars.Visible = True
 | 
			
		||||
    end
 | 
			
		||||
    object Chart1FitSeries1: TFitSeries
 | 
			
		||||
      Active = False
 | 
			
		||||
      Title = 'Fit'
 | 
			
		||||
      ZPosition = 4
 | 
			
		||||
      AxisIndexX = 1
 | 
			
		||||
      AxisIndexY = 0
 | 
			
		||||
      Pen.Color = clGreen
 | 
			
		||||
      Pointer.Brush.Color = clGreen
 | 
			
		||||
      Pointer.HorizSize = 3
 | 
			
		||||
      Pointer.Pen.Color = clGreen
 | 
			
		||||
      Pointer.Style = psTriangle
 | 
			
		||||
      Pointer.VertSize = 3
 | 
			
		||||
      Pointer.Visible = True
 | 
			
		||||
      Source = RandomChartSource1
 | 
			
		||||
      XErrorBars.Pen.Color = clGreen
 | 
			
		||||
      XErrorBars.Visible = True
 | 
			
		||||
      YErrorBars.Pen.Color = clGreen
 | 
			
		||||
      YErrorBars.Visible = True
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  object Panel1: TPanel
 | 
			
		||||
    Left = 0
 | 
			
		||||
    Height = 601
 | 
			
		||||
    Top = 0
 | 
			
		||||
    Width = 208
 | 
			
		||||
    Align = alLeft
 | 
			
		||||
    BevelOuter = bvNone
 | 
			
		||||
    ClientHeight = 601
 | 
			
		||||
    ClientWidth = 208
 | 
			
		||||
    TabOrder = 1
 | 
			
		||||
    object CbRotated: TCheckBox
 | 
			
		||||
      AnchorSideLeft.Control = Panel1
 | 
			
		||||
      AnchorSideTop.Side = asrBottom
 | 
			
		||||
      AnchorSideBottom.Control = Panel1
 | 
			
		||||
      AnchorSideBottom.Side = asrBottom
 | 
			
		||||
      Left = 8
 | 
			
		||||
      Height = 19
 | 
			
		||||
      Top = 574
 | 
			
		||||
      Width = 61
 | 
			
		||||
      Anchors = [akLeft, akBottom]
 | 
			
		||||
      BorderSpacing.Left = 8
 | 
			
		||||
      BorderSpacing.Top = 8
 | 
			
		||||
      BorderSpacing.Bottom = 8
 | 
			
		||||
      Caption = 'Rotated'
 | 
			
		||||
      OnChange = CbRotatedChange
 | 
			
		||||
      TabOrder = 0
 | 
			
		||||
    end
 | 
			
		||||
    object GbXErr: TGroupBox
 | 
			
		||||
      AnchorSideLeft.Control = Panel1
 | 
			
		||||
      AnchorSideTop.Control = RgChartSource
 | 
			
		||||
      AnchorSideTop.Side = asrBottom
 | 
			
		||||
      AnchorSideRight.Control = Panel1
 | 
			
		||||
      AnchorSideRight.Side = asrBottom
 | 
			
		||||
      Left = 8
 | 
			
		||||
      Height = 153
 | 
			
		||||
      Top = 109
 | 
			
		||||
      Width = 192
 | 
			
		||||
      Anchors = [akTop, akLeft, akRight]
 | 
			
		||||
      AutoSize = True
 | 
			
		||||
      BorderSpacing.Top = 8
 | 
			
		||||
      BorderSpacing.Around = 8
 | 
			
		||||
      Caption = 'x error bars'
 | 
			
		||||
      ClientHeight = 133
 | 
			
		||||
      ClientWidth = 188
 | 
			
		||||
      TabOrder = 1
 | 
			
		||||
      object RbXErrConst: TRadioButton
 | 
			
		||||
        AnchorSideLeft.Control = CbXErrShow
 | 
			
		||||
        AnchorSideTop.Control = CbXErrShow
 | 
			
		||||
        AnchorSideTop.Side = asrBottom
 | 
			
		||||
        Left = 16
 | 
			
		||||
        Height = 19
 | 
			
		||||
        Top = 33
 | 
			
		||||
        Width = 66
 | 
			
		||||
        BorderSpacing.Top = 10
 | 
			
		||||
        Caption = 'constant'
 | 
			
		||||
        Checked = True
 | 
			
		||||
        OnChange = RbXErrConstChange
 | 
			
		||||
        TabOrder = 4
 | 
			
		||||
        TabStop = True
 | 
			
		||||
      end
 | 
			
		||||
      object RbXErrPercent: TRadioButton
 | 
			
		||||
        AnchorSideLeft.Control = RbXErrConst
 | 
			
		||||
        AnchorSideTop.Control = RbXErrConst
 | 
			
		||||
        AnchorSideTop.Side = asrBottom
 | 
			
		||||
        Left = 16
 | 
			
		||||
        Height = 19
 | 
			
		||||
        Top = 56
 | 
			
		||||
        Width = 79
 | 
			
		||||
        BorderSpacing.Top = 4
 | 
			
		||||
        Caption = 'percentage'
 | 
			
		||||
        OnChange = RbXErrPercentChange
 | 
			
		||||
        TabOrder = 0
 | 
			
		||||
      end
 | 
			
		||||
      object RbXErrChartSource: TRadioButton
 | 
			
		||||
        AnchorSideLeft.Control = RbXErrConst
 | 
			
		||||
        AnchorSideTop.Control = RbXErrPercent
 | 
			
		||||
        AnchorSideTop.Side = asrBottom
 | 
			
		||||
        Left = 16
 | 
			
		||||
        Height = 19
 | 
			
		||||
        Top = 79
 | 
			
		||||
        Width = 72
 | 
			
		||||
        BorderSpacing.Top = 4
 | 
			
		||||
        Caption = 'individual'
 | 
			
		||||
        OnChange = RbXErrChartSourceChange
 | 
			
		||||
        TabOrder = 1
 | 
			
		||||
      end
 | 
			
		||||
      object EdXErrConst: TFloatSpinEdit
 | 
			
		||||
        AnchorSideLeft.Control = RbXErrPercent
 | 
			
		||||
        AnchorSideLeft.Side = asrBottom
 | 
			
		||||
        AnchorSideTop.Control = RbXErrConst
 | 
			
		||||
        AnchorSideTop.Side = asrCenter
 | 
			
		||||
        AnchorSideRight.Control = GbXErr
 | 
			
		||||
        AnchorSideRight.Side = asrBottom
 | 
			
		||||
        Left = 119
 | 
			
		||||
        Height = 23
 | 
			
		||||
        Top = 31
 | 
			
		||||
        Width = 61
 | 
			
		||||
        Alignment = taRightJustify
 | 
			
		||||
        Anchors = [akTop, akLeft, akRight]
 | 
			
		||||
        BorderSpacing.Left = 24
 | 
			
		||||
        BorderSpacing.Right = 8
 | 
			
		||||
        DecimalPlaces = 1
 | 
			
		||||
        Increment = 0.1
 | 
			
		||||
        MaxValue = 2
 | 
			
		||||
        MinValue = 0
 | 
			
		||||
        OnChange = EdXErrConstChange
 | 
			
		||||
        TabOrder = 2
 | 
			
		||||
        Value = 1
 | 
			
		||||
      end
 | 
			
		||||
      object EdXErrPercent: TFloatSpinEdit
 | 
			
		||||
        AnchorSideLeft.Control = RbXErrPercent
 | 
			
		||||
        AnchorSideLeft.Side = asrBottom
 | 
			
		||||
        AnchorSideTop.Control = RbXErrPercent
 | 
			
		||||
        AnchorSideTop.Side = asrCenter
 | 
			
		||||
        AnchorSideRight.Control = EdXErrConst
 | 
			
		||||
        AnchorSideRight.Side = asrBottom
 | 
			
		||||
        Left = 119
 | 
			
		||||
        Height = 23
 | 
			
		||||
        Top = 54
 | 
			
		||||
        Width = 61
 | 
			
		||||
        Alignment = taRightJustify
 | 
			
		||||
        Anchors = [akTop, akLeft, akRight]
 | 
			
		||||
        BorderSpacing.Left = 24
 | 
			
		||||
        DecimalPlaces = 1
 | 
			
		||||
        Increment = 2
 | 
			
		||||
        MinValue = 0
 | 
			
		||||
        OnChange = EdXErrPercentChange
 | 
			
		||||
        TabOrder = 3
 | 
			
		||||
        Value = 10
 | 
			
		||||
        Visible = False
 | 
			
		||||
      end
 | 
			
		||||
      object CbXErrShow: TCheckBox
 | 
			
		||||
        AnchorSideLeft.Control = GbXErr
 | 
			
		||||
        AnchorSideTop.Control = GbXErr
 | 
			
		||||
        Left = 16
 | 
			
		||||
        Height = 19
 | 
			
		||||
        Top = 4
 | 
			
		||||
        Width = 102
 | 
			
		||||
        BorderSpacing.Left = 16
 | 
			
		||||
        BorderSpacing.Top = 4
 | 
			
		||||
        Caption = 'Show error bars'
 | 
			
		||||
        Checked = True
 | 
			
		||||
        OnChange = CbXErrShowChange
 | 
			
		||||
        State = cbChecked
 | 
			
		||||
        TabOrder = 5
 | 
			
		||||
      end
 | 
			
		||||
      object CbXErrDifferent: TCheckBox
 | 
			
		||||
        AnchorSideLeft.Control = CbXErrShow
 | 
			
		||||
        AnchorSideTop.Control = RbXErrChartSource
 | 
			
		||||
        AnchorSideTop.Side = asrBottom
 | 
			
		||||
        Left = 16
 | 
			
		||||
        Height = 19
 | 
			
		||||
        Top = 106
 | 
			
		||||
        Width = 135
 | 
			
		||||
        BorderSpacing.Top = 8
 | 
			
		||||
        BorderSpacing.Bottom = 8
 | 
			
		||||
        Caption = 'asymmetric error bars'
 | 
			
		||||
        OnChange = CbXErrDifferentChange
 | 
			
		||||
        TabOrder = 6
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    object GbYErr: TGroupBox
 | 
			
		||||
      AnchorSideLeft.Control = Panel1
 | 
			
		||||
      AnchorSideTop.Control = GbXErr
 | 
			
		||||
      AnchorSideTop.Side = asrBottom
 | 
			
		||||
      AnchorSideRight.Control = Panel1
 | 
			
		||||
      AnchorSideRight.Side = asrBottom
 | 
			
		||||
      Left = 8
 | 
			
		||||
      Height = 153
 | 
			
		||||
      Top = 278
 | 
			
		||||
      Width = 192
 | 
			
		||||
      Anchors = [akTop, akLeft, akRight]
 | 
			
		||||
      AutoSize = True
 | 
			
		||||
      BorderSpacing.Top = 8
 | 
			
		||||
      BorderSpacing.Around = 8
 | 
			
		||||
      Caption = 'y error bars'
 | 
			
		||||
      ClientHeight = 133
 | 
			
		||||
      ClientWidth = 188
 | 
			
		||||
      TabOrder = 2
 | 
			
		||||
      object RbYErrConst: TRadioButton
 | 
			
		||||
        AnchorSideLeft.Control = CbYErrShow
 | 
			
		||||
        AnchorSideTop.Control = CbYErrShow
 | 
			
		||||
        AnchorSideTop.Side = asrBottom
 | 
			
		||||
        Left = 16
 | 
			
		||||
        Height = 19
 | 
			
		||||
        Top = 33
 | 
			
		||||
        Width = 66
 | 
			
		||||
        BorderSpacing.Top = 10
 | 
			
		||||
        Caption = 'constant'
 | 
			
		||||
        Checked = True
 | 
			
		||||
        OnChange = RbYErrConstChange
 | 
			
		||||
        TabOrder = 4
 | 
			
		||||
        TabStop = True
 | 
			
		||||
      end
 | 
			
		||||
      object RbYErrPercent: TRadioButton
 | 
			
		||||
        AnchorSideLeft.Control = CbYErrShow
 | 
			
		||||
        AnchorSideTop.Control = RbYErrConst
 | 
			
		||||
        AnchorSideTop.Side = asrBottom
 | 
			
		||||
        Left = 16
 | 
			
		||||
        Height = 19
 | 
			
		||||
        Top = 56
 | 
			
		||||
        Width = 79
 | 
			
		||||
        BorderSpacing.Top = 4
 | 
			
		||||
        Caption = 'percentage'
 | 
			
		||||
        OnChange = RbYErrPercentChange
 | 
			
		||||
        TabOrder = 0
 | 
			
		||||
      end
 | 
			
		||||
      object RbYErrChartSource: TRadioButton
 | 
			
		||||
        AnchorSideLeft.Control = CbYErrShow
 | 
			
		||||
        AnchorSideTop.Control = RbYErrPercent
 | 
			
		||||
        AnchorSideTop.Side = asrBottom
 | 
			
		||||
        Left = 16
 | 
			
		||||
        Height = 19
 | 
			
		||||
        Top = 79
 | 
			
		||||
        Width = 72
 | 
			
		||||
        BorderSpacing.Top = 4
 | 
			
		||||
        Caption = 'individual'
 | 
			
		||||
        OnChange = RbYErrChartSourceChange
 | 
			
		||||
        TabOrder = 1
 | 
			
		||||
      end
 | 
			
		||||
      object EdYErrConst: TFloatSpinEdit
 | 
			
		||||
        AnchorSideLeft.Control = RbYErrPercent
 | 
			
		||||
        AnchorSideLeft.Side = asrBottom
 | 
			
		||||
        AnchorSideTop.Control = RbYErrConst
 | 
			
		||||
        AnchorSideTop.Side = asrCenter
 | 
			
		||||
        AnchorSideRight.Control = GbYErr
 | 
			
		||||
        AnchorSideRight.Side = asrBottom
 | 
			
		||||
        Left = 119
 | 
			
		||||
        Height = 23
 | 
			
		||||
        Top = 31
 | 
			
		||||
        Width = 61
 | 
			
		||||
        Alignment = taRightJustify
 | 
			
		||||
        Anchors = [akTop, akLeft, akRight]
 | 
			
		||||
        BorderSpacing.Left = 24
 | 
			
		||||
        BorderSpacing.Right = 8
 | 
			
		||||
        DecimalPlaces = 1
 | 
			
		||||
        Increment = 0.1
 | 
			
		||||
        MaxValue = 2
 | 
			
		||||
        MinValue = 0
 | 
			
		||||
        OnChange = EdYErrConstChange
 | 
			
		||||
        TabOrder = 2
 | 
			
		||||
        Value = 1
 | 
			
		||||
      end
 | 
			
		||||
      object EdYErrPercent: TFloatSpinEdit
 | 
			
		||||
        AnchorSideLeft.Control = RbYErrPercent
 | 
			
		||||
        AnchorSideLeft.Side = asrBottom
 | 
			
		||||
        AnchorSideTop.Control = RbYErrPercent
 | 
			
		||||
        AnchorSideTop.Side = asrCenter
 | 
			
		||||
        AnchorSideRight.Control = EdYErrConst
 | 
			
		||||
        AnchorSideRight.Side = asrBottom
 | 
			
		||||
        Left = 119
 | 
			
		||||
        Height = 23
 | 
			
		||||
        Top = 54
 | 
			
		||||
        Width = 61
 | 
			
		||||
        Alignment = taRightJustify
 | 
			
		||||
        Anchors = [akTop, akLeft, akRight]
 | 
			
		||||
        BorderSpacing.Left = 24
 | 
			
		||||
        DecimalPlaces = 1
 | 
			
		||||
        Increment = 2
 | 
			
		||||
        MinValue = 0
 | 
			
		||||
        OnChange = EdYErrPercentChange
 | 
			
		||||
        TabOrder = 3
 | 
			
		||||
        Value = 10
 | 
			
		||||
        Visible = False
 | 
			
		||||
      end
 | 
			
		||||
      object CbYErrShow: TCheckBox
 | 
			
		||||
        AnchorSideLeft.Control = GbYErr
 | 
			
		||||
        AnchorSideTop.Control = GbYErr
 | 
			
		||||
        Left = 16
 | 
			
		||||
        Height = 19
 | 
			
		||||
        Top = 4
 | 
			
		||||
        Width = 102
 | 
			
		||||
        BorderSpacing.Left = 16
 | 
			
		||||
        BorderSpacing.Top = 4
 | 
			
		||||
        Caption = 'Show error bars'
 | 
			
		||||
        Checked = True
 | 
			
		||||
        OnChange = CbYErrShowChange
 | 
			
		||||
        State = cbChecked
 | 
			
		||||
        TabOrder = 5
 | 
			
		||||
      end
 | 
			
		||||
      object CbYErrDifferent: TCheckBox
 | 
			
		||||
        AnchorSideLeft.Control = CbYErrShow
 | 
			
		||||
        AnchorSideTop.Control = RbYErrChartSource
 | 
			
		||||
        AnchorSideTop.Side = asrBottom
 | 
			
		||||
        Left = 16
 | 
			
		||||
        Height = 19
 | 
			
		||||
        Top = 106
 | 
			
		||||
        Width = 135
 | 
			
		||||
        BorderSpacing.Top = 8
 | 
			
		||||
        BorderSpacing.Bottom = 8
 | 
			
		||||
        Caption = 'asymmetric error bars'
 | 
			
		||||
        OnChange = CbYErrDifferentChange
 | 
			
		||||
        TabOrder = 6
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    object RgChartSource: TRadioGroup
 | 
			
		||||
      AnchorSideLeft.Control = Panel1
 | 
			
		||||
      AnchorSideTop.Control = Panel1
 | 
			
		||||
      Left = 8
 | 
			
		||||
      Height = 85
 | 
			
		||||
      Top = 8
 | 
			
		||||
      Width = 185
 | 
			
		||||
      AutoFill = True
 | 
			
		||||
      AutoSize = True
 | 
			
		||||
      BorderSpacing.Around = 8
 | 
			
		||||
      Caption = 'Chart source'
 | 
			
		||||
      ChildSizing.LeftRightSpacing = 16
 | 
			
		||||
      ChildSizing.VerticalSpacing = 4
 | 
			
		||||
      ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
 | 
			
		||||
      ChildSizing.EnlargeVertical = crsHomogenousChildResize
 | 
			
		||||
      ChildSizing.ShrinkHorizontal = crsScaleChilds
 | 
			
		||||
      ChildSizing.ShrinkVertical = crsScaleChilds
 | 
			
		||||
      ChildSizing.Layout = cclLeftToRightThenTopToBottom
 | 
			
		||||
      ChildSizing.ControlsPerLine = 1
 | 
			
		||||
      ClientHeight = 65
 | 
			
		||||
      ClientWidth = 181
 | 
			
		||||
      ItemIndex = 0
 | 
			
		||||
      Items.Strings = (
 | 
			
		||||
        'RandomChartSource'
 | 
			
		||||
        'ListChartSource'
 | 
			
		||||
        'UserDefinedChartSource'
 | 
			
		||||
      )
 | 
			
		||||
      OnClick = RgChartSourceClick
 | 
			
		||||
      TabOrder = 3
 | 
			
		||||
    end
 | 
			
		||||
    object GbErrorBarStyle: TGroupBox
 | 
			
		||||
      AnchorSideLeft.Control = GbYErr
 | 
			
		||||
      AnchorSideTop.Control = GbYErr
 | 
			
		||||
      AnchorSideTop.Side = asrBottom
 | 
			
		||||
      AnchorSideRight.Control = GbYErr
 | 
			
		||||
      AnchorSideRight.Side = asrBottom
 | 
			
		||||
      Left = 16
 | 
			
		||||
      Height = 78
 | 
			
		||||
      Top = 447
 | 
			
		||||
      Width = 176
 | 
			
		||||
      Anchors = [akTop, akLeft, akRight]
 | 
			
		||||
      AutoSize = True
 | 
			
		||||
      BorderSpacing.Top = 8
 | 
			
		||||
      BorderSpacing.Bottom = 8
 | 
			
		||||
      BorderSpacing.Around = 8
 | 
			
		||||
      Caption = 'Error bar style'
 | 
			
		||||
      ClientHeight = 58
 | 
			
		||||
      ClientWidth = 172
 | 
			
		||||
      TabOrder = 4
 | 
			
		||||
      object EdErrPenWidth: TSpinEdit
 | 
			
		||||
        AnchorSideLeft.Side = asrBottom
 | 
			
		||||
        AnchorSideTop.Control = GbErrorBarStyle
 | 
			
		||||
        AnchorSideRight.Control = GbErrorBarStyle
 | 
			
		||||
        AnchorSideRight.Side = asrBottom
 | 
			
		||||
        Left = 103
 | 
			
		||||
        Height = 23
 | 
			
		||||
        Top = 4
 | 
			
		||||
        Width = 61
 | 
			
		||||
        Alignment = taRightJustify
 | 
			
		||||
        Anchors = [akTop, akRight]
 | 
			
		||||
        BorderSpacing.Left = 24
 | 
			
		||||
        BorderSpacing.Top = 4
 | 
			
		||||
        BorderSpacing.Right = 8
 | 
			
		||||
        MaxValue = 5
 | 
			
		||||
        MinValue = 1
 | 
			
		||||
        OnChange = EdErrPenWidthChange
 | 
			
		||||
        TabOrder = 0
 | 
			
		||||
        Value = 1
 | 
			
		||||
      end
 | 
			
		||||
      object LblErrLineWidth: TLabel
 | 
			
		||||
        AnchorSideLeft.Control = GbErrorBarStyle
 | 
			
		||||
        AnchorSideTop.Control = EdErrPenWidth
 | 
			
		||||
        AnchorSideTop.Side = asrCenter
 | 
			
		||||
        Left = 16
 | 
			
		||||
        Height = 15
 | 
			
		||||
        Top = 8
 | 
			
		||||
        Width = 56
 | 
			
		||||
        BorderSpacing.Left = 16
 | 
			
		||||
        BorderSpacing.Top = 12
 | 
			
		||||
        Caption = 'Pen width:'
 | 
			
		||||
        ParentColor = False
 | 
			
		||||
      end
 | 
			
		||||
      object Label1: TLabel
 | 
			
		||||
        AnchorSideLeft.Control = LblErrLineWidth
 | 
			
		||||
        AnchorSideTop.Control = CbErrPenStyle
 | 
			
		||||
        AnchorSideTop.Side = asrCenter
 | 
			
		||||
        Left = 16
 | 
			
		||||
        Height = 15
 | 
			
		||||
        Top = 32
 | 
			
		||||
        Width = 50
 | 
			
		||||
        Caption = 'Pen style:'
 | 
			
		||||
        ParentColor = False
 | 
			
		||||
      end
 | 
			
		||||
      object CbErrPenStyle: TChartComboBox
 | 
			
		||||
        AnchorSideLeft.Control = EdErrPenWidth
 | 
			
		||||
        AnchorSideTop.Control = EdErrPenWidth
 | 
			
		||||
        AnchorSideTop.Side = asrBottom
 | 
			
		||||
        AnchorSideRight.Control = EdErrPenWidth
 | 
			
		||||
        AnchorSideRight.Side = asrBottom
 | 
			
		||||
        Left = 103
 | 
			
		||||
        Height = 22
 | 
			
		||||
        Top = 28
 | 
			
		||||
        Width = 61
 | 
			
		||||
        Options = [ccoPatternBrush, ccoPatternPen]
 | 
			
		||||
        PenPattern = '1|1'
 | 
			
		||||
        PointerStyle = psNone
 | 
			
		||||
        BorderSpacing.Top = 1
 | 
			
		||||
        BorderSpacing.Bottom = 8
 | 
			
		||||
        ItemHeight = 16
 | 
			
		||||
        ItemIndex = 0
 | 
			
		||||
        TabOrder = 1
 | 
			
		||||
        OnChange = CbErrPenStyleChange
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  object ChartListbox1: TChartListbox
 | 
			
		||||
    Left = 710
 | 
			
		||||
    Height = 593
 | 
			
		||||
    Top = 4
 | 
			
		||||
    Width = 140
 | 
			
		||||
    Chart = Chart1
 | 
			
		||||
    CheckStyle = cbsRadiobutton
 | 
			
		||||
    Align = alRight
 | 
			
		||||
    BorderSpacing.Top = 4
 | 
			
		||||
    BorderSpacing.Right = 4
 | 
			
		||||
    BorderSpacing.Bottom = 4
 | 
			
		||||
    ItemHeight = 0
 | 
			
		||||
    TabOrder = 2
 | 
			
		||||
  end
 | 
			
		||||
  object StringGrid1: TStringGrid
 | 
			
		||||
    Left = 854
 | 
			
		||||
    Height = 593
 | 
			
		||||
    Top = 4
 | 
			
		||||
    Width = 278
 | 
			
		||||
    Align = alRight
 | 
			
		||||
    BorderSpacing.Around = 4
 | 
			
		||||
    ColCount = 4
 | 
			
		||||
    DefaultColWidth = 68
 | 
			
		||||
    FixedCols = 0
 | 
			
		||||
    TabOrder = 3
 | 
			
		||||
    OnPrepareCanvas = StringGrid1PrepareCanvas
 | 
			
		||||
    Cells = (
 | 
			
		||||
      4
 | 
			
		||||
      0
 | 
			
		||||
      0
 | 
			
		||||
      'x'
 | 
			
		||||
      1
 | 
			
		||||
      0
 | 
			
		||||
      'y'
 | 
			
		||||
      2
 | 
			
		||||
      0
 | 
			
		||||
      'dx'
 | 
			
		||||
      3
 | 
			
		||||
      0
 | 
			
		||||
      'dy'
 | 
			
		||||
    )
 | 
			
		||||
  end
 | 
			
		||||
  object RandomChartSource1: TRandomChartSource
 | 
			
		||||
    PointsNumber = 10
 | 
			
		||||
    RandSeed = 56490104
 | 
			
		||||
    XMax = 10
 | 
			
		||||
    XMin = 0
 | 
			
		||||
    YMax = 10
 | 
			
		||||
    YMin = 0
 | 
			
		||||
    XErrorBarData.Kind = ebkConst
 | 
			
		||||
    XErrorBarData.ValuePlus = 1
 | 
			
		||||
    YErrorBarData.Kind = ebkConst
 | 
			
		||||
    YErrorBarData.ValuePlus = 1
 | 
			
		||||
    left = 353
 | 
			
		||||
    top = 136
 | 
			
		||||
  end
 | 
			
		||||
  object ListChartSource1: TListChartSource
 | 
			
		||||
    left = 353
 | 
			
		||||
    top = 204
 | 
			
		||||
  end
 | 
			
		||||
  object UserDefinedChartSource1: TUserDefinedChartSource
 | 
			
		||||
    OnGetChartDataItem = UserDefinedChartSource1GetChartDataItem
 | 
			
		||||
    left = 353
 | 
			
		||||
    top = 280
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										522
									
								
								components/tachart/demo/errorbars/main.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										522
									
								
								components/tachart/demo/errorbars/main.pas
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,522 @@
 | 
			
		||||
unit main;
 | 
			
		||||
 | 
			
		||||
{$mode objfpc}{$H+}
 | 
			
		||||
 | 
			
		||||
interface
 | 
			
		||||
 | 
			
		||||
uses
 | 
			
		||||
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
 | 
			
		||||
  Spin, ValEdit, Grids, TAGraph, TASources, TASeries, TAChartListbox,
 | 
			
		||||
  TAFuncSeries, TADrawUtils, TAChartCombos, TACustomSource;
 | 
			
		||||
 | 
			
		||||
type
 | 
			
		||||
 | 
			
		||||
  { TMainForm }
 | 
			
		||||
 | 
			
		||||
  TMainForm = class(TForm)
 | 
			
		||||
    CbYErrDifferent: TCheckBox;
 | 
			
		||||
    CbYErrShow: TCheckBox;
 | 
			
		||||
    Chart1: TChart;
 | 
			
		||||
    Chart1BSplineSeries1: TBSplineSeries;
 | 
			
		||||
    Chart1CubicSplineSeries1: TCubicSplineSeries;
 | 
			
		||||
    Chart1FitSeries1: TFitSeries;
 | 
			
		||||
    Chart1LineSeries1: TLineSeries;
 | 
			
		||||
    CbRotated: TCheckBox;
 | 
			
		||||
    CbErrPenStyle: TChartComboBox;
 | 
			
		||||
    ChartListbox1: TChartListbox;
 | 
			
		||||
    CbXErrShow: TCheckBox;
 | 
			
		||||
    CbXErrDifferent: TCheckBox;
 | 
			
		||||
    EdXErrConst: TFloatSpinEdit;
 | 
			
		||||
    EdYErrConst: TFloatSpinEdit;
 | 
			
		||||
    EdXErrPercent: TFloatSpinEdit;
 | 
			
		||||
    EdYErrPercent: TFloatSpinEdit;
 | 
			
		||||
    GbXErr: TGroupBox;
 | 
			
		||||
    GbYErr: TGroupBox;
 | 
			
		||||
    GbErrorBarStyle: TGroupBox;
 | 
			
		||||
    Label1: TLabel;
 | 
			
		||||
    LblErrLineWidth: TLabel;
 | 
			
		||||
    ListChartSource1: TListChartSource;
 | 
			
		||||
    Panel1: TPanel;
 | 
			
		||||
    RgChartSource: TRadioGroup;
 | 
			
		||||
    RbYErrChartSource: TRadioButton;
 | 
			
		||||
    RbXErrConst: TRadioButton;
 | 
			
		||||
    RbYErrConst: TRadioButton;
 | 
			
		||||
    RbXErrPercent: TRadioButton;
 | 
			
		||||
    RbXErrChartSource: TRadioButton;
 | 
			
		||||
    RandomChartSource1: TRandomChartSource;
 | 
			
		||||
    RbYErrPercent: TRadioButton;
 | 
			
		||||
    EdErrPenWidth: TSpinEdit;
 | 
			
		||||
    StringGrid1: TStringGrid;
 | 
			
		||||
    UserDefinedChartSource1: TUserDefinedChartSource;
 | 
			
		||||
 | 
			
		||||
    procedure CbErrPenStyleChange(Sender: TObject);
 | 
			
		||||
    procedure CbRotatedChange(Sender: TObject);
 | 
			
		||||
 | 
			
		||||
    procedure CbXErrShowChange(Sender: TObject);
 | 
			
		||||
    procedure CbYErrShowChange(Sender: TObject);
 | 
			
		||||
 | 
			
		||||
    procedure CbXErrDifferentChange(Sender: TObject);
 | 
			
		||||
    procedure CbYErrDifferentChange(Sender: TObject);
 | 
			
		||||
 | 
			
		||||
    procedure Chart1AfterPaint(ASender: TChart);
 | 
			
		||||
 | 
			
		||||
    procedure EdErrPenWidthChange(Sender: TObject);
 | 
			
		||||
 | 
			
		||||
    procedure EdXErrConstChange(Sender: TObject);
 | 
			
		||||
    procedure EdYErrConstChange(Sender: TObject);
 | 
			
		||||
 | 
			
		||||
    procedure EdXErrPercentChange(Sender: TObject);
 | 
			
		||||
    procedure EdYErrPercentChange(Sender: TObject);
 | 
			
		||||
 | 
			
		||||
    procedure FormCreate(Sender: TObject);
 | 
			
		||||
 | 
			
		||||
    procedure RbXErrConstChange(Sender: TObject);
 | 
			
		||||
    procedure RbYErrConstChange(Sender: TObject);
 | 
			
		||||
 | 
			
		||||
    procedure RbXErrPercentChange(Sender: TObject);
 | 
			
		||||
    procedure RbYErrPercentChange(Sender: TObject);
 | 
			
		||||
 | 
			
		||||
    procedure RbXErrChartSourceChange(Sender: TObject);
 | 
			
		||||
    procedure RbYErrChartSourceChange(Sender: TObject);
 | 
			
		||||
 | 
			
		||||
    procedure RgChartSourceClick(Sender: TObject);
 | 
			
		||||
 | 
			
		||||
    procedure StringGrid1PrepareCanvas(sender: TObject; aCol, aRow: Integer;
 | 
			
		||||
      aState: TGridDrawState);
 | 
			
		||||
 | 
			
		||||
    procedure UserDefinedChartSource1GetChartDataItem(
 | 
			
		||||
      ASource: TUserDefinedChartSource; AIndex: Integer; var AItem: TChartDataItem);
 | 
			
		||||
 | 
			
		||||
  private
 | 
			
		||||
    procedure PopulateListSource;
 | 
			
		||||
    procedure PopulateUserData;
 | 
			
		||||
    procedure SetXErrorBarParams;
 | 
			
		||||
    procedure SetYErrorBarParams;
 | 
			
		||||
 | 
			
		||||
  public
 | 
			
		||||
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
var
 | 
			
		||||
  MainForm: TMainForm;
 | 
			
		||||
 | 
			
		||||
implementation
 | 
			
		||||
 | 
			
		||||
{$R *.lfm}
 | 
			
		||||
 | 
			
		||||
uses
 | 
			
		||||
  Math;
 | 
			
		||||
 | 
			
		||||
type
 | 
			
		||||
  TDataRec = record
 | 
			
		||||
    x, y, dxp, dxn, dyp, dyn: Double;
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
var
 | 
			
		||||
  Data: array of TDataRec;
 | 
			
		||||
 | 
			
		||||
type
 | 
			
		||||
  TMySource = class(TCustomChartSource)
 | 
			
		||||
  public
 | 
			
		||||
    property XErrorBarData;
 | 
			
		||||
    property YErrorBarData;
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
{ TMainForm }
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.CbRotatedChange(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  if CbRotated.Checked then begin
 | 
			
		||||
    Chart1LineSeries1.AxisIndexX := 0;
 | 
			
		||||
    Chart1LineSeries1.AxisIndexY := 1;
 | 
			
		||||
  end else begin
 | 
			
		||||
    Chart1LineSeries1.AxisIndexX := 1;
 | 
			
		||||
    Chart1LineSeries1.AxisIndexY := 0;
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  Chart1BSplineSeries1.AxisIndexX := Chart1lineSeries1.AxisIndexX;
 | 
			
		||||
  Chart1BSplineSeries1.AxisIndexY := Chart1LineSeries1.AxisIndexY;
 | 
			
		||||
 | 
			
		||||
  Chart1CubicSplineSeries1.AxisIndexX := Chart1lineSeries1.AxisIndexX;
 | 
			
		||||
  Chart1CubicSplineSeries1.AxisIndexY := Chart1LineSeries1.AxisIndexY;
 | 
			
		||||
 | 
			
		||||
  Chart1FitSeries1.AxisIndexX := Chart1lineSeries1.AxisIndexX;
 | 
			
		||||
  Chart1FitSeries1.AxisIndexY := Chart1LineSeries1.AxisIndexY;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.CbXErrShowChange(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  Chart1LineSeries1.XErrorBars.Visible := CbXErrShow.Checked;
 | 
			
		||||
  Chart1BSplineSeries1.XErrorBars.Visible := CbXErrShow.Checked;
 | 
			
		||||
  Chart1CubicSplineSeries1.XErrorBars.Visible := CbXErrShow.Checked;
 | 
			
		||||
  Chart1FitSeries1.XErrorBars.Visible := CbXErrShow.Checked;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.CbXErrDifferentChange(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  SetXErrorBarParams;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.CbYErrDifferentChange(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  SetYErrorBarParams;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.CbYErrShowChange(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  Chart1LineSeries1.YErrorBars.Visible := CbYErrShow.Checked;
 | 
			
		||||
  Chart1BSplineSeries1.YErrorBars.Visible := CbYErrShow.Checked;
 | 
			
		||||
  Chart1CubicSplineSeries1.YErrorBars.Visible := CbYErrShow.Checked;
 | 
			
		||||
  Chart1FitSeries1.YErrorBars.Visible := CbYErrShow.Checked;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.Chart1AfterPaint(ASender: TChart);
 | 
			
		||||
const
 | 
			
		||||
  EPS = 1E-9;
 | 
			
		||||
var
 | 
			
		||||
  i: Integer;
 | 
			
		||||
  src: TCustomChartSource;
 | 
			
		||||
  x, y, dxp, dxn, dyp, dyn: Double;
 | 
			
		||||
  fx, fy: Double;
 | 
			
		||||
  sp, sn: String;
 | 
			
		||||
begin
 | 
			
		||||
  src := Chart1LineSeries1.Source;
 | 
			
		||||
  StringGrid1.RowCount := src.Count + 1;
 | 
			
		||||
  fx := EdXErrPercent.Value * 0.01;
 | 
			
		||||
  fy := EdYErrPercent.Value * 0.01;
 | 
			
		||||
  for i:=1 to StringGrid1.RowCount-1 do begin
 | 
			
		||||
    x := src.Item[i-1]^.X;
 | 
			
		||||
    y := src.Item[i-1]^.Y;
 | 
			
		||||
    src.GetXErrorBarValues(i-1, dxp, dxn);
 | 
			
		||||
    src.GetYErrorBarValues(i-1, dyp, dyn);
 | 
			
		||||
    StringGrid1.Cells[0, i] := Format('%.3f', [x]);
 | 
			
		||||
    StringGrid1.Cells[1, i] := Format('%.3f', [y]);
 | 
			
		||||
    if (dxp = 0) and (dxn = 0) then
 | 
			
		||||
      StringGrid1.Cells[2, i] := ''
 | 
			
		||||
    else if SameValue(dxp, dxn, EPS) then
 | 
			
		||||
      StringGrid1.Cells[2, i] := Format('±%.3f', [dxp])
 | 
			
		||||
    else
 | 
			
		||||
      StringGrid1.Cells[2, i] := Format('+%.2f/-%.2f', [dxp, dxn]);
 | 
			
		||||
    if (dyp = 0) and (dyn = 0) then
 | 
			
		||||
      StringGrid1.Cells[3, i] := ''
 | 
			
		||||
    else if SameValue(dyp, dyn, EPS) then
 | 
			
		||||
      StringGrid1.Cells[3, i] := Format('±%.3f', [dyp])
 | 
			
		||||
    else
 | 
			
		||||
      StringGrid1.Cells[3, i] := Format('+%.2f/-%.2f', [dyp, dyn]);
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.CbErrPenStyleChange(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  Chart1LineSeries1.XErrorBars.Pen.Style := CbErrPenStyle.PenStyle;
 | 
			
		||||
  Chart1BSplineSeries1.XErrorBars.Pen.Style := CbErrPenStyle.PenStyle;
 | 
			
		||||
  Chart1CubicSplineSeries1.XErrorBars.Pen.Style := CbErrPenStyle.PenStyle;
 | 
			
		||||
  Chart1FitSeries1.XErrorBars.Pen.Style := CbErrPenStyle.PenStyle;
 | 
			
		||||
 | 
			
		||||
  Chart1LineSeries1.YErrorBars.Pen.Style := CbErrPenStyle.PenStyle;
 | 
			
		||||
  Chart1BSplineSeries1.YErrorBars.Pen.Style := CbErrPenStyle.PenStyle;
 | 
			
		||||
  Chart1CubicSplineSeries1.YErrorBars.Pen.Style := CbErrPenStyle.PenStyle;
 | 
			
		||||
  Chart1FitSeries1.YErrorBars.Pen.Style := CbErrPenStyle.PenStyle;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.EdXErrConstChange(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  SetXErrorBarParams;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.EdErrPenWidthChange(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  Chart1LineSeries1.XErrorBars.Pen.Width := EdErrPenWidth.Value;
 | 
			
		||||
  Chart1BSplineSeries1.XErrorBars.Pen.Width := EdErrPenWidth.Value;
 | 
			
		||||
  Chart1CubicSplineSeries1.XErrorBars.Pen.Width := EdErrPenWidth.Value;
 | 
			
		||||
  Chart1FitSeries1.XErrorBars.Pen.Width := EdErrPenWidth.Value;
 | 
			
		||||
 | 
			
		||||
  Chart1LineSeries1.YErrorBars.Pen.Width := EdErrPenWidth.Value;
 | 
			
		||||
  Chart1BSplineSeries1.YErrorBars.Pen.Width := EdErrPenWidth.Value;
 | 
			
		||||
  Chart1CubicSplineSeries1.YErrorBars.Pen.Width := EdErrPenWidth.Value;
 | 
			
		||||
  Chart1FitSeries1.YErrorBars.Pen.Width := EdErrPenWidth.Value;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.StringGrid1PrepareCanvas(sender: TObject; aCol, aRow: Integer;
 | 
			
		||||
  aState: TGridDrawState);
 | 
			
		||||
var
 | 
			
		||||
  ts: TTextStyle;
 | 
			
		||||
begin
 | 
			
		||||
  ts := StringGrid1.Canvas.TextStyle;
 | 
			
		||||
  ts.Alignment := taCenter;
 | 
			
		||||
  StringGrid1.Canvas.TextStyle := ts;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.UserDefinedChartSource1GetChartDataItem(
 | 
			
		||||
  ASource: TUserDefinedChartSource; AIndex: Integer; var AItem: TChartDataItem);
 | 
			
		||||
begin
 | 
			
		||||
  AItem.X := Data[AIndex].X;
 | 
			
		||||
  AItem.Y := Data[AIndex].Y;
 | 
			
		||||
  if ASource.XCount > 1 then
 | 
			
		||||
    AItem.XList[0] := Data[AIndex].dxp;
 | 
			
		||||
  if ASource.XCount > 2 then
 | 
			
		||||
    AItem.XList[1] := Data[AIndex].dxn;
 | 
			
		||||
  if ASource.YCount > 1 then
 | 
			
		||||
    AItem.YList[0] := Data[AIndex].dyp;
 | 
			
		||||
  if ASource.YCount > 2 then
 | 
			
		||||
    AItem.YList[1] := Data[AIndex].dyn;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.EdXErrPercentChange(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  SetXErrorBarParams;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.EdYErrConstChange(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  SetYErrorBarParams;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.EdYErrPercentChange(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  SetYErrorBarParams;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.FormCreate(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  PopulateUserData;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.PopulateListSource;
 | 
			
		||||
const
 | 
			
		||||
  N = 10;
 | 
			
		||||
  XMIN = 0;
 | 
			
		||||
  XMAX = 10;
 | 
			
		||||
var
 | 
			
		||||
  i: Integer;
 | 
			
		||||
  x, y: Double;
 | 
			
		||||
  idx: Integer;
 | 
			
		||||
  fx, fy: Double;
 | 
			
		||||
begin
 | 
			
		||||
  RandSeed := 1;
 | 
			
		||||
  fx := EdXErrPercent.Value * 0.01 * (XMAX - XMIN);
 | 
			
		||||
  fy := EdYErrPercent.Value * 0.01 * (XMAX - XMIN);
 | 
			
		||||
 | 
			
		||||
  ListChartSource1.Clear;
 | 
			
		||||
//  ListChartSource1.XCount := IfThen(CbXErrShow.Checked and RbXErrChartSource.Checked, 2, 1);
 | 
			
		||||
//  ListChartSource1.YCount := IfThen(CbYErrShow.Checked and RbYErrChartSource.Checked, 2, 1);
 | 
			
		||||
  ListChartSource1.BeginUpdate;
 | 
			
		||||
  try
 | 
			
		||||
    for i:=0 to N-1 do begin
 | 
			
		||||
      x := XMIN + (XMAX - XMIN) * i / (N-1);
 | 
			
		||||
      y := sqr(x - 5) / 2.5 + (random*2 - 1) * 0.5;
 | 
			
		||||
      idx := ListChartSource1.Add(x, y);
 | 
			
		||||
      if ListChartSource1.XCount > 1 then
 | 
			
		||||
        ListChartSource1.Item[idx]^.SetX(1, random * fx);
 | 
			
		||||
      if ListChartSource1.XCount > 2 then
 | 
			
		||||
        ListChartSource1.Item[idx]^.SetX(2, random * fx);
 | 
			
		||||
      if ListChartSource1.YCount > 1 then
 | 
			
		||||
        ListChartSource1.Item[idx]^.SetY(1, random * fy);
 | 
			
		||||
      if ListChartSource1.YCount > 2 then
 | 
			
		||||
        ListChartSource1.Item[idx]^.SetY(2, random * fy);
 | 
			
		||||
    end;
 | 
			
		||||
  finally
 | 
			
		||||
    ListChartSource1.EndUpdate;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.PopulateUserData;
 | 
			
		||||
const
 | 
			
		||||
  N = 10;
 | 
			
		||||
  XMIN = 0;
 | 
			
		||||
  XMAX = 10;
 | 
			
		||||
var
 | 
			
		||||
  i: Integer;
 | 
			
		||||
  x, y: Double;
 | 
			
		||||
  fx, fy: Double;
 | 
			
		||||
begin
 | 
			
		||||
  RandSeed := 2;
 | 
			
		||||
  fx := EdXErrConst.Value;
 | 
			
		||||
  fy := EdYErrConst.Value;
 | 
			
		||||
 | 
			
		||||
  SetLength(Data, N);
 | 
			
		||||
  for i := 0 to N - 1 do begin
 | 
			
		||||
    x := XMIN + (XMAX - XMIN) * i / (N-1);
 | 
			
		||||
    y := 10 - sqr(x - 5) / 2.5 + (random*2 - 1) * 0.5;
 | 
			
		||||
    Data[i].x := x;
 | 
			
		||||
    Data[i].y := y;
 | 
			
		||||
    Data[i].dxp := random*fx;
 | 
			
		||||
    Data[i].dxn := 0.5 * Data[i].dxp;
 | 
			
		||||
    Data[i].dyp := random * fy;
 | 
			
		||||
    Data[i].dyn := 0.5 * Data[i].dyp;
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  UserDefinedChartSource1.PointsNumber := N;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.RgChartSourceClick(Sender: TObject);
 | 
			
		||||
var
 | 
			
		||||
  src: TCustomChartSource;
 | 
			
		||||
begin
 | 
			
		||||
  case RgChartSource.ItemIndex of
 | 
			
		||||
    0: begin
 | 
			
		||||
         Chart1LineSeries1.Source := RandomChartSource1;
 | 
			
		||||
         Chart1BSplineSeries1.Source := RandomChartSource1;
 | 
			
		||||
         Chart1CubicSplineSeries1.Source := RandomChartSource1;
 | 
			
		||||
         Chart1FitSeries1.Source := RandomChartSource1;
 | 
			
		||||
       end;
 | 
			
		||||
    1: begin
 | 
			
		||||
         Chart1LineSeries1.Source := ListChartSource1;
 | 
			
		||||
         Chart1BSplineSeries1.Source := ListChartSource1;
 | 
			
		||||
         Chart1CubicSplineSeries1.Source := ListChartSource1;
 | 
			
		||||
         Chart1FitSeries1.Source := ListChartSource1;
 | 
			
		||||
       end;
 | 
			
		||||
    2: begin
 | 
			
		||||
         Chart1LineSeries1.Source := UserDefinedChartSource1;
 | 
			
		||||
         Chart1BSplineSeries1.Source := UserDefinedChartSource1;
 | 
			
		||||
         Chart1CubicSplineSeries1.Source := UserDefinedChartSource1;
 | 
			
		||||
         Chart1FitSeries1.Source := UserDefinedChartSource1;
 | 
			
		||||
       end;
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  SetXErrorBarParams;
 | 
			
		||||
  SetYErrorBarParams;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.RbXErrConstChange(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  EdXErrConst.Show;
 | 
			
		||||
  EdXErrPercent.Hide;
 | 
			
		||||
  SetXErrorBarParams;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.RbYErrConstChange(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  EdYErrConst.Show;
 | 
			
		||||
  EdYErrPercent.Hide;
 | 
			
		||||
  SetYErrorBarParams;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.RbXErrPercentChange(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  EdXErrConst.Hide;
 | 
			
		||||
  EdXErrPercent.Show;
 | 
			
		||||
  SetXErrorBarParams;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.RbYErrPercentChange(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  EdYErrConst.Hide;
 | 
			
		||||
  EdYErrPercent.Show;
 | 
			
		||||
  SetYErrorBarParams;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.RbXErrChartSourceChange(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  EdXErrConst.Hide;
 | 
			
		||||
  EdXErrPercent.Hide;
 | 
			
		||||
  SetXErrorBarParams;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.RbYErrChartSourceChange(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  EdYErrConst.Hide;
 | 
			
		||||
  EdYErrPercent.Hide;
 | 
			
		||||
  SetYErrorBarParams;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.SetXErrorBarParams;
 | 
			
		||||
begin
 | 
			
		||||
  if RbXErrConst.Checked then
 | 
			
		||||
    with RandomChartSource1 do begin
 | 
			
		||||
      XErrorBarData.Kind := ebkConst;
 | 
			
		||||
      XErrorBarData.ValuePlus := EdXErrConst.Value;
 | 
			
		||||
      if CbXErrDifferent.Checked then
 | 
			
		||||
        XErrorBarData.ValueMinus := 0.5 * XErrorBarData.ValuePlus
 | 
			
		||||
      else
 | 
			
		||||
        XErrorBarData.ValueMinus := -1;
 | 
			
		||||
      XCount := 1;
 | 
			
		||||
    end
 | 
			
		||||
  else if RbXErrPercent.Checked then
 | 
			
		||||
    with RandomChartSource1 do begin
 | 
			
		||||
      XErrorBarData.Kind := ebkPercent;
 | 
			
		||||
      XErrorBarData.ValuePlus := EdXErrPercent.Value;
 | 
			
		||||
      if CbXErrDifferent.Checked then
 | 
			
		||||
        XErrorBarData.ValueMinus := 0.5 * XErrorBarData.ValuePlus
 | 
			
		||||
      else
 | 
			
		||||
        XErrorBarData.ValueMinus := -1;
 | 
			
		||||
      XCount := 1;
 | 
			
		||||
    end
 | 
			
		||||
  else if RbXErrChartSource.Checked then
 | 
			
		||||
    with RandomChartSource1 do begin
 | 
			
		||||
      XErrorBarData.Kind := ebkChartSource;
 | 
			
		||||
      XErrorBarData.ValuePlus := 20;   // 20% of X extent
 | 
			
		||||
      XErrorBarData.IndexPlus := 1;
 | 
			
		||||
      if CbXErrDifferent.Checked then begin
 | 
			
		||||
        XErrorBarData.IndexMinus := 2;
 | 
			
		||||
        XErrorBarData.ValueMinus := XErrorBarData.ValuePlus;
 | 
			
		||||
        XCount := 3;
 | 
			
		||||
      end else begin
 | 
			
		||||
        XErrorBarData.IndexMinus := -1;
 | 
			
		||||
        XErrorBarData.ValueMinus := -1;
 | 
			
		||||
        XCount := 2;
 | 
			
		||||
      end;
 | 
			
		||||
    end
 | 
			
		||||
  else
 | 
			
		||||
    exit;
 | 
			
		||||
 | 
			
		||||
  ListChartSource1.XErrorBarData.Assign(RandomChartSource1.XErrorBarData);
 | 
			
		||||
  ListChartSource1.XCount := RandomChartSource1.XCount;
 | 
			
		||||
  PopulateListSource;
 | 
			
		||||
 | 
			
		||||
  UserDefinedChartSource1.XErrorBarData.Assign(RandomChartSource1.XErrorBarData);
 | 
			
		||||
  UserDefinedChartSource1.XCount := RandomChartSource1.XCount;
 | 
			
		||||
  UserDefinedChartSource1.Reset;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainForm.SetYErrorBarParams;
 | 
			
		||||
begin
 | 
			
		||||
  if RbYErrConst.Checked then
 | 
			
		||||
    with RandomChartSource1 do begin
 | 
			
		||||
      YErrorBarData.Kind := ebkConst;
 | 
			
		||||
      YErrorBarData.ValuePlus := EdYErrConst.Value;
 | 
			
		||||
      if CbYErrDifferent.Checked then
 | 
			
		||||
        YErrorBarData.ValueMinus := 0.5 * YErrorBarData.ValuePlus
 | 
			
		||||
      else
 | 
			
		||||
        YErrorBarData.ValueMinus := -1;
 | 
			
		||||
      YCount := 1;
 | 
			
		||||
    end
 | 
			
		||||
  else if RbYErrPercent.Checked then
 | 
			
		||||
    with RandomChartSource1 do begin
 | 
			
		||||
      YErrorBarData.Kind := ebkPercent;
 | 
			
		||||
      YErrorBarData.ValuePlus := EdYErrPercent.Value;
 | 
			
		||||
      if CbYErrDifferent.Checked then
 | 
			
		||||
        YErrorBarData.ValueMinus := 0.5 * YErrorBarData.ValuePlus
 | 
			
		||||
      else
 | 
			
		||||
        YErrorBarData.ValueMinus := -1;
 | 
			
		||||
      YCount := 1;
 | 
			
		||||
    end
 | 
			
		||||
  else if RbYErrChartSource.Checked then
 | 
			
		||||
    with RandomChartSource1 do begin
 | 
			
		||||
      YErrorBarData.Kind := ebkChartSource;
 | 
			
		||||
      YErrorBarData.ValuePlus := 20;   // 20% of X extent
 | 
			
		||||
      YErrorBarData.IndexPlus := 1;
 | 
			
		||||
      if CbYErrDifferent.Checked then begin
 | 
			
		||||
        YErrorBarData.IndexMinus := 2;
 | 
			
		||||
        YErrorBarData.ValueMinus := YErrorBarData.ValuePlus;
 | 
			
		||||
        YCount := 3;
 | 
			
		||||
      end else begin
 | 
			
		||||
        YErrorBarData.IndexMinus := -1;
 | 
			
		||||
        YErrorBarData.ValueMinus := -1;
 | 
			
		||||
        YCount := 2;
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  else
 | 
			
		||||
    exit;
 | 
			
		||||
 | 
			
		||||
  ListChartSource1.YErrorBarData.Assign(RandomChartSource1.YErrorBarData);
 | 
			
		||||
  ListChartSource1.YCount := RandomChartSource1.YCount;
 | 
			
		||||
  PopulateListSource;
 | 
			
		||||
 | 
			
		||||
  UserDefinedChartSource1.YErrorBarData.Assign(RandomChartSource1.YErrorBarData);
 | 
			
		||||
  UserDefinedChartSource1.YCount := RandomChartSource1.YCount;
 | 
			
		||||
  UserDefinedChartSource1.Reset;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
end.
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user