Fixed bug concerning x-label centering in BarChart.
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/AnotherBarActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/AnotherBarActivity.java
index f45d041..f9b7d4d 100644
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/AnotherBarActivity.java
+++ b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/AnotherBarActivity.java
@@ -62,7 +62,6 @@
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
- xAxis.setCenterXLabelText(true);
xAxis.setSpaceBetweenLabels(0);
xAxis.setDrawGridLines(false);
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivityMultiDataset.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivityMultiDataset.java
index 21b17ac..67db088 100644
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivityMultiDataset.java
+++ b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivityMultiDataset.java
@@ -85,7 +85,6 @@
l.setTypeface(tf);
XAxis xl = mChart.getXAxis();
- xl.setCenterXLabelText(true);
xl.setTypeface(tf);
YAxis leftAxis = mChart.getAxisLeft();
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/ListViewBarChartActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/ListViewBarChartActivity.java
index 3dd51f1..3b627a0 100644
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/ListViewBarChartActivity.java
+++ b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/ListViewBarChartActivity.java
@@ -91,7 +91,6 @@
holder.chart.setValueTextColor(Color.WHITE);
XAxis xAxis = holder.chart.getXAxis();
- xAxis.setCenterXLabelText(true);
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTf);
xAxis.setDrawGridLines(false);
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/StackedBarActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/StackedBarActivity.java
index 846d1e4..039e94a 100644
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/StackedBarActivity.java
+++ b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/StackedBarActivity.java
@@ -82,7 +82,6 @@
XAxis xLabels = mChart.getXAxis();
xLabels.setPosition(XAxisPosition.TOP);
- xLabels.setCenterXLabelText(true);
// mChart.setDrawXLabels(false);
// mChart.setDrawYLabels(false);
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/listviewitems/BarChartItem.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/listviewitems/BarChartItem.java
index 17880d7..f7e5525 100644
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/listviewitems/BarChartItem.java
+++ b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/listviewitems/BarChartItem.java
@@ -54,7 +54,6 @@
holder.chart.setDrawBarShadow(false);
XAxis xAxis = holder.chart.getXAxis();
- xAxis.setCenterXLabelText(true);
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTf);
xAxis.setDrawGridLines(false);
diff --git a/MPChartLib/src/com/github/mikephil/charting/components/XAxis.java b/MPChartLib/src/com/github/mikephil/charting/components/XAxis.java
index 950a85b..ed898f0 100644
--- a/MPChartLib/src/com/github/mikephil/charting/components/XAxis.java
+++ b/MPChartLib/src/com/github/mikephil/charting/components/XAxis.java
@@ -47,9 +47,6 @@
*/
public int mYAxisLabelModulus = 1;
- /** if true, x-axis label text is centered when using barcharts */
- private boolean mCenterXAxisLabels = false;
-
/**
* if set to true, the chart will avoid that the first and last label entry
* in the chart "clip" off the edge of the chart
@@ -71,26 +68,6 @@
}
/**
- * returns true if centering x-axis labels when using barcharts is enabled,
- * false if not
- *
- * @return
- */
- public boolean isCenterXLabelsEnabled() {
- return mCenterXAxisLabels;
- }
-
- /**
- * set this to true to center the x-label text when using barcharts ,
- * default: false
- *
- * @param enabled
- */
- public void setCenterXLabelText(boolean enabled) {
- mCenterXAxisLabels = enabled;
- }
-
- /**
* if set to true, the x-label entries will adjust themselves when scaling
* the graph default: true
*
diff --git a/MPChartLib/src/com/github/mikephil/charting/renderer/XAxisRenderer.java b/MPChartLib/src/com/github/mikephil/charting/renderer/XAxisRenderer.java
index ec4c609..60eb0c6 100644
--- a/MPChartLib/src/com/github/mikephil/charting/renderer/XAxisRenderer.java
+++ b/MPChartLib/src/com/github/mikephil/charting/renderer/XAxisRenderer.java
@@ -121,10 +121,6 @@
position[0] = i;
- // center the text
- if (mXAxis.isCenterXLabelsEnabled())
- position[0] += 0.5f;
-
mTrans.pointValuesToPixel(position);
if (mViewPortHandler.isInBoundsX(position[0])) {
diff --git a/MPChartLib/src/com/github/mikephil/charting/renderer/XAxisRendererBarChart.java b/MPChartLib/src/com/github/mikephil/charting/renderer/XAxisRendererBarChart.java
index f09edb0..990d42d 100644
--- a/MPChartLib/src/com/github/mikephil/charting/renderer/XAxisRendererBarChart.java
+++ b/MPChartLib/src/com/github/mikephil/charting/renderer/XAxisRendererBarChart.java
@@ -39,11 +39,12 @@
for (int i = 0; i < mXAxis.getValues().size(); i += mXAxis.mAxisLabelModulus) {
position[0] = i * step + i * bd.getGroupSpace()
- + bd.getGroupSpace() / 2f - 0.5f;
+ + bd.getGroupSpace() / 2f;
- // center the text
- if (mXAxis.isCenterXLabelsEnabled())
- position[0] += (step / 2f);
+ // consider groups (center label for each group)
+ if (step > 1) {
+ position[0] += ((float) step - 1f) / 2f;
+ }
mTrans.pointValuesToPixel(position);