根据我提供的数组列表,我的 YAxis 标签的 MPCHART 不适合,并且与堆叠的水平条形图不对齐?
shift 标签未显示且未与水平堆叠条形图对齐
chart.getDescription().setEnabled(false);
chart.setNoDataText("No data available here !");
chart.setMaxVisibleValueCount(40);
chart.setPinchZoom(false);
chart.setDoubleTapToZoomEnabled(false);
chart.setDrawGridBackground(false);
chart.setDrawBarShadow(false);
chart.setDrawValueAboveBar(false);
chart.setHighlightFullBarEnabled(false);
// change the position of the y-labels
chart.getAxisLeft().setEnabled(false);
YAxis rightAxis = chart.getAxisRight();
rightAxis.setEnabled(true);
rightAxis.setDrawGridLines(false);
rightAxis.setTypeface(Utils.setFont(SingleEquipmentDashboard.this));
rightAxis.setLabelCount(arrayListHour.size());
rightAxis.setGranularity(1f);
getFromTime 包含转换为浮点时间的 UTC 时间
if (data.getCurrentShiftDowntimes().size() > 0) {
float temp = Utils.getShiftChartTime("", data.getCurrentShiftDowntimes().get(0).getFromTime());
if (temp > 0) {
rightAxis.calculate(temp, chart.getYMax() + temp);
chart.setVisibleYRangeMaximum(temp, YAxis.AxisDependency.RIGHT);
}
}
主要问题是值没有格式化到正确的位置
rightAxis.setValueFormatter(new ValueFormatter() {
@Override
public String getFormattedValue(float value) {
if (value <= -1) {
/*Display positive Hours number in Previous date chart*/
value = 24 + value;
}
if (value >= 24) {
value = value - 24;
}
return String.format("%02d", (int) value);
}
});
chart.getXAxis().setEnabled(false);
Legend l = chart.getLegend();
l.setEnabled(false);
chart.invalidate();