Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Chartroid/.idea/checkstyle-idea.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Chartroid/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,8 +1,41 @@
package com.hqyxjy.ldf.chartroidlib.base;

import android.content.Context;
import android.view.ViewGroup;

/**
* Created by ldf on 17/5/8.
*/

public class Chart {
import com.hqyxjy.ldf.chartroidlib.component.Entry;
import com.hqyxjy.ldf.chartroidlib.data.ChartData;
import com.hqyxjy.ldf.chartroidlib.data.iset.IDataSet;

public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Entry>>> extends ViewGroup{
/**
* Extra offsets to be appended to the viewport
*/
private float extraTopOffset = 0.f,
extraRightOffset = 0.f,
extraBottomOffset = 0.f,
extraLeftOffset = 0.f;

private float mMinTopOffset = 0.f,
minRightOffset = 0.f,
minBottomOffset = 0.f,
minLeftOffset = 0.f;

public Chart(Context context){
super(context);
init();
}

@Override
protected void onLayout(boolean b, int i, int i1, int i2, int i3) {

}

private void init() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ public class ChartTrackHandler {
private float offsetBottom;

/**
* transMatrix used for touch events
* transMatrix used for transfrom events
*/
protected final Matrix transMatrix = new Matrix();
/**
* touchMatrix used for touch events
*/
protected final Matrix touchMatrix = new Matrix();

private float chartWidth;
private float chartHeight;
Expand Down Expand Up @@ -194,4 +198,16 @@ public Matrix translate(final float[] aimPoint) {

return save;
}

public float getChartHeight() {
return 0;
}

public Matrix getTouchMatrix() {
return touchMatrix;
}

public Matrix getTransMatrix() {
return transMatrix;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,141 @@
package com.hqyxjy.ldf.chartroidlib.component;

import android.os.Parcel;
import android.os.ParcelFormatException;
import android.os.Parcelable;

/**
* Created by ldf on 17/5/6.
*/

public class Entry implements Parcelable{
private float yVal;
private float xVal;
private float xIndex;
private float data;
private Object attachment;// 附件

public Entry() {
}

/**
* A Entry represents one single entry in the chart.
*
* @param yVal the y value (the actual value of the entry)
* @param xVal 对应X轴值的链表中的index,所以此数值不能超过X轴链表的长度
*/
public Entry(float yVal, float xVal) {
this.yVal = yVal;
this.xVal = xVal;
}

/**
* A Entry represents one single entry in the chart.
*
* @param yVal the y value (the actual value of the entry)
* @param xVal the corresponding index in the x value array (index on the
* x-axis of the chart, must NOT be higher than the length of the
* x-values String array)
* @param data Spot for additional attachment this Entry represents.
*/
public Entry(float yVal, float xVal, Object data) {
this(yVal, xVal);
this.attachment = data;
}
/**
* returns the x-index the value of this object is mapped to
*
* @return
*/
public float getXVal() {
return xVal;
}

/**
* sets the x-index for the entry
*
* @param x
*/
public void setXVal(int x) {
this.xVal = x;
}

/**
* Returns the total value the entry represents.
*
* @return
*/
public float getYVal() {
return yVal;
}

/**
* Sets the value for the entry.
*
* @param yVal
*/
public void setYVal(float yVal) {
this.yVal = yVal;
}

/**
* Returns the attachment, additional information that this Entry represents, or
* null, if no attachment has been specified.
*
* @return
*/
public Object getAttachment() {
return attachment;
}

/**
* Sets additional attachment this Entry should represent.
*
* @param attachment
*/
public void setAttachment(Object attachment) {
this.attachment = attachment;
}

/**
* returns an exact copy of the entry
*
* @return
*/
public Entry copy() {
Entry e = new Entry(yVal, xVal, attachment);
return e;
}

/**
* Compares value, xVal and attachment of the entries. Returns true if entries
* are equal in those points, false if not. Does not check by hash-code like
* it's done by the "equals" method.
*
* @param e
* @return
*/
public boolean equalTo(Entry e) {

if (e == null)
return false;

if (e.attachment != this.attachment)
return false;
if (e.xVal != this.xVal)
return false;

if (Math.abs(e.yVal - this.yVal) > 0.00001f)
return false;

return true;
}

/**
* returns a string representation of the entry containing x-index and value
*/
@Override
public String toString() {
return "Entry, xVal: " + xVal + " yVal (sum): " + getYVal();
}

@Override
public int describeContents() {
Expand All @@ -19,18 +144,24 @@ public int describeContents() {

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeFloat(this.yVal);
dest.writeFloat(this.xVal);
dest.writeFloat(this.xIndex);
dest.writeFloat(this.data);
}

public Entry() {
if (attachment != null) {
if (attachment instanceof Parcelable) {
dest.writeInt(1);
dest.writeParcelable((Parcelable) this.attachment, flags);
} else {
throw new ParcelFormatException("Cannot parcel an Entry with non-parcelable attachment");
}
} else {
dest.writeInt(0);
}
}

protected Entry(Parcel in) {
this.xVal = in.readFloat();
this.xIndex = in.readFloat();
this.data = in.readFloat();
this.yVal = in.readFloat();
this.xVal = in.readInt();
this.attachment = in.readParcelable(Object.class.getClassLoader());
}

public static final Creator<Entry> CREATOR = new Creator<Entry>() {
Expand Down
Loading