Commits

jmpascal committed 35f5033

Create a new parameter for BarChart : Show/Hide Axis.

Comments (0)

Files changed (1)

HoloGraphLibrary/src/com/echo/holographlibrary/BarGraph.java

     private Paint mPaint = new Paint();
     private Rect mRectangle = null;
     private boolean mShowBarText = true;
+    private boolean mShowAxis = true;
     private int mIndexSelected = -1;
     private OnBarClickedListener mListener;
     private Bitmap mFullImage;
         mShowBarText = show;
     }
     
+    public void setShowAxis(boolean show){
+        mShowAxis = show;
+    }
+    
     public void setBars(ArrayList<Bar> points){
         this.mBars = points;
         mShouldUpdate = true;
             }
              
             // Draw x-axis line
-            mPaint.setColor(Color.BLACK);
-            mPaint.setStrokeWidth(2 * mContext.getResources().getDisplayMetrics().density);
-            mPaint.setAlpha(50);
-            mPaint.setAntiAlias(true);
-            canvas.drawLine(0, getHeight()-bottomPadding+10* mContext.getResources().getDisplayMetrics().density, getWidth(), getHeight()-bottomPadding+10* mContext.getResources().getDisplayMetrics().density, mPaint);
-            
+            if (mShowAxis){
+                mPaint.setColor(Color.BLACK);
+                mPaint.setStrokeWidth(2 * mContext.getResources().getDisplayMetrics().density);
+                mPaint.setAlpha(50);
+                mPaint.setAntiAlias(true);
+                canvas.drawLine(0, getHeight()-bottomPadding+10* mContext.getResources().getDisplayMetrics().density, getWidth(), getHeight()-bottomPadding+10* mContext.getResources().getDisplayMetrics().density, mPaint);
+            }
             float barWidth = (getWidth() - (padding*2)*mBars.size())/mBars.size();
 
             // Maximum y value = sum of all values.
                 bar.setRegion(new Region(mRectangle.left-selectPadding, mRectangle.top-selectPadding, mRectangle.right+selectPadding, mRectangle.bottom+selectPadding));
 
                 // Draw x-axis label text
-                this.mPaint.setTextSize(AXIS_LABEL_FONT_SIZE * mContext.getResources().getDisplayMetrics().scaledDensity);
-                int x = (int)(((mRectangle.left+mRectangle.right)/2)-(this.mPaint.measureText(bar.getName())/2));
-                int y = (int) (getHeight()-3 * mContext.getResources().getDisplayMetrics().scaledDensity);
-                canvas.drawText(bar.getName(), x, y, this.mPaint);
+                if (mShowAxis){
+                    this.mPaint.setTextSize(AXIS_LABEL_FONT_SIZE * mContext.getResources().getDisplayMetrics().scaledDensity);
+                    int x = (int)(((mRectangle.left+mRectangle.right)/2)-(this.mPaint.measureText(bar.getName())/2));
+                    int y = (int) (getHeight()-3 * mContext.getResources().getDisplayMetrics().scaledDensity);
+                    canvas.drawText(bar.getName(), x, y, this.mPaint);
+                }
 
                 // Draw value text
                 if (mShowBarText){