Resizing Chart - axis labels in wrong location
Posted: Wed Oct 29, 2008 7:48 pm
I've been looking at the "Chart CustomChartRect" example in the features demo and attempting to get my chart to behave correctly. I apparently am doing something wrong but haven't been able to spot the problem.
I can successfully resize the chart using the TRectangle resized event. But my axis labels are drawn in the incorrect locations:
1. The left axis is where it should be, but the labels are in the middle of the graph.
2. The left axis title is in the left wall instead of being left of the axis.
3. The bottom axis labels are inside the graph as well.
I've tried adjusting various properties but cannot get it to behave. Can you point me in the direction of a property to check?
Thanks
Mike Simmons
unit APMGR022;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Apmgrgl, Buttons, APMGRDAT, dxSkinsCore, dxSkinsDefaultPainters,
dxSkinsdxBarPainter, cxPropertiesStore, dxBar, cxClasses,
cxLookAndFeelPainters, TeeGalleryPanel, cxSplitter, StdCtrls, TeeLisB,
cxControls, cxContainer, cxEdit, cxGroupBox, TeeProcs, TeEngine, Chart,
ExtCtrls, TeeComma, TeeEdit, Teetools, TeeDataTableTool, Series,
TeeSelectorTool;
type
TGraphForm = class(TForm)
dxBarManager1: TdxBarManager;
dxBarManager1Bar1: TdxBar;
dxBarButton1: TdxBarButton;
cxPropertiesStore1: TcxPropertiesStore;
TeeCommander1: TTeeCommander;
Chart1: TChart;
cxGroupBox1: TcxGroupBox;
ChartListBox1: TChartListBox;
Splitter2: TcxSplitter;
ChartGalleryPanel1: TChartGalleryPanel;
Splitter1: TcxSplitter;
ChartEditor1: TChartEditor;
procedure dxBarButton1Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure ChartGalleryPanel1ChangeChart(Sender: TObject);
procedure TeeCommander1SetLabel(Sender: TTeeCommander; var Text: string);
procedure SetChartVisibility;
procedure ToggleDataTable(Sender: TObject);
procedure ShowHideGallery(Sender: TObject);
procedure ShowHideSeries(Sender: TObject);
procedure TogglePercent(Sender: TObject);
procedure Setup(PPct, DataTable: Boolean);
procedure MakeBar(SeriesTitle: String; MultB: TMultiBar; SColor: TColor);
procedure MakeArea(SeriesTitle: String; Transp: Integer; SColor: TColor);
procedure LoadSeriesData(SeriesData: PtrChartSeriesTable; SeriesName: String );
procedure SetCaption(Title: String);
procedure ChartTool1Dragged(Sender: TObject);
procedure Chart1AfterDraw(Sender: TObject);
private
{ Private declarations }
MarkTips: TMarksTipTool;
DATA: TDataTableTool;
BarTemp: TBarSeries;
AreaTemp: TAreaSeries;
LastMultiBar: TMultiBar;
Rect1: TRectangleTool;
public
{ Public declarations }
end;
var
GraphForm: TGraphForm;
implementation
{$R *.dfm}
procedure TGraphForm.ChartGalleryPanel1ChangeChart(Sender: TObject);
var tmpSeries : TChartSeries;
begin
tmpSeries:=ChartGalleryPanel1.SelectedChart[0];
ChangeAllSeriesType(Chart1,TChartSeriesClass(tmpSeries.ClassType));
end;
procedure TGraphForm.dxBarButton1Click(Sender: TObject);
begin
Close;
end;
procedure TGraphForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
cxPropertiesStore1.StoreTo(False);
Action := caFree;
end;
procedure TGraphForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
Canclose := True;
end;
procedure TGraphForm.FormShow(Sender: TObject);
begin
cxPropertiesStore1.StorageName := 'SOFTWARE\ISD\' + G_SoftwareName + '\CurrentVersion\' + Self.Name;
cxPropertiesStore1.RestoreFrom;
end;
procedure TGraphForm.TeeCommander1SetLabel(Sender: TTeeCommander;
var Text: string);
begin
Text := '';
end;
procedure TGraphForm.Setup(PPct, DataTable: Boolean);
Var
RPos,i,j: Integer;
begin
// Adjust Title Line properties
Chart1.Title.Text.Clear;
Chart1.Color := clWhite;
Chart1.Title.Font.Color := clNavy;
Chart1.Title.Font.Size := 12;
Chart1.Foot.Font.Color := clNavy;
Chart1.Foot.Font.Size := 12;
Chart1.Pages.AutoScale := True;
Chart1.Legend.Visible := False; // Hide series legend
Chart1.OnClickSeries := nil;
// Create mouseover tip displayer and add to chart
MarkTips := TMarksTipTool.Create(self);
MarkTips.Style := smsValue;
MarkTips.MouseAction := mtmMove;
MarkTips.MouseDelay := 200;
MarkTips.Active := True;
Chart1.Tools.Add(MarkTips);
// Create DataTableTool and add to chart
DATA := TDataTableTool.Create(Self);
DATA.ParentChart := Chart1;
DATA.AutoPosition := True;
DATA.ClipText := True;
DATA.Active := DataTable;
Chart1.Tools.Add(DATA);
Rect1 := TRectangleTool.CReate(Self);
With Rect1 do
Begin
ParentChart := Chart1;
Active := False;
Callout.Brush.BackColor := clAqua;
Callout.Arrow.Visible := False;
Shape.Shadow.HorizSize := 0;
Shape.Shadow.VertSize := 0;
Shape.Transparency := 75;
Shape.AutoSize := False;
Shape.Cursor := crHandPoint;
OnDragged := ChartTool1Dragged;
OnResized := ChartTool1Dragged;
Visible := True;
End;
Chart1.Tools.Add(RECT1);
Rect1.Active := False;
//Chart1.CustomChartRect:=True;
// TSEL := TSelectorTool.Create(self);
// TSEL.AllowDrag := True;
// TSEL.ParentChart := Chart1;
// TSEL.AllowResizeChart := True;
// Chart1.Tools.Add(TSEL);
RPos := 0;
With TeeCommander1 do
Begin
For i := 0 to Pred(ControlCount) do
Begin
If Controls is TSpeedButton
Then j := (Controls as TSpeedButton).Boundsrect.Right
Else
If Controls is TLabel
Then j := (Controls as TLabel).Boundsrect.Right
Else j := 0;
If j > RPos
Then RPos := j;
End;
End;
With TeeCommander1.CreateButton(RPos + 4 ,ShowHideGallery,'Gallery','',103) do
Begin
DM1.TChartImageList.GetBitMap(3, Glyph);
NumGlyphs := 1;
RPos := RPos + 29;
End;
With TeeCommander1.CreateButton(RPos + 4,ToggleDataTable,'Data Table','',101) do
Begin
DM1.TChartImageList.GetBitMap(1, Glyph);
NumGlyphs := 1;
RPos := RPos + 29;
End;
With TeeCommander1.CreateButton(RPos + 4,ShowHideSeries,'Series List','',102) do
Begin
DM1.TChartImageList.GetBitMap(2, Glyph);
NumGlyphs := 1;
RPos := RPos + 29;
End;
If PPct
Then Begin
With TeeCommander1.CreateButton(RPos + 4,TogglePercent,'Percentage View','',100) do
Begin
DM1.TChartImageList.GetBitMap(0, Glyph);
NumGlyphs := 1;
End;
End;
With ChartGalleryPanel1 do
begin
NumCols:=1;
NumRows:=9;
CreateChartList([THorizBarSeries,TLineSeries,THorizLineSeries,
TBarSeries, TCircledSeries,
TAreaSeries,TPieSeries,THorizAreaSeries,
TPointSeries]);
end;
end;
procedure TGraphForm.SetChartVisibility;
begin
If (not ChartListBox1.Visible) and
(not ChartGalleryPanel1.Visible)
Then Begin
cxGroupBox1.Visible := False;
Splitter1.Visible := False;
Exit;
End;
Splitter1.Visible := True;
cxGroupBox1.Visible := True;
Splitter2.Visible := ChartListBox1.Visible and
ChartGalleryPanel1.Visible;
If ChartListBox1.Visible and
(not ChartGalleryPanel1.Visible)
Then ChartListBox1.Align := ALClient
Else Begin
If ChartListBox1.Align = ALClient
Then Begin
ChartListBox1.Align := ALTop;
ChartListBox1.Height := cxGroupBox1.Height div 4;
End;
End;
end;
procedure TGraphForm.TogglePercent(Sender: TObject);
Var
i: Integer;
begin
(Sender as TSpeedButton).AllowAllUp := True;
if Chart1.SeriesCount > 0 then
for i := 0 to Chart1.SeriesCount-1 do
if (Chart1.Series is TBarSeries) or
(Chart1.Series is THorizBarSeries)
then begin
With TCustomBarSeries(Chart1.Series) do
Begin
If MultiBar <> mbStacked100
Then Begin
LastMultiBar := MultiBar;
MultiBar := mbStacked100;
End
Else Begin
MultiBar := LastMultibar;
End;
(Sender as TSpeedButton).Down := MultiBar = mbStacked100;
End;
Exit; // only do for 1st bar found
end;
(Sender as TSpeedButton).Down := False;
end;
procedure TGraphForm.ShowHideSeries(Sender: TObject);
begin
ChartListBox1.Visible := not ChartListBox1.Visible;
(Sender as TSpeedButton).AllowAllUp := True;
(Sender as TSpeedButton).Down := ChartListBox1.Visible;
SetChartVisibility;
end;
procedure TGraphForm.ShowHideGallery(Sender: TObject);
begin
ChartGalleryPanel1.Visible := not ChartGalleryPanel1.Visible;
(Sender as TSpeedButton).AllowAllUp := True;
(Sender as TSpeedButton).Down := ChartGalleryPanel1.Visible;
SetChartVisibility;
end;
procedure TGraphForm.ToggleDataTable(Sender: TObject);
begin
Data.Active := not Data.Active;
(Sender as TSpeedButton).AllowAllUp := True;
(Sender as TSpeedButton).Down := Data.Active;
end;
procedure TGraphForm.MakeBar(SeriesTitle: String; MultB: TMultiBar; SColor: TColor);
begin
BarTemp := TBarSeries.Create(Self);
With BarTemp do
Begin
ParentChart := Chart1;
Title := SeriesTitle;
Marks.Style := smsValue;
Marks.Visible := False;
Color := SColor;
MultiBar := MultB;
End;
LastMultiBar := MultB;
end;
procedure TGraphForm.MakeArea(SeriesTitle: String; Transp: Integer; SColor: TColor);
begin
AreaTemp := TAreaSeries.Create(Self);
With AreaTemp do
Begin
ParentChart := Chart1;
Title := SeriesTitle;
Marks.Style := smsValue;
Marks.Visible := False;
Transparency := TRansp;
Color := SColor;
End;
end;
procedure TGraphForm.SetCaption(Title: String);
Begin
Caption := Title + ' (AM022)';
End;
procedure TGraphForm.ChartTool1Dragged(Sender: TObject);
begin
with Chart1 do
begin
ChartRect:=Rect1.Bounds;
Chart1.Axes.Left.LabelsSize:=-10;
Chart1.Axes.Bottom.LabelsSize:=-10;
Invalidate;
end;
end;
procedure TGraphForm.LoadSeriesData(SeriesData: PtrChartSeriesTable; SeriesName: String );
Var
i,j: Integer;
Col: TColor;
begin
With Chart1 do
Begin
For i := 0 to Pred(SeriesCount) do
Begin
If Series.Title = SeriesName
Then Begin
Series.Clear;
For j := Low(SeriesData^) to High(SeriesData^) do
Begin
Col := SeriesData^[j].Color;
If Col = -1
Then Col := clTeeColor;
Series.Add(SeriesData^[j].Value,
SeriesData^[j].PointName, Col);
If SeriesData^[j].Value = 0
Then Series[i].SetNull(j);
End;
End;
End;
End;
ChartListBox1.UpdateSeries;
end;
procedure TGraphForm.Chart1AfterDraw(Sender: TObject);
begin
If not Rect1.Active
Then Begin
Rect1.Left := Chart1.ChartRect.Left;
Rect1.Top := Chart1.ChartRect.Top;
Rect1.Height := Chart1.ChartHeight;
Rect1.Width := Chart1.ChartWidth;
Rect1.Active := True;
Chart1.Title.CustomPosition:=True;
Chart1.Legend.CustomPosition:=True;
Chart1.CustomChartRect:=True;
End;
end;
end.
object GraphForm: TGraphForm
Left = 0
Top = 0
Caption = 'GraphForm'
ClientHeight = 528
ClientWidth = 564
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnClose = FormClose
OnCloseQuery = FormCloseQuery
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13
object TeeCommander1: TTeeCommander
Left = 0
Top = 26
Width = 564
Height = 33
Panel = Chart1
Align = alTop
ParentShowHint = False
TabOrder = 0
ChartEditor = ChartEditor1
OnSetLabel = TeeCommander1SetLabel
end
object Chart1: TChart
Left = 169
Top = 59
Width = 395
Height = 469
Foot.Text.Strings = (
'')
Title.Font.Height = -16
Title.Text.Strings = (
'TChart')
Pages.AutoScale = True
OnAfterDraw = Chart1AfterDraw
Align = alClient
Color = clWhite
TabOrder = 1
ColorPaletteIndex = 13
end
object cxGroupBox1: TcxGroupBox
Left = 0
Top = 59
Align = alLeft
Style.BorderStyle = ebsNone
TabOrder = 6
Visible = False
Height = 469
Width = 161
object ChartListBox1: TChartListBox
Left = 2
Top = 18
Width = 157
Height = 97
Chart = Chart1
Align = alTop
ItemHeight = 24
TabOrder = 0
Visible = False
end
object Splitter2: TcxSplitter
Left = 2
Top = 115
Width = 157
Height = 8
HotZoneClassName = 'TcxSimpleStyle'
AlignSplitter = salTop
Control = ChartListBox1
Visible = False
end
object ChartGalleryPanel1: TChartGalleryPanel
Left = 2
Top = 123
Width = 157
Height = 344
Smooth = True
OnChangeChart = ChartGalleryPanel1ChangeChart
Align = alClient
BevelOuter = bvNone
ParentColor = True
TabOrder = 2
Visible = False
end
end
object Splitter1: TcxSplitter
Left = 161
Top = 59
Width = 8
Height = 469
HotZoneClassName = 'TcxSimpleStyle'
Control = cxGroupBox1
end
object dxBarManager1: TdxBarManager
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
Categories.Strings = (
'Default')
Categories.ItemsVisibles = (
2)
Categories.Visibles = (
True)
PopupMenuLinks = <>
UseSystemFont = True
Left = 168
Top = 144
DockControlHeights = (
0
0
26
0)
object dxBarManager1Bar1: TdxBar
AllowClose = False
AllowCustomizing = False
AllowQuickCustomizing = False
Caption = 'Main Menu'
CaptionButtons = <>
DockedDockingStyle = dsTop
DockedLeft = 0
DockedTop = 0
DockingStyle = dsTop
FloatLeft = 590
FloatTop = 8
FloatClientWidth = 0
FloatClientHeight = 0
IsMainMenu = True
ItemLinks = <
item
Visible = True
ItemName = 'dxBarButton1'
end>
MultiLine = True
OneOnRow = True
Row = 0
UseOwnFont = False
Visible = True
WholeRow = True
end
object dxBarButton1: TdxBarButton
Caption = 'Close'
Category = 0
Hint = 'Close'
Visible = ivAlways
OnClick = dxBarButton1Click
end
end
object cxPropertiesStore1: TcxPropertiesStore
Active = False
Components = <
item
Component = Owner
Properties.Strings = (
'Left'
'Top')
end>
StorageName = 'cxPropertiesStore1'
StorageType = stRegistry
Left = 272
Top = 208
end
object ChartEditor1: TChartEditor
Chart = Chart1
TreeView = True
Left = 344
Top = 280
end
end
I can successfully resize the chart using the TRectangle resized event. But my axis labels are drawn in the incorrect locations:
1. The left axis is where it should be, but the labels are in the middle of the graph.
2. The left axis title is in the left wall instead of being left of the axis.
3. The bottom axis labels are inside the graph as well.
I've tried adjusting various properties but cannot get it to behave. Can you point me in the direction of a property to check?
Thanks
Mike Simmons
unit APMGR022;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Apmgrgl, Buttons, APMGRDAT, dxSkinsCore, dxSkinsDefaultPainters,
dxSkinsdxBarPainter, cxPropertiesStore, dxBar, cxClasses,
cxLookAndFeelPainters, TeeGalleryPanel, cxSplitter, StdCtrls, TeeLisB,
cxControls, cxContainer, cxEdit, cxGroupBox, TeeProcs, TeEngine, Chart,
ExtCtrls, TeeComma, TeeEdit, Teetools, TeeDataTableTool, Series,
TeeSelectorTool;
type
TGraphForm = class(TForm)
dxBarManager1: TdxBarManager;
dxBarManager1Bar1: TdxBar;
dxBarButton1: TdxBarButton;
cxPropertiesStore1: TcxPropertiesStore;
TeeCommander1: TTeeCommander;
Chart1: TChart;
cxGroupBox1: TcxGroupBox;
ChartListBox1: TChartListBox;
Splitter2: TcxSplitter;
ChartGalleryPanel1: TChartGalleryPanel;
Splitter1: TcxSplitter;
ChartEditor1: TChartEditor;
procedure dxBarButton1Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure ChartGalleryPanel1ChangeChart(Sender: TObject);
procedure TeeCommander1SetLabel(Sender: TTeeCommander; var Text: string);
procedure SetChartVisibility;
procedure ToggleDataTable(Sender: TObject);
procedure ShowHideGallery(Sender: TObject);
procedure ShowHideSeries(Sender: TObject);
procedure TogglePercent(Sender: TObject);
procedure Setup(PPct, DataTable: Boolean);
procedure MakeBar(SeriesTitle: String; MultB: TMultiBar; SColor: TColor);
procedure MakeArea(SeriesTitle: String; Transp: Integer; SColor: TColor);
procedure LoadSeriesData(SeriesData: PtrChartSeriesTable; SeriesName: String );
procedure SetCaption(Title: String);
procedure ChartTool1Dragged(Sender: TObject);
procedure Chart1AfterDraw(Sender: TObject);
private
{ Private declarations }
MarkTips: TMarksTipTool;
DATA: TDataTableTool;
BarTemp: TBarSeries;
AreaTemp: TAreaSeries;
LastMultiBar: TMultiBar;
Rect1: TRectangleTool;
public
{ Public declarations }
end;
var
GraphForm: TGraphForm;
implementation
{$R *.dfm}
procedure TGraphForm.ChartGalleryPanel1ChangeChart(Sender: TObject);
var tmpSeries : TChartSeries;
begin
tmpSeries:=ChartGalleryPanel1.SelectedChart[0];
ChangeAllSeriesType(Chart1,TChartSeriesClass(tmpSeries.ClassType));
end;
procedure TGraphForm.dxBarButton1Click(Sender: TObject);
begin
Close;
end;
procedure TGraphForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
cxPropertiesStore1.StoreTo(False);
Action := caFree;
end;
procedure TGraphForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
Canclose := True;
end;
procedure TGraphForm.FormShow(Sender: TObject);
begin
cxPropertiesStore1.StorageName := 'SOFTWARE\ISD\' + G_SoftwareName + '\CurrentVersion\' + Self.Name;
cxPropertiesStore1.RestoreFrom;
end;
procedure TGraphForm.TeeCommander1SetLabel(Sender: TTeeCommander;
var Text: string);
begin
Text := '';
end;
procedure TGraphForm.Setup(PPct, DataTable: Boolean);
Var
RPos,i,j: Integer;
begin
// Adjust Title Line properties
Chart1.Title.Text.Clear;
Chart1.Color := clWhite;
Chart1.Title.Font.Color := clNavy;
Chart1.Title.Font.Size := 12;
Chart1.Foot.Font.Color := clNavy;
Chart1.Foot.Font.Size := 12;
Chart1.Pages.AutoScale := True;
Chart1.Legend.Visible := False; // Hide series legend
Chart1.OnClickSeries := nil;
// Create mouseover tip displayer and add to chart
MarkTips := TMarksTipTool.Create(self);
MarkTips.Style := smsValue;
MarkTips.MouseAction := mtmMove;
MarkTips.MouseDelay := 200;
MarkTips.Active := True;
Chart1.Tools.Add(MarkTips);
// Create DataTableTool and add to chart
DATA := TDataTableTool.Create(Self);
DATA.ParentChart := Chart1;
DATA.AutoPosition := True;
DATA.ClipText := True;
DATA.Active := DataTable;
Chart1.Tools.Add(DATA);
Rect1 := TRectangleTool.CReate(Self);
With Rect1 do
Begin
ParentChart := Chart1;
Active := False;
Callout.Brush.BackColor := clAqua;
Callout.Arrow.Visible := False;
Shape.Shadow.HorizSize := 0;
Shape.Shadow.VertSize := 0;
Shape.Transparency := 75;
Shape.AutoSize := False;
Shape.Cursor := crHandPoint;
OnDragged := ChartTool1Dragged;
OnResized := ChartTool1Dragged;
Visible := True;
End;
Chart1.Tools.Add(RECT1);
Rect1.Active := False;
//Chart1.CustomChartRect:=True;
// TSEL := TSelectorTool.Create(self);
// TSEL.AllowDrag := True;
// TSEL.ParentChart := Chart1;
// TSEL.AllowResizeChart := True;
// Chart1.Tools.Add(TSEL);
RPos := 0;
With TeeCommander1 do
Begin
For i := 0 to Pred(ControlCount) do
Begin
If Controls is TSpeedButton
Then j := (Controls as TSpeedButton).Boundsrect.Right
Else
If Controls is TLabel
Then j := (Controls as TLabel).Boundsrect.Right
Else j := 0;
If j > RPos
Then RPos := j;
End;
End;
With TeeCommander1.CreateButton(RPos + 4 ,ShowHideGallery,'Gallery','',103) do
Begin
DM1.TChartImageList.GetBitMap(3, Glyph);
NumGlyphs := 1;
RPos := RPos + 29;
End;
With TeeCommander1.CreateButton(RPos + 4,ToggleDataTable,'Data Table','',101) do
Begin
DM1.TChartImageList.GetBitMap(1, Glyph);
NumGlyphs := 1;
RPos := RPos + 29;
End;
With TeeCommander1.CreateButton(RPos + 4,ShowHideSeries,'Series List','',102) do
Begin
DM1.TChartImageList.GetBitMap(2, Glyph);
NumGlyphs := 1;
RPos := RPos + 29;
End;
If PPct
Then Begin
With TeeCommander1.CreateButton(RPos + 4,TogglePercent,'Percentage View','',100) do
Begin
DM1.TChartImageList.GetBitMap(0, Glyph);
NumGlyphs := 1;
End;
End;
With ChartGalleryPanel1 do
begin
NumCols:=1;
NumRows:=9;
CreateChartList([THorizBarSeries,TLineSeries,THorizLineSeries,
TBarSeries, TCircledSeries,
TAreaSeries,TPieSeries,THorizAreaSeries,
TPointSeries]);
end;
end;
procedure TGraphForm.SetChartVisibility;
begin
If (not ChartListBox1.Visible) and
(not ChartGalleryPanel1.Visible)
Then Begin
cxGroupBox1.Visible := False;
Splitter1.Visible := False;
Exit;
End;
Splitter1.Visible := True;
cxGroupBox1.Visible := True;
Splitter2.Visible := ChartListBox1.Visible and
ChartGalleryPanel1.Visible;
If ChartListBox1.Visible and
(not ChartGalleryPanel1.Visible)
Then ChartListBox1.Align := ALClient
Else Begin
If ChartListBox1.Align = ALClient
Then Begin
ChartListBox1.Align := ALTop;
ChartListBox1.Height := cxGroupBox1.Height div 4;
End;
End;
end;
procedure TGraphForm.TogglePercent(Sender: TObject);
Var
i: Integer;
begin
(Sender as TSpeedButton).AllowAllUp := True;
if Chart1.SeriesCount > 0 then
for i := 0 to Chart1.SeriesCount-1 do
if (Chart1.Series is TBarSeries) or
(Chart1.Series is THorizBarSeries)
then begin
With TCustomBarSeries(Chart1.Series) do
Begin
If MultiBar <> mbStacked100
Then Begin
LastMultiBar := MultiBar;
MultiBar := mbStacked100;
End
Else Begin
MultiBar := LastMultibar;
End;
(Sender as TSpeedButton).Down := MultiBar = mbStacked100;
End;
Exit; // only do for 1st bar found
end;
(Sender as TSpeedButton).Down := False;
end;
procedure TGraphForm.ShowHideSeries(Sender: TObject);
begin
ChartListBox1.Visible := not ChartListBox1.Visible;
(Sender as TSpeedButton).AllowAllUp := True;
(Sender as TSpeedButton).Down := ChartListBox1.Visible;
SetChartVisibility;
end;
procedure TGraphForm.ShowHideGallery(Sender: TObject);
begin
ChartGalleryPanel1.Visible := not ChartGalleryPanel1.Visible;
(Sender as TSpeedButton).AllowAllUp := True;
(Sender as TSpeedButton).Down := ChartGalleryPanel1.Visible;
SetChartVisibility;
end;
procedure TGraphForm.ToggleDataTable(Sender: TObject);
begin
Data.Active := not Data.Active;
(Sender as TSpeedButton).AllowAllUp := True;
(Sender as TSpeedButton).Down := Data.Active;
end;
procedure TGraphForm.MakeBar(SeriesTitle: String; MultB: TMultiBar; SColor: TColor);
begin
BarTemp := TBarSeries.Create(Self);
With BarTemp do
Begin
ParentChart := Chart1;
Title := SeriesTitle;
Marks.Style := smsValue;
Marks.Visible := False;
Color := SColor;
MultiBar := MultB;
End;
LastMultiBar := MultB;
end;
procedure TGraphForm.MakeArea(SeriesTitle: String; Transp: Integer; SColor: TColor);
begin
AreaTemp := TAreaSeries.Create(Self);
With AreaTemp do
Begin
ParentChart := Chart1;
Title := SeriesTitle;
Marks.Style := smsValue;
Marks.Visible := False;
Transparency := TRansp;
Color := SColor;
End;
end;
procedure TGraphForm.SetCaption(Title: String);
Begin
Caption := Title + ' (AM022)';
End;
procedure TGraphForm.ChartTool1Dragged(Sender: TObject);
begin
with Chart1 do
begin
ChartRect:=Rect1.Bounds;
Chart1.Axes.Left.LabelsSize:=-10;
Chart1.Axes.Bottom.LabelsSize:=-10;
Invalidate;
end;
end;
procedure TGraphForm.LoadSeriesData(SeriesData: PtrChartSeriesTable; SeriesName: String );
Var
i,j: Integer;
Col: TColor;
begin
With Chart1 do
Begin
For i := 0 to Pred(SeriesCount) do
Begin
If Series.Title = SeriesName
Then Begin
Series.Clear;
For j := Low(SeriesData^) to High(SeriesData^) do
Begin
Col := SeriesData^[j].Color;
If Col = -1
Then Col := clTeeColor;
Series.Add(SeriesData^[j].Value,
SeriesData^[j].PointName, Col);
If SeriesData^[j].Value = 0
Then Series[i].SetNull(j);
End;
End;
End;
End;
ChartListBox1.UpdateSeries;
end;
procedure TGraphForm.Chart1AfterDraw(Sender: TObject);
begin
If not Rect1.Active
Then Begin
Rect1.Left := Chart1.ChartRect.Left;
Rect1.Top := Chart1.ChartRect.Top;
Rect1.Height := Chart1.ChartHeight;
Rect1.Width := Chart1.ChartWidth;
Rect1.Active := True;
Chart1.Title.CustomPosition:=True;
Chart1.Legend.CustomPosition:=True;
Chart1.CustomChartRect:=True;
End;
end;
end.
object GraphForm: TGraphForm
Left = 0
Top = 0
Caption = 'GraphForm'
ClientHeight = 528
ClientWidth = 564
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnClose = FormClose
OnCloseQuery = FormCloseQuery
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13
object TeeCommander1: TTeeCommander
Left = 0
Top = 26
Width = 564
Height = 33
Panel = Chart1
Align = alTop
ParentShowHint = False
TabOrder = 0
ChartEditor = ChartEditor1
OnSetLabel = TeeCommander1SetLabel
end
object Chart1: TChart
Left = 169
Top = 59
Width = 395
Height = 469
Foot.Text.Strings = (
'')
Title.Font.Height = -16
Title.Text.Strings = (
'TChart')
Pages.AutoScale = True
OnAfterDraw = Chart1AfterDraw
Align = alClient
Color = clWhite
TabOrder = 1
ColorPaletteIndex = 13
end
object cxGroupBox1: TcxGroupBox
Left = 0
Top = 59
Align = alLeft
Style.BorderStyle = ebsNone
TabOrder = 6
Visible = False
Height = 469
Width = 161
object ChartListBox1: TChartListBox
Left = 2
Top = 18
Width = 157
Height = 97
Chart = Chart1
Align = alTop
ItemHeight = 24
TabOrder = 0
Visible = False
end
object Splitter2: TcxSplitter
Left = 2
Top = 115
Width = 157
Height = 8
HotZoneClassName = 'TcxSimpleStyle'
AlignSplitter = salTop
Control = ChartListBox1
Visible = False
end
object ChartGalleryPanel1: TChartGalleryPanel
Left = 2
Top = 123
Width = 157
Height = 344
Smooth = True
OnChangeChart = ChartGalleryPanel1ChangeChart
Align = alClient
BevelOuter = bvNone
ParentColor = True
TabOrder = 2
Visible = False
end
end
object Splitter1: TcxSplitter
Left = 161
Top = 59
Width = 8
Height = 469
HotZoneClassName = 'TcxSimpleStyle'
Control = cxGroupBox1
end
object dxBarManager1: TdxBarManager
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
Categories.Strings = (
'Default')
Categories.ItemsVisibles = (
2)
Categories.Visibles = (
True)
PopupMenuLinks = <>
UseSystemFont = True
Left = 168
Top = 144
DockControlHeights = (
0
0
26
0)
object dxBarManager1Bar1: TdxBar
AllowClose = False
AllowCustomizing = False
AllowQuickCustomizing = False
Caption = 'Main Menu'
CaptionButtons = <>
DockedDockingStyle = dsTop
DockedLeft = 0
DockedTop = 0
DockingStyle = dsTop
FloatLeft = 590
FloatTop = 8
FloatClientWidth = 0
FloatClientHeight = 0
IsMainMenu = True
ItemLinks = <
item
Visible = True
ItemName = 'dxBarButton1'
end>
MultiLine = True
OneOnRow = True
Row = 0
UseOwnFont = False
Visible = True
WholeRow = True
end
object dxBarButton1: TdxBarButton
Caption = 'Close'
Category = 0
Hint = 'Close'
Visible = ivAlways
OnClick = dxBarButton1Click
end
end
object cxPropertiesStore1: TcxPropertiesStore
Active = False
Components = <
item
Component = Owner
Properties.Strings = (
'Left'
'Top')
end>
StorageName = 'cxPropertiesStore1'
StorageType = stRegistry
Left = 272
Top = 208
end
object ChartEditor1: TChartEditor
Chart = Chart1
TreeView = True
Left = 344
Top = 280
end
end