3

I am working on project which requires graph drawing. I have used this Library. Its working perfectly only problem i am facing is that, the horizontal labels are not scrolling.This X-axis labels are always fixed. Whereas vertical labels are automatically adjusted when i zoom in and out.

4

1 回答 1

2

标签似乎无法滚动,但它们可以更新以反映当前视口中的数据;但是,这不能通过静态水平标签分配来完成。例如,以下将不起作用:

horizontalLables = new String[] {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"};
graphView.setHorizontalLabels(horizontalLables);

相反,有必要使用 CustomLabelFormatter,如下所示:

graphView.setCustomLabelFormatter(new CustomLabelFormatter() {
    @Override
    public String formatLabel(double value, boolean isValueX) {
        if (isValueX) {
            // Assuming only 7 total values here
            return horizontalLables[(int) value];
        } else
            return String.format("%.2f", value);
    }
});

然后,您可以指定要显示的标签数量并允许滚动,如下所示:

graphView.getGraphViewStyle().setNumHorizontalLabels(4);
graphView.setViewPort(0, 3);
graphView.setScrollable(true);

希望有帮助。

于 2014-05-20T18:12:02.340 回答