Coder Social home page Coder Social logo

skyline's Introduction

Skyline

Skyline is a kline library for android client, provide professional market charts. Skyline only draw the candles displayed on current screen. So its render speed will be faster than all drawing. Skyline has rich support of technical indicators. You can customize indicators on main graph area and sub graph area as you want. Skyline already have build-in indicator algorithm implementations. And if you want to support any other indicators, only need to wrapper your own calculate data with IndicatorWrapper or create your own SubGraphDrawer, then place into skyline, skyline will automatically adjust the view based on the incoming data. Skyline also support multi-gestures include drag, scale(x direction and y direction).

Why named Skyline

Skyline hope each candle can rise to sky high!

Preview

skyline

Installation

implementation 'io.trubi.android:skyline:1.0.0'

Structure

 |-----------------------------------------------------------|
 | Main graph top text area, draw indicator value            |
 |-----------------------------------------------------------|
 |                                                           |
 | Main graph area                                           |
 | - Draw K line                                             |
 | - Draw indicators                                         |           
 |                                                           |
 |-----------------------------------------------------------|
 | Sub graph top text area, draw sub graph indicator value   |
 |-----------------------------------------------------------|
 |                                                           |
 | Sub graph area                                            |
 | - Draw sub graph indicators                               |
 |                                                           |
 |-----------------------------------------------------------|
 | Bottom text area, draw x axis value                       |
 |-----------------------------------------------------------|

How to use

Add skyline

In xml

<io.trubi.skyline.Skyline
    android:id="@+id/skyline"
    android:layout_width="match_parent"
    android:layout_height="300dp" />

Display candles

val candles = ... // prepare candle data
skyline.setCandles(candles)
skyline.invalidate()

Switch mode

// show simple line
kView?.modeLine()
// show candle stick
kView?.modeCandle()

How to custom style

In skyline, use FlavorDescription to describe how skyline looks

FlavorDescription(
    name                  = "default",

    backgroundColor       = Color.TRANSPARENT,
    borderColor           = Color.parseColor("#45FFFFFF"),

    xAxisColor            = Color.parseColor("#45FFFFFF"),
    xAxisLabelColor       = Color.parseColor("#45FFFFFF"),

    yAxisColor            = Color.parseColor("#45FFFFFF"),
    yAxisLabelColor       = Color.parseColor("#45FFFFFF"),

    increasingColor       = Color.parseColor("#2EBD85"),
    decreasingColor       = Color.parseColor("#E24537"),

    timeLineColor         = Color.parseColor("#2587b4"),

    markLabelTextColor    = Color.parseColor("#FFFFFFFF"),

    crossLineColor        = Color.LTGRAY,
    crossLabelColor       = Color.YELLOW
)
val flavor = FlavorDescription(...)
skyline?.setFlavor(flavor)

Custom main graph indicator

Use IndicatorWrapper to describe custome indicator.

val wrapper = IndicatorWrapper()
wrapper.color = Color.parseColor("#20acea")
wrapper.width = 2f
wrapper.displayName = "indicator name"
wrapper.indicators = arraylistof(...) // compute indicator value

skyline.addMainGraphIndicator(wrapper)

Custom sub graph

Interface SubGraphDrawer define how to draw sub graph.

interface SubGraphDrawer {

    fun getTouchedIndicatorsByIos(indexOnScreen: Int): ArrayList<IndicatorWrapper>

    fun beforeDrawCandles(...)

    fun onDrawEachCandle(...)

    fun afterDrawCandles(...)

}

Implement interface SubGraphDrawer to draw custom graph and set into skyline

class VolDrawer: SubGraphDrawer {
    ...
}

skyline.setSubGraphDrawer(VolDrawer())

Add crossline

There is two build-in crossline implementation CrossLineView and DCFWCrossLineView.

In xml

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="300dp">

    <io.trubi.skyline.Skyline
        android:id="@+id/skyline"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <io.trubi.skyline.cross.CrossLineView
        android:id="@+id/crossLine"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone"/>

</RelativeLayout>

Crossline need to place above skyline.

In kotlin

crossLine?.updateCandleRect(candle, candleRect)
crossLine?.updateXAxisStr(...)
crossLine?.updateYCoordinate(...)
...

Gesture

Implement interface IKToucher to handle gesture logic. Skyline already have two build-in implementation SimpleKToucher and DCFWKToucher

skyline.addToucher(SimpleKToucher())

Build-in indicator support

Algorithm

  • SMA
  • EMA
  • BOLL
  • MACD
  • KDJ
  • RSI
  • WR

Sub graph drawer

  • VolDrawer
  • MacdDrawer
  • WilliamsRDrawer
  • LineDrawer

skyline's People

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.