Skip to content

Commit

Permalink
feat: add more example of chart usage
Browse files Browse the repository at this point in the history
  • Loading branch information
SeptiawanAjiP committed Sep 15, 2023
1 parent f8e24e3 commit 73a7dc9
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 39 deletions.
19 changes: 17 additions & 2 deletions app/src/main/java/com/dewakoding/androidchartjsapp/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,27 @@ class MainActivity : AppCompatActivity() {
setContentView(binding.root)

binding.androidChart1.setChart(
ChartType.RADAR,
ChartType.BAR,
arrayOf("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday"),
arrayOf(10, 3, 5, 8, 9),
"of quantity")
binding.androidChart2.setChart(
ChartType.BAR,
ChartType.LINE,
arrayOf("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday"),
arrayOf(10, 3, 5, 8, 9),
"of quantity")
binding.androidChart3.setChart(
ChartType.PIE,
arrayOf("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday"),
arrayOf(10, 3, 5, 8, 9),
"of quantity")
binding.androidChart4.setChart(
ChartType.DOUGHNUT,
arrayOf("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday"),
arrayOf(10, 3, 5, 8, 9),
"of quantity")
binding.androidChart5.setChart(
ChartType.POLAR_AREA,
arrayOf("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday"),
arrayOf(10, 3, 5, 8, 9),
"of quantity")
Expand Down
122 changes: 85 additions & 37 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,46 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:id="@+id/tv_title_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:text="Pie Chart"
android:textSize="24sp"
android:textStyle="bold"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"/>
<com.dewakoding.androidchartjs.AndroidChartJSView
android:id="@+id/android_chart_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_title_1"/>
<TextView
android:id="@+id/tv_title_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/android_chart_1"
app:layout_constraintLeft_toLeftOf="parent"
android:text="Bar Chart"
android:textSize="24sp"
android:textStyle="bold"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"/>
<com.dewakoding.androidchartjs.AndroidChartJSView
android:id="@+id/android_chart_2"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/tv_title_2"
app:layout_constraintLeft_toLeftOf="parent"/>
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/tv_title_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bar Chart"
android:textSize="24sp"
android:textStyle="bold"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"/>

<com.dewakoding.androidchartjs.AndroidChartJSView
android:id="@+id/android_chart_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_title_1"/>

<TextView
android:id="@+id/tv_title_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Line Chart"
android:textSize="24sp"
android:textStyle="bold"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"/>
<com.dewakoding.androidchartjs.AndroidChartJSView
android:id="@+id/android_chart_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/tv_title_2"
app:layout_constraintLeft_toLeftOf="parent"/>
<TextView
android:id="@+id/tv_title_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pie Chart"
android:textSize="24sp"
android:textStyle="bold"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"/>
<com.dewakoding.androidchartjs.AndroidChartJSView
android:id="@+id/android_chart_3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/tv_title_2"
app:layout_constraintLeft_toLeftOf="parent"/>
<TextView
android:id="@+id/tv_title_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Doughnut Chart"
android:textSize="24sp"
android:textStyle="bold"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"/>
<com.dewakoding.androidchartjs.AndroidChartJSView
android:id="@+id/android_chart_4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/tv_title_2"
app:layout_constraintLeft_toLeftOf="parent"/>
<TextView
android:id="@+id/tv_title_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Doughnut Chart"
android:textSize="24sp"
android:textStyle="bold"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"/>
<com.dewakoding.androidchartjs.AndroidChartJSView
android:id="@+id/android_chart_5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/tv_title_2"
app:layout_constraintLeft_toLeftOf="parent"/>
</LinearLayout>



</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

0 comments on commit 73a7dc9

Please sign in to comment.