Skip to content

Windmill-hq/LineChart

Repository files navigation

LineChart

Simple graphic representation of data changing during the time

drawing drawing

How to use?

  1. Copy chartLib as module to your project
  2. In settings.gradle file add library as module ':chartLib', so the file should look like
  include ':chartLib', ':YOUR_APP_NAME'
  1. In module level build.gradle file add next line to block dependencies
dependencies{
    implementation project(':chartLib')
}
  1. Declare TimeLineChart view in your layout as shown below
    <com.contest.chart.TimeLineChart
            android:id="@+id/chart"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" /> 
  1. Find chart view and set prepared data
      val chartData : LineChartData = prepareData()
      val chart: TimeLineChart = findViewById(R.id.chart)
      chart.setTitle("YOUR CHART TITLE")
      chart.setData(chartData)
  1. Chart supports Light and Dark themes, to switch between them just call method switchTheme() on class instance
chart.switchTheme()
  1. In order to represent your data, chart requires you to provide data as instance of class LineChartData
class LineChartData(val id: Int) {
  val brokenLines = ArrayList<BrokenLine>()
  lateinit var timeLine: LongArray
}

Field timeLine is array of long that represented time line during wich your data changes.
Since chart can represent a few chart lines simultaneously in one view with the same time frame, you need to provide your data as instance of class BrokenLine and add it to brokenLines list.

Class BrokenLine declaration

class BrokenLine(val points: FloatArray, val name: String, val color: String)

where:
points - array of values of your data
name - name of data
color - color in HEX format

IMPORTANT: size of points and timeLine arrays should be always equal

  1. Min API level 21

About

Graphic representation of data changing during the time

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages