You've already forked lazarus-ccr
fpspreadsheet: More on date/time formats for axis labels.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9074 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -64,8 +64,11 @@ end;
|
|||||||
|
|
||||||
procedure TForm1.ComboBox1CloseUp(Sender: TObject);
|
procedure TForm1.ComboBox1CloseUp(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
Combobox1.Text := Combobox1.Items[Combobox1.ItemIndex];
|
if ComboBox1.ItemIndex > -1 then
|
||||||
LoadFile(Combobox1.Text);
|
begin
|
||||||
|
Combobox1.Text := Combobox1.Items[Combobox1.ItemIndex];
|
||||||
|
LoadFile(Combobox1.Text);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.FormCreate(Sender: TObject);
|
procedure TForm1.FormCreate(Sender: TObject);
|
||||||
|
@ -247,6 +247,8 @@ type
|
|||||||
FInverted: Boolean;
|
FInverted: Boolean;
|
||||||
FLabelFont: TsFont;
|
FLabelFont: TsFont;
|
||||||
FLabelFormat: String;
|
FLabelFormat: String;
|
||||||
|
FLabelFormatFromSource: Boolean;
|
||||||
|
FLabelFormatDateTime: String;
|
||||||
FLabelFormatPercent: String;
|
FLabelFormatPercent: String;
|
||||||
FLabelRotation: Integer;
|
FLabelRotation: Integer;
|
||||||
FLogarithmic: Boolean;
|
FLogarithmic: Boolean;
|
||||||
@ -274,6 +276,8 @@ type
|
|||||||
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;
|
||||||
|
property LabelFormatDateTime: String read FLabelFormatDateTime write FLabelFormatDateTime;
|
||||||
|
property LabelFormatFromSource: Boolean read FLabelFormatFromSource write FLabelFormatFromSource;
|
||||||
property LabelFormatPercent: String read FLabelFormatPercent write FLabelFormatPercent;
|
property LabelFormatPercent: String read FLabelFormatPercent write FLabelFormatPercent;
|
||||||
property LabelRotation: Integer read FLabelRotation write FLabelRotation;
|
property LabelRotation: Integer read FLabelRotation write FLabelRotation;
|
||||||
property Logarithmic: Boolean read FLogarithmic write FLogarithmic;
|
property Logarithmic: Boolean read FLogarithmic write FLogarithmic;
|
||||||
@ -1190,6 +1194,8 @@ begin
|
|||||||
FLabelFont.Style := [];
|
FLabelFont.Style := [];
|
||||||
FLabelFont.Color := scBlack;
|
FLabelFont.Color := scBlack;
|
||||||
|
|
||||||
|
FLabelFormatFromSource := true;
|
||||||
|
FLabelFormatDateTime := '';
|
||||||
FLabelFormatPercent := '0%';
|
FLabelFormatPercent := '0%';
|
||||||
FLabelRotation := 0;
|
FLabelRotation := 0;
|
||||||
FShowLabels := true;
|
FShowLabels := true;
|
||||||
|
@ -12,7 +12,8 @@ uses
|
|||||||
fpszipper,
|
fpszipper,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
laz2_xmlread, laz2_DOM,
|
laz2_xmlread, laz2_DOM,
|
||||||
fpsTypes, fpSpreadsheet, fpsChart, fpsUtils, fpsReaderWriter, fpsXMLCommon;
|
fpsTypes, fpSpreadsheet, fpsChart, fpsUtils, fpsNumFormat,
|
||||||
|
fpsReaderWriter, fpsXMLCommon;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -693,9 +694,15 @@ var
|
|||||||
ticks: TsChartAxisTicks = [];
|
ticks: TsChartAxisTicks = [];
|
||||||
begin
|
begin
|
||||||
nodeName := AStyleNode.NodeName;
|
nodeName := AStyleNode.NodeName;
|
||||||
|
|
||||||
s := GetAttrValue(AStyleNode, 'style:data-style-name');
|
s := GetAttrValue(AStyleNode, 'style:data-style-name');
|
||||||
if s <> '' then
|
if s <> '' then
|
||||||
s := TsChartNumberFormatList(FNumberFormatList).FindFormatByName(s);
|
s := TsChartNumberFormatList(FNumberFormatList).FindFormatByName(s);
|
||||||
|
if IsDateTimeFormat(s) then
|
||||||
|
begin
|
||||||
|
Axis.DateTime := true;
|
||||||
|
Axis.LabelFormatDateTime := s;
|
||||||
|
end else
|
||||||
if (AChart.StackMode = csmStackedPercentage) and ((Axis = AChart.YAxis) or (Axis = AChart.Y2Axis)) then
|
if (AChart.StackMode = csmStackedPercentage) and ((Axis = AChart.YAxis) or (Axis = AChart.Y2Axis)) then
|
||||||
Axis.LabelFormatPercent := s
|
Axis.LabelFormatPercent := s
|
||||||
else
|
else
|
||||||
|
@ -27,7 +27,7 @@ uses
|
|||||||
TASeries, TARadialSeries, TAFitUtils, TAFuncSeries, TAMultiSeries,
|
TASeries, TARadialSeries, TAFitUtils, TAFuncSeries, TAMultiSeries,
|
||||||
TATransformations, TAChartAxisUtils, TAChartAxis, TAStyles, TATools, TAGraph,
|
TATransformations, TAChartAxisUtils, TAChartAxis, TAStyles, TATools, TAGraph,
|
||||||
// FPSpreadsheet
|
// FPSpreadsheet
|
||||||
fpsTypes, fpSpreadsheet, fpsUtils, fpsChart,
|
fpsTypes, fpSpreadsheet, fpsUtils, fpsNumFormat, fpsChart,
|
||||||
// FPSpreadsheet Visual
|
// FPSpreadsheet Visual
|
||||||
fpSpreadsheetCtrls, fpSpreadsheetGrid, fpsVisualUtils;
|
fpSpreadsheetCtrls, fpSpreadsheetGrid, fpsVisualUtils;
|
||||||
|
|
||||||
@ -1141,7 +1141,7 @@ begin
|
|||||||
Result.Title := src.Title;
|
Result.Title := src.Title;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Assign series to axis for primary and secondary axes support
|
// Assign series index to axis for primary and secondary axes support
|
||||||
case ASeries.XAxis of
|
case ASeries.XAxis of
|
||||||
alPrimary:
|
alPrimary:
|
||||||
Result.AxisIndexX := FChart.AxisList.GetAxisByAlign(calBottom).Index;
|
Result.AxisIndexX := FChart.AxisList.GetAxisByAlign(calBottom).Index;
|
||||||
@ -1785,6 +1785,9 @@ begin
|
|||||||
// Labels
|
// Labels
|
||||||
Convert_sFont_to_Font(AWorkbookAxis.LabelFont, axis.Marks.LabelFont);
|
Convert_sFont_to_Font(AWorkbookAxis.LabelFont, axis.Marks.LabelFont);
|
||||||
axis.Marks.LabelFont.Orientation := round(AWorkbookAxis.LabelRotation * 10);
|
axis.Marks.LabelFont.Orientation := round(AWorkbookAxis.LabelRotation * 10);
|
||||||
|
if (AWorkbookAxis.LabelFormat <> '') and not IsDateTimeFormat(AWorkbookAxis.LabelFormat) then
|
||||||
|
axis.Marks.Format := Convert_NumFormatStr_to_FormatStr(AWorkbookAxis.LabelFormat);
|
||||||
|
|
||||||
|
|
||||||
// Axis line
|
// Axis line
|
||||||
UpdateChartPen(AWorkbookAxis.Chart, AWorkbookAxis.AxisLine, axis.AxisPen);
|
UpdateChartPen(AWorkbookAxis.Chart, AWorkbookAxis.AxisLine, axis.AxisPen);
|
||||||
@ -1839,9 +1842,34 @@ begin
|
|||||||
axis.Intervals.MinLength := 20;
|
axis.Intervals.MinLength := 20;
|
||||||
axis.Intervals.Tolerance := 0;
|
axis.Intervals.Tolerance := 0;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TsWorkbookChartLink.UpdateChartAxisLabels(AWorkbookChart: TsChart);
|
||||||
|
var
|
||||||
|
axis: TChartAxis;
|
||||||
|
begin
|
||||||
|
if FChart.SeriesCount = 0 then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
axis := FChart.BottomAxis;
|
||||||
|
case AWorkbookChart.GetChartType of
|
||||||
|
ctScatter, ctBubble:
|
||||||
|
begin
|
||||||
|
axis.Marks.Source := nil;
|
||||||
|
axis.Marks.Style := smsValue;
|
||||||
|
end;
|
||||||
|
ctBar, ctLine, ctArea:
|
||||||
|
begin
|
||||||
|
axis.Marks.Source := TChartSeries(FChart.Series[0]).Source;
|
||||||
|
if not AWorkbookChart.Series[0].LabelRange.IsEmpty then
|
||||||
|
axis.Marks.Style := smsLabel
|
||||||
|
else
|
||||||
|
axis.Marks.Style := smsXValue;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
// Date/time?
|
// Date/time?
|
||||||
if AWorkbookAxis.DateTime then
|
if AWorkbookChart.XAxis.DateTime then
|
||||||
begin
|
begin
|
||||||
axis.Marks.Source := TDateTimeIntervalChartsource.Create(FChart);
|
axis.Marks.Source := TDateTimeIntervalChartsource.Create(FChart);
|
||||||
axis.Marks.Style := smsLabel;
|
axis.Marks.Style := smsLabel;
|
||||||
@ -1853,28 +1881,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TsWorkbookChartLink.UpdateChartAxisLabels(AWorkbookChart: TsChart);
|
|
||||||
begin
|
|
||||||
if FChart.SeriesCount = 0 then
|
|
||||||
exit;
|
|
||||||
|
|
||||||
case AWorkbookChart.GetChartType of
|
|
||||||
ctScatter, ctBubble:
|
|
||||||
begin
|
|
||||||
FChart.BottomAxis.Marks.Source := nil;
|
|
||||||
FChart.BottomAxis.Marks.Style := smsValue;
|
|
||||||
end;
|
|
||||||
ctBar, ctLine, ctArea:
|
|
||||||
begin
|
|
||||||
FChart.BottomAxis.Marks.Source := TChartSeries(FChart.Series[0]).Source;
|
|
||||||
if not AWorkbookChart.Series[0].LabelRange.IsEmpty then
|
|
||||||
FChart.BottomAxis.Marks.Style := smsLabel
|
|
||||||
else
|
|
||||||
FChart.BottomAxis.Marks.Style := smsXValue;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TsWorkbookChartLink.UpdateChartBackground(AWorkbookChart: TsChart);
|
procedure TsWorkbookChartLink.UpdateChartBackground(AWorkbookChart: TsChart);
|
||||||
begin
|
begin
|
||||||
FChart.Color := Convert_sColor_to_Color(AWorkbookChart.Background.Color);
|
FChart.Color := Convert_sColor_to_Color(AWorkbookChart.Background.Color);
|
||||||
|
Reference in New Issue
Block a user