forked from academiadocodigo/TBGWebCharts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Charts.Options.pas
126 lines (123 loc) · 3.85 KB
/
Charts.Options.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
unit Charts.Options;
interface
uses
Interfaces;
type
TModelHTMLChartsOptions = class(TInterfacedObject, iModelHTMLOptions)
private
FParent : iModelHTMLChartsConfig;
FScales : iModelHTMLScales;
FLegend : iModelHTMLLegend;
FTitle : iModelHTMLTitle<iModelHTMLOptions>;
FTooltip : iModelHTMLTooltip<iModelHTMLOptions>;
FSemiCircule : Boolean;
FPlugins : iModelHTMLPlugins;
FSkipEmptyData : Boolean;
FHideLabelEmptyData : Boolean;
public
constructor Create(Parent : iModelHTMLChartsConfig);
destructor Destroy; override;
class function New(Parent : iModelHTMLChartsConfig) : iModelHTMLOptions;
function HideLabelEmptyData(Value : Boolean) : iModelHTMLOptions;
function Legend : iModelHTMLLegend;
function Plugins : iModelHTMLPlugins;
function Result : String;
function Scales : iModelHTMLScales;
function SemiCircule ( Value : Boolean ) : iModelHTMLOptions;
function SkipEmptyData(Value : Boolean) : iModelHTMLOptions;
function Title : iModelHTMLTitle<iModelHTMLOptions>;
function Tooltip : iModelHTMLTooltip<iModelHTMLOptions>;
function &End : iModelHTMLChartsConfig;
end;
implementation
uses
Charts.Scales,
Charts.Legends,
Charts.Title,
Charts.Tooltip,
Injection,
Charts.Plugins, System.SysUtils;
{ TModelHTMLChartsOptions<T> }
function TModelHTMLChartsOptions.&End: iModelHTMLChartsConfig;
begin
Result := FParent;
end;
function TModelHTMLChartsOptions.HideLabelEmptyData(
Value: Boolean): iModelHTMLOptions;
begin
Result := Self;
FHideLabelEmptyData := Value;
end;
function TModelHTMLChartsOptions.Legend: iModelHTMLLegend;
begin
Result := FLegend;
end;
constructor TModelHTMLChartsOptions.Create(Parent : iModelHTMLChartsConfig);
begin
{$IF RTLVERSION > 27 }
TInjection.Weak(@FParent, Parent);
{$ELSE}
FParent := Parent;
{$IFEND}
FScales := TModelHTMLChartsScales.New(Self);
FLegend := TModelHTMLChartsLegends.New(Self);
FTitle := TModelHTMLChartsTitle<iModelHTMLOptions>.New(Self);
FTooltip := TModelHTMLChartsTooltip<iModelHTMLOptions>.New(Self);
FPlugins := TModelHtmlChartsPlugins.New(Self);
end;
destructor TModelHTMLChartsOptions.Destroy;
begin
inherited;
end;
class function TModelHTMLChartsOptions.New(Parent : iModelHTMLChartsConfig): iModelHTMLOptions;
begin
Result := Self.Create(Parent);
end;
function TModelHTMLChartsOptions.Plugins: iModelHTMLPlugins;
begin
Result := FPlugins;
end;
function TModelHTMLChartsOptions.Result: String;
begin
Result := '';
Result := Result + 'options: { ';
if FSemiCircule then
begin
Result := Result + 'circumference : Math.PI, ';
Result := Result + 'rotation : -Math.PI, ';
end;
Result := Result + FScales.Result;
Result := Result + FLegend.Result;
Result := Result + FTitle.Result;
Result := Result + FTooltip.Result;
Result := Result + ' responsive: true, ';
Result := Result + FPlugins.Result;
Result := Format('%s skipEmptyData: %s,', [Result, LowerCase(BoolToStr(FSkipEmptyData, true))]);
Result := Format('%s hideLabelEmptyData: %s,', [Result, LowerCase(BoolToStr(FHideLabelEmptyData, true))]);
Result := Result + '}';
end;
function TModelHTMLChartsOptions.Scales: iModelHTMLScales;
begin
Result := FScales;
end;
function TModelHTMLChartsOptions.SemiCircule(
Value: Boolean): iModelHTMLOptions;
begin
Result := Self;
FSemiCircule := Value;
end;
function TModelHTMLChartsOptions.SkipEmptyData(
Value: Boolean): iModelHTMLOptions;
begin
Result := Self;
FSkipEmptyData := Value;
end;
function TModelHTMLChartsOptions.Title: iModelHTMLTitle<iModelHTMLOptions>;
begin
Result := FTitle;
end;
function TModelHTMLChartsOptions.Tooltip: iModelHTMLTooltip<iModelHTMLOptions>;
begin
Result := FTooltip;
end;
end.