##一、折线图
坐标轴
Axis.setAxisColor
坐标轴颜色Axis.setAxisWidth
坐标轴宽度Axis.setTextSize
坐标轴刻度字体大小Axis.setTextColor
坐标轴刻度字体颜色
折线@LeafLineChart
Line.setLineWidth
折线宽度Line.setLineColor
折线颜色Line.setPointRadius
点的大小Line.setPointColor
点的颜色Line.setHasLabels
是否有标签Line.setLabelColor
标签背景色Line.setLabelRadius
标签弧度Line.setFill
是否填充Line.setFillColr
填充颜色(默认为有透明度的折线颜色)
MoveSelectLineChart 新增:
Line.setOpenMoveSelect
是否开启滑动选值Line.setMoveLineColor
移动标尺线的颜色
- 多线条支持
- 移动选值
<com.beiing.leafchart.LeafLineChart
android:id="@+id/leaf_chart"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#ffffff"/>
初始化X轴数据:
private List<AxisValue> getAxisValuesX(){
List<AxisValue> axisValues = new ArrayList<>();
for (int i = 1; i <= 12; i++) {
AxisValue value = new AxisValue();
value.setLabel(i + "月");
axisValues.add(value);
}
return axisValues;
}
初始化Y轴数据:
private List<AxisValue> getAxisValuesY(){
List<AxisValue> axisValues = new ArrayList<>();
for (int i = 0; i < 11; i++) {
AxisValue value = new AxisValue();
value.setLabel(String.valueOf(i * 10));
axisValues.add(value);
}
return axisValues;
}
初始化点数据和相关设置:
private Line getFoldLine(){
List<PointValue> pointValues = new ArrayList<>();
for (int i = 1; i <= 12; i++) {
PointValue pointValue = new PointValue();
pointValue.setX( (i - 1) / 11f);
float var = (float) (Math.random() * 100);
pointValue.setLabel(String.valueOf(var));
pointValue.setY(var / 100);
pointValues.add(pointValue);
}
Line line = new Line(pointValues);
line.setLineColor(Color.parseColor("#33B5E5")).setPointColor(Color.YELLOW).
setCubic(false).setPointRadius(3).setHasLabels(true)
.setFill(false);
return line;
}
Axis axisX = new Axis(getAxisValuesX());
axisX.setAxisColor(Color.parseColor("#33B5E5")).setTextColor(Color.DKGRAY).setHasLines(true);
Axis axisY = new Axis(getAxisValuesY());
axisY.setAxisColor(Color.parseColor("#33B5E5")).setTextColor(Color.DKGRAY).setHasLines(true).setShowText(true);
lineChart.setAxisX(axisX);
lineChart.setAxisY(axisY);
List<Line> lines = new ArrayList<>();
lines.add(getFoldLine());
lines.add(getCompareLine());
lineChart.setChartData(lines);
lineChart.showWithAnimation(3000);
//无动画
//lineChart.show();
使用类似折线图
###2.1 设置
Square.setWidth
直方图宽度Square.setBorderWidth
边框宽度Square.setBorderColor
边框颜色Square.setFill
是否填充Square.setHasLabels
是否有标签Square.setLabelColor
标签背景色Square.setLabelRadius
标签弧度
###2.2 效果图
#License
Copyright 2016 LineChen <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.