|
|
|
|
@ -259,7 +259,7 @@ public class DeviceAlarmInfoLineChartActivity extends BaseViewBindingActivity<Ac
|
|
|
|
|
if(bean!=null && bean.getCode()==20000 && bean.isSuccess() && bean.getData()!=null && !bean.getData().isEmpty()){
|
|
|
|
|
deviceAlarmDataList.clear();
|
|
|
|
|
deviceAlarmDataList.addAll(bean.getData());
|
|
|
|
|
Collections.reverse(deviceAlarmDataList);
|
|
|
|
|
//Collections.reverse(deviceAlarmDataList);
|
|
|
|
|
List<Entry> entries1 = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < deviceAlarmDataList.size(); i++) {
|
|
|
|
|
try {
|
|
|
|
|
@ -292,7 +292,7 @@ public class DeviceAlarmInfoLineChartActivity extends BaseViewBindingActivity<Ac
|
|
|
|
|
private void setDes() {
|
|
|
|
|
Description description = new Description();
|
|
|
|
|
description.setText("");
|
|
|
|
|
description.setTextSize(10);
|
|
|
|
|
description.setTextSize(12);
|
|
|
|
|
description.setTextColor(Color.BLUE);
|
|
|
|
|
binding.linechart.setDescription(description);
|
|
|
|
|
|
|
|
|
|
@ -300,7 +300,7 @@ public class DeviceAlarmInfoLineChartActivity extends BaseViewBindingActivity<Ac
|
|
|
|
|
Legend legend = binding.linechart.getLegend();
|
|
|
|
|
//legend.setForm(Legend.LegendForm.NONE);
|
|
|
|
|
legend.setTextColor(Color.GRAY);
|
|
|
|
|
legend.setTextSize(13);
|
|
|
|
|
legend.setTextSize(14);
|
|
|
|
|
|
|
|
|
|
binding.linechart.setNoDataText("无数据");
|
|
|
|
|
binding.linechart.setExtraBottomOffset(20f);
|
|
|
|
|
@ -324,7 +324,6 @@ public class DeviceAlarmInfoLineChartActivity extends BaseViewBindingActivity<Ac
|
|
|
|
|
dataSet1.setFillDrawable(new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[]{Color.argb(127, 235, 170, 106), Color.parseColor("#00FA5544")}));
|
|
|
|
|
dataSet1.setLineWidth(1);
|
|
|
|
|
dataSet1.setDrawValues(false);
|
|
|
|
|
// dataSet1.setValueFormatter(new MyValueFormatter());
|
|
|
|
|
|
|
|
|
|
sets.add(dataSet1);
|
|
|
|
|
LineData lineData = new LineData(sets);
|
|
|
|
|
@ -333,8 +332,8 @@ public class DeviceAlarmInfoLineChartActivity extends BaseViewBindingActivity<Ac
|
|
|
|
|
XAxis xAxis = binding.linechart.getXAxis();
|
|
|
|
|
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
|
|
|
|
|
xAxis.setAxisMinimum(1);//设置x轴最小
|
|
|
|
|
xAxis.setTextSize(8);
|
|
|
|
|
xAxis.setTextColor(Color.parseColor("#FC863E"));
|
|
|
|
|
xAxis.setTextSize(12);
|
|
|
|
|
//xAxis.setTextColor(Color.parseColor("#FC863E"));
|
|
|
|
|
xAxis.setEnabled(true);//是否显示x轴是否禁用
|
|
|
|
|
xAxis.setDrawLabels(true); //设置x轴标签 即x轴上显示的数值
|
|
|
|
|
xAxis.setDrawGridLines(true);//是否设置x轴上每个点对应的线 即 竖向的网格线
|
|
|
|
|
@ -345,6 +344,12 @@ public class DeviceAlarmInfoLineChartActivity extends BaseViewBindingActivity<Ac
|
|
|
|
|
YAxis yAxis = binding.linechart.getAxisRight();
|
|
|
|
|
yAxis.setEnabled(false);
|
|
|
|
|
|
|
|
|
|
//设置左边Y轴的样式
|
|
|
|
|
YAxis axisLeft = binding.linechart.getAxisLeft();
|
|
|
|
|
axisLeft.setTextSize(12);
|
|
|
|
|
//设置字体颜色
|
|
|
|
|
//axisLeft.setTextColor(Color.parseColor("#FC863E"));
|
|
|
|
|
|
|
|
|
|
float ratio = (float) xlabellistdatas.size() / (float) 10;
|
|
|
|
|
if (ratio < 1) {
|
|
|
|
|
ratio = 1.0f;
|
|
|
|
|
@ -362,7 +367,12 @@ public class DeviceAlarmInfoLineChartActivity extends BaseViewBindingActivity<Ac
|
|
|
|
|
binding.linechart.setScaleEnabled(false);
|
|
|
|
|
//设置为可左右滑动
|
|
|
|
|
binding.linechart.setDragEnabled(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 假设chart是你的LineChart或BarChart对象
|
|
|
|
|
// binding.linechart.postDelayed(() -> {
|
|
|
|
|
// // 获取最后一个可见的X值
|
|
|
|
|
// float lastX = binding.linechart.getHighestVisibleX();
|
|
|
|
|
// // 移动视图中心到这个X值
|
|
|
|
|
// binding.linechart.moveViewToX(lastX);
|
|
|
|
|
// },1000);
|
|
|
|
|
}
|
|
|
|
|
}
|