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 adf97ac056
commit cdf7594b48
3 changed files with 25 additions and 3 deletions

View File

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

View File

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

View File

@ -23,9 +23,9 @@ uses
LCLVersion, Forms, Controls, Graphics, GraphUtil, Dialogs,
// TAChart
TATypes, TATextElements, TAChartUtils, TADrawUtils, TALegend,
TACustomSource, TASources, TACustomSeries, TASeries, TARadialSeries,
TAFitUtils, TAFuncSeries, TAMultiSeries, TATransformations,
TAChartAxisUtils, TAChartAxis, TAStyles, TATools, TAGraph,
TACustomSource, TASources, TACustomSeries, TAIntervalSources,
TASeries, TARadialSeries, TAFitUtils, TAFuncSeries, TAMultiSeries,
TATransformations, TAChartAxisUtils, TAChartAxis, TAStyles, TATools, TAGraph,
// FPSpreadsheet
fpsTypes, fpSpreadsheet, fpsUtils, fpsChart,
// FPSpreadsheet Visual
@ -1266,6 +1266,12 @@ begin
for j := FChart.AxisList[i].Minors.Count-1 downto 0 do
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
calLeft, calBottom:
FChart.AxisList[i].Title.Caption := '';
@ -1833,6 +1839,18 @@ begin
axis.Intervals.MinLength := 20;
axis.Intervals.Tolerance := 0;
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;
procedure TsWorkbookChartLink.UpdateChartAxisLabels(AWorkbookChart: TsChart);