diff --git a/components/fpspreadsheet/source/common/fpschart.pas b/components/fpspreadsheet/source/common/fpschart.pas index 5f5db8240..a87ff87b9 100644 --- a/components/fpspreadsheet/source/common/fpschart.pas +++ b/components/fpspreadsheet/source/common/fpschart.pas @@ -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; diff --git a/components/fpspreadsheet/source/common/fpsopendocumentchart.pas b/components/fpspreadsheet/source/common/fpsopendocumentchart.pas index e052bf232..95a5f4fa0 100644 --- a/components/fpspreadsheet/source/common/fpsopendocumentchart.pas +++ b/components/fpspreadsheet/source/common/fpsopendocumentchart.pas @@ -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; diff --git a/components/fpspreadsheet/source/visual/fpspreadsheetchart.pas b/components/fpspreadsheet/source/visual/fpspreadsheetchart.pas index 709b9b497..2c55b6a52 100644 --- a/components/fpspreadsheet/source/visual/fpspreadsheetchart.pas +++ b/components/fpspreadsheet/source/visual/fpspreadsheetchart.pas @@ -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);