我希望我的应用程序能够显示频率响应图形,但我找不到任何具有此功能的图形库。我目前正在使用MPAndroidChart进行其他一些图表(这是很棒的!)但遗憾的是,我找不到任何方法来使用它来绘制原状。我也尝试过使用numAndroidCharts (数字图表日志图示例),但是这个库似乎已经损坏/过时了,因为我甚至无法让示例代码正常工作。就你所知,是否有办法实现这一目标?
发布于 2017-04-13 09:49:41
我使用带有转换值的日志刻度的MPAndroidChart。
例如,如果您的值是1E-5
value = 1E-5;
Entry entry = new Entry();
entry.setX(Math.log10(value)); // entry.getX() will return -5因为您现在的值是-5,所以需要创建一个AxisFormatter来显示它真的代表一个对数值:
public class Log10AxisValueFormatter implements IAxisValueFormatter {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return String.format(Locale.ENGLISH, "%.2E", Math.pow(10,value));
}
}在创建图表时,需要将此实例设置为您的轴:
XAxis xAxis = chart.getXAxis();
xAxis.setValueFormatter(new Log10AxisValueFormatter());https://stackoverflow.com/questions/43388383
复制相似问题