fpspreadsheet: Support date/time axis in stockseries

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9073 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-12-06 13:28:50 +00:00
parent a203cac202
commit 9cf4d83c2d
3 changed files with 25 additions and 3 deletions

View File

@ -260,6 +260,7 @@ type
FTitle: TsChartText; FTitle: TsChartText;
FPositionValue: Double; FPositionValue: Double;
FShowLabels: Boolean; FShowLabels: Boolean;
FDateTime: Boolean;
public public
constructor Create(AChart: TsChart); constructor Create(AChart: TsChart);
destructor Destroy; override; destructor Destroy; override;
@ -269,6 +270,7 @@ type
property AutomaticMinorSteps: Boolean read FAutomaticMinorSteps write FAutomaticMinorSteps; property AutomaticMinorSteps: Boolean read FAutomaticMinorSteps write FAutomaticMinorSteps;
property AxisLine: TsChartLine read FAxisLine write FAxisLine; property AxisLine: TsChartLine read FAxisLine write FAxisLine;
property CategoryRange: TsChartRange read FCategoryRange write FCategoryRange; property CategoryRange: TsChartRange read FCategoryRange write FCategoryRange;
property DateTime: Boolean read FDateTime write FDateTime;
property Inverted: Boolean read FInverted write FInverted; property Inverted: Boolean read FInverted write FInverted;
property LabelFont: TsFont read FLabelFont write FLabelFont; property LabelFont: TsFont read FLabelFont write FLabelFont;
property LabelFormat: String read FLabelFormat write FLabelFormat; property LabelFormat: String read FLabelFormat write FLabelFormat;

View File

@ -676,6 +676,8 @@ begin
ReadChartCellRange(subNode, 'table:cell-range-address', axis.CategoryRange); ReadChartCellRange(subNode, 'table:cell-range-address', axis.CategoryRange);
'chart:grid': 'chart:grid':
ReadChartAxisGrid(subNode, AStyleNode, AChart, axis); ReadChartAxisGrid(subNode, AStyleNode, AChart, axis);
'chartooo:date-scale':
axis.DateTime := true;
end; end;
subNode := subNode.NextSibling; subNode := subNode.NextSibling;
end; end;

View File

@ -23,9 +23,9 @@ uses
LCLVersion, Forms, Controls, Graphics, GraphUtil, Dialogs, LCLVersion, Forms, Controls, Graphics, GraphUtil, Dialogs,
// TAChart // TAChart
TATypes, TATextElements, TAChartUtils, TADrawUtils, TALegend, TATypes, TATextElements, TAChartUtils, TADrawUtils, TALegend,
TACustomSource, TASources, TACustomSeries, TASeries, TARadialSeries, TACustomSource, TASources, TACustomSeries, TAIntervalSources,
TAFitUtils, TAFuncSeries, TAMultiSeries, TATransformations, TASeries, TARadialSeries, TAFitUtils, TAFuncSeries, TAMultiSeries,
TAChartAxisUtils, TAChartAxis, TAStyles, TATools, TAGraph, TATransformations, TAChartAxisUtils, TAChartAxis, TAStyles, TATools, TAGraph,
// FPSpreadsheet // FPSpreadsheet
fpsTypes, fpSpreadsheet, fpsUtils, fpsChart, fpsTypes, fpSpreadsheet, fpsUtils, fpsChart,
// FPSpreadsheet Visual // FPSpreadsheet Visual
@ -1266,6 +1266,12 @@ begin
for j := FChart.AxisList[i].Minors.Count-1 downto 0 do for j := FChart.AxisList[i].Minors.Count-1 downto 0 do
FChart.AxisList[i].Minors.Delete(j); FChart.AxisList[i].Minors.Delete(j);
if (FChart.AxisList[i].Marks.Source is TDateTimeIntervalChartSource) then
begin
FChart.AxisList[i].Marks.Source.Free;
FChart.AxisList[i].Marks.Style := smsValue;
end;
case FChart.AxisList[i].Alignment of case FChart.AxisList[i].Alignment of
calLeft, calBottom: calLeft, calBottom:
FChart.AxisList[i].Title.Caption := ''; FChart.AxisList[i].Title.Caption := '';
@ -1833,6 +1839,18 @@ begin
axis.Intervals.MinLength := 20; axis.Intervals.MinLength := 20;
axis.Intervals.Tolerance := 0; axis.Intervals.Tolerance := 0;
end; end;
// Date/time?
if AWorkbookAxis.DateTime then
begin
axis.Marks.Source := TDateTimeIntervalChartsource.Create(FChart);
axis.Marks.Style := smsLabel;
with TDateTimeIntervalChartSource(axis.Marks.Source) do
begin
Params.MaxLength := 120;
SuppressPrevUnit := false;
end;
end;
end; end;
procedure TsWorkbookChartLink.UpdateChartAxisLabels(AWorkbookChart: TsChart); procedure TsWorkbookChartLink.UpdateChartAxisLabels(AWorkbookChart: TsChart);