Git Product home page Git Product logo

arcchartview's Introduction

APK Android Arsenal

ArcChartViewDemo

You can use this library to draw Arc charts

and show your statistics or anything you want

or maybe get some ratings from user.

you can download the Demo apk file (you can first adjust your Chart in the app and then implement it in code)

1 - Getting Started

By this instructions you can add this library and i will explain how use it.

Add Maven to your root build.gradle

First of all Add it in your root build.gradle at the end of repositories:

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

Add Dependency

Add the dependency to your app build.gradle file

dependencies
{
    compile 'com.github.imaNNeoFighT:ArcChartView:v1.0.0'
}

And then sync your gradle and take a tea.

2 - About The View

You can simply use this View like other Views in android, just add ArcChartView in your java code or xml.

View Properties

* in XML

you can use this properties for make everything you want, and all of them is arbitary,and can change via xml or java code/

  • acv_lines_count by this property you can specify lines count of chart (i mean arc lines), default value is 10

  • acv_lines_space by this property you can specify lines space (lines margin), default value is 4dp

  • acv_lines_width by this property you can specify lines width , default value is 6dp

  • acv_sections_count by this property you can specify sections count , default value is 8

  • acv_sections_space by this property you can specify sections space (sections margin) , default value is 4dp

  • acv_mid_start_extra_offset by this property you can specify center extra offest size, default value is 16dp

  • acv_icon_size by this property you can specify the icons size, default value is 32dp

  • acv_start_degree_offset by this property you can specify offset of start degree to design the view, default value is 0f

  • acv_allow_setting_value_by_touch by this property you can disable or enable allow setting value by touch feature, default value is true

* in Code

//acv_lines_count
myArcChartView.linesCount = 10
  
//acv_lines_space
myArcChartView.linesSpace = DpHandler.dpToPx(ctx,4) 

//acv_lines_width
myArcChartView.linesWidth = DpHandler.dpToPx(ctx,6)
 
//acv_sections_count
myArcChartView.sectionsCount = 8 

//acv_sections_space
myArcChartView.sectionsSpace = DpHandler.dpToPx(ctx,2) 

//acv_mid_start_extra_offset
myArcChartView.midStartExtraOffset = DpHandler.dpToPx(ctx,16)
 
//acv_icon_size
myArcChartView.iconSize = DpHandler.dpToPx(ctx,32) 

//acv_start_degree_offset
myArcChartView.startDegreeOffset = 0f 

//acv_allow_setting_value_by_touch
myArcChartView.allowSettingValueByTouch = true 

set and get Sections value

keep in mind that sections position starts with 0

to get a section value use this function

value = myArcChartView.getSectionValue(sectionPos)

and to set a section value use this function

myArcChartView.getSectionValue(sectionPos,sectionValue)

change filled and unFilled colors

to set the unFilled color (the section color that drawn behind) use this function

myArcChartView.setFilldeColor(sectionPos, Color.BLACK)

and to set the filled color (the section color that drawn in top) use this function

myArcChartView.setUnFilldeColor(sectionPos,Color.LTGRAY)

change section icons

to set the icons use this function

myArcChartView.setSectionIcons(sectionIcons : MutableList<Bitmap?>)

View listener (ArcListener)

you can handle some actions (only sectionsIconClick for now) just set a listener and make your logic

myArcChartView.listener = object : ArcChartView.AcvListener {
            override fun onSectionsIconClicked(sectionPos: Int) {
                //Handle Your Logic Here
                Toast.makeText(applicationContext, sectionPos.toString(),Toast.LENGTH_SHORT).show()
            }
        }

setValueByTouch (and callback)

You can set values by touch and you can disable this feature by 'acv_allow_setting_value_by_touch' attribute. Also you can set a callBack listener to find out when values changed.

myArcChartView.listener = object : ArcChartView.AcvListener {
            override fun onStartSettingSectionValue(sectionPos: Int, sectionValue: Int) {
                tvSectionsValue.setText("onStartSettingSectionValue $sectionPos $sectionValue")
            }

            override fun onContinueSettingSectionValue(sectionPos: Int, sectionValue: Int) {
                tvSectionsValue.setText("onContinueSettingSectionValue $sectionPos $sectionValue")
            }

            override fun onFinishedSettingSectionValue(sectionPos: Int, sectionValue: Int) {
                tvSectionsValue.setText("onFinishedSettingSectionValue $sectionPos $sectionValue")
            }
        }

Implementing Rotate Animation (using startDegreeOffset attribute)

    val anim = ValueAnimator.ofFloat(0f,360f).apply {
                repeatCount = ValueAnimator.INFINITE
                repeatMode = ValueAnimator.RESTART
                interpolator = OvershootInterpolator()
                duration = 3000
            }
            anim.addUpdateListener {
                if(isAnimating)
                    myArcChartView.startDegreeOffset =
                            it.animatedValue as Float
            }
            anim.start()

3 - Some Samples

Sample 1

    <com.neo.arcchartview.ArcChartView
        android:id="@+id/arc_chart_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toTopOf="@+id/view_separator"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:acv_lines_count="10"
        app:acv_lines_width="6dp"
        app:acv_lines_space="4dp"
        app:acv_sections_count="8"
        app:acv_sections_space="2dp"
        app:acv_icon_size="32dp"
        app:acv_mid_start_extra_offset="12dp"
        />

Sample 2

    <com.neo.arcchartview.ArcChartView
        android:id="@+id/arc_chart_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toTopOf="@+id/view_separator"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:acv_lines_count="4"
        app:acv_lines_width="17dp"
        app:acv_lines_space="2dp"
        app:acv_sections_count="3"
        app:acv_sections_space="6dp"
        app:acv_icon_size="36dp"
        app:acv_mid_start_extra_offset="0dp"
        />

Sample 3

    <com.neo.arcchartview.ArcChartView
        android:id="@+id/arc_chart_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toTopOf="@+id/view_separator"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:acv_lines_count="6"
        app:acv_lines_width="14dp"
        app:acv_lines_space="0dp"
        app:acv_sections_count="18"
        app:acv_sections_space="0dp"
        app:acv_icon_size="14dp"
        app:acv_mid_start_extra_offset="8dp"
        />

arcchartview's People

Contributors

imanneo avatar

Watchers

 avatar  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.