本文介绍了Graphview在Eclipse可以在X和放大器; Y轴采用不同的LabelFormats?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个图,我需要Y轴显示给1DP。这部作品通过执行以下code。

I have a graph and I need the Y axis to display to 1dp. This works by doing the following code.

NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumFractionDigits(1);
graph.getGridLabelRenderer().setLabelFormatter(new DefaultLabelFormatter(nf, nf));

我需要的X轴在结束时显示2串1的开头和1。这部作品通过执行以下code。

I need the X axis to display 2 strings, 1 at the beginning and 1 at the end. This works by doing the following code.

StaticLabelsFormatter staticLabelsFormatter = new StaticLabelsFormatter(graph);
staticLabelsFormatter.setHorizontalLabels(new String[] {firstStr,lastStr});
graph.getGridLabelRenderer().setLabelFormatter(staticLabelsFormatter);
graph.getGridLabelRenderer().setNumHorizontalLabels(2); 

我的问题是,我不能在同一个图形一举两得!

My problem is I can't do both on the same graph!

单独却不能在一起工作都感激地收到任何想法

Both work individually but not together, any ideas gratefully recieved

我使用Graphview 4.0版

I am using version 4.0 of Graphview

推荐答案

是的,你可以结合静态标签和动态标签。

yes you can combine the static labels and dynamic labels.

使用的StaticLabelFormatter并设置dyamic标签格式。
http://jjoe64.github.io/GraphView/javadoc/com/jjoe64/graphview/helper/StaticLabelsFormatter.html#setDynamicLabelFormatter-com.jjoe64.graphview.LabelFormatter-

Use the StaticLabelFormatter and set the dyamic label formatter.http://jjoe64.github.io/GraphView/javadoc/com/jjoe64/graphview/helper/StaticLabelsFormatter.html#setDynamicLabelFormatter-com.jjoe64.graphview.LabelFormatter-

这样的事情应该工作:

NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumFractionDigits(1);

StaticLabelsFormatter staticLabelsFormatter = new StaticLabelsFormatter(graph);
staticLabelsFormatter.setHorizontalLabels(new String[] {firstStr,lastStr});
staticLabelsFormatter.setDynamicLabelFormatter(new DefaultLabelFormatter(nf, nf));
graph.getGridLabelRenderer().setLabelFormatter(staticLabelsFormatter);
graph.getGridLabelRenderer().setNumHorizontalLabels(2); 

文档

这篇关于Graphview在Eclipse可以在X和放大器; Y轴采用不同的LabelFormats?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 21:33