我正在使用jjoe64 GraphView库在我的应用中创建一个GraphView栏。
当我创建一个新的DataPoint时,它需要2个值:X int和Y int,如下所示:
GraphView graph = (GraphView) findViewById(R.id.graph);
BarGraphSeries<DataPoint> series = new BarGraphSeries<DataPoint>(new DataPoint[] {
new DataPoint(0, -1),
new DataPoint(1, 5),
new DataPoint(2, 3),
new DataPoint(3, 2),
new DataPoint(4, 6)
});
graph.addSeries(series);
如何使用字符串替换底部的X int?
编辑#1
答案 0 :(得分:3)
你叫什么&#34;底部&#34;是&#34; X轴&#34;。要标记它,请使用
StaticLabelsFormatter staticLabelsFormatter = new StaticLabelsFormatter(graph);
staticLabelsFormatter.setHorizontalLabels(new String[] {"old", "middle", "new"});
graph.getGridLabelRenderer().setLabelFormatter(staticLabelsFormatter);
进一步阅读:Documentation
或者如果您使用GraphView 3.x:
graphView.setHorizontalLabels(new String[] {"0.5", "1", "1.5", "2.0"});