@@ -192,14 +192,6 @@ function alertAndThrow(err: string) {
192
192
throw new Error ( err ) ;
193
193
}
194
194
195
- // converts to true|undefined an option from an excel cell
196
- function boolOption ( cell : undefined | null | string | boolean ) : true | undefined {
197
- if ( ! cell || cell === 'false' ) {
198
- return undefined ;
199
- }
200
- return true ;
201
- }
202
-
203
195
function _buildChart ( name : string , sheet : { [ key : string ] : string } [ ] ) : AjfWidget {
204
196
if ( sheet == null || sheet . length === 0 ) {
205
197
alertAndThrow ( 'Empty sheet for chart ' + name ) ;
@@ -211,6 +203,12 @@ function _buildChart(name: string, sheet: {[key: string]: string}[]): AjfWidget
211
203
'stacked' ,
212
204
'beginAtZeroX' ,
213
205
'beginAtZeroY' ,
206
+ 'axisLabelX' ,
207
+ 'axisLabelY' ,
208
+ 'axisMinX' ,
209
+ 'axisMinY' ,
210
+ 'axisMaxX' ,
211
+ 'axisMaxY' ,
214
212
'removeZeroValues' ,
215
213
'mainDataNumberThreshold' ,
216
214
] ;
@@ -247,9 +245,15 @@ function _buildChart(name: string, sheet: {[key: string]: string}[]): AjfWidget
247
245
labelsFormula = { formula : labelsJs } ;
248
246
}
249
247
250
- const stacked = boolOption ( options [ 'stacked' ] ) ;
251
- const beginAtZeroX = boolOption ( options [ 'beginAtZeroX' ] ) ;
252
- const beginAtZeroY = boolOption ( options [ 'beginAtZeroY' ] ) ;
248
+ const stacked = Boolean ( options [ 'stacked' ] ) ;
249
+ const beginAtZeroX = Boolean ( options [ 'beginAtZeroX' ] ) ;
250
+ const beginAtZeroY = Boolean ( options [ 'beginAtZeroY' ] ) ;
251
+ const axisLabelX = options [ 'axisLabelX' ] ;
252
+ const axisLabelY = options [ 'axisLabelY' ] ;
253
+ const axisMinX = options [ 'axisMinX' ] ;
254
+ const axisMinY = options [ 'axisMinY' ] ;
255
+ const axisMaxX = options [ 'axisMaxX' ] ;
256
+ const axisMaxY = options [ 'axisMaxY' ] ;
253
257
const removeZeroValues =
254
258
options [ 'removeZeroValues' ] != null ? Boolean ( options [ 'removeZeroValues' ] ) : true ;
255
259
const mainDataNumberThreshold =
@@ -310,11 +314,37 @@ function _buildChart(name: string, sheet: {[key: string]: string}[]): AjfWidget
310
314
} ) ;
311
315
312
316
const scales : Chart . ChartScales = { } ;
313
- if ( stacked || beginAtZeroX ) {
314
- scales . xAxes = [ { stacked, ticks : beginAtZeroX ? { beginAtZero : true } : undefined } ] ;
317
+ if ( stacked || beginAtZeroX || axisMinX != null || axisMaxX != null || axisLabelX ) {
318
+ const axisX : Chart . ChartXAxe = {
319
+ stacked,
320
+ ticks : { beginAtZero : beginAtZeroX } ,
321
+ } ;
322
+ if ( axisMinX != null ) {
323
+ axisX . ticks ! . suggestedMin = Number ( axisMinX ) ;
324
+ }
325
+ if ( axisMaxX != null ) {
326
+ axisX . ticks ! . suggestedMax = Number ( axisMaxX ) ;
327
+ }
328
+ if ( axisLabelX ) {
329
+ axisX . scaleLabel = { display : true , labelString : axisLabelX } ;
330
+ }
331
+ scales . xAxes = [ axisX ] ;
315
332
}
316
- if ( stacked || beginAtZeroY ) {
317
- scales . yAxes = [ { stacked, ticks : { beginAtZero : true } } ] ;
333
+ if ( stacked || beginAtZeroY || axisMinY != null || axisMaxY != null || axisLabelY ) {
334
+ const axisY : Chart . ChartYAxe = {
335
+ stacked,
336
+ ticks : { beginAtZero : stacked || beginAtZeroY } ,
337
+ } ;
338
+ if ( axisMinY != null ) {
339
+ axisY . ticks ! . suggestedMin = Number ( axisMinY ) ;
340
+ }
341
+ if ( axisMaxY != null ) {
342
+ axisY . ticks ! . suggestedMax = Number ( axisMaxY ) ;
343
+ }
344
+ if ( axisLabelY ) {
345
+ axisY . scaleLabel = { display : true , labelString : axisLabelY } ;
346
+ }
347
+ scales . yAxes = [ axisY ] ;
318
348
}
319
349
return createWidget ( {
320
350
name,
0 commit comments