Skip to content

Commit ade3414

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents f2cac89 + 8a6fb29 commit ade3414

File tree

1 file changed

+75
-2
lines changed

1 file changed

+75
-2
lines changed

README.md

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
# ChartHelper
22
## MPAndroidChart辅助类,减少初始化属性和设置数据等操作。
33

4+
5+
![示例图1](https://github.com/chenyy0708/ChartHelper/blob/master/img/%E7%A4%BA%E4%BE%8B%E5%9B%BE.png)
6+
7+
![示例图1](https://github.com/chenyy0708/ChartHelper/blob/master/img/%E7%A4%BA%E4%BE%8B%E5%9B%BE2.png)
8+
9+
10+
11+
412
## 1. 饼状图
513

614
![饼图](https://github.com/chenyy0708/ChartHelper/blob/master/img/%E9%A5%BC%E5%9B%BE.png)
715

16+
817
### 属性
918

1019
```
@@ -84,7 +93,71 @@ public class TestPieData implements IPieData {
8493
```
8594

8695

96+
## 2.柱状图
8797

88-
![示例图1](https://github.com/chenyy0708/ChartHelper/blob/master/img/%E7%A4%BA%E4%BE%8B%E5%9B%BE.png)
98+
![柱状图](https://github.com/chenyy0708/ChartHelper/blob/master/img/%E5%8D%95%E6%9F%B1%E7%8A%B6%E5%9B%BE%E5%92%8C%E5%A4%9A%E6%9F%B1%E7%8A%B6%E5%9B%BE.png)
99+
100+
### 属性
101+
102+
```
103+
new BarChartHelper.Builder()
104+
.setContext(this)
105+
// 柱状图
106+
.setBarChart(bar_chart)
107+
// 多柱状图
108+
.setBarSetData(data)
109+
// 单柱状图
110+
.setBarData(data.get(0))
111+
// 多柱状图 标签名集合
112+
.setLabels(names)
113+
// 一页X轴显示个数
114+
.setDisplayCount(3)
115+
// 标签显示隐藏
116+
.setLegendEnable(false)
117+
// 标签文字大小
118+
.setLegendTextSize(20)
119+
// 是否显示右边Y轴
120+
.setyAxisRightEnable(false)
121+
// X,Y轴是否绘制网格线
122+
.setDrawGridLines(false)
123+
// 缩放
124+
.setScaleEnabled(true)
125+
// 是否可以通过双击屏幕放大图表
126+
.setDoubleTapToZoomEnabled(true)
127+
// 柱状图描述 图表右下角
128+
.setDescriptionEnable(false)
129+
// 按比例放缩柱状图
130+
.setPinchZoom(true)
131+
// 多柱状图 每组柱之间的宽度,只在多柱状图生效
132+
.setGroupSpace(0.4f)
133+
// 单柱状图 每个柱的宽度,只在单柱状图生效
134+
.setBarWidth(0.3f)
135+
// x,y轴动画时间和类型
136+
.setDurationMillis(2000)
137+
.setEasing(Easing.EasingOption.Linear)
138+
// 单柱状图颜色
139+
.setBarColor(Color.parseColor("#0000FF"))
140+
// 多柱状图颜色
141+
.setBarColors(chartColors)
142+
// X轴是否显示自定义数据,在IBarData接口中定义
143+
.setXValueEnable(true)
144+
.build();
145+
```
146+
147+
148+
> 数据bean只需要实现IBarData接口
149+
150+
```
151+
public interface IBarData {
152+
/**
153+
* 图表Y轴值
154+
*/
155+
float getValue();
156+
157+
/**
158+
* X轴对应Name
159+
*/
160+
String getLabelName();
161+
}
162+
```
89163

90-
![示例图1](https://github.com/chenyy0708/ChartHelper/blob/master/img/%E7%A4%BA%E4%BE%8B%E5%9B%BE2.png)

0 commit comments

Comments
 (0)