Coder Social home page Coder Social logo

oneacorn / xfree-mpandroidchart Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 11.48 MB

A LineChart based on MPAndroidChart 3.1.0 allows unsorted data to be displayed on x-Axis which MPAndroidChart is not allowed.

Kotlin 4.36% Java 95.64%
android linechart mpandroidchart selectarea unsorted x-axis negativearraysizeexception

xfree-mpandroidchart's Introduction

XFree-MPAndroidChart

中文文档

XFree-MPAndroidChart is based on MPAndroidChart 3.1.0, The purpose of this library is to solve the problem that the LineChart of MPAndroidChart can't add unsorted entries. When adding unsorted entries to MPAndroidChart, it will crash and the following error is displayed

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.acorn.myframeapp, PID: 13758
    java.lang.NegativeArraySizeException: -2
        at com.github.mikephil.charting.utils.Transformer.generateTransformedValuesLine(Transformer.java:178)
        at com.github.mikephil.charting.renderer.LineChartRenderer.drawValues(LineChartRenderer.java:567)
        at com.github.mikephil.charting.charts.BarLineChartBase.onDraw(BarLineChartBase.java:297)

Note that the performance of XFree-MPAndroidChart is slightly inferior to that of MPAndroidChart

Preview

Sorted data

github

Unsorted data

github

use XFreeLineDataSet.mPointVisibleThreshold to determined whether the circles are displayed

//when mPointVisibleThreshold<=0 the circles on the lines will always displayed.
//when mPointVisibleThreshold>0,
//Whether the circles are displayed or not is determined by the number of entries which simultaneously shown on the screen
//When the number of entries shown on the screen is less than the mPointVisibleThreshold, those circles will be displayed.
mXFreeLineDataSet.mPointVisibleThreshold = 100

github

Select Area

github

github

Installation

Gradle

Step 1. Add the JitPack repository to your build file

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

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

Step 2. Add the dependency

	dependencies {
	        implementation 'com.github.oneAcorn:XFree-MPAndroidChart:v1.0.10'
	}

Usage

Most of the usages for XFree-MPAndroidChart are the same as for MPAndroidChart.

The differences are shown below.

  1. Create the instance object of chart view:AAChartView
    <com.acorn.xfreechart.library.XFreeLineChart
    android:id="@+id/lineChart"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
  1. Create a LineDataSet
//In XFree-MPAndroidChart we use the XFreeLineDataSet instead of the LineDataSet
val set = XFreeLineDataSet(binding.lineChart, null, "Test Data")

3 Create the Highlighter

//In XFree-MPAndroidChart we use the XFreeHighlighter instead of the ChartHighlighter
xFreeChart.highlighter = XFreeHighlighter(this)

xfree-mpandroidchart's People

Contributors

oneacorn avatar

Watchers

 avatar

xfree-mpandroidchart's Issues

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.