Minor bugfix concerning addXValue().
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/RealtimeLineChartActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/RealtimeLineChartActivity.java
index 3c0bf9c..1cb994d 100644
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/RealtimeLineChartActivity.java
+++ b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/RealtimeLineChartActivity.java
@@ -82,15 +82,43 @@
xl.setTextColor(Color.WHITE);
xl.setDrawGridLines(false);
xl.setAvoidFirstLastClipping(true);
+ xl.setSpaceBetweenLabels(5);
+ xl.setEnabled(false);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(tf);
leftAxis.setTextColor(Color.WHITE);
- leftAxis.setAxisMaxValue(120f);
+ leftAxis.setAxisMaxValue(100f);
+ leftAxis.setAxisMinValue(0f);
+ leftAxis.setStartAtZero(false);
leftAxis.setDrawGridLines(true);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setEnabled(false);
+
+// new Thread(new Runnable() {
+//
+// @Override
+// public void run() {
+// for(int i = 0; i < 5000; i++) {
+//
+// runOnUiThread(new Runnable() {
+//
+// @Override
+// public void run() {
+// addEntry();
+// }
+// });
+//
+// try {
+// Thread.sleep(35);
+// } catch (InterruptedException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+// }
+// }
+// }).start();
}
@Override
@@ -116,7 +144,7 @@
return true;
}
- private int year = 15;
+ private int year = 2015;
private void addEntry() {
@@ -135,17 +163,17 @@
// add a new x-value first
data.addXValue(mMonths[data.getXValCount() % 12] + " "
+ (year + data.getXValCount() / 12));
- data.addEntry(new Entry((float) (Math.random() * 40) + 40f, set.getEntryCount()), 0);
+ data.addEntry(new Entry((float) (Math.random() * 40) + 30f, set.getEntryCount()), 0);
// let the chart know it's data has changed
mChart.notifyDataSetChanged();
// limit the number of visible entries
- mChart.setVisibleXRange(6);
+ mChart.setVisibleXRange(120);
// mChart.setVisibleYRange(30, AxisDependency.LEFT);
// move to the latest entry
- mChart.moveViewToX(data.getXValCount() - 7);
+ mChart.moveViewToX(data.getXValCount() - 121);
// this automatically refreshes the chart (calls invalidate())
// mChart.moveViewTo(data.getXValCount()-7, 55f,
@@ -161,14 +189,15 @@
LineDataSet set = new LineDataSet(null, "Dynamic Data");
set.setAxisDependency(AxisDependency.LEFT);
set.setColor(ColorTemplate.getHoloBlue());
- set.setCircleColor(ColorTemplate.getHoloBlue());
+ set.setCircleColor(Color.WHITE);
set.setLineWidth(2f);
set.setCircleSize(4f);
set.setFillAlpha(65);
set.setFillColor(ColorTemplate.getHoloBlue());
set.setHighLightColor(Color.rgb(244, 117, 117));
set.setValueTextColor(Color.WHITE);
- set.setValueTextSize(10f);
+ set.setValueTextSize(9f);
+ set.setDrawValues(false);
return set;
}
diff --git a/MPChartLib/src/com/github/mikephil/charting/charts/BarLineChartBase.java b/MPChartLib/src/com/github/mikephil/charting/charts/BarLineChartBase.java
index 42e8baf..7750e7f 100644
--- a/MPChartLib/src/com/github/mikephil/charting/charts/BarLineChartBase.java
+++ b/MPChartLib/src/com/github/mikephil/charting/charts/BarLineChartBase.java
@@ -174,9 +174,7 @@
if (mDataNotSet)
return;
- long starttime = System.currentTimeMillis();
-
- calcModulus();
+ long starttime = System.currentTimeMillis();calcModulus();
mXAxisRenderer.calcXBounds(this, mXAxis.mAxisLabelModulus);
mRenderer.calcXBounds(this, mXAxis.mAxisLabelModulus);
diff --git a/MPChartLib/src/com/github/mikephil/charting/data/ChartData.java b/MPChartLib/src/com/github/mikephil/charting/data/ChartData.java
index e309f04..cff3ae3 100644
--- a/MPChartLib/src/com/github/mikephil/charting/data/ChartData.java
+++ b/MPChartLib/src/com/github/mikephil/charting/data/ChartData.java
@@ -389,6 +389,8 @@
* @param xVal
*/
public void addXValue(String xVal) {
+
+ mXValAverageLength = (mXValAverageLength + xVal.length()) / 2f;
mXVals.add(xVal);
}