Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Feat: Ability to set bar max bar height for every bar #4

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
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ captures/
.idea/dictionaries
.idea/libraries
.idea/caches
.idea/markdown-navigator.xml
.idea/misc.xml
.idea/codeStyles/Project.xml
.idea/dbnavigator.xml
.idea/encodings.xml
.idea/markdown-navigator/profiles_settings.xml
.idea/misc.xml
.idea/vcs.xml

# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
Expand Down
29 changes: 0 additions & 29 deletions .idea/codeStyles/Project.xml

This file was deleted.

19 changes: 0 additions & 19 deletions .idea/gradle.xml

This file was deleted.

34 changes: 0 additions & 34 deletions .idea/misc.xml

This file was deleted.

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

This file was deleted.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.android.tools.build:gradle:3.1.4'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
8 changes: 4 additions & 4 deletions charts/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ android {
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
compile 'com.android.support:support-v4:27.0.1'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:support-v4:27.1.1'
}
16 changes: 16 additions & 0 deletions charts/src/main/java/com/hadiidbouk/charts/BarData.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ public class BarData {
private String barTitle;
private float barValue;
private String pinText;
private float maxValue = 0.0f;

public float getMaxValue() {
return maxValue;
}

public void setMaxValue(float maxValue) {
this.maxValue = maxValue;
}

public String getPinText() {
return pinText;
Expand Down Expand Up @@ -41,6 +50,13 @@ public BarData(String barTitle, float barValue, String pinText) {
this.pinText = pinText;
}

public BarData(String barTitle, float barValue, String pinText, float maxValue) {
this.barTitle = barTitle;
this.barValue = barValue;
this.pinText = pinText;
this.maxValue = maxValue;
}

public BarData() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public void build() {
int i = 0;
for (BarData data : mDataList) {
int barValue = (int) (data.getBarValue() * 100);
mMaxValue = data.getMaxValue();
FrameLayout bar = getBar(data.getBarTitle(), barValue, i);
linearLayout.addView(bar);
i++;
Expand Down
14 changes: 7 additions & 7 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion "27.0.1"
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.hadiidbouk.chartprogressbar"
minSdkVersion 14
Expand All @@ -20,12 +20,12 @@ android {
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile project(path: ':charts')
implementation 'com.android.support:appcompat-v7:27.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
implementation project(path: ':charts')
implementation 'com.android.support:appcompat-v7:27.1.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ protected void onCreate(Bundle savedInstanceState) {

ArrayList<BarData> dataList = new ArrayList<>();

BarData data = new BarData("Sep", 3.4f, "3.4€");
BarData data = new BarData("Sep", 3.4f, "3.4€", 10f);
dataList.add(data);

data = new BarData("Oct", 8.0f, "8.0€");
data = new BarData("Oct", 8.0f, "8.0€", 20f);
dataList.add(data);

data = new BarData("Nov", 1.8f, "1.8€");
data = new BarData("Nov", 1.8f, "1.8€", 40f);
dataList.add(data);

data = new BarData("Dec", 7.3f, "7.3€");
data = new BarData("Dec", 7.3f, "7.3€", 100f);
dataList.add(data);

data = new BarData("Jan", 6.2f, "6.2€");
data = new BarData("Jan", 6.2f, "6.2€", 25f);
dataList.add(data);

data = new BarData("Feb", 3.3f, "3.3€");
data = new BarData("Feb", 3.3f, "3.3€", 20f);
dataList.add(data);

mChart = (ChartProgressBar) findViewById(R.id.ChartProgressBar);
Expand Down
2 changes: 1 addition & 1 deletion sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
app:hdBarWidth="7dp"
app:hdBarRadius="10dp"
app:hdMaxValue="10"
app:hdEmptyColor="@color/empty"
app:hdEmptyColor="@color/bar_title_txt_selected_color"
app:hdProgressColor="@color/progress"
app:hdProgressClickColor="@color/progress_click"
app:hdPinBackgroundColor="@color/pin_background"
Expand Down