11
22package com .github .mikephil .charting .charts ;
33
4- import android .animation .Animator ;
5- import android .animation .ObjectAnimator ;
6- import android .annotation .TargetApi ;
74import android .content .Context ;
85import android .graphics .Color ;
96import android .graphics .Paint ;
10- import android .graphics .Path ;
117import android .graphics .RectF ;
12- import android .os .Build ;
138import android .util .AttributeSet ;
149import android .util .Log ;
1510
@@ -171,10 +166,10 @@ public void setData(BarData data) {
171166 protected void calcMinMax (boolean fixedValues ) {
172167 super .calcMinMax (fixedValues );
173168
174- if (!mStartAtZero && getYMin () >= 0f ) {
175- mYChartMin = getYMin ();
176- mDeltaY = Math .abs (mYChartMax - mYChartMin );
177- }
169+ // if (!mStartAtZero && getYMin() >= 0f) {
170+ // mYChartMin = getYMin();
171+ // mDeltaY = Math.abs(mYChartMax - mYChartMin);
172+ // }
178173
179174 // increase deltax by 1 because the bars have a width of 1
180175 mDeltaX ++;
@@ -186,9 +181,6 @@ protected void drawHighlights() {
186181 // if there are values to highlight and highlighnting is enabled, do it
187182 if (mHighlightEnabled && mHighLightIndicatorEnabled && valuesToHighlight ()) {
188183
189- // distance between highlight arrow and bar
190- float offsetY = mDeltaY * 0.04f ;
191-
192184 for (int i = 0 ; i < mIndicesToHightlight .length ; i ++) {
193185
194186 Highlight h = mIndicesToHightlight [i ];
@@ -204,30 +196,26 @@ protected void drawHighlights() {
204196
205197 Entry e = getEntryByDataSetIndex (index , dataSetIndex );
206198
207- float y = e .getSum () * mPhaseY ;
208- float top = y >= 0 ? y : 0 ;
209- float bottom = y <= 0 ? y : 0 ;
210-
211- float left = index + ds .getBarSpace () / 2f ;
212- float right = index + 1f - ds .getBarSpace () / 2f ;
213-
214- RectF highlight = new RectF (left , top , right , bottom );
215- transformRect (highlight );
216-
217- mDrawCanvas .drawRect (highlight , mHighlightPaint );
218-
219- if (mDrawHighlightArrow ) {
220-
221- mHighlightPaint .setAlpha (200 );
222-
223- Path arrow = new Path ();
224- arrow .moveTo (index + 0.5f , y + offsetY * 0.3f );
225- arrow .lineTo (index + 0.2f , y + offsetY );
226- arrow .lineTo (index + 0.8f , y + offsetY );
227-
228- transformPath (arrow );
229- mDrawCanvas .drawPath (arrow , mHighlightPaint );
230- }
199+ prepareBar (e .getXIndex (), e .getSum (), ds .getBarSpace ());
200+
201+ mDrawCanvas .drawRect (mBarRect , mHighlightPaint );
202+
203+ // if (mDrawHighlightArrow) {
204+ //
205+ //
206+ // // distance between highlight arrow and bar
207+ // float offsetY = mDeltaY * 0.04f;
208+ //
209+ // mHighlightPaint.setAlpha(200);
210+ //
211+ // Path arrow = new Path();
212+ // arrow.moveTo(index + 0.5f, y + offsetY * 0.3f);
213+ // arrow.lineTo(index + 0.2f, y + offsetY);
214+ // arrow.lineTo(index + 0.8f, y + offsetY);
215+ //
216+ // transformPath(arrow);
217+ // mDrawCanvas.drawPath(arrow, mHighlightPaint);
218+ // }
231219 }
232220 }
233221 }
@@ -339,14 +327,15 @@ protected void drawData() {
339327 */
340328 private void prepareBar (float x , float y , float space ) {
341329
342- float left = x + space / 2f ;
343- float right = x + 1f - space / 2f ;
344- float top = (y >= 0 ? y : 0 ) * mPhaseY ;
345- float bottom = (y <= 0 ? y : 0 ) * mPhaseY ;
330+ float spaceHalf = space / 2f ;
331+ float left = x + spaceHalf ;
332+ float right = x + 1f - spaceHalf ;
333+ float top = y >= 0 ? y : 0 ;
334+ float bottom = y <= 0 ? y : 0 ;
346335
347336 mBarRect .set (left , top , right , bottom );
348337
349- transformRect (mBarRect );
338+ transformRectWithPhase (mBarRect );
350339
351340 // if a shadow is drawn, prepare it too
352341 if (mDrawBarShadow ) {
0 commit comments