Effect:
Serving:
DrawWeb (Canvas C) in RadarChartRenderer
protected Path mDrawWebBg = new Path();
protected void drawWeb(Canvas c) {
Path surface = mDrawWebBg;
surface.reset();
boolean hasMovedToPoint = false;
for (int i = 0; i < maxEntryCount; i += xIncrements) {
if (mChart.isWebBackgroundEnable()) {
// Draw the path of the background
if(! hasMovedToPoint) { surface.moveTo(p.x, p.y); hasMovedToPoint =true;
} else{ surface.lineTo(p.x, p.y); }}}if (mChart.isWebBackgroundEnable()) {
// Fill the background
drawFilledPath(c, surface, mChart.getWebBackgroundColor(), mChart.getWebBackgroundFillAlpha());
}
surface.close();
Copy the code
2. Call the waiter in RadarChart:
/** * Spider background color is off by default */
private boolean mWebBackgroundEnable = false;
/** * web background color, default */
private int mWebBackgroundColor = -1;
/** * Opacity (0-255) */
private int mWebBackgroundFillAlpha = 180;
/** * Set web background color and transparency **@param color
* @param fillAlpha* /
public void setWebBackgroundColor(boolean isOpen, int color, int fillAlpha) {
this.mWebBackgroundEnable = isOpen;
this.mWebBackgroundColor = color;
this.mWebBackgroundFillAlpha = fillAlpha;
}
public int getWebBackgroundColor() {
return mWebBackgroundColor;
}
public int getWebBackgroundFillAlpha() {
return mWebBackgroundFillAlpha;
}
public boolean isWebBackgroundEnable() {
return mWebBackgroundEnable;
}
Copy the code
3. It’s your turn to call the waiter:
chart.setWebBackgroundColor(true, Color.rgb(255.189.0), 180);
Copy the code
Restaurant Address:
Github.com/hzl512/MPAn…
Give a star if you like