diff --git a/components/fpspreadsheet/examples/visual/fpschart/workbookchartsource/fpschartsource.lpi b/components/fpspreadsheet/examples/visual/fpschart/workbookchartsource/fpschartsource.lpi
index 2cf944a0f..7ef3e16a0 100644
--- a/components/fpspreadsheet/examples/visual/fpschart/workbookchartsource/fpschartsource.lpi
+++ b/components/fpspreadsheet/examples/visual/fpschart/workbookchartsource/fpschartsource.lpi
@@ -61,6 +61,9 @@
+
+
+
diff --git a/components/fpspreadsheet/examples/visual/fpschart/workbookchartsource/mainform.lfm b/components/fpspreadsheet/examples/visual/fpschart/workbookchartsource/mainform.lfm
index b2dde7172..7a74bf880 100644
--- a/components/fpspreadsheet/examples/visual/fpschart/workbookchartsource/mainform.lfm
+++ b/components/fpspreadsheet/examples/visual/fpschart/workbookchartsource/mainform.lfm
@@ -2,22 +2,22 @@ object Form1: TForm1
Left = 256
Height = 618
Top = 127
- Width = 828
+ Width = 1047
Caption = 'Form1'
ClientHeight = 618
- ClientWidth = 828
+ ClientWidth = 1047
+ LCLVersion = '3.99.0.0'
OnCreate = FormCreate
- LCLVersion = '1.8.4.0'
object Panel1: TPanel
Left = 0
Height = 33
Top = 0
- Width = 828
+ Width = 1047
Align = alTop
AutoSize = True
BevelOuter = bvNone
ClientHeight = 33
- ClientWidth = 828
+ ClientWidth = 1047
TabOrder = 0
object BtnDeleteSheet: TButton
AnchorSideLeft.Control = Panel1
@@ -32,8 +32,8 @@ object Form1: TForm1
BorderSpacing.Right = 4
BorderSpacing.Bottom = 4
Caption = 'Delete sheet'
- OnClick = BtnDeleteSheetClick
TabOrder = 0
+ OnClick = BtnDeleteSheetClick
end
object BtnRenameSheet: TButton
AnchorSideLeft.Control = BtnDeleteSheet
@@ -48,15 +48,15 @@ object Form1: TForm1
BorderSpacing.Right = 4
BorderSpacing.Bottom = 4
Caption = 'Rename sheet'
- OnClick = BtnRenameSheetClick
TabOrder = 1
+ OnClick = BtnRenameSheetClick
end
end
object sWorkbookTabControl1: TsWorkbookTabControl
Left = 5
Height = 581
Top = 37
- Width = 280
+ Width = 475
TabIndex = 0
Tabs.Strings = (
'Sheet1'
@@ -68,10 +68,12 @@ object Form1: TForm1
Left = 2
Height = 556
Top = 23
- Width = 276
+ Width = 471
AutoCalc = True
FrozenCols = 0
FrozenRows = 0
+ PageBreakPen.Color = clBlue
+ PageBreakPen.Style = psDash
ReadFormulas = True
WorkbookSource = sWorkbookSource1
Align = alClient
@@ -84,10 +86,10 @@ object Form1: TForm1
end
end
object Panel2: TPanel
- Left = 285
+ Left = 480
Height = 581
Top = 37
- Width = 543
+ Width = 567
Align = alClient
BevelOuter = bvNone
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
@@ -97,13 +99,13 @@ object Form1: TForm1
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 581
- ClientWidth = 543
+ ClientWidth = 567
TabOrder = 2
object Chart1: TChart
Left = 0
Height = 194
Top = 0
- Width = 543
+ Width = 567
AxisList = <
item
Grid.Color = clSilver
@@ -128,17 +130,16 @@ object Form1: TForm1
'Chart from 1st sheet'
)
Title.Visible = True
- object Chart1AreaSeries1: TAreaSeries
- AreaBrush.Color = clSkyBlue
- AreaLinesPen.Style = psClear
+ object Chart1LineSeries1: TLineSeries
Source = sWorkbookChartSource1
+ Styles = ChartStyles1
end
end
object Chart2: TChart
Left = 0
Height = 194
Top = 194
- Width = 543
+ Width = 567
AxisList = <
item
Grid.Color = clSilver
@@ -164,6 +165,9 @@ object Form1: TForm1
)
Title.Visible = True
object Chart2BarSeries1: TBarSeries
+ BarBrush.Color = 9934847
+ BarWidthStyle = bwPercentMin
+ Depth = 6
Marks.Distance = 5
Marks.Format = '%.2f'
Marks.Frame.Visible = False
@@ -171,8 +175,6 @@ object Form1: TForm1
Marks.LinkPen.Color = clGray
Marks.OverlapPolicy = opHideNeighbour
Marks.Style = smsCustom
- BarBrush.Color = 9934847
- Depth = 6
Source = sWorkbookChartSource2
end
end
@@ -180,7 +182,7 @@ object Form1: TForm1
Left = 0
Height = 193
Top = 388
- Width = 543
+ Width = 567
AxisList = <
item
Visible = False
@@ -208,10 +210,11 @@ object Form1: TForm1
Title.Visible = True
object Chart3PieSeries1: TPieSeries
Legend.Multiplicity = lmPoint
+ Exploded = True
+ MarkPositions = pmpInside
Marks.Distance = 10
Marks.Format = '%2:s'
Marks.Style = smsLabel
- MarkPositions = pmpInside
Source = sWorkbookChartSource3
end
end
@@ -220,7 +223,7 @@ object Form1: TForm1
Left = 0
Height = 4
Top = 33
- Width = 828
+ Width = 1047
Align = alTop
Shape = bsTopLine
end
@@ -233,22 +236,39 @@ object Form1: TForm1
object sWorkbookSource1: TsWorkbookSource
FileFormat = sfUser
Options = [boAutoCalc, boReadFormulas]
- left = 152
- top = 184
+ Left = 152
+ Top = 184
end
object sWorkbookChartSource3: TsWorkbookChartSource
WorkbookSource = sWorkbookSource1
- left = 544
- top = 503
+ Left = 544
+ Top = 503
end
object sWorkbookChartSource2: TsWorkbookChartSource
WorkbookSource = sWorkbookSource1
- left = 544
- top = 316
+ Left = 544
+ Top = 316
end
object sWorkbookChartSource1: TsWorkbookChartSource
WorkbookSource = sWorkbookSource1
- left = 544
- top = 120
+ Left = 544
+ Top = 120
+ end
+ object ChartStyles1: TChartStyles
+ Styles = <
+ item
+ Brush.Color = clRed
+ Pen.Color = clRed
+ end
+ item
+ Brush.Color = clBlue
+ Pen.Color = clBlue
+ end
+ item
+ Brush.Color = clYellow
+ Pen.Color = clOlive
+ end>
+ Left = 688
+ Top = 120
end
end
diff --git a/components/fpspreadsheet/examples/visual/fpschart/workbookchartsource/mainform.pas b/components/fpspreadsheet/examples/visual/fpschart/workbookchartsource/mainform.pas
index d7905fcd3..1b88b97d0 100644
--- a/components/fpspreadsheet/examples/visual/fpschart/workbookchartsource/mainform.pas
+++ b/components/fpspreadsheet/examples/visual/fpschart/workbookchartsource/mainform.pas
@@ -5,9 +5,9 @@ unit mainform;
interface
uses
- Classes, SysUtils, FileUtil, TAGraph, TASources, TASeries, Forms, Controls,
- Graphics, Dialogs, ExtCtrls, StdCtrls, fpspreadsheetctrls, fpspreadsheetgrid,
- fpspreadsheetchart, fpsallformats;
+ Classes, SysUtils, FileUtil, TAGraph, TASources, TASeries, TAStyles, Forms,
+ Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, fpspreadsheetctrls,
+ fpspreadsheetgrid, fpspreadsheetchart, fpsallformats;
type
@@ -16,13 +16,16 @@ type
TForm1 = class(TForm)
Bevel1: TBevel;
BtnDeleteSheet: TButton;
+ BtnRenameSheet: TButton;
Button2: TButton;
Chart1: TChart;
- Chart1AreaSeries1: TAreaSeries;
+ Chart1AreaSeries1: TLineSeries;
+ Chart1LineSeries1: TLineSeries;
Chart2: TChart;
Chart2BarSeries1: TBarSeries;
Chart3: TChart;
Chart3PieSeries1: TPieSeries;
+ ChartStyles1: TChartStyles;
Panel1: TPanel;
Panel2: TPanel;
Splitter1: TSplitter;
@@ -53,11 +56,14 @@ implementation
procedure TForm1.FormCreate(Sender: TObject);
begin
sWorkbookSource1.Filename := 'test-data.xlsx';
- sWorkbookChartSource1.XRange := 'Sheet1!A2:A21';
- sWorkbookChartSource1.YRange := 'Sheet1!B2:B21';
- sWorkbookChartSource2.XRange := 'Sheet2!A2:A16';
- sWorkbookChartSource2.YRange := 'Sheet2!B2:B16';
- sWorkbookChartSource3.XRange := 'Sheet3!A2:A5';
+
+ sWorkbookChartSource1.XRange := 'Sheet1!A2:A32';
+ sWorkbookChartSource1.YRange := '(Sheet1!B2:B32) (Sheet1!C2:C32) (Sheet1!D2:D17;Sheet1!E18:E32)';
+
+ sWorkbookChartSource2.XRange := 'Sheet2!A2:A27';
+ sWorkbookChartSource2.YRange := 'Sheet2!B2:B27';
+
+ sWorkbookChartSource3.XRange := 'Sheet3!C2:C5';
sWorkbookChartSource3.YRange := 'Sheet3!B2:B5';
sWorkbookChartSource3.LabelRange := 'Sheet3!A2:A5';
end;
diff --git a/components/fpspreadsheet/examples/visual/fpschart/workbookchartsource/test-data.xlsx b/components/fpspreadsheet/examples/visual/fpschart/workbookchartsource/test-data.xlsx
index 9ad612dbf..0d885c44b 100644
Binary files a/components/fpspreadsheet/examples/visual/fpschart/workbookchartsource/test-data.xlsx and b/components/fpspreadsheet/examples/visual/fpschart/workbookchartsource/test-data.xlsx differ
diff --git a/components/fpspreadsheet/source/visual/fpspreadsheetchart.pas b/components/fpspreadsheet/source/visual/fpspreadsheetchart.pas
index 20a3cec18..3ce2d6af4 100644
--- a/components/fpspreadsheet/source/visual/fpspreadsheetchart.pas
+++ b/components/fpspreadsheet/source/visual/fpspreadsheetchart.pas
@@ -524,16 +524,16 @@ end;
and to worksheet changes by selecting the tab corresponding to the selected
worksheet.
- @param AChangedItems Set with elements identifying whether workbook,
- worksheet, cell content or cell formatting has changed
- @param AData Additional data, not used here
+ (@param AChangedItems Set of elements identifying whether workbook,
+ worksheet, cell content or cell formatting has changed)
+ (@param AData Additional data, contains the worksheet for worksheet-related items)
@see TsNotificationItem
-------------------------------------------------------------------------------}
procedure TsWorkbookChartSource.ListenerNotification(
AChangedItems: TsNotificationItems; AData: Pointer = nil);
var
- ir, i: Integer;
+ ir, i, j: Integer;
cell: PCell;
ResetDone: Boolean;
rng: TsXYLRange;
@@ -555,13 +555,25 @@ begin
// Used worksheet will be deleted?
if (lniWorksheetRemoving in AChangedItems) then
+ begin
for rng in TsXYLRange do
for i := 0 to High(FWorksheets[rng]) do
- if TsWorksheet(AData) = FWorksheets[rng, i] then begin
- FWorksheets[rng] := nil;
- FRangeStr[rng] := BuildRangeStr(rng);
- Prepare(rng);
+ if TsWorksheet(AData) = FWorksheets[rng, i] then
+ begin
+ for j := i+1 to High(FWorksheets[rng]) do
+ FWorksheets[rng, j-1] := FWorksheets[rng, j];
+ SetLength(FWorkSheets[rng], Length(FWorksheets[rng])-1);
+ for j := i+1 to High(FRanges[rng]) do
+ FRanges[rng, j-1] := FRanges[rng, j];
+ SetLength(FRanges[rng], Length(FRanges[rng])-1);
end;
+ for rng in TsXYLRange do
+ begin
+ FRangeStr[rng] := BuildRangeStr(rng);
+ Prepare(rng);
+ end;
+ Reset;
+ end;
// Cell changes: Enforce recalculation of axes if modified cell is within the
// x or y range(s).
@@ -625,12 +637,28 @@ var
ok: Boolean;
i, j: Integer;
begin
+ if (FWorkbookSource = nil) then
+ begin
+ FPointsNumber := 0;
+ Reset;
+ exit;
+ end;
+
+ s := FRangeStr[AIndex];
+ if (s = '') then
+ begin
+ if AIndex = rngY then
+ begin
+ FPointsNumber := 0;
+ Reset;
+ exit;
+ end;
+ end;
+
// Split range string into parts for the individual xindex and yindex parts.
// Each part is enclosed by parenthesis.
// Example for two y ranges:
// '(A1:A10) (B1:B5;B6:B11)' --> 1st y range is A1:A10, 2nd y range is B1:B5 and B6:B11
- s := '';
- s := FRangeStr[AIndex];
if (s <> '') and (s[Length(s)] = ')') then
Delete(s, Length(s), 1);
for i := 1 to Length(s) do
@@ -656,17 +684,6 @@ begin
else ;
end;
- // Trivial valdiation
- if (Workbook = nil) or (not ok) then
- begin
- FWorksheets[AIndex] := nil;
- SetLength(FRanges[AIndex], 0);
- if AIndex = rngY then
- FPointsNumber := 0;
- Reset;
- exit;
- end;
-
// Extract range parameters and store them in FRanges
SetLength(FRanges[AIndex], Length(sa));
SetLength(FWorksheets[AIndex], Length(sa));
@@ -682,8 +699,8 @@ begin
Reset;
end else
if (Workbook.GetWorksheetCount > 0) then begin
- if FWorksheets[AIndex] = nil then
- exit;
+ if FWorksheets[AIndex, i] = nil then
+ raise Exception.Create('Worksheet not found in ' + sa[i]);
end;
end;
// Make sure to include worksheet name in RangeString.