Code & example cleanup

This commit is contained in:
Philipp Jahoda 2016-02-16 16:34:49 +01:00
parent 9c92003c3e
commit 4f1f5bc3ef
23 changed files with 9 additions and 279 deletions

View file

@ -29,10 +29,6 @@
android:id="@+id/actionToggleAdjustXLegend"
android:title="Toggle AdjustXLegend">
</item>
<item
android:id="@+id/actionToggleFilter"
android:title="Toggle filter">
</item>
<item
android:id="@+id/actionSave"
android:title="Save to Gallery">

View file

@ -25,10 +25,6 @@
android:id="@+id/animateXY"
android:title="Animate XY">
</item>
<item
android:id="@+id/actionToggleFilter"
android:title="Toggle filter">
</item>
<item
android:id="@+id/actionSave"
android:title="Save to Gallery">

View file

@ -21,10 +21,6 @@
android:id="@+id/actionToggleAdjustXLegend"
android:title="Toggle AdjustXLegend">
</item>
<item
android:id="@+id/actionToggleFilter"
android:title="Toggle filter">
</item>
<item
android:id="@+id/actionSave"
android:title="Save to Gallery">

View file

@ -37,10 +37,6 @@
android:id="@+id/actionToggleAdjustXLegend"
android:title="Toggle AdjustXLegend">
</item>
<item
android:id="@+id/actionToggleFilter"
android:title="Toggle filter">
</item>
<item
android:id="@+id/actionSave"
android:title="Save to SD-Card">

View file

@ -25,10 +25,6 @@
android:id="@+id/animateXY"
android:title="Animate XY">
</item>
<item
android:id="@+id/actionToggleFilter"
android:title="Toggle filter">
</item>
<item
android:id="@+id/actionSave"
android:title="Save to Gallery">

View file

