@@ -80,6 +80,7 @@ export class HorizontalBarChartRenderer extends BarChartRenderer {
80
80
buffer . setInverted ( this . mChart . isInverted ( dataSet . getAxisDependency ( ) ) ) ;
81
81
buffer . setBarWidth ( this . mChart . getBarData ( ) . getBarWidth ( ) ) ;
82
82
buffer . setYAxisMin ( this . mChart . getAxis ( dataSet . getAxisDependency ( ) ) . getAxisMinimum ( ) ) ;
83
+ buffer . setYAxisMax ( this . mChart . getAxis ( dataSet . getAxisDependency ( ) ) . getAxisMaximum ( ) ) ;
83
84
84
85
buffer . feed ( dataSet ) ;
85
86
@@ -161,16 +162,17 @@ export class HorizontalBarChartRenderer extends BarChartRenderer {
161
162
break ;
162
163
}
163
164
164
- if ( ! this . mViewPortHandler . isInBoundsX ( buffer . buffer [ isInverted ? ( j + 2 ) : j ] ) ) {
165
+ const entry = dataSet . getEntryForIndex ( j / 4 ) ;
166
+ const val = entry [ yKey ] ;
167
+
168
+ if ( ! this . mViewPortHandler . isInBoundsX ( buffer . buffer [ j + ( val >= 0 ? 0 : 2 ) ] ) ) {
165
169
continue ;
166
170
}
167
171
168
172
if ( ! this . mViewPortHandler . isInBoundsBottom ( buffer . buffer [ j + 1 ] ) ) {
169
173
continue ;
170
174
}
171
175
172
- const entry = dataSet . getEntryForIndex ( j / 4 ) ;
173
- const val = entry [ yKey ] ;
174
176
const formattedValue = formatter . getBarLabel ( entry , dataSet ) ;
175
177
176
178
// calculate the correct offset depending on the draw position of the value
@@ -184,13 +186,15 @@ export class HorizontalBarChartRenderer extends BarChartRenderer {
184
186
}
185
187
186
188
if ( dataSet . isDrawValuesEnabled ( ) ) {
187
- this . drawValue ( c , formattedValue , isInverted ? ( buffer . buffer [ j ] - negOffset ) : ( buffer . buffer [ j + 2 ] + posOffset ) , y + halfTextHeight , dataSet . getValueTextColor ( j / 2 ) ) ;
189
+ this . drawValue ( c , formattedValue ,
190
+ val >= 0 ? ( buffer . buffer [ j + 2 ] + posOffset ) : ( buffer . buffer [ j + 0 ] + negOffset ) ,
191
+ y + halfTextHeight , dataSet . getValueTextColor ( j / 2 ) ) ;
188
192
}
189
193
190
194
if ( entry . icon != null && dataSet . isDrawIconsEnabled ( ) ) {
191
195
const icon = entry . icon ;
192
196
193
- let px = isInverted ? ( buffer . buffer [ j ] - negOffset ) : ( buffer . buffer [ j + 2 ] + posOffset ) ;
197
+ let px = val >= 0 ? ( buffer . buffer [ j + 2 ] + posOffset ) : ( buffer . buffer [ j + 0 ] + negOffset ) ;
194
198
let py = y ;
195
199
196
200
px += iconsOffset . x ;
@@ -221,7 +225,7 @@ export class HorizontalBarChartRenderer extends BarChartRenderer {
221
225
break ;
222
226
}
223
227
224
- if ( ! this . mViewPortHandler . isInBoundsX ( buffer . buffer [ isInverted ? ( bufferIndex + 2 ) : bufferIndex ] ) ) {
228
+ if ( ! this . mViewPortHandler . isInBoundsX ( buffer . buffer [ bufferIndex + ( entry [ yKey ] >= 0 ? 0 : 2 ) ] ) ) {
225
229
continue ;
226
230
}
227
231
@@ -242,13 +246,15 @@ export class HorizontalBarChartRenderer extends BarChartRenderer {
242
246
}
243
247
244
248
if ( dataSet . isDrawValuesEnabled ( ) ) {
245
- this . drawValue ( c , formattedValue , isInverted ? ( buffer . buffer [ bufferIndex ] - negOffset ) : ( buffer . buffer [ bufferIndex + 2 ] + posOffset ) , buffer . buffer [ bufferIndex + 1 ] + halfTextHeight , color ) ;
249
+ this . drawValue ( c , formattedValue ,
250
+ entry [ yKey ] >= 0 ? ( buffer . buffer [ bufferIndex + 2 ] + posOffset ) : ( buffer . buffer [ bufferIndex + 0 ] + negOffset ) ,
251
+ buffer . buffer [ bufferIndex + 1 ] + halfTextHeight , color ) ;
246
252
}
247
253
248
254
if ( entry . icon != null && dataSet . isDrawIconsEnabled ( ) ) {
249
255
const icon = entry . icon ;
250
256
251
- let px = isInverted ? ( buffer . buffer [ bufferIndex ] - negOffset ) : ( buffer . buffer [ bufferIndex + 2 ] + posOffset ) ;
257
+ let px = entry [ yKey ] >= 0 ? ( buffer . buffer [ bufferIndex + 2 ] + posOffset ) : ( buffer . buffer [ bufferIndex + 0 ] + negOffset ) ;
252
258
let py = buffer . buffer [ bufferIndex + 1 ] ;
253
259
254
260
px += iconsOffset . x ;
0 commit comments