我正在使用MP圖表來顯示評論,除了X軸值顯示爲浮動值(針對特定類型的評論的數量)之外,一切都工作正常。MP android圖表顯示水平條形圖的X軸的浮動值?
這是我使用的代碼:
BarData data = new BarData(getXAxisValues(), getDataSet(properties));
chart.setData(data);
chart.getXAxis().setEnabled(false); // hides horizontal grid lines inside chart
YAxis leftAxis = chart.getAxisLeft();
chart.getAxisRight().setEnabled(false); // hides horizontal grid lines with below line
leftAxis.setEnabled(false); // hides vertical grid lines inside chart
/*chart.animateXY(2000, 2000);*/ // for animating reviews display
chart.invalidate();
chart.setClickable(false);
chart.setDescription(""); // Hide the description
chart.getLegend().setEnabled(false);
chart.setDoubleTapToZoomEnabled(false);
chart.setPinchZoom(false);
leftAxis.setDrawLabels(true);
private ArrayList<BarDataSet> getDataSet(Properties properties) {
ArrayList<BarDataSet> dataSets = null;
ArrayList<BarEntry> valueSet1 = new ArrayList<>();
BarEntry v1e1 = new BarEntry(properties.getRating10().intValue(), 0);
valueSet1.add(v1e1);
BarEntry v1e2 = new BarEntry(properties.getRating20().intValue(), 1);
valueSet1.add(v1e2);
BarEntry v1e3 = new BarEntry(properties.getRating30().intValue(), 2);
valueSet1.add(v1e3);
BarEntry v1e4 = new BarEntry(properties.getRating40().intValue(), 3);
valueSet1.add(v1e4);
BarEntry v1e5 = new BarEntry(properties.getRating50().intValue(), 4);
valueSet1.add(v1e5);
BarDataSet barDataSet1 = new BarDataSet(valueSet1, "Asset");
barDataSet1.setColors(ColorTemplate.COLORFUL_COLORS);
dataSets = new ArrayList<>();
dataSets.add(barDataSet1);
return dataSets;
}
private ArrayList<String> getXAxisValues() {
ArrayList<String> xAxis = new ArrayList<>();
xAxis.add("12.0");
xAxis.add("4.0");
xAxis.add("4");
xAxis.add("4");
xAxis.add("4");
return xAxis;
}
在這裏,我的設置數據到水平條形圖。
我想要的紅色圓圈標記值是整數,而不是浮動。 任何人都可以幫助我嗎?
我試過這個選項。但仍然我得到的價值不是int值。我有整數值的條目。如果我有4個任務完成,即輸入爲(4,1),那麼欄上顯示的值是10.是嗎?@Manikanta – Sid
除非我看到您的值格式化程序和您設置值的方式,否則我可以對此進行評論。 – Manikanta
你能幫我解決這個問題嗎? http://stackoverflow.com/questions/36735219/how-to-add-entries-in-mpandroid-chart @Manikanta – Sid