1- XML class to tag Deco View element
xmlns:custom="http://schemas.android.com/apk/res-auto"
custom:dv_lineWidth="5dp"
android:id="@+id/dynamicArcView"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_toRightOf="@+id/tvProjectEndDate"
android:layout_above="@+id/projectStatus"
android:layout_alignParentTop="true">
custom:dv_lineWidth="5dp"
android:id="@+id/dynamicArcView"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_toRightOf="@+id/tvProjectEndDate"
android:layout_above="@+id/projectStatus"
android:layout_alignParentTop="true">
android:layout_width="60dp"
android:layout_height="40dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="30sp"
android:layout_above="@+id/tvProjectEndDate"
android:layout_toRightOf="@+id/textView5"
android:layout_toEndOf="@+id/textView5"
android:layout_marginLeft="30dp"
android:layout_marginBottom="10dp" />
2- Make following change in corresponding Activity JAVA class.
//Adding the coe to show the graph start
//SeriesItem seriesItem = new SeriesItem.Builder(Color.parseColor("#00B0CA"))
SeriesItem seriesItem = new SeriesItem.Builder(Color.parseColor("#e60000"))
.setRange(0, 100, 0)
.build();
//first 0 indicate start, second 100 indicate we have to cover 100% area of the round graph and thrid 0 indidate current starting point.
final DecoView decoView = (com.hookedonplay.decoviewlib.DecoView)vi.findViewById(R.id.dynamicArcView);
final int backIndex = decoView.addSeries(seriesItem);
/*decoView.addEvent(new DecoEvent.Builder(50)
.setIndex(backIndex)
.build());cmd
*/
int series1Index = decoView.addSeries(seriesItem);
.setIndex(backIndex)
.build());cmd
*/
int series1Index = decoView.addSeries(seriesItem);
final TextView textPercentage = (TextView)vi.findViewById(R.id.percentage);
final float totalSprint = Float.parseFloat(projectDataCollection.get(position).get(KEY_TOTAL_SPRINT));
final float completedSprint = Float.parseFloat(projectDataCollection.get(position).get(KEY_COMPLETED_SPRINT));
float percentBuild = (completedSprint/totalSprint);
//Above code is to calculate perfect % Value that need to be show inside graph
decoView.addEvent(new DecoEvent.Builder(percentBuild * 100f)
.setIndex(backIndex)
.build());
final float totalSprint = Float.parseFloat(projectDataCollection.get(position).get(KEY_TOTAL_SPRINT));
final float completedSprint = Float.parseFloat(projectDataCollection.get(position).get(KEY_COMPLETED_SPRINT));
float percentBuild = (completedSprint/totalSprint);
//Above code is to calculate perfect % Value that need to be show inside graph
decoView.addEvent(new DecoEvent.Builder(percentBuild * 100f)
.setIndex(backIndex)
.build());
seriesItem.addArcSeriesItemListener(new SeriesItem.SeriesItemListener() {
@Override
public void onSeriesItemAnimationProgress(float percentComplete, float currentPosition) {
float percentFilled = (completedSprint/totalSprint);
textPercentage.setText(String.format("%.0f%%", percentFilled * 100f));
textPercentage.setTextColor(Color.parseColor("#e60000"));
}
@Override
public void onSeriesItemAnimationProgress(float percentComplete, float currentPosition) {
float percentFilled = (completedSprint/totalSprint);
textPercentage.setText(String.format("%.0f%%", percentFilled * 100f));
textPercentage.setTextColor(Color.parseColor("#e60000"));
}
@Override
public void onSeriesItemDisplayProgress(float percentComplete) {
public void onSeriesItemDisplayProgress(float percentComplete) {
}
});
});
//Adding the code to show the graph End]
3- Add following dependecies in build.gradle
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.github.bmarrdev:android-DecoView-charting:v0.9.3'
}
No comments:
Post a Comment