GeezerVison is showing github.com — Reinvented Markers - interface based, enhanced default behaviour · FlyingAndroid/MPAndroidChart@51f0e53
File treeExpand file treeCollapse file tree Open diff view settings src/com/xxmassdeveloper/mpchartexample
MPChartLib/src/main/java/com/github/mikephil/charting
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: MPChartExample/AndroidManifest.xml -10Lines changed: 0 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 47 | 47 | <activity android:name="RadarChartActivitry"></activity> | 48 | 48 | <activity android:name="LineChartActivityColored"></activity> | 49 | 49 | <activity android:name="DynamicalAddingActivity"></activity> | 50 | | - <activity android:name=".realm.RealmDatabaseActivityLine"></activity> | 51 | | - <activity android:name=".realm.RealmDatabaseActivityBar"></activity> | 52 | | - <activity android:name=".realm.RealmDatabaseActivityHorizontalBar"></activity> | 53 | | - <activity android:name=".realm.RealmDatabaseActivityScatter"></activity> | 54 | | - <activity android:name=".realm.RealmDatabaseActivityCandle"></activity> | 55 | | - <activity android:name=".realm.RealmDatabaseActivityBubble"></activity> | 56 | | - <activity android:name=".realm.RealmDatabaseActivityPie"></activity> | 57 | | - <activity android:name=".realm.RealmDatabaseActivityRadar"></activity> | 58 | | - <activity android:name=".realm.RealmMainActivity"></activity> | 59 | 50 | <activity android:name="RealtimeLineChartActivity"></activity> | 60 | 51 | <activity android:name="CombinedChartActivity"></activity> | 61 | 52 | <activity android:name="PerformanceLineChart"></activity> | 62 | 53 | <activity android:name="BarChartActivitySinus"></activity> | 63 | 54 | <activity android:name="ScrollViewActivity"></activity> | 64 | 55 | <activity android:name="StackedBarActivityNegative"></activity> | 65 | | - <activity android:name=".realm.RealmWikiExample"></activity> | 66 | 56 | <activity android:name=".BarChartPositiveNegative"></activity> | 67 | 57 | <activity android:name=".FilledLineActivity"></activity> | 68 | 58 | <activity android:name=".HalfPieChartActivity"></activity> | |
Collapse file Copy file name to clipboardExpand all lines: MPChartExample/build.gradle +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | apply plugin: 'com.android.application' | 2 | | -apply plugin: 'realm-android' | | 2 | +//apply plugin: 'realm-android' | 3 | 3 |
| 4 | 4 | android { | 5 | 5 | compileSdkVersion 23 | |
Collapse file Copy file name to clipboardExpand all lines: MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivity.java +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -119,7 +119,9 @@ protected void onCreate(Bundle savedInstanceState) { | 119 | 119 | // l.setCustom(ColorTemplate.VORDIPLOM_COLORS, new String[] { "abc", | 120 | 120 | // "def", "ghj", "ikl", "mno" }); | 121 | 121 |
| 122 | | - mChart.setMarkerView(new XYMarkerView(this, xAxisFormatter)); | | 122 | + XYMarkerView mv = new XYMarkerView(this, xAxisFormatter); | | 123 | + mv.setChartView(mChart); // For bounds control | | 124 | + mChart.setMarker(mv); // Set the marker to the chart | 123 | 125 |
| 124 | 126 | setData(12, 50); | 125 | 127 |
| |
Collapse file Copy file name to clipboardExpand all lines: MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivityMultiDataset.java +2-3Lines changed: 2 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -70,9 +70,8 @@ protected void onCreate(Bundle savedInstanceState) { | 70 | 70 | // create a custom MarkerView (extend MarkerView) and specify the layout | 71 | 71 | // to use for it | 72 | 72 | MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view); | 73 | | - | 74 | | - // set the marker to the chart | 75 | | - mChart.setMarkerView(mv); | | 73 | + mv.setChartView(mChart); // For bounds control | | 74 | + mChart.setMarker(mv); // Set the marker to the chart | 76 | 75 |
| 77 | 76 | mSeekBarX.setProgress(10); | 78 | 77 | mSeekBarY.setProgress(100); | |
Collapse file Copy file name to clipboardExpand all lines: MPChartExample/src/com/xxmassdeveloper/mpchartexample/DynamicalAddingActivity.java +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -87,11 +87,11 @@ private void removeLastEntry() { | 87 | 87 |
| 88 | 88 | if (set != null) { | 89 | 89 |
| 90 | | - Entry e = set.getEntryForXPos(set.getEntryCount() - 1); | | 90 | + Entry e = set.getEntryForXValue(set.getEntryCount() - 1); | 91 | 91 |
| 92 | 92 | data.removeEntry(e, 0); | 93 | 93 | // or remove by index | 94 | | - // mData.removeEntryByXPos(xIndex, dataSetIndex); | | 94 | + // mData.removeEntryByXValue(xIndex, dataSetIndex); | 95 | 95 | data.notifyDataChanged(); | 96 | 96 | mChart.notifyDataSetChanged(); | 97 | 97 | mChart.invalidate(); | |
Collapse file Copy file name to clipboardExpand all lines: MPChartExample/src/com/xxmassdeveloper/mpchartexample/InvertedLineChartActivity.java +2-3Lines changed: 2 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -79,9 +79,8 @@ protected void onCreate(Bundle savedInstanceState) { | 79 | 79 | // create a custom MarkerView (extend MarkerView) and specify the layout | 80 | 80 | // to use for it | 81 | 81 | MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view); | 82 | | - | 83 | | - // set the marker to the chart | 84 | | - mChart.setMarkerView(mv); | | 82 | + mv.setChartView(mChart); // For bounds control | | 83 | + mChart.setMarker(mv); // Set the marker to the chart | 85 | 84 |
| 86 | 85 | XAxis xl = mChart.getXAxis(); | 87 | 86 | xl.setAvoidFirstLastClipping(true); | |
Collapse file Copy file name to clipboardExpand all lines: MPChartExample/src/com/xxmassdeveloper/mpchartexample/LineChartActivity1.java +2-3Lines changed: 2 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -92,9 +92,8 @@ protected void onCreate(Bundle savedInstanceState) { | 92 | 92 | // create a custom MarkerView (extend MarkerView) and specify the layout | 93 | 93 | // to use for it | 94 | 94 | MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view); | 95 | | - | 96 | | - // set the marker to the chart | 97 | | - mChart.setMarkerView(mv); | | 95 | + mv.setChartView(mChart); // For bounds control | | 96 | + mChart.setMarker(mv); // Set the marker to the chart | 98 | 97 |
| 99 | 98 | // x-axis limit line | 100 | 99 | LimitLine llXAxis = new LimitLine(10f, "Index 10"); | |
Collapse file Copy file name to clipboardExpand all lines: MPChartExample/src/com/xxmassdeveloper/mpchartexample/RadarChartActivitry.java +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 14 | 14 | import com.github.mikephil.charting.components.AxisBase; | 15 | 15 | import com.github.mikephil.charting.components.Legend; | 16 | 16 | import com.github.mikephil.charting.components.Legend.LegendPosition; | | 17 | +import com.github.mikephil.charting.components.MarkerImage; | 17 | 18 | import com.github.mikephil.charting.components.MarkerView; | 18 | 19 | import com.github.mikephil.charting.components.XAxis; | 19 | 20 | import com.github.mikephil.charting.components.YAxis; | @@ -58,9 +59,8 @@ protected void onCreate(Bundle savedInstanceState) { | 58 | 59 | // create a custom MarkerView (extend MarkerView) and specify the layout | 59 | 60 | // to use for it | 60 | 61 | MarkerView mv = new RadarMarkerView(this, R.layout.radar_markerview); | 61 | | - | 62 | | - // set the marker to the chart | 63 | | - mChart.setMarkerView(mv); | | 62 | + mv.setChartView(mChart); // For bounds control | | 63 | + mChart.setMarker(mv); // Set the marker to the chart | 64 | 64 |
| 65 | 65 | setData(); | 66 | 66 |
| |
Collapse file Copy file name to clipboardExpand all lines: MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/MyMarkerView.java +4-8Lines changed: 4 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 8 | 8 | import com.github.mikephil.charting.data.CandleEntry; | 9 | 9 | import com.github.mikephil.charting.data.Entry; | 10 | 10 | import com.github.mikephil.charting.highlight.Highlight; | | 11 | +import com.github.mikephil.charting.utils.MPPointF; | 11 | 12 | import com.github.mikephil.charting.utils.Utils; | 12 | 13 | import com.xxmassdeveloper.mpchartexample.R; | 13 | 14 |
| @@ -40,17 +41,12 @@ public void refreshContent(Entry e, Highlight highlight) { | 40 | 41 |
| 41 | 42 | tvContent.setText("" + Utils.formatNumber(e.getY(), 0, true)); | 42 | 43 | } | 43 | | - } | 44 | 44 |
| 45 | | - @Override | 46 | | - public int getXOffset(float xpos) { | 47 | | - // this will center the marker-view horizontally | 48 | | - return -(getWidth() / 2); | | 45 | + super.refreshContent(e, highlight); | 49 | 46 | } | 50 | 47 |
| 51 | 48 | @Override | 52 | | - public int getYOffset(float ypos) { | 53 | | - // this will cause the marker-view to be above the selected value | 54 | | - return -getHeight(); | | 49 | + public MPPointF getOffset() { | | 50 | + return new MPPointF(-(getWidth() / 2), -getHeight()); | 55 | 51 | } | 56 | 52 | } |
Collapse file Copy file name to clipboardExpand all lines: MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/RadarMarkerView.java +4-8Lines changed: 4 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 10 | 10 | import com.github.mikephil.charting.data.Entry; | 11 | 11 | import com.github.mikephil.charting.formatter.FormattedStringCache; | 12 | 12 | import com.github.mikephil.charting.highlight.Highlight; | | 13 | +import com.github.mikephil.charting.utils.MPPointF; | 13 | 14 | import com.github.mikephil.charting.utils.Utils; | 14 | 15 | import com.xxmassdeveloper.mpchartexample.R; | 15 | 16 |
| @@ -38,17 +39,12 @@ public RadarMarkerView(Context context, int layoutResource) { | 38 | 39 | public void refreshContent(Entry e, Highlight highlight) { | 39 | 40 | float value = e.getY(); | 40 | 41 | tvContent.setText(mFormattedStringCache.getFormattedValue(value) + " %"); | 41 | | - } | 42 | 42 |
| 43 | | - @Override | 44 | | - public int getXOffset(float xpos) { | 45 | | - // this will center the marker-view horizontally | 46 | | - return -(getWidth() / 2); | | 43 | + super.refreshContent(e, highlight); | 47 | 44 | } | 48 | 45 |
| 49 | 46 | @Override | 50 | | - public int getYOffset(float ypos) { | 51 | | - // this will cause the marker-view to be above the selected value | 52 | | - return -getHeight()-10; | | 47 | + public MPPointF getOffset() { | | 48 | + return new MPPointF(-(getWidth() / 2), -getHeight() - 10); | 53 | 49 | } | 54 | 50 | } |
|