我是编码的新手,所以在错误中道歉......
我正在使用GraphView github代码。 我需要创建line和Bar组合成一个图形。 在这里,我希望线条和条形系列的最大值显示在y轴的顶部。目前它没有按我的要求显示。
这是一段代码: // 12670这是条形和折线系列的最大值。 6
public void initGraphNew(GraphView graph) {
String lll = "12670";[![// this is max value in bar and line series. 6 point value not touching y axis top va][1]][1]lue please check.
LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(new DataPoint[]{
new DataPoint(1, (double) 6000),
new DataPoint(2, (double) 5866),
new DataPoint(3, (double) 7340),
new DataPoint(4, (double) 10340),
new DataPoint(5, (double) 1000),
new DataPoint(6, (double) 12670),
new DataPoint(7, (double) 3000)
});
series.setDrawBackground(false);
series.setAnimated(true);
series.setDrawDataPoints(true);
series.setColor(Color.argb(255, 63, 174, 237));
BarGraphSeries<DataPoint> series1 = new BarGraphSeries<DataPoint>(new DataPoint[]{
new DataPoint(1, (double) 5544),
new DataPoint(2, (double) 10000),
new DataPoint(3, (double) 1000),
new DataPoint(4, (double) 2),
new DataPoint(5, (double) 3400),
new DataPoint(6, (double) 12670),
new DataPoint(7, (double) 4000)
});
series1.setDrawValuesOnTop(false);
series1.setValuesOnTopColor(Color.RED);
graph.getGridLabelRenderer().setTextSize(22f);
series1.setDataWidth(1d);
series1.setAnimated(true);
series1.setColor(Color.argb(255, 247, 100, 10));
graph.addSeries(series1);
graph.addSeries(series);
graph.getViewport().setMinX((double) 0);
graph.getViewport().setMaxX((double) 7);
graph.getGridLabelRenderer().setNumHorizontalLabels(8);
graph.getViewport().setMinY((double) 0);
graph.getViewport().setMaxY((double) 12670);
graph.getGridLabelRenderer().setNumVerticalLabels(6);
StaticLabelsFormatter staticLabelsFormatter = new StaticLabelsFormatter(graph);
String[] vLables = new String[6];
double new_value = 12670 / 5;
double next = 0;
for (int i = 0; i < 6; i++) {
if (i == 0) {
vLables[i] = "";
} else {
vLables[i] = ((int) next) + "";
}
next = next + new_value;
}
staticLabelsFormatter.setVerticalLabels(vLables);
graph.getGridLabelRenderer().setLabelFormatter(staticLabelsFormatter);
graph.getViewport().setXAxisBoundsManual(true);
graph.getViewport().setYAxisBoundsManual(false);
graph.getViewport().setScrollable(true);
graph.getLegendRenderer().setVisible(false);
graph.getGridLabelRenderer().setHorizontalLabelsColor(Color.BLACK);
graph.getGridLabelRenderer().setVerticalLabelsColor(Color.BLACK);
graph.getGridLabelRenderer().setGridColor(Color.GRAY);
graph.getGridLabelRenderer().setHighlightZeroLines(false);
graph.getGridLabelRenderer().setGridStyle(GridLabelRenderer.GridStyle.NONE);
graph.getViewport().setDrawBorder(true);
}