Skip to content

Commit

Permalink
Merge PR
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilJay committed Jan 16, 2016
2 parents 9379008 + 4fcc7cc commit 825bd2a
Show file tree
Hide file tree
Showing 18 changed files with 75 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private LineData generateLineData() {
set.setColor(Color.rgb(240, 238, 70));
set.setLineWidth(2.5f);
set.setCircleColor(Color.rgb(240, 238, 70));
set.setCircleSize(5f);
set.setCircleRadius(5f);
set.setFillColor(Color.rgb(240, 238, 70));
set.setDrawCubic(true);
set.setDrawValues(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private void setData(int count, float range) {
//set1.setDrawFilled(true);
set1.setDrawCircles(false);
set1.setLineWidth(1.8f);
set1.setCircleSize(4f);
set1.setCircleRadius(4f);
set1.setCircleColor(Color.WHITE);
set1.setHighLightColor(Color.rgb(244, 117, 117));
set1.setColor(Color.WHITE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private void initWithDummyData() {
// create a dataset and give it a type (0)
LineDataSet set1 = new LineDataSet(yVals, "DataSet");
set1.setLineWidth(3f);
set1.setCircleSize(5f);
set1.setCircleRadius(5f);

ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
dataSets.add(set1); // add the datasets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private void addDataSet() {

LineDataSet set = new LineDataSet(yVals, "DataSet " + count);
set.setLineWidth(2.5f);
set.setCircleSize(4.5f);
set.setCircleRadius(4.5f);

int color = mColors[count % mColors.length];

Expand Down Expand Up @@ -209,7 +209,7 @@ private LineDataSet createSet() {

LineDataSet set = new LineDataSet(null, "DataSet 1");
set.setLineWidth(2.5f);
set.setCircleSize(4.5f);
set.setCircleRadius(4.5f);
set.setColor(Color.rgb(240, 99, 99));
set.setCircleColor(Color.rgb(240, 99, 99));
set.setHighLightColor(Color.rgb(190, 190, 190));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ private void setData(int count, float range) {
LineDataSet set1 = new LineDataSet(yVals, "DataSet 1");

set1.setLineWidth(1.5f);
set1.setCircleSize(4f);
set1.setCircleRadius(4f);

// create a data object with the datasets
LineData data = new LineData(xVals, set1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ private void setData(int count, float range) {
set1.setColor(Color.BLACK);
set1.setCircleColor(Color.BLACK);
set1.setLineWidth(1f);
set1.setCircleSize(3f);
set1.setCircleRadius(3f);
set1.setDrawCircleHole(false);
set1.setValueTextSize(9f);
set1.setFillAlpha(65);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ private void setData(int count, float range) {
set1.setColor(ColorTemplate.getHoloBlue());
set1.setCircleColor(Color.WHITE);
set1.setLineWidth(2f);
set1.setCircleSize(3f);
set1.setCircleRadius(3f);
set1.setFillAlpha(65);
set1.setFillColor(ColorTemplate.getHoloBlue());
set1.setHighLightColor(Color.rgb(244, 117, 117));
Expand All @@ -322,7 +322,7 @@ private void setData(int count, float range) {
set2.setColor(Color.RED);
set2.setCircleColor(Color.WHITE);
set2.setLineWidth(2f);
set2.setCircleSize(3f);
set2.setCircleRadius(3f);
set2.setFillAlpha(65);
set2.setFillColor(Color.RED);
set2.setDrawCircleHole(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private LineData getData(int count, float range) {
// set1.setFillColor(Color.RED);

set1.setLineWidth(1.75f);
set1.setCircleSize(3f);
set1.setCircleRadius(3f);
set1.setColor(Color.WHITE);
set1.setCircleColor(Color.WHITE);
set1.setHighLightColor(Color.WHITE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private LineData generateDataLine(int cnt) {

LineDataSet d1 = new LineDataSet(e1, "New DataSet " + cnt + ", (1)");
d1.setLineWidth(2.5f);
d1.setCircleSize(4.5f);
d1.setCircleRadius(4.5f);
d1.setHighLightColor(Color.rgb(244, 117, 117));
d1.setDrawValues(false);

Expand All @@ -115,7 +115,7 @@ private LineData generateDataLine(int cnt) {

LineDataSet d2 = new LineDataSet(e2, "New DataSet " + cnt + ", (2)");
d2.setLineWidth(2.5f);
d2.setCircleSize(4.5f);
d2.setCircleRadius(4.5f);
d2.setHighLightColor(Color.rgb(244, 117, 117));
d2.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
d2.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

LineDataSet d = new LineDataSet(values, "DataSet " + (z + 1));
d.setLineWidth(2.5f);
d.setCircleSize(4f);
d.setCircleRadius(4f);

int color = mColors[z % mColors.length];
d.setColor(color);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private LineDataSet createSet() {
set.setColor(ColorTemplate.getHoloBlue());
set.setCircleColor(Color.WHITE);
set.setLineWidth(2f);
set.setCircleSize(4f);
set.setCircleRadius(4f);
set.setFillAlpha(65);
set.setFillColor(ColorTemplate.getHoloBlue());
set.setHighLightColor(Color.rgb(244, 117, 117));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ protected LineData getComplexity() {
ds4.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[3]);

ds1.setLineWidth(2.5f);
ds1.setCircleSize(3f);
ds1.setCircleRadius(3f);
ds2.setLineWidth(2.5f);
ds2.setCircleSize(3f);
ds2.setCircleRadius(3f);
ds3.setLineWidth(2.5f);
ds3.setCircleSize(3f);
ds3.setCircleRadius(3f);
ds4.setLineWidth(2.5f);
ds4.setCircleSize(3f);
ds4.setCircleRadius(3f);


// load DataSets from textfiles in assets folders
Expand Down
17 changes: 15 additions & 2 deletions MPChartLib/src/com/github/mikephil/charting/charts/PieChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ private void calcAngles() {
mDrawAngles = new float[mData.getYValCount()];
mAbsoluteAngles = new float[mData.getYValCount()];

float yValueSum = mData.getYValueSum();

List<IPieDataSet> dataSets = mData.getDataSets();

int cnt = 0;
Expand All @@ -210,7 +212,7 @@ private void calcAngles() {

for (int j = 0; j < set.getEntryCount(); j++) {

mDrawAngles[cnt] = calcAngle(Math.abs(set.getEntryForIndex(j).getVal()));
mDrawAngles[cnt] = calcAngle(Math.abs(set.getEntryForIndex(j).getVal()), yValueSum);

if (cnt == 0) {
mAbsoluteAngles[cnt] = mDrawAngles[cnt];
Expand Down Expand Up @@ -255,7 +257,18 @@ public boolean needsHighlight(int xIndex, int dataSetIndex) {
* @return
*/
private float calcAngle(float value) {
return value / mData.getYValueSum() * mMaxAngle;
return calcAngle(value, mData.getYValueSum());
}

/**
* calculates the needed angle for a given value
*
* @param value
* @param yValueSum
* @return
*/
private float calcAngle(float value, float yValueSum) {
return value / yValueSum * mMaxAngle;
}

@Override
Expand Down
42 changes: 33 additions & 9 deletions MPChartLib/src/com/github/mikephil/charting/data/LineDataSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class LineDataSet extends LineRadarDataSet<Entry> implements ILineDataSet
private int mCircleColorHole = Color.WHITE;

/** the radius of the circle-shaped value indicators */
private float mCircleSize = 8f;
private float mCircleRadius = 8f;

/** sets the intensity of the cubic lines */
private float mCubicIntensity = 0.2f;
Expand All @@ -45,7 +45,7 @@ public class LineDataSet extends LineRadarDataSet<Entry> implements ILineDataSet
public LineDataSet(List<Entry> yVals, String label) {
super(yVals, label);

// mCircleSize = Utils.convertDpToPixel(4f);
// mCircleRadius = Utils.convertDpToPixel(4f);
// mLineWidth = Utils.convertDpToPixel(1f);

mCircleColors = new ArrayList<Integer>();
Expand All @@ -67,7 +67,7 @@ public DataSet<Entry> copy() {

LineDataSet copied = new LineDataSet(yVals, getLabel());
copied.mColors = mColors;
copied.mCircleSize = mCircleSize;
copied.mCircleRadius = mCircleRadius;
copied.mCircleColors = mCircleColors;
copied.mDashPathEffect = mDashPathEffect;
copied.mDrawCircles = mDrawCircles;
Expand Down Expand Up @@ -98,19 +98,43 @@ public float getCubicIntensity() {
return mCubicIntensity;
}


/**
* sets the size (radius) of the circle shpaed value indicators, default
* size = 4f
*
* sets the radius of the drawn circles.
* Default radius = 4f
*
* @param radius
*/
public void setCircleRadius(float radius) {
mCircleRadius = Utils.convertDpToPixel(radius);
}

@Override
public float getCircleRadius() {
return mCircleRadius;
}

/**
* sets the size (radius) of the circle shpaed value indicators,
* default size = 4f
*
* This method is deprecated because of unclarity. Use setCircleRadius instead.
*
* @param size
*/
@Deprecated
public void setCircleSize(float size) {
mCircleSize = Utils.convertDpToPixel(size);
setCircleRadius(size);
}

@Override
/**
*
* This function is deprecated because of unclarity. Use getCircleRadius instead.
*
*/
@Deprecated
public float getCircleSize() {
return mCircleSize;
return getCircleRadius();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void setCircleSize(float size) {
}

@Override
public float getCircleSize() {
public float getCircleRadius() {
return mCircleSize;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public interface ILineDataSet extends ILineRadarDataSet<Entry> {
/**
* Returns the size of the drawn circles.
*/
float getCircleSize();
float getCircleRadius();

/**
* Returns the color at the given index of the DataSet's circle-color array.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public void drawValues(Canvas c) {
Transformer trans = mChart.getTransformer(dataSet.getAxisDependency());

// make sure the values do not interfear with the circles
int valOffset = (int) (dataSet.getCircleSize() * 1.75f);
int valOffset = (int) (dataSet.getCircleRadius() * 1.75f);

if (!dataSet.isDrawCirclesEnabled())
valOffset = valOffset / 2;
Expand Down Expand Up @@ -506,7 +506,7 @@ protected void drawCircles(Canvas c) {

trans.pointValuesToPixel(buffer.buffer);

float halfsize = dataSet.getCircleSize() / 2f;
float halfsize = dataSet.getCircleRadius() / 2f;

for (int j = 0, count = (int) Math.ceil((maxx - minx) * phaseX + minx) * 2; j < count; j += 2) {

Expand All @@ -525,7 +525,7 @@ protected void drawCircles(Canvas c) {

mRenderPaint.setColor(circleColor);

c.drawCircle(x, y, dataSet.getCircleSize(),
c.drawCircle(x, y, dataSet.getCircleRadius(),
mRenderPaint);

if (dataSet.isDrawCircleHoleEnabled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ public void drawValues(Canvas c) {

PieData data = mChart.getData();
List<IPieDataSet> dataSets = data.getDataSets();

float yValueSum = data.getYValueSum();

boolean drawXVals = mChart.isDrawSliceTextEnabled();

int cnt = 0;
Expand Down Expand Up @@ -215,7 +218,7 @@ public void drawValues(Canvas c) {
+ center.y);

float value = mChart.isUsePercentValuesEnabled() ? entry.getVal()
/ data.getYValueSum() * 100f : entry.getVal();
/ yValueSum * 100f : entry.getVal();

ValueFormatter formatter = dataSet.getValueFormatter();

Expand Down

0 comments on commit 825bd2a

Please sign in to comment.