Skip to content

Commit

Permalink
feat: export as xml widget
Browse files Browse the repository at this point in the history
  • Loading branch information
SeptiawanAjiP committed Sep 8, 2023
1 parent 29ef863 commit c8b32a3
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 10,919 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}

buildFeatures {
viewBinding true
}
}

dependencies {
Expand Down
15 changes: 12 additions & 3 deletions app/src/main/java/com/dewakoding/androidchartjsapp/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
package com.dewakoding.androidchartjsapp

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.dewakoding.androidchartjs.AndroidCharJsActivity
import androidx.appcompat.app.AppCompatActivity
import com.dewakoding.androidchartjs.util.CommonConst
import com.dewakoding.androidchartjsapp.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {
private val binding by lazy { ActivityMainBinding.inflate(layoutInflater) }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)

class MainActivity : AndroidCharJsActivity() {
binding.androidChart.setChart(CommonConst.CHART_JS_BAR, arrayOf("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday"), arrayOf(10, 3, 5, 8, 9))
}

}
12 changes: 4 additions & 8 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.dewakoding.androidchartjs.AndroidChartJSView
android:id="@+id/android_chart"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions chartjs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.google.code.gson:gson:2.10.1'
}
6 changes: 3 additions & 3 deletions chartjs/src/main/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
const ctx = document.getElementById("myChart");

new Chart(ctx, {
type: "bar",
type: Android.getType(),
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
labels: JSON.parse(Android.getLabel()),
datasets: [
{
label: "# of Votes",
data: [12, 19, 3, 5, 2, 3],
data: JSON.parse(Android.getData()),
borderWidth: 1,
},
],
Expand Down
Loading

0 comments on commit c8b32a3

Please sign in to comment.