|
3 | 3 |
|
4 | 4 | import android.graphics.Color; |
5 | 5 | import android.os.Bundle; |
6 | | -import android.util.Log; |
7 | | -import android.view.Menu; |
8 | | -import android.view.MenuItem; |
9 | 6 | import android.view.WindowManager; |
10 | 7 | import android.widget.SeekBar; |
11 | 8 | import android.widget.SeekBar.OnSeekBarChangeListener; |
12 | 9 | import android.widget.TextView; |
13 | | -import android.widget.Toast; |
14 | 10 |
|
15 | 11 | import com.github.mikephil.charting.charts.LineChart; |
16 | 12 | import com.github.mikephil.charting.components.Legend; |
17 | | -import com.github.mikephil.charting.components.XAxis; |
18 | | -import com.github.mikephil.charting.data.DataSet; |
19 | 13 | import com.github.mikephil.charting.data.Entry; |
20 | 14 | import com.github.mikephil.charting.data.LineData; |
21 | 15 | import com.github.mikephil.charting.data.LineDataSet; |
22 | | -import com.github.mikephil.charting.data.filter.Approximator; |
23 | | -import com.github.mikephil.charting.data.filter.Approximator.ApproximatorType; |
24 | | -import com.github.mikephil.charting.listener.OnChartValueSelectedListener; |
25 | | -import com.github.mikephil.charting.utils.Highlight; |
26 | 16 | import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase; |
27 | 17 |
|
28 | 18 | import java.util.ArrayList; |
@@ -81,147 +71,6 @@ protected void onCreate(Bundle savedInstanceState) { |
81 | 71 | mChart.invalidate(); |
82 | 72 | } |
83 | 73 |
|
84 | | - @Override |
85 | | - public boolean onCreateOptionsMenu(Menu menu) { |
86 | | - getMenuInflater().inflate(R.menu.line, menu); |
87 | | - return true; |
88 | | - } |
89 | | - |
90 | | - @Override |
91 | | - public boolean onOptionsItemSelected(MenuItem item) { |
92 | | - |
93 | | - switch (item.getItemId()) { |
94 | | - case R.id.actionToggleValues: { |
95 | | - mChart.resetAverage(); |
96 | | - break; |
97 | | - } |
98 | | - case R.id.actionToggleHighlight: { |
99 | | - if (mChart.isHighlightEnabled()) |
100 | | - mChart.setHighlightEnabled(false); |
101 | | - else |
102 | | - mChart.setHighlightEnabled(true); |
103 | | - mChart.invalidate(); |
104 | | - break; |
105 | | - } |
106 | | - case R.id.actionToggleFilled: { |
107 | | - |
108 | | - ArrayList<LineDataSet> sets = (ArrayList<LineDataSet>) mChart.getData() |
109 | | - .getDataSets(); |
110 | | - |
111 | | - for (LineDataSet set : sets) { |
112 | | - if (set.isDrawFilledEnabled()) |
113 | | - set.setDrawFilled(false); |
114 | | - else |
115 | | - set.setDrawFilled(true); |
116 | | - } |
117 | | - mChart.invalidate(); |
118 | | - break; |
119 | | - } |
120 | | - case R.id.actionToggleCircles: { |
121 | | - ArrayList<LineDataSet> sets = (ArrayList<LineDataSet>) mChart.getData() |
122 | | - .getDataSets(); |
123 | | - |
124 | | - for (LineDataSet set : sets) { |
125 | | - if (set.isDrawCirclesEnabled()) |
126 | | - set.setDrawCircles(false); |
127 | | - else |
128 | | - set.setDrawCircles(true); |
129 | | - } |
130 | | - mChart.invalidate(); |
131 | | - break; |
132 | | - } |
133 | | - case R.id.actionToggleCubic: { |
134 | | - ArrayList<LineDataSet> sets = (ArrayList<LineDataSet>) mChart.getData() |
135 | | - .getDataSets(); |
136 | | - |
137 | | - for (LineDataSet set : sets) { |
138 | | - if (set.isDrawCubicEnabled()) |
139 | | - set.setDrawCubic(false); |
140 | | - else |
141 | | - set.setDrawCubic(true); |
142 | | - } |
143 | | - mChart.invalidate(); |
144 | | - break; |
145 | | - } |
146 | | - case R.id.actionToggleStartzero: { |
147 | | - mChart.getAxisLeft().setStartAtZero(!mChart.getAxisLeft().isStartAtZeroEnabled()); |
148 | | - mChart.getAxisRight().setStartAtZero(!mChart.getAxisRight().isStartAtZeroEnabled()); |
149 | | - mChart.invalidate(); |
150 | | - break; |
151 | | - } |
152 | | - case R.id.actionTogglePinch: { |
153 | | - if (mChart.isPinchZoomEnabled()) |
154 | | - mChart.setPinchZoom(false); |
155 | | - else |
156 | | - mChart.setPinchZoom(true); |
157 | | - |
158 | | - mChart.invalidate(); |
159 | | - break; |
160 | | - } |
161 | | - case R.id.animateX: { |
162 | | - mChart.animateX(3000); |
163 | | - break; |
164 | | - } |
165 | | - case R.id.animateY: { |
166 | | - mChart.animateY(3000); |
167 | | - break; |
168 | | - } |
169 | | - case R.id.animateXY: { |
170 | | - mChart.animateXY(3000, 3000); |
171 | | - break; |
172 | | - } |
173 | | - case R.id.actionToggleAdjustXLegend: { |
174 | | - XAxis xLabels = mChart.getXAxis(); |
175 | | - |
176 | | - if (xLabels.isAdjustXLabelsEnabled()) |
177 | | - xLabels.setAdjustXLabels(false); |
178 | | - else |
179 | | - xLabels.setAdjustXLabels(true); |
180 | | - |
181 | | - mChart.invalidate(); |
182 | | - break; |
183 | | - } |
184 | | - case R.id.actionToggleFilter: { |
185 | | - |
186 | | - // the angle of filtering is 35° |
187 | | - Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 35); |
188 | | - |
189 | | - if (!mChart.isFilteringEnabled()) { |
190 | | - mChart.enableFiltering(a); |
191 | | - } else { |
192 | | - mChart.disableFiltering(); |
193 | | - } |
194 | | - mChart.invalidate(); |
195 | | - |
196 | | - // |
197 | | - // for(int i = 0; i < 10; i++) { |
198 | | - // mChart.addEntry(new Entry((float) (Math.random() * 100), |
199 | | - // i+2), 0); |
200 | | - // mChart.invalidate(); |
201 | | - // } |
202 | | - // |
203 | | - // Toast.makeText(getApplicationContext(), "valcount: " + |
204 | | - // mChart.getDataOriginal().getYValCount() + ", valsum: " + |
205 | | - // mChart.getDataOriginal().getYValueSum(), |
206 | | - // Toast.LENGTH_SHORT).show(); |
207 | | - // |
208 | | - break; |
209 | | - } |
210 | | - case R.id.actionSave: { |
211 | | - if (mChart.saveToPath("title" + System.currentTimeMillis(), "")) { |
212 | | - Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!", |
213 | | - Toast.LENGTH_SHORT).show(); |
214 | | - } else |
215 | | - Toast.makeText(getApplicationContext(), "Saving FAILED!", Toast.LENGTH_SHORT) |
216 | | - .show(); |
217 | | - |
218 | | - // mChart.saveToGallery("title"+System.currentTimeMillis()) |
219 | | - break; |
220 | | - } |
221 | | - } |
222 | | - return true; |
223 | | - } |
224 | | - |
225 | 74 | @Override |
226 | 75 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { |
227 | 76 |
|
|
0 commit comments