Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MPAndroidChart-如何左对齐条形图_Android_Bar Chart_Mpandroidchart - Fatal编程技术网

MPAndroidChart-如何左对齐条形图

MPAndroidChart-如何左对齐条形图,android,bar-chart,mpandroidchart,Android,Bar Chart,Mpandroidchart,我使用以下代码在对话框中格式化MPAndroidChart条形图: mChart = (BarChart) compareDialog.findViewById(R.id.bar_chart); mChart.setDrawBarShadow(false); mChart.setDrawValueAboveBar(true); mChart.getDescription().setEnabled(false); mChart.setMaxVisibleValueCount(60);

我使用以下代码在对话框中格式化MPAndroidChart条形图:

 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);
由于某些原因,当条形图少于8条时(图表可以显示的最大值),我的条形图将与条形图显示右对齐。我想让他们改成左对齐。我试图在Stack Overflow和官方MPAndroidChart GitHub上寻找解决方案,但似乎没有发布任何解决方案。有人知道我做错了什么吗