你好我在MPAndroidChart上使用BubbleChart。我的X值非常大,所以我的气泡尺寸非常小,为了看到气泡是必要的,可以在图表上放大很多。我设置大尺寸的气泡,但他们保持小。那是我的代码。
BubbleChart bubbleChart =(BubbleChart)findViewById(R.id.bubbleChart);
ArrayList<BubbleEntry> entries = new ArrayList<>();
entries.add(new BubbleEntry(323,1f,10f));
entries.add(new BubbleEntry(981,5f, 10f));
entries.add(new BubbleEntry(1300,3f ,10f));
XAxis xAxis = bubbleChart.getXAxis();
xAxis.setAxisMinimum(0);
xAxis.setAxisMaximum(1440);
YAxis yAxis = bubbleChart.getAxisLeft();
yAxis.setAxisMinimum(0);
yAxis.setAxisMaximum(8);
YAxis yAxis2=bubbleChart.getAxisRight();
yAxis2.setAxisMinimum(0);
yAxis2.setAxisMaximum(8);
BubbleDataSet bubbleDataSet = new BubbleDataSet(entries, "");
bubbleDataSet.setColor(Color.RED,180);
BubbleData data= new BubbleData(bubbleDataSet);
bubbleChart.setData(data);
截图: bubblechart
答案 0 :(得分:0)
这种问题可以通过预处理数据并乘以标量来解决。因此,您可以尝试将y值或z值乘以标量(我们选择100f
)而不是您上面的内容:
public static float SCALAR = 100f;
ArrayList<BubbleEntry> entries = new ArrayList<>();
entries.add(new BubbleEntry(323, 10 * SCALAR, 10 * SCALAR));
entries.add(new BubbleEntry(981, 5 * SCALAR, 10 * SCALAR));
entries.add(new BubbleEntry(1300, 3 * SCALAR, 10 * SCALAR));
如果您在y值或y轴上有标签,则可以编写自定义IAxisValueFormatter
或IValueFormatter
以返回原始y值:
public class MyValueFormatter implements IValueFormatter {
String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
return Float.toString(value / SCALAR);
}
}