File tree 2 files changed +18
-6
lines changed
2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,9 @@ export class XAxisRenderer extends AxisRenderer {
158
158
const labelRotationAngleDegrees = axis . getLabelRotationAngle ( ) ;
159
159
const centeringEnabled = axis . isCenterAxisLabelsEnabled ( ) ;
160
160
const entryCount = axis . mEntryCount ;
161
+ if ( entryCount === 0 ) {
162
+ return ;
163
+ }
161
164
const length = entryCount * 2 ;
162
165
if ( this . labelsPositionsBuffer . length !== length ) {
163
166
this . labelsPositionsBuffer = Utils . createArrayBuffer ( length ) ;
Original file line number Diff line number Diff line change @@ -119,17 +119,26 @@ export class XAxisRendererHorizontalBarChart extends XAxisRenderer {
119
119
const axis = this . mXAxis ;
120
120
const labelRotationAngleDegrees = axis . getLabelRotationAngle ( ) ;
121
121
const centeringEnabled = axis . isCenterAxisLabelsEnabled ( ) ;
122
-
123
- const positions = Utils . createNativeArray ( axis . mEntryCount * 2 ) ;
124
-
125
- for ( let i = 0 ; i < positions . length ; i += 2 ) {
122
+ const entryCount = axis . mEntryCount ;
123
+ if ( entryCount === 0 ) {
124
+ return ;
125
+ }
126
+ if ( this . labelsPositionsBuffer . length !== length ) {
127
+ this . labelsPositionsBuffer = Utils . createArrayBuffer ( length ) ;
128
+ }
129
+ const positionsBuffer = this . labelsPositionsBuffer ;
130
+ for ( let i = 0 ; i < length ; i += 2 ) {
126
131
// only fill x values
127
132
if ( centeringEnabled ) {
128
- positions [ i + 1 ] = axis . mCenteredEntries [ i / 2 ] ;
133
+ positionsBuffer [ i ] = axis . mCenteredEntries [ i / 2 ] ;
129
134
} else {
130
- positions [ i + 1 ] = axis . mEntries [ i / 2 ] ;
135
+ positionsBuffer [ i ] = axis . mEntries [ i / 2 ] ;
136
+ }
137
+ if ( i + 1 < length ) {
138
+ positionsBuffer [ i + 1 ] = 0 ;
131
139
}
132
140
}
141
+ const positions = Utils . pointsFromBuffer ( positionsBuffer ) ;
133
142
134
143
this . mTrans . pointValuesToPixel ( positions ) ;
135
144
const labels = axis . mLabels ;
You can’t perform that action at this time.
0 commit comments