@@ -47,7 +47,7 @@ export interface IPivotDateDimensionOptions {
47
47
export class IgxPivotDateDimension implements IPivotDimension {
48
48
/** Enables/Disables a particular dimension from pivot structure. */
49
49
public enabled = true ;
50
-
50
+
51
51
/**
52
52
* Gets/Sets data type
53
53
*/
@@ -75,12 +75,57 @@ export class IgxPivotDateDimension implements IPivotDimension {
75
75
return this . _resourceStrings ;
76
76
}
77
77
78
+ /**
79
+ * Gets/Sets the base dimension that is used by this class to determine the other dimensions and their values.
80
+ * Having base dimension set is required in order for the Date Dimensions to show.
81
+ */
82
+ public get baseDimension ( ) : IPivotDimension {
83
+ return this . _baseDimension ;
84
+ }
85
+ public set baseDimension ( value : IPivotDimension ) {
86
+ this . _baseDimension = value ;
87
+ this . initialize ( this . baseDimension , this . options ) ;
88
+ }
89
+
90
+ /**
91
+ * Gets/Sets the options for the predefined date dimensions whether to show quarter, years and etc.
92
+ */
93
+ public get options ( ) : IPivotDateDimensionOptions {
94
+ return this . _options ;
95
+ }
96
+ public set options ( value : IPivotDateDimensionOptions ) {
97
+ this . _options = value ;
98
+ if ( this . baseDimension ) {
99
+ this . initialize ( this . baseDimension , this . options ) ;
100
+ }
101
+ }
102
+
103
+ /**
104
+ * @deprecated in version 15.1.x. Please use the new `options`
105
+ *
106
+ * Gets the base dimension that is used by this class to determine the other dimensions and their values.
107
+ * Having base dimension set is required in order for the Date Dimensions to show.
108
+ */
109
+ public get inBaseDimension ( ) : IPivotDimension {
110
+ return this . _baseDimension ;
111
+ }
112
+
113
+ /**
114
+ * @deprecated in version 15.1.x. Please use the new `options`
115
+ *
116
+ * Gets the options for the predefined date dimensions whether to show quarter, years and etc.
117
+ */
118
+ public get inOptions ( ) : IPivotDateDimensionOptions {
119
+ return this . _options ;
120
+ }
121
+
78
122
/** @hidden @internal */
79
123
public childLevel ?: IPivotDimension ;
80
124
/** @hidden @internal */
81
125
public memberName = 'AllPeriods' ;
82
126
private _resourceStrings = CurrentResourceStrings . GridResStrings ;
83
-
127
+ private _baseDimension : IPivotDimension ;
128
+ private _options : IPivotDateDimensionOptions = { } ;
84
129
/**
85
130
* Creates additional pivot date dimensions based on a provided dimension describing date data:
86
131
*
@@ -92,13 +137,16 @@ export class IgxPivotDateDimension implements IPivotDimension {
92
137
* new IgxPivotDateDimension({ memberName: 'Date', enabled: true }, { total: false, months: false });
93
138
* ```
94
139
*/
95
- constructor ( public inBaseDimension : IPivotDimension , public inOptions : IPivotDateDimensionOptions = { } ) {
96
- const options = { ...this . defaultOptions , ...inOptions } ;
97
-
98
- if ( ! inBaseDimension ) {
99
- console . warn ( `Please provide data child level to the pivot dimension.` ) ;
100
- return ;
140
+ constructor ( private _inBaseDimension : IPivotDimension , private _inOptions : IPivotDateDimensionOptions = { } ) {
141
+ this . _options = _inOptions ;
142
+ this . _baseDimension = _inBaseDimension ;
143
+ if ( this . baseDimension && this . options ) {
144
+ this . initialize ( this . baseDimension , this . options ) ;
101
145
}
146
+ }
147
+
148
+ protected initialize ( inBaseDimension , inOptions ) {
149
+ const options = { ...this . defaultOptions , ...inOptions } ;
102
150
103
151
this . dataType = GridColumnDataType . Date ;
104
152
inBaseDimension . dataType = GridColumnDataType . Date ;
0 commit comments