上菜:git
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()) {
//繪製背景的路徑
if (!hasMovedToPoint) {
surface.moveTo(p.x, p.y);
hasMovedToPoint = true;
} else {
surface.lineTo(p.x, p.y);
}
}
}
if (mChart.isWebBackgroundEnable()) {
//填充背景
drawFilledPath(c, surface, mChart.getWebBackgroundColor(), mChart.getWebBackgroundFillAlpha());
}
surface.close();
複製代碼
/** * 蛛網背景色默認關閉設置 */
private boolean mWebBackgroundEnable = false;
/** * 蛛網背景色,默認 */
private int mWebBackgroundColor = -1;
/** * 不透明度 (0-255) */
private int mWebBackgroundFillAlpha = 180;
/** * 設置蛛網背景色與透明度 * * @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;
}
複製代碼
chart.setWebBackgroundColor(true, Color.rgb(255, 189, 0), 180);
複製代碼
github.com/hzl512/MPAn…github
喜歡就給個star唄~markdown