Giter Site home page Giter Site logo

sharifmrcreed / jetpack_compose_graphs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jaikeerthick/composable-graphs

0.0 0.0 0.0 317 KB

✨ A very Minimal, Sleek and Powerful Graph library for Android using Jetpack Compose

License: Apache License 2.0

Kotlin 100.00%

jetpack_compose_graphs's Introduction

Composable-Graphs ( Jetpack Compose )

tag

✨ A very Minimal, Sleek and Lightweight Graph library for Android using Jetpack Compose

Gradle Setup

Latest version:

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}

dependencies {
    implementation 'com.github.jaikeerthick:Composable-Graphs:v1.0'
}

Screenshots


Usage

  1. Bar Graph
BarGraph(
  dataList = listOf(20, 30, 10, 60, 35), //  dataList : List<Number>
)
  1. Line Graph
LineGraph(
    xAxisData = listOf("Sun", "Mon", "Tues", "Wed", "Thur", "Fri", "Sat").map {
        GraphData.String(it)
    }, // xAxisData : List<GraphData>, and GraphData accepts both Number and String types
    yAxisData = listOf(200, 40, 60, 450, 700, 30, 50),
)

Example for passing String and Number:

xAxisData = listOf("Sun", "Mon", "Tues", "Wed", "Thur", "Fri", "Sat").map {
                       GraphData.String(it)
            }

xAxisData = listOf(20, 40, 30, 50, 70, 0, 40).map {
                       GraphData.Number(it)
            }

Note: xAxisData can be of GraphData.String & GraphData.Number, but yAxisData can be only of type Number

Styling

BarGraphStyle and LineGraphStyle can be used to style the Graphs effetively

You can control the following things using Style classes:

  • Height
  • Padding
  • Colors
  • Visibility - control visibility for crosshair, labels, headers, etc.
// BarGraph
val style = BarGraphStyle(
                    visibility = BarGraphVisibility(
                        isYAxisLabelVisible = true
                    )
                )

// LineGraph
val style2 = LineGraphStyle(
                    visibility = LinearGraphVisibility(
                        isHeaderVisible = true,
                        isYAxisLabelVisible = false,
                        isCrossHairVisible = true
                    ),
                    colors = LinearGraphColors(
                        lineColor = GraphAccent2,
                        pointColor = GraphAccent2,
                        clickHighlightColor = PointHighlight2,
                        fillGradient = Brush.verticalGradient(
                            listOf(Gradient3, Gradient2)
                        )
                    )
                )

And you can pass it to the graph like this:

 BarGraph(
    dataList = listOf(20, 30, 10, 60, 35),
    style = style
)   



Contribution:

Fork the repo and create PRs 🦄

jetpack_compose_graphs's People

Contributors

jaikeerthick avatar ngallazzi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.