Skip to content

Commit e7da575

Browse files
authored
Merge pull request #196 from AppDevNext/serialize
Entry, dataset and chartdata serializable
2 parents 03d55f6 + afd52f2 commit e7da575

File tree

5 files changed

+23
-14
lines changed

5 files changed

+23
-14
lines changed

MPChartLib/src/main/java/com/github/mikephil/charting/data/ChartData.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.github.mikephil.charting.highlight.Highlight;
1010
import com.github.mikephil.charting.interfaces.datasets.IDataSet;
1111

12+
import java.io.Serializable;
1213
import java.util.ArrayList;
1314
import java.util.List;
1415

@@ -18,7 +19,7 @@
1819
*
1920
* @author Philipp Jahoda
2021
*/
21-
public abstract class ChartData<T extends IDataSet<? extends Entry>> {
22+
public abstract class ChartData<T extends IDataSet<? extends Entry>> implements Serializable {
2223

2324
/**
2425
* maximum y-value in the value array across all axes

MPChartLib/src/main/java/com/github/mikephil/charting/data/DataSet.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
package com.github.mikephil.charting.data;
33

4+
import java.io.Serializable;
45
import java.util.ArrayList;
56
import java.util.List;
67

@@ -12,7 +13,7 @@
1213
*
1314
* @author Philipp Jahoda
1415
*/
15-
public abstract class DataSet<T extends Entry> extends BaseDataSet<T> {
16+
public abstract class DataSet<T extends Entry> extends BaseDataSet<T> implements Serializable {
1617

1718
/**
1819
* the entries that this DataSet represents / holds together

MPChartLib/src/main/java/com/github/mikephil/charting/data/Entry.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@
88

99
import com.github.mikephil.charting.utils.Utils;
1010

11+
import java.io.Serializable;
12+
1113
/**
1214
* Class representing one entry in the chart. Might contain multiple values.
1315
* Might only contain a single value depending on the used constructor.
14-
*
16+
*
1517
* @author Philipp Jahoda
1618
*/
17-
public class Entry extends BaseEntry implements Parcelable {
19+
public class Entry extends BaseEntry implements Parcelable, Serializable {
1820

19-
/** the x value */
21+
/**
22+
* the x value
23+
*/
2024
private float x = 0f;
2125

2226
public Entry() {
@@ -37,8 +41,8 @@ public Entry(float x, float y) {
3741
/**
3842
* A Entry represents one single entry in the chart.
3943
*
40-
* @param x the x value
41-
* @param y the y value (the actual value of the entry)
44+
* @param x the x value
45+
* @param y the y value (the actual value of the entry)
4246
* @param data Spot for additional data this Entry represents.
4347
*/
4448
public Entry(float x, float y, Object data) {
@@ -73,7 +77,7 @@ public Entry(float x, float y, Drawable icon, Object data) {
7377

7478
/**
7579
* Returns the x-value of this Entry object.
76-
*
80+
*
7781
* @return
7882
*/
7983
public float getX() {
@@ -82,7 +86,7 @@ public float getX() {
8286

8387
/**
8488
* Sets the x-value of this Entry object.
85-
*
89+
*
8690
* @param x
8791
*/
8892
public void setX(float x) {
@@ -91,7 +95,7 @@ public void setX(float x) {
9195

9296
/**
9397
* returns an exact copy of the entry
94-
*
98+
*
9599
* @return
96100
*/
97101
public Entry copy() {
@@ -103,7 +107,7 @@ public Entry copy() {
103107
* Compares value, xIndex and data of the entries. Returns true if entries
104108
* are equal in those points, false if not. Does not check by hash-code like
105109
* it's done by the "equals" method.
106-
*
110+
*
107111
* @param e
108112
* @return
109113
*/

MPChartLib/src/main/java/com/github/mikephil/charting/formatter/DefaultFillFormatter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider;
66
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
77

8+
import java.io.Serializable;
9+
810
/**
911
* Default formatter that calculates the position of the filled line.
1012
*
1113
* @author Philipp Jahoda
1214
*/
13-
public class DefaultFillFormatter implements IFillFormatter
14-
{
15+
public class DefaultFillFormatter implements IFillFormatter, Serializable {
1516

1617
@Override
1718
public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {

MPChartLib/src/main/java/com/github/mikephil/charting/highlight/Highlight.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33

44
import com.github.mikephil.charting.components.YAxis;
55

6+
import java.io.Serializable;
7+
68
/**
79
* Contains information needed to determine the highlighted value.
810
*
911
* @author Philipp Jahoda
1012
*/
11-
public class Highlight {
13+
public class Highlight implements Serializable {
1214

1315
/**
1416
* the x-value of the highlighted value

0 commit comments

Comments
 (0)