Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BarLineChart-text-color #5423

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
9 changes: 2 additions & 7 deletions MPChartLib/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.github.mikephil.charting">

<!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
</application> -->
android:supportsRtl="true" />

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -1671,4 +1671,16 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
mViewPortHandler.refresh(mViewPortHandler.getMatrixTouch(), this, true);
}
}

/**
* Sets the text color to use for the labels. Make sure to use
* getResources().getColor(...) when using a color from the resources.
*
* @param color
*/
public void setTextColor(int color) {
mAxisRendererLeft.setTextColor(color);
mAxisRendererRight.setTextColor(color);
mXAxisRenderer.setTextColor(color);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -784,13 +784,11 @@ protected void drawMarkers(Canvas canvas) {
if (mMarker == null || !isDrawMarkersEnabled() || !valuesToHighlight())
return;

for (int i = 0; i < mIndicesToHighlight.length; i++) {

Highlight highlight = mIndicesToHighlight[i];
for (Highlight highlight : mIndicesToHighlight) {

IDataSet set = mData.getDataSetByIndex(highlight.getDataSetIndex());

Entry e = mData.getEntryForHighlight(mIndicesToHighlight[i]);
Entry e = mData.getEntryForHighlight(highlight);
int entryIndex = set.getEntryIndex(e);

// make sure entry not null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,9 @@ public boolean needsHighlight(int index) {
if (!valuesToHighlight())
return false;

for (int i = 0; i < mIndicesToHighlight.length; i++)

// check if the xvalue for the given dataset needs highlight
if ((int) mIndicesToHighlight[i].getX() == index)
// check if the xvalue for the given dataset needs highlight
for (Highlight highlight : mIndicesToHighlight)
if ((int) highlight.getX() == index)
return true;

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ public void disableGridDashedLine() {
* @return
*/
public boolean isGridDashedLineEnabled() {
return mGridDashPathEffect == null ? false : true;
return mGridDashPathEffect != null;
}

/**
Expand Down Expand Up @@ -645,7 +645,7 @@ public void disableAxisLineDashedLine() {
* @return
*/
public boolean isAxisLineDashedLineEnabled() {
return mAxisLineDashPathEffect == null ? false : true;
return mAxisLineDashPathEffect != null;
}

/**
Expand Down Expand Up @@ -813,4 +813,14 @@ public void setSpaceMax(float mSpaceMax)
{
this.mSpaceMax = mSpaceMax;
}

/**
* Sets the text color to use for the labels. Make sure to use
* getResources().getColor(...) when using a color from the resources.
*
* @param color
*/
public void setTextColor(int color) {
mTextColor = color;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ public abstract class BaseDataSet<T extends Entry> implements IDataSet<T> {
* Default constructor.
*/
public BaseDataSet() {
mColors = new ArrayList<Integer>();
mValueColors = new ArrayList<Integer>();
mColors = new ArrayList<>();
mValueColors = new ArrayList<>();

// default color
mColors.add(Color.rgb(140, 234, 255));
Expand Down Expand Up @@ -201,7 +201,7 @@ public void setColors(int[] colors, Context c) {
*/
public void addColor(int color) {
if (mColors == null)
mColors = new ArrayList<Integer>();
mColors = new ArrayList<>();
mColors.add(color);
}

Expand Down Expand Up @@ -244,7 +244,7 @@ public void setColors(int[] colors, int alpha) {
*/
public void resetColors() {
if (mColors == null) {
mColors = new ArrayList<Integer>();
mColors = new ArrayList<>();
}
mColors.clear();
}
Expand Down Expand Up @@ -499,7 +499,6 @@ protected void copy(BaseDataSet baseDataSet) {
baseDataSet.mIconsOffset = mIconsOffset;
baseDataSet.mValueColors = mValueColors;
baseDataSet.mValueFormatter = mValueFormatter;
baseDataSet.mValueColors = mValueColors;
baseDataSet.mValueTextSize = mValueTextSize;
baseDataSet.mVisible = mVisible;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,14 @@ else if (last == first && n == 0) {
* @param c
*/
public abstract void renderLimitLines(Canvas c);

/**
* Sets the text color to use for the labels. Make sure to use
* getResources().getColor(...) when using a color from the resources.
*
* @param color
*/
public void setTextColor(int color) {
mAxis.setTextColor(color);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1034,12 +1034,12 @@ protected void drawRoundedSlices(Canvas c) {
// draw only if the value is greater than zero
if ((Math.abs(e.getY()) > Utils.FLOAT_EPSILON)) {

double v = Math.toRadians((angle + sliceAngle)
* phaseY);
float x = (float) ((r - circleRadius)
* Math.cos(Math.toRadians((angle + sliceAngle)
* phaseY)) + center.x);
* Math.cos(v) + center.x);
float y = (float) ((r - circleRadius)
* Math.sin(Math.toRadians((angle + sliceAngle)
* phaseY)) + center.y);
* Math.sin(v) + center.y);

mRenderPaint.setColor(dataSet.getColor(j));
mBitmapCanvas.drawCircle(x, y, circleRadius, mRenderPaint);
Expand All @@ -1051,7 +1051,7 @@ protected void drawRoundedSlices(Canvas c) {
}

/**
* Releases the drawing bitmap. This should be called when {@link LineChart#onDetachedFromWindow()}.
* Releases the drawing bitmap. This should be called when .
*/
public void releaseBitmap() {
if (mBitmapCanvas != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package com.github.mikephil.charting.test;

import com.github.mikephil.charting.data.Entry;
import static junit.framework.Assert.assertEquals;

import com.github.mikephil.charting.data.filter.Approximator;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

import static junit.framework.Assert.assertEquals;

/**
* Created by philipp on 07/06/16.
*/
Expand All @@ -18,19 +14,7 @@ public class ApproximatorTest {
@Test
public void testApproximation() {

float[] points = new float[]{
10, 20,
20, 30,
25, 25,
30, 28,
31, 31,
33, 33,
40, 40,
44, 40,
48, 23,
50, 20,
55, 20,
60, 25};
float[] points = new float[]{10, 20, 20, 30, 25, 25, 30, 28, 31, 31, 33, 33, 40, 40, 44, 40, 48, 23, 50, 20, 55, 20, 60, 25};

assertEquals(24, points.length);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.github.mikephil.charting.data.BarEntry;

import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -25,7 +26,7 @@ public void testGroupBars() {
List<BarEntry> values1 = new ArrayList<>();
List<BarEntry> values2 = new ArrayList<>();

for(int i = 0; i < 5; i++) {
for (int i = 0; i < 5; i++) {
values1.add(new BarEntry(i, 50));
values2.add(new BarEntry(i, 60));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class DataSetTest {
@Test
public void testCalcMinMax() {

List<Entry> entries = new ArrayList<Entry>();
List<Entry> entries = new ArrayList<>();
entries.add(new Entry(10, 10));
entries.add(new Entry(15, 2));
entries.add(new Entry(21, 5));
Expand Down Expand Up @@ -58,7 +58,7 @@ public void testCalcMinMax() {
@Test
public void testAddRemoveEntry() {

List<Entry> entries = new ArrayList<Entry>();
List<Entry> entries = new ArrayList<>();
entries.add(new Entry(10, 10));
entries.add(new Entry(15, 2));
entries.add(new Entry(21, 5));
Expand Down Expand Up @@ -143,7 +143,7 @@ public void testAddRemoveEntry() {
@Test
public void testGetEntryForXValue() {

List<Entry> entries = new ArrayList<Entry>();
List<Entry> entries = new ArrayList<>();
entries.add(new Entry(10, 10));
entries.add(new Entry(15, 5));
entries.add(new Entry(21, 5));
Expand Down Expand Up @@ -183,7 +183,7 @@ public void testGetEntryForXValue() {
public void testGetEntryForXValueWithDuplicates() {

// sorted list of values (by x position)
List<Entry> values = new ArrayList<Entry>();
List<Entry> values = new ArrayList<>();
values.add(new Entry(0, 10));
values.add(new Entry(1, 20));
values.add(new Entry(2, 30));
Expand Down
Loading