@ -147,18 +147,6 @@ public class AnotherBarActivity extends DemoBase implements OnSeekBarChangeListe
mChart.animateXY(3000, 3000);
break;
}
case R.id.actionToggleFilter: {
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 25);
if (!mChart.isFilteringEnabled()) {
mChart.enableFiltering(a);
} else {
mChart.disableFiltering();
}
mChart.invalidate();
break;
}
case R.id.actionSave: {
if (mChart.saveToGallery("title" + System.currentTimeMillis(), 50)) {
Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",

View file

@ -188,18 +188,6 @@ public class BarChartActivity extends DemoBase implements OnSeekBarChangeListene
mChart.animateXY(3000, 3000);
break;
}
case R.id.actionToggleFilter: {
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 25);
if (!mChart.isFilteringEnabled()) {
mChart.enableFiltering(a);
} else {
mChart.disableFiltering();
}
mChart.invalidate();
break;
}
case R.id.actionSave: {
if (mChart.saveToGallery("title" + System.currentTimeMillis(), 50)) {
Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",

View file

@ -169,18 +169,6 @@ public class BarChartActivitySinus extends DemoBase implements OnSeekBarChangeLi
mChart.animateXY(2000, 2000);
break;
}
case R.id.actionToggleFilter: {
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 25);
if (!mChart.isFilteringEnabled()) {
mChart.enableFiltering(a);
} else {
mChart.disableFiltering();
}
mChart.invalidate();
break;
}
case R.id.actionSave: {
if (mChart.saveToGallery("title" + System.currentTimeMillis(), 50)) {
Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",

View file

@ -133,18 +133,6 @@ public class BubbleChartActivity extends DemoBase implements OnSeekBarChangeList
mChart.notifyDataSetChanged();
break;
}
case R.id.actionToggleFilter: {
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 25);
if (!mChart.isFilteringEnabled()) {
mChart.enableFiltering(a);
} else {
mChart.disableFiltering();
}
mChart.invalidate();
break;
}
case R.id.actionSave: {
// mChart.saveToGallery("title"+System.currentTimeMillis());
mChart.saveToPath("title" + System.currentTimeMillis(), "");

View file

@ -198,19 +198,6 @@ public class CubicLineChartActivity extends DemoBase implements OnSeekBarChangeL
mChart.animateXY(3000, 3000);
break;
}
case R.id.actionToggleFilter: {
// the angle of filtering is 35°
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 35);
if (!mChart.isFilteringEnabled()) {
mChart.enableFiltering(a);
} else {
mChart.disableFiltering();
}
mChart.invalidate();
break;
}
case R.id.actionSave: {
if (mChart.saveToPath("title" + System.currentTimeMillis(), "")) {
Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",

View file

@ -190,18 +190,6 @@ public class HorizontalBarChartActivity extends DemoBase implements OnSeekBarCha
mChart.animateXY(3000, 3000);
break;
}
case R.id.actionToggleFilter: {
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 25);
if (!mChart.isFilteringEnabled()) {
mChart.enableFiltering(a);
} else {
mChart.disableFiltering();
}
mChart.invalidate();
break;
}
case R.id.actionSave: {
if (mChart.saveToGallery("title" + System.currentTimeMillis(), 50)) {
Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",

View file

@ -201,19 +201,6 @@ public class InvertedLineChartActivity extends DemoBase implements OnSeekBarChan
mChart.notifyDataSetChanged();
break;
}
case R.id.actionToggleFilter: {
// the angle of filtering is 35°
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 35);
if (!mChart.isFilteringEnabled()) {
mChart.enableFiltering(a);
} else {
mChart.disableFiltering();
}
mChart.invalidate();
break;
}
case R.id.actionSave: {
if (mChart.saveToPath("title" + System.currentTimeMillis(), "")) {
Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",

View file

@ -270,19 +270,6 @@ public class LineChartActivity1 extends DemoBase implements OnSeekBarChangeListe
mChart.animateXY(3000, 3000);
break;
}
case R.id.actionToggleFilter: {
// the angle of filtering is 35°
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 35);
if (!mChart.isFilteringEnabled()) {
mChart.enableFiltering(a);
} else {
mChart.disableFiltering();
}
mChart.invalidate();
break;
}
case R.id.actionSave: {
if (mChart.saveToPath("title" + System.currentTimeMillis(), "")) {
Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",

View file

@ -228,19 +228,6 @@ public class LineChartActivity2 extends DemoBase implements OnSeekBarChangeListe
mChart.animateXY(3000, 3000);
break;
}
case R.id.actionToggleFilter: {
// the angle of filtering is 35°
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 35);
if (!mChart.isFilteringEnabled()) {
mChart.enableFiltering(a);
} else {
mChart.disableFiltering();
}
mChart.invalidate();
break;
}
case R.id.actionSave: {
if (mChart.saveToPath("title" + System.currentTimeMillis(), "")) {
Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",

View file

@ -155,19 +155,6 @@ public class MultiLineChartActivity extends DemoBase implements OnSeekBarChangeL
mChart.invalidate();
break;
}
case R.id.actionToggleFilter: {
// the angle of filtering is 35°
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 35);
if (!mChart.isFilteringEnabled()) {
mChart.enableFiltering(a);
} else {
mChart.disableFiltering();
}
mChart.invalidate();
break;
}
case R.id.actionSave: {
// mChart.saveToGallery("title"+System.currentTimeMillis());
mChart.saveToPath("title" + System.currentTimeMillis(), "");

View file

@ -137,18 +137,6 @@ public class ScatterChartActivity extends DemoBase implements OnSeekBarChangeLis
mChart.notifyDataSetChanged();
break;
}
case R.id.actionToggleFilter: {
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 25);
if (!mChart.isFilteringEnabled()) {
mChart.enableFiltering(a);
} else {
mChart.disableFiltering();
}
mChart.invalidate();
break;
}
case R.id.actionSave: {
// mChart.saveToGallery("title"+System.currentTimeMillis());
mChart.saveToPath("title" + System.currentTimeMillis(), "");

View file

@ -161,18 +161,6 @@ public class StackedBarActivity extends DemoBase implements OnSeekBarChangeListe
mChart.animateXY(3000, 3000);
break;
}
case R.id.actionToggleFilter: {
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 25);
if (!mChart.isFilteringEnabled()) {
mChart.enableFiltering(a);
} else {
mChart.disableFiltering();
}
mChart.invalidate();
break;
}
case R.id.actionSave: {
if (mChart.saveToGallery("title" + System.currentTimeMillis(), 50)) {
Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!", Toast.LENGTH_SHORT).show();

View file

@ -175,18 +175,6 @@ public class StackedBarActivityNegative extends DemoBase implements
mChart.animateXY(3000, 3000);
break;
}
case R.id.actionToggleFilter: {
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 25);
if (!mChart.isFilteringEnabled()) {
mChart.enableFiltering(a);
} else {
mChart.disableFiltering();
}
mChart.invalidate();
break;
}
case R.id.actionSave: {
if (mChart.saveToGallery("title" + System.currentTimeMillis(), 50)) {
Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",

View file

@ -10,8 +10,8 @@ import com.github.mikephil.charting.data.BarData;
import com.github.mikephil.charting.data.BarEntry;
import com.github.mikephil.charting.highlight.BarHighlighter;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
import com.github.mikephil.charting.interfaces.dataprovider.BarDataProvider;
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
import com.github.mikephil.charting.renderer.BarChartRenderer;
import com.github.mikephil.charting.renderer.XAxisRendererBarChart;
@ -30,11 +30,6 @@ public class BarChart extends BarLineChartBase<BarData> implements BarDataProvid
*/
private boolean mDrawValueAboveBar = true;
/**
* if set to true, all values of a stack are drawn individually, and not just their sum
*/
// private boolean mDrawValuesForWholeStack = true;
/**
* if set to true, a grey area is drawn behind each bar that indicates the maximum value
*/
@ -166,25 +161,6 @@ public class BarChart extends BarLineChartBase<BarData> implements BarDataProvid
return mDrawValueAboveBar;
}
// /**
// * if set to true, all values of a stack are drawn individually, and not
// * just their sum
// *
// * @param enabled
// */
// public void setDrawValuesForWholeStack(boolean enabled) {
// mDrawValuesForWholeStack = enabled;
// }
//
// /**
// * returns true if all values of a stack are drawn, and not just their sum
// *
// * @return
// */
// public boolean isDrawValuesForWholeStackEnabled() {
// return mDrawValuesForWholeStack;
// }
/**
* If set to true, a grey area is drawn behind each bar that indicates the maximum value. Enabling his will reduce
* performance by about 50%.

View file

@ -22,7 +22,6 @@ import com.github.mikephil.charting.data.BarData;
import com.github.mikephil.charting.data.BarEntry;
import com.github.mikephil.charting.data.BarLineScatterCandleBubbleData;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.filter.Approximator;
import com.github.mikephil.charting.highlight.ChartHighlighter;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.interfaces.dataprovider.BarLineScatterCandleBubbleDataProvider;
@ -84,11 +83,6 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleBubbleData<
private boolean mScaleXEnabled = true;
private boolean mScaleYEnabled = true;
/**
* if true, data filtering is enabled
*/
protected boolean mFilterData = false;
/**
* paint object for the (by default) lightgrey background of the grid
*/
@ -333,11 +327,6 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleBubbleData<
calcMinMax();
// if (mAxisLeft.needsDefaultFormatter())
// mAxisLeft.setValueFormatter(mDefaultFormatter);
// if (mAxisRight.needsDefaultFormatter())
// mAxisRight.setValueFormatter(mDefaultFormatter);
mAxisRendererLeft.computeAxis(mAxisLeft.mAxisMinimum, mAxisLeft.mAxisMaximum);
mAxisRendererRight.computeAxis(mAxisRight.mAxisMinimum, mAxisRight.mAxisMaximum);
@ -1329,33 +1318,6 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleBubbleData<
return mXAxis;
}
/**
* Enables data filtering for the chart data, filtering will use the user
* customized Approximator handed over to this method.
*
* @param a
*/
public void enableFiltering(Approximator a) {
mFilterData = true;
// mApproximator = a;
}
/**
* Disables data filtering for the chart.
*/
public void disableFiltering() {
mFilterData = false;
}
/**
* returns true if data filtering is enabled, false if not
*
* @return
*/
public boolean isFilteringEnabled() {
return mFilterData;
}
/**
* If set to true, both x and y axis can be scaled simultaneously with 2 fingers, if false,
* x and y axis can be scaled separately. default: false
@ -1443,10 +1405,12 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleBubbleData<
mAxisRendererRight = rendererRightYAxis;
}
@Override
public float getYChartMax() {
return Math.max(mAxisLeft.mAxisMaximum, mAxisRight.mAxisMaximum);
}
@Override
public float getYChartMin() {
return Math.min(mAxisLeft.mAxisMinimum, mAxisRight.mAxisMinimum);
}

View file

@ -32,18 +32,18 @@ import com.github.mikephil.charting.components.Legend;
import com.github.mikephil.charting.components.MarkerView;
import com.github.mikephil.charting.data.ChartData;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.formatter.DefaultValueFormatter;
import com.github.mikephil.charting.formatter.ValueFormatter;
import com.github.mikephil.charting.highlight.ChartHighlighter;
import com.github.mikephil.charting.interfaces.datasets.IDataSet;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.interfaces.dataprovider.ChartInterface;
import com.github.mikephil.charting.interfaces.datasets.IDataSet;
import com.github.mikephil.charting.listener.ChartTouchListener;
import com.github.mikephil.charting.listener.OnChartGestureListener;
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
import com.github.mikephil.charting.renderer.DataRenderer;
import com.github.mikephil.charting.renderer.LegendRenderer;
import com.github.mikephil.charting.formatter.DefaultValueFormatter;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.utils.Utils;
import com.github.mikephil.charting.formatter.ValueFormatter;
import com.github.mikephil.charting.utils.ViewPortHandler;
import java.io.File;
@ -447,13 +447,6 @@ public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Ent
calculateOffsets();
mOffsetsCalculated = true;
}
// if (mDrawCanvas == null) {
// mDrawCanvas = new Canvas(mDrawBitmap);
// }
// clear everything
// mDrawBitmap.eraseColor(Color.TRANSPARENT);
}
/**
@ -966,27 +959,6 @@ public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Ent
public OnChartGestureListener getOnChartGestureListener() {
return mGestureListener;
}
//
// /**
// * If set to true, value highlighting is enabled for all underlying data of
// * the chart which means that all values can be highlighted programmatically
// * or by touch gesture.
// *
// * @param enabled
// */
// public void setHighlightEnabled(boolean enabled) {
// if (mData != null)
// mData.setHighlightEnabled(enabled);
// }
//
// /**
// * Returns true if highlighting of values is enabled, false if not
// *
// * @return
// */
// public boolean isHighlightEnabled() {
// return mData == null ? true : mData.isHighlightEnabled();
// }
/**
* returns the current y-max value across all DataSets
@ -1739,7 +1711,7 @@ public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Ent
//Log.i(LOG_TAG, "Detaching...");
if(mUnbind)
if (mUnbind)
unbindDrawables(this);
}

View file

@ -11,12 +11,12 @@ import com.github.mikephil.charting.data.CombinedData;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.ScatterData;
import com.github.mikephil.charting.highlight.CombinedHighlighter;
import com.github.mikephil.charting.interfaces.datasets.IBubbleDataSet;
import com.github.mikephil.charting.interfaces.dataprovider.BarDataProvider;
import com.github.mikephil.charting.interfaces.dataprovider.BubbleDataProvider;
import com.github.mikephil.charting.interfaces.dataprovider.CandleDataProvider;
import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider;
import com.github.mikephil.charting.interfaces.dataprovider.ScatterDataProvider;
import com.github.mikephil.charting.interfaces.datasets.IBubbleDataSet;
import com.github.mikephil.charting.renderer.CombinedChartRenderer;
/**

View file

@ -268,7 +268,6 @@ public class YAxisRendererHorizontalBarChart extends YAxisRenderer {
mLimitLinePaint.setTextAlign(Align.RIGHT);
c.drawText(label, pts[0] - xOffset, mViewPortHandler.contentBottom() - yOffset, mLimitLinePaint);
}
}
}
}