2017-11-15 11 views
0

:がある場合MPAndroidChart - 私はダイアログでMPAndroidChart BarChartコントロールをフォーマットするために、次のコードを持ってどのように左揃えBarChartコントロールバー

mChart = (BarChart) compareDialog.findViewById(R.id.bar_chart); 

mChart.setDrawBarShadow(false); 
mChart.setDrawValueAboveBar(true); 
mChart.getDescription().setEnabled(false); 
mChart.setMaxVisibleValueCount(60); 
mChart.setPinchZoom(false); 
mChart.setDrawGridBackground(false); 

final Typeface tf = Typeface.createFromAsset(getAssets(), 
        "Arimo-Regular.ttf"); 

XAxis xAxis = mChart.getXAxis(); 
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); 
xAxis.setDrawGridLines(false); 
xAxis.setGranularity(1f); 
xAxis.setTypeface(tf); 
xAxis.setTextSize(16f); 
xAxis.setAxisMinimum(tests.size() - 8.5f); 
xAxis.setLabelCount(8); 

IAxisValueFormatter formatter = new IAxisValueFormatter() { 
    @Override 
    public String getFormattedValue(float value, AxisBase axis) { 
     int intValue = (int) value; 
      return (tests.size() > intValue && intValue >= 0) ? tests.get(intValue) : ""; 
    } 
}; 
xAxis.setValueFormatter(formatter); 

YAxis yAxis = mChart.getAxisLeft(); 
yAxis.setDrawGridLines(true); 
yAxis.setSpaceTop(15f); 
yAxis.setTypeface(tf); 
yAxis.setTextSize(16f); 
yAxis.setAxisMinimum(0f); 
yAxis.setLabelCount(10, false); 

YAxis rightAxis = mChart.getAxisRight(); 
rightAxis.setEnabled(false); 

Legend l = mChart.getLegend(); 
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM); 
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT); 
l.setOrientation(Legend.LegendOrientation.HORIZONTAL); 
l.setDrawInside(false); 
l.setForm(Legend.LegendForm.SQUARE); 
l.setFormSize(9f); 
l.setTextSize(16f); 
l.setXEntrySpace(4f); 

何らかの理由で、私のバーは右詰めBarChartコントロール表示にしています8小節未満(グラフが表示できる最大値)代わりに左に揃えてもらいたいです。 Stack Overflowと公式のMPAndroidChart GitHubの両方のソリューションを探してみましたが、投稿されたソリューションはないようです。誰かが私が間違っていることを知っていますか?

答えて

0

てみてください、あなたのデフォルトaxis.IはあなたがV 2.1.6のために使用しているバージョンを知らないように、左の軸を作るために:

barDataSet.setAxisDependency(YAxis.AxisDependency.LEFT); 
+0

いや、私のために動作しませんでした、 –

関連する問題