MPAndroidChart

repository·master·Indexed 12 days ago

https://github.com/philjay/mpandroidchart

A library for creating interactive charts in Android applications, supporting LineChart, BarChart, CombinedChart, PieChart, ScatterChart, CandlestickChart, BubbleChart, and RadarChart. Version v3.1.0 provides tools for data point management via the Entry class.

Tokens
1.2K
Snippets
5
Records
8
Agent score
49%

What's inside MPAndroidChart

  1. Supported Chart Types

    master

    MPAndroidChart supports a wide variety of chart visualizations, including:

    • LineChart: Simple designs, cubic lines, and gradient fills.
    • BarChart: Standard, grouped DataSets, and Horizontal BarCharts.
    • CombinedChart: Overlays multiple chart types (e.g., bar and line charts).
    • PieChart: Circular charts with selection support.
    • ScatterChart: Data points using various shapes (squares, triangles, circles, etc.).
    • CandlestickChart: Specialized for financial data.
    • BubbleChart: Bubbles where area indicates the yValue.
    • RadarChart: Spider web style charts.
  2. Install MPAndroidChart via Maven

    master

    For Maven-based projects, add the JitPack repository to your pom.xml and include the MPAndroidChart dependency with the group ID com.github.PhilJay.

    <!-- <repositories> section of pom.xml -->
    <repository>
        <id>jitpack.io</id>
       <url>https://jitpack.io</url>
    </repository>
    
    <!-- <dependencies> section of pom.xml -->
    <dependency>
        <groupId>com.github.PhilJay</groupId>
        <artifactId>MPAndroidChart</artifactId>
        <version>v3.1.0</version>
    </dependency>
  3. Install MPAndroidChart via Gradle

    master

    To use MPAndroidChart in an Android project, add the JitPack repository to your repositories block and then add the library as an implementation dependency in your dependencies block.

    repositories {
        maven { url 'https://jitpack.io' }
    }
    
    dependencies {
        implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
    }
  4. Compare and copy Entry objects

    master

    To duplicate an entry, use the copy() method, which creates a new Entry with the same x, y, and data values.

    To check if two entries are logically equivalent, use equalTo(Entry e). This method compares the data, x, and y values using a small epsilon (Utils.FLOAT_EPSILON) to account for floating-point precision errors. Note that equalTo is distinct from the standard equals method as it focuses on value equality rather than hash-code equality.

    Entry e1 = new Entry(1f, 10f);
    Entry e2 = e1.copy();
    
    boolean isSame = e1.equalTo(e2);
  5. Create data points using the Entry class

    master

    The Entry class represents a single data point in a chart. It contains an x value and a y value (the actual value of the entry). You can also attach an optional Drawable icon or an arbitrary Object for additional data to each entry.

    Constructors

    • Entry(): Default empty constructor.
    • Entry(float x, float y): Basic entry with x and y coordinates.
    • Entry(float x, float y, Object data): Entry with x, y, and custom data.
    • Entry(float x, float y, Drawable icon): Entry with x, y, and an icon.
    • Entry(float x, float y, Drawable icon, Object data): Full entry with x, y, icon, and custom data.
    // Basic entry
    Entry entry = new Entry(1f, 10f);
    
    // Entry with custom data
    Entry entryWithData = new Entry(2f, 20f, "my_metadata");
    
    // Entry with an icon and data
    Entry entryWithIcon = new Entry(3f, 30f, myDrawable, myData);