Skip to main content
Version: 2.0.0-alpha.16

Introduction

Vico is a light and extensible chart library for Android. It’s compatible with both Jetpack Compose and the view system, but its two main modules—compose and views—are independent.

Foreword by Patryk Goworowski

As a library compatible with both Jetpack Compose and views, Vico is quite unique. It doesn’t depend on the interoperability between the two UI systems. The shared, main logic resides in the core module and depends on the Android SDK. It doesn’t know anything about Jetpack Compose or views. Likewise, the compose module doesn’t know anything about views, and the views module doesn’t know anything about Jetpack Compose.

I was a little curious about Jetpack Compose’s internals and how come it is interoperable with views. “Can you, fairly easily, share the code used to draw on the canvas between these two UI paradigms?” I asked myself. The answer is yes.

core uses android.graphics.Canvas (also used by views) to draw charts, and DrawScope (used by Jetpack Compose) exposes an instance of android.graphics.Canvas via DrawScope#canvas#nativeCanvas. It’s similar for other APIs, like Path. This approach encourages a greater level of abstraction and promotes the separation of concerns. It also helped make Vico’s API highly extensible.