본문 바로가기
Programming/Android

[Android] Jetpack Compose Chart - vico 사용하기

by 코딩여걸 2023. 9. 20.
728x90

graph를 그리기 위해 제일 먼저 뜨는 vico를 사용해 보았다.

https://github.com/patrykandpatrick/vico

 

GitHub - patrykandpatrick/vico: A light and extensible chart library for Android.

A light and extensible chart library for Android. Contribute to patrykandpatrick/vico development by creating an account on GitHub.

github.com

vico


build.gradle.kts(:app)

  • minSdk최소 16(뷰 시스템의 경우) 또는 최소 21(Jetpack Compose의 경우)로 설정되어 있는지 확인

코드 추가

dependencies {
    // For Jetpack Compose.
    implementation("com.patrykandpatrick.vico:compose:1.12.0")

    // For `compose`. Creates a `ChartStyle` based on an M2 Material Theme.
    implementation("com.patrykandpatrick.vico:compose-m2:1.12.0")

    // For `compose`. Creates a `ChartStyle` based on an M3 Material Theme.
    implementation("com.patrykandpatrick.vico:compose-m3:1.12.0")

    // Houses the core logic for charts and other elements. Included in all other modules.
    implementation("com.patrykandpatrick.vico:core:1.12.0")

    // For the view system.
    implementation("com.patrykandpatrick.vico:views:1.12.0")
}

각자의 코드 스타일대로 넣어주면 된다.

더보기
dependencies {
    // For Jetpack Compose.
    implementation "com.patrykandpatrick.vico:compose:1.12.0"

    // For `compose`. Creates a `ChartStyle` based on an M2 Material Theme.
    implementation "com.patrykandpatrick.vico:compose-m2:1.12.0"

    // For `compose`. Creates a `ChartStyle` based on an M3 Material Theme.
    implementation "com.patrykandpatrick.vico:compose-m3:1.12.0"

    // Houses the core logic for charts and other elements. Included in all other modules.
    implementation "com.patrykandpatrick.vico:core:1.12.0"

    // For the view system.
    implementation "com.patrykandpatrick.vico:views:1.12.0"
}

👆 이렇게 쓰이는 곳도 있을 것이다.

 

이렇게 다 한 다음에 sync now를 눌러준다.

그럼 적용 완료!

728x90

댓글