Skip to content

Commit d34670f

Browse files
committed
Remove noDataTextDescription - this can be done via noDataText as well
1 parent 643f901 commit d34670f

File tree

8 files changed

+9
-39
lines changed

8 files changed

+9
-39
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ protected void onCreate(Bundle savedInstanceState) {
7373

7474
// no description text
7575
mChart.getDescription().setEnabled(false);
76-
mChart.setNoDataTextDescription("You need to provide data for the chart.");
7776

7877
// enable touch gestures
7978
mChart.setTouchEnabled(true);

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ protected void onCreate(Bundle savedInstanceState) {
6262

6363
// no description text
6464
mChart.getDescription().setEnabled(false);
65-
mChart.setNoDataTextDescription("You need to provide data for the chart.");
6665

6766
// enable touch gestures
6867
mChart.setTouchEnabled(true);

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ private void setupChart(LineChart chart, LineData data, int color) {
5757

5858
// no description text
5959
chart.getDescription().setEnabled(false);
60-
chart.setNoDataTextDescription("You need to provide data for the chart.");
6160

6261
// mChart.setDrawHorizontalGrid(false);
6362
//

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ protected void onCreate(Bundle savedInstanceState) {
5454

5555
// no description text
5656
mChart.getDescription().setEnabled(false);
57-
mChart.setNoDataTextDescription("You need to provide data for the chart.");
5857

5958
// enable touch gestures
6059
mChart.setTouchEnabled(true);

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ protected void onCreate(Bundle savedInstanceState) {
4343

4444
// no description text
4545
mChart.getDescription().setEnabled(false);
46-
mChart.setNoDataTextDescription("You need to provide data for the chart.");
4746

4847
// enable touch gestures
4948
mChart.setTouchEnabled(true);

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ protected void onCreate(Bundle savedInstanceState) {
3939
mChart = (LineChart) findViewById(R.id.chart1);
4040
mChart.setOnChartValueSelectedListener(this);
4141

42-
// no description text
43-
mChart.getDescription().setEnabled(false);
44-
mChart.setNoDataTextDescription("You need to provide data for the chart.");
42+
// enable description text
43+
mChart.getDescription().setEnabled(true);
4544

4645
// enable touch gestures
4746
mChart.setTouchEnabled(true);

MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmBaseActivity.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ protected void setup(Chart<?> chart) {
3737

3838
// no description text
3939
chart.getDescription().setEnabled(false);
40-
chart.setNoDataTextDescription("You need to provide data for the chart.");
4140

4241
// enable touch gestures
4342
chart.setTouchEnabled(true);

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

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import android.graphics.Paint;
1414
import android.graphics.Paint.Align;
1515
import android.graphics.RectF;
16+
import android.graphics.Typeface;
1617
import android.graphics.drawable.Drawable;
1718
import android.os.Environment;
1819
import android.provider.MediaStore.Images;
@@ -149,12 +150,6 @@ public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Ent
149150
*/
150151
private OnChartGestureListener mGestureListener;
151152

152-
/**
153-
* text that is displayed when the chart is empty that describes why the
154-
* chart is empty
155-
*/
156-
private String mNoDataTextDescription;
157-
158153
protected LegendRenderer mLegendRenderer;
159154

160155
/**
@@ -411,29 +406,12 @@ protected void onDraw(Canvas canvas) {
411406
if (mData == null) {
412407

413408
boolean hasText = !TextUtils.isEmpty(mNoDataText);
414-
boolean hasDescription = !TextUtils.isEmpty(mNoDataTextDescription);
415-
float line1height = hasText ? Utils.calcTextHeight(mInfoPaint, mNoDataText) : 0.f;
416-
float line2height = hasDescription ? Utils.calcTextHeight(mInfoPaint, mNoDataTextDescription) : 0.f;
417-
float lineSpacing = (hasText && hasDescription) ?
418-
(mInfoPaint.getFontSpacing() - line1height) : 0.f;
419-
420-
// if no data, inform the user
421-
422-
float y = (getHeight() -
423-
(line1height + lineSpacing + line2height)) / 2.f
424-
+ line1height;
425409

426410
if (hasText) {
427-
canvas.drawText(mNoDataText, getWidth() / 2, y, mInfoPaint);
428-
429-
if (hasDescription) {
430-
y = y + line1height + lineSpacing;
431-
}
411+
MPPointF c = getCenter();
412+
canvas.drawText(mNoDataText, c.x, c.y, mInfoPaint);
432413
}
433414

434-
if (hasDescription) {
435-
canvas.drawText(mNoDataTextDescription, getWidth() / 2, y, mInfoPaint);
436-
}
437415
return;
438416
}
439417

@@ -1181,13 +1159,12 @@ public void setNoDataTextColor(int color) {
11811159
}
11821160

11831161
/**
1184-
* Sets descriptive text to explain to the user why there is no chart
1185-
* available Defaults to empty if not set
1162+
* Sets the typeface to be used for the no data text.
11861163
*
1187-
* @param text
1164+
* @param tf
11881165
*/
1189-
public void setNoDataTextDescription(String text) {
1190-
mNoDataTextDescription = text;
1166+
public void setNoDataTextTypeface(Typeface tf) {
1167+
mInfoPaint.setTypeface(tf);
11911168
}
11921169

11931170
/**

0 commit comments

Comments
 (0)