| | |
| | | private List<PointValue> mPointValues = new ArrayList<>(); |
| | | private List<AxisValue> mAxisXValues = new ArrayList<>(); |
| | | |
| | | private TextView tv_sub; |
| | | private TextView tv_sub,tv_unit; |
| | | private String sensorKey, mac, name, unit; |
| | | private float maxValue; |
| | | |
| | |
| | | initTopBar(); |
| | | tv_title.setText("动态走势"); |
| | | tv_sub = findView(R.id.tv_sub); |
| | | tv_unit = findView(R.id.tv_unit); |
| | | tv_sub.setText(name + "动态走势图"); |
| | | tv_unit.setText("单位:" + unit); |
| | | chartView = findView(R.id.chart); |
| | | initLineChart(); |
| | | } |
| | |
| | | data.setLines(lines); |
| | | data.setValueLabelBackgroundColor(Color.TRANSPARENT);//此处设置坐标点旁边的文字背景 |
| | | data.setValueLabelBackgroundEnabled(false); |
| | | data.setValueLabelsTextColor(Color.GRAY); |
| | | data.setValueLabelsTextColor(Color.WHITE); |
| | | data.setValueLabelTextSize(8); |
| | | |
| | | //坐标轴 |
| | | axisX = new Axis(); //X轴 |
| | | axisX.setHasTiltedLabels(true); //X坐标轴字体是斜的显示还是直的,true是斜的显示 |
| | | axisX.setHasTiltedLabels(false); //X坐标轴字体是斜的显示还是直的,true是斜的显示 |
| | | axisX.setName("实时数据"); //表格名称 |
| | | axisX.setTextSize(8);//设置字体大小 |
| | | axisX.setTextColor(getResources().getColor(R.color.blue_txt)); |
| | |
| | | axisY = Axis.generateAxisFromRange((float) 0.0, maxValue == 0 ? 100 : maxValue, maxValue == 0 ? 10 : maxValue / 16); //Y轴 |
| | | // axisY = new Axis(); |
| | | axisY.setAutoGenerated(false); |
| | | AxisValueFormatter yvalue = new SimpleAxisValueFormatter(1); |
| | | axisY.setFormatter(yvalue); |
| | | // AxisValueFormatter yvalue = new SimpleAxisValueFormatter(1); |
| | | // axisY.setFormatter(yvalue); |
| | | axisY.setHasLines(true); |
| | | axisY.setHasSeparationLine(true); |
| | | axisY.setName("单位:" + unit);//y轴标注 |
| | | axisY.setTextSize(10);//设置字体大小 |
| | | axisY.setName(" ");//y轴标注 |
| | | axisY.setTextSize(8);//设置字体大小 |
| | | axisY.setTextColor(getResources().getColor(R.color.blue_txt)); |
| | | axisY.setLineColor(getResources().getColor(R.color.blue_txt)); |
| | | data.setAxisYLeft(axisY); //Y轴设置在左边 |