From 35faecc61f9da65558d778f34969e535d1301aa9 Mon Sep 17 00:00:00 2001 From: Philipp Jahoda Date: Fri, 15 Aug 2014 20:47:13 +0200 Subject: [PATCH] Added dialog for example that the feature drawing into the chart by gesture is currenlty not available. --- .../mpchartexample/BarChartActivity.java | 4 ++-- .../mpchartexample/notimportant/MainActivity.java | 14 ++++++++++---- .../com/github/mikephil/charting/charts/Chart.java | 3 ++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivity.java index cd0ca7906..19e8e791d 100644 --- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivity.java +++ b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivity.java @@ -222,13 +222,13 @@ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { tvY.setText("" + (mSeekBarY.getProgress())); ArrayList xVals = new ArrayList(); - for (int i = 0; i < mSeekBarX.getProgress(); i++) { + for (int i = 0; i < mSeekBarX.getProgress()+1; i++) { xVals.add(mMonths[i % 12]); } ArrayList yVals1 = new ArrayList(); - for (int i = 0; i < mSeekBarX.getProgress(); i++) { + for (int i = 0; i < mSeekBarX.getProgress()+1; i++) { float mult = (mSeekBarY.getProgress() + 1); float val = (float) (Math.random() * mult) + 3; yVals1.add(new Entry(val, i)); diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/notimportant/MainActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/notimportant/MainActivity.java index 5d2037a2b..d86a93f4c 100644 --- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/notimportant/MainActivity.java +++ b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/notimportant/MainActivity.java @@ -2,6 +2,7 @@ package com.xxmassdeveloper.mpchartexample.notimportant; import android.app.Activity; +import android.app.AlertDialog; import android.content.Context; import android.content.Intent; import android.net.Uri; @@ -22,7 +23,6 @@ import com.xxmassdeveloper.mpchartexample.AnotherBarActivity; import com.xxmassdeveloper.mpchartexample.BarChartActivity; import com.xxmassdeveloper.mpchartexample.BarChartActivityMultiDataset; -import com.xxmassdeveloper.mpchartexample.DrawChartActivity; import com.xxmassdeveloper.mpchartexample.InvertedLineChartActivity; import com.xxmassdeveloper.mpchartexample.LineChartActivity; import com.xxmassdeveloper.mpchartexample.ListViewBarChartActivity; @@ -48,7 +48,7 @@ protected void onCreate(Bundle savedInstanceState) { // initialize the utilities Utils.init(getResources()); - + ArrayList objects = new ArrayList(); objects.add(new ContentItem("Line Chart", "A simple demonstration of the linechart.")); @@ -126,8 +126,14 @@ public void onItemClick(AdapterView av, View v, int pos, long arg3) { startActivity(i); break; case 8: - i = new Intent(this, DrawChartActivity.class); - startActivity(i); + // i = new Intent(this, DrawChartActivity.class); + // startActivity(i); + + AlertDialog.Builder b = new AlertDialog.Builder(this); + b.setTitle("Feature not available"); + b.setMessage("Due to recent changes to the data model of the library, this feature is temporarily not available."); + b.setPositiveButton("OK", null); + b.create().show(); break; case 9: i = new Intent(this, SimpleChartDemo.class); diff --git a/MPChartLib/src/com/github/mikephil/charting/charts/Chart.java b/MPChartLib/src/com/github/mikephil/charting/charts/Chart.java index a1a067ead..eeee72bb8 100644 --- a/MPChartLib/src/com/github/mikephil/charting/charts/Chart.java +++ b/MPChartLib/src/com/github/mikephil/charting/charts/Chart.java @@ -1009,7 +1009,8 @@ protected void drawMarkers() { int xIndex = mIndicesToHightlight[i].getXIndex(); - drawMarkerView(xIndex, mIndicesToHightlight[i].getDataSetIndex()); + if (xIndex < mCurrentData.getXVals().size()) + drawMarkerView(xIndex, mIndicesToHightlight[i].getDataSetIndex()); } }