Skip to content

davidmigloz/line-chart

Repository files navigation

line-chart

A simple Android line chart library.

Features:

  • Auto-scaling drawing area and labels
  • Grid lines
  • Baseline
  • Zero line
  • Different filling modes
  • Custom label formatters
  • Scrubbing support
  • Data change animations
  • Fully customizable styles
  • Theme-friendly

Screenshot of the library being used in a real app:

Take a look at the sample app to see the library working.

Default Custom styles Animation

Usage

Step 1

Add the JitPack repository to your build.gradle file:

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

Step 2

Add the dependency:

dependencies {
	implementation 'com.github.davidmigloz:line-chart:2.1.0'
}

CHANGELOG

Step 3

Use LineChartView in your layout:

<com.davidmiguel.linechart.LineChartView
    android:id="@+id/lineChart"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    app:linechart_gridXDivisions="5"
    app:linechart_gridYDivisions="5"
    app:linechart_fillColor="@color/blue"
    app:linechart_lineColor="@color/white"
    app:linechart_scrubEnabled="false" />

XML attributes

Take a look to attrs.xml.

Methods

Take a look to LineChart.kt.

Listeners

If you want to listen to scrub events, you can register a OnScrubListener:

lineChart.scrubListener = OnScrubListener { value: Any? ->
    //...
}

Contributing

If you find any issues or have any questions, ideas... feel free to open an issue. Pull request are very appreciated.

Credits

This library is inspired by the power of MPAndroidChart and the simplicity of Spark.

License

Copyright (c) 2021 David Miguel Lozano

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.