解决hellocharts折线图由于特殊数据不能展示的问题(比如
private void calculateMaxViewport() {
tempMaximumViewport.set( Float.MAX_VALUE, Float.MIN_VALUE, Float.MIN_VALUE, Float.MAX_VALUE );
LineChartData data =dataProvider.getLineChartData();
for (Line line : data.getLines()) {
// Calculate max and min for viewport.
for (PointValue pointValue : line.getValues()) {
if (pointValue.getX()
tempMaximumViewport.left = pointValue.getX();
}
if (pointValue.getX() >tempMaximumViewport.right) {
tempMaximumViewport.right = pointValue.getX();
}
if (pointValue.getY()
tempMaximumViewport.bottom = pointValue.getY();
}
if (pointValue.getY() >tempMaximumViewport.top) {
tempMaximumViewport.top = pointValue.getY();
}
}
}
if (tempMaximumViewport.top ==tempMaximumViewport.bottom) {//解决最大值最小值相等时,图不能展示问题
tempMaximumViewport.top =tempMaximumViewport.top *2;
tempMaximumViewport.bottom =0;
}else if (tempMaximumViewport.bottom ==0.0) {//解决最大值最小值相等时全部为0时,图不能展示问题
tempMaximumViewport.top =1;
tempMaximumViewport.bottom =0;
}
}