Created
July 9, 2018 03:34
-
-
Save ArsenyMalkov/71dc4ff9ed7567096d13fc0ab076381e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <android.support.constraint.ConstraintLayout | |
| xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| > | |
| <com.anychart.anychart.AnyChartView | |
| android:id="@+id/any_chart_view" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| /> | |
| <ProgressBar | |
| android:id="@+id/progress_bar" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| app:layout_constraintBottom_toBottomOf="parent" | |
| app:layout_constraintEnd_toEndOf="parent" | |
| app:layout_constraintStart_toStartOf="parent" | |
| app:layout_constraintTop_toTopOf="parent" | |
| /> | |
| </android.support.constraint.ConstraintLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class PieChartActivity extends AppCompatActivity { | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_chart_common); | |
| AnyChartView anyChartView = findViewById(R.id.any_chart_view); | |
| anyChartView.setProgressBar(findViewById(R.id.progress_bar)); | |
| Pie pie = AnyChart.pie(); | |
| List<DataEntry> data = new ArrayList<>(); | |
| data.add(new ValueDataEntry("Apples", 6371664)); | |
| data.add(new ValueDataEntry("Pears", 789622)); | |
| data.add(new ValueDataEntry("Bananas", 7216301)); | |
| data.add(new ValueDataEntry("Grapes", 1486621)); | |
| data.add(new ValueDataEntry("Oranges", 1200000)); | |
| pie.setData(data); | |
| pie.setTitle("Fruits imported in 2015 (in kg)"); | |
| pie.getLabels().setPosition("outside"); | |
| pie.getLegend().getTitle().setEnabled(true); | |
| pie.getLegend().getTitle() | |
| .setText("Retail channels") | |
| .setPadding(0d, 0d, 10d, 0d); | |
| pie.getLegend() | |
| .setPosition("center-bottom") | |
| .setItemsLayout(LegendLayout.HORIZONTAL) | |
| .setAlign(EnumsAlign.CENTER); | |
| anyChartView.setChart(pie); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment