Skip to content

Commit 7045400

Browse files
committed
Fixed example project crash, fixed issues concerning dynamical data adding.
1 parent f516b45 commit 7045400

5 files changed

Lines changed: 26 additions & 13 deletions

File tree

282 Bytes
Binary file not shown.

MPChartExample/src/com/xxmassdeveloper/mpchartexample/ListViewBarChartActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private BarData generateData(int cnt) {
131131

132132
BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);
133133
d.setBarSpacePercent(20f);
134-
d.setColors(ColorTemplate.VORDIPLOM_COLORS, getApplicationContext());
134+
d.setColors(ColorTemplate.VORDIPLOM_COLORS);
135135
d.setBarShadowColor(Color.rgb(203, 203, 203));
136136

137137
ArrayList<BarDataSet> sets = new ArrayList<BarDataSet>();

MPChartLib/src/com/github/mikephil/charting/charts/Chart.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,9 @@ public void setData(T data) {
347347
"Cannot set data for chart. Provided data object is null.");
348348
return;
349349
}
350-
351-
// Log.i(LOG_TAG, "xvalcount: " + data.getXValCount());
352-
// Log.i(LOG_TAG, "entrycount: " + data.getYValCount());
350+
351+
// Log.i(LOG_TAG, "xvalcount: " + data.getXValCount());
352+
// Log.i(LOG_TAG, "entrycount: " + data.getYValCount());
353353

354354
// LET THE CHART KNOW THERE IS DATA
355355
mDataNotSet = false;
@@ -633,9 +633,9 @@ protected float[] generateTransformedValuesLineScatter(ArrayList<? extends Entry
633633
float[] valuePoints = new float[entries.size() * 2];
634634

635635
for (int j = 0; j < valuePoints.length; j += 2) {
636-
636+
637637
Entry e = entries.get(j / 2);
638-
638+
639639
valuePoints[j] = e.getXIndex();
640640
valuePoints[j + 1] = e.getVal() * mPhaseY;
641641
}

MPChartLib/src/com/github/mikephil/charting/charts/LineChart.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,14 @@ protected void init() {
5656
protected void calcMinMax(boolean fixedValues) {
5757
super.calcMinMax(fixedValues);
5858

59-
// if there is only one value in the chart
60-
if (mOriginalData.getYValCount() == 1
61-
|| mOriginalData.getYValCount() <= mOriginalData.getDataSetCount()) {
59+
// // if there is only one value in the chart
60+
// if (mOriginalData.getYValCount() == 1
61+
// || mOriginalData.getYValCount() <= mOriginalData.getDataSetCount()) {
62+
// mDeltaX = 1;
63+
// }
64+
65+
if (mDeltaX == 0 && mOriginalData.getYValCount() > 0)
6266
mDeltaX = 1;
63-
}
6467
}
6568

6669
@Override

MPChartLib/src/com/github/mikephil/charting/charts/ScatterChart.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ public ScatterChart(Context context, AttributeSet attrs, int defStyle) {
3636
super(context, attrs, defStyle);
3737
}
3838

39+
@Override
40+
protected void calcMinMax(boolean fixedValues) {
41+
super.calcMinMax(fixedValues);
42+
43+
if (mDeltaX == 0 && mOriginalData.getYValCount() > 0)
44+
mDeltaX = 1;
45+
}
46+
3947
@Override
4048
protected void drawData() {
4149

@@ -144,7 +152,8 @@ protected void drawValues() {
144152

145153
if (mDrawUnitInChart) {
146154

147-
mDrawCanvas.drawText(mValueFormatter.getFormattedValue(val) + mUnit, positions[j],
155+
mDrawCanvas.drawText(mValueFormatter.getFormattedValue(val) + mUnit,
156+
positions[j],
148157
positions[j + 1] - shapeSize, mValuePaint);
149158
} else {
150159

@@ -162,8 +171,9 @@ protected void drawHighlights() {
162171

163172
for (int i = 0; i < mIndicesToHightlight.length; i++) {
164173

165-
ScatterDataSet set = mCurrentData.getDataSetByIndex(mIndicesToHightlight[i].getDataSetIndex());
166-
174+
ScatterDataSet set = mCurrentData.getDataSetByIndex(mIndicesToHightlight[i]
175+
.getDataSetIndex());
176+
167177
mHighlightPaint.setColor(set.getHighLightColor());
168178

169179
int xIndex = mIndicesToHightlight[i].getXIndex(); // get the

0 commit comments

Comments
 (0)