228 | 229 | ````java 230 | public class CircleGraphFormula extends PaintedGraphFormula { 231 | 232 | private float r; 233 | private int angle; 234 | Paint paint; 235 | 236 | public CircleGraphFormula(Context context,float r,int angle){ 237 | super(context); 238 | this.r = r; 239 | this.angle = angle; 240 | paint = new Paint(); 241 | 242 | getGraphPaint().setStyle(Paint.Style.STROKE); 243 | getPointPaint().setColor(getGraphPaint().getColor()); 244 | setPointCircleRadius(getPointCircleRadius()*1.2f); 245 | 246 | addCustomPoint(0,r); 247 | addCustomPoint(0,-r); 248 | addCustomPoint(r,0); 249 | addCustomPoint(-r,0); 250 | } 251 | 252 | @Override 253 | protected boolean onDraw(AXGraphCanvas canvas) { 254 | canvas.setRadiusFromAxis(true); 255 | canvas.drawCircle(0,0,r, getGraphPaint()); 256 | 257 | if (angle!=0) { 258 | float angleR = (float) Math.toRadians(angle); 259 | String text = angle+"°"; 260 | 261 | paint.setColor(Color.parseColor("#03DAC5")); 262 | paint.setStrokeWidth(getGraphPaint().getStrokeWidth()); 263 | final float x = (float) Math.cos(angleR) * r; 264 | final float y = (float) Math.sin(angleR) * r; 265 | 266 | float r2 = r/5; 267 | paint.setStyle(Paint.Style.STROKE); 268 | canvas.drawArc(-r2,-r2,r2,r2,-angle,angle,true,paint); 269 | 270 | paint.setStyle(Paint.Style.FILL); 271 | paint.setTextSize(canvas.findGraphX(r)/10); 272 | canvas.drawText(text,r2,r2/1.5f, Gravity.CENTER_VERTICAL|Gravity.LEFT,paint); 273 | 274 | canvas.drawLine(0,0,x,0,paint); 275 | paint.setPathEffect(new DashPathEffect(new float[] {20f/canvas.getGraphScale(),20f/canvas.getGraphScale()}, 0f)); 276 | canvas.drawLine(x,y,x,0,paint); 277 | canvas.drawLine(0,y,x,y,paint); 278 | paint.setPathEffect(null); 279 | 280 | paint.setColor(canvas.getGraphView().getContext().getResources().getColor(R.color.colorPrimary)); 281 | canvas.drawLine(0,0,x,y,paint); 282 | 283 | int savedColor = getPointPaint().getColor(); 284 | getPointPaint().setColor(paint.getColor()); 285 | drawPoint(canvas,x,y, AXGraphPointType.CUSTOM); 286 | getPointPaint().setColor(savedColor); 287 | } 288 | return true; //skip drawing function 289 | } 290 | 291 | @Override 292 | public float function(float x) { 293 | return Float.POSITIVE_INFINITY; //undefined 294 | } 295 | } 296 | ```` 297 |