@@ -232,6 +232,19 @@ const validateSeriesData = (series: Partial<PlotData>, validateNumericY: boolean
232
232
} ;
233
233
234
234
const validateBarData = ( data : Partial < PlotData > ) => {
235
+ const isXEmpty = data . x && isArrayOrTypedArray ( data . x ) && data . x . length === 0 ;
236
+ const isYEmpty = data . y && isArrayOrTypedArray ( data . y ) && data . y . length === 0 ;
237
+ if ( isXEmpty || isYEmpty ) {
238
+ let emptyMsg = 'Bar chart: ' ;
239
+ if ( isXEmpty && isYEmpty ) {
240
+ emptyMsg += 'both x and y arrays are empty.' ;
241
+ } else if ( isXEmpty ) {
242
+ emptyMsg += 'x array is empty.' ;
243
+ } else if ( isYEmpty ) {
244
+ emptyMsg += 'y array is empty.' ;
245
+ }
246
+ throw new Error ( emptyMsg ) ;
247
+ }
235
248
if ( data . orientation === 'h' ) {
236
249
if ( ! isNumberArray ( data . x ) && ! isDateArray ( data . x ) ) {
237
250
throw new Error (
@@ -245,8 +258,10 @@ const validateBarData = (data: Partial<PlotData>) => {
245
258
) ;
246
259
}
247
260
validateSeriesData ( data , false ) ;
248
- } else if ( ! isNumberArray ( data . y ) && ! isStringArray ( data . y ) && ! isObjectArray ( data . y ) ) {
249
- throw new Error ( `Non numeric, string, or object Y values encountered, type: ${ typeof data . y } ` ) ;
261
+ } else {
262
+ if ( ! isNumberArray ( data . y ) && ! isStringArray ( data . y ) && ! isObjectArray ( data . y ) ) {
263
+ throw new Error ( `Non numeric, string, or object Y values encountered, type: ${ typeof data . y } ` ) ;
264
+ }
250
265
}
251
266
} ;
252
267
const isScatterMarkers = ( mode : string ) : boolean => {
0 commit comments