FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Getting started · AnyChart/AnyChart-Android Wiki · GitHub

Getting started

ArsenyMalkov edited this page Jul 28, 2023 · 12 revisions

You should have already set up the latest Android Studio.

Create a new project and select appropriate API level (AnyChart library for Android compatible with API 19+).

Create new project


Select API level


Add an empty Activity and put in layout and Activity name.

Add Activity


Customize Activity


Add the repository to the project build.gradle at the end of repositories (WARNING: Make sure you add it under allprojects, not under the buildscript).

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

Then add the dependency to the module build.gradle and synchronize project with Gradle.

dependencies {
        implementation 'com.github.AnyChart:AnyChart-Android:1.1.5'
}

Add the repository


Add the dependency and sync the project


Add AnyChart view to the Activity layout.

<com.anychart.AnyChartView
        android:id="@+id/any_chart_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />

Add a view to a layout


Add Java code to the Activity. For example, if you want to create pie chart:

Pie pie = AnyChart.pie();

List<DataEntry> data = new ArrayList<>();
data.add(new ValueDataEntry("John", 10000));
data.add(new ValueDataEntry("Jake", 12000));
data.add(new ValueDataEntry("Peter", 18000));

pie.data(data);

AnyChartView anyChartView = (AnyChartView) findViewById(R.id.any_chart_view);
anyChartView.setChart(pie);

Add Java code


Make sure you have these package imports at the top of your Activity file.

import com.anychart.AnyChart;
import com.anychart.AnyChartView;
import com.anychart.DataEntry;
import com.anychart.Pie;
import com.anychart.ValueDataEntry;

import java.util.ArrayList;
import java.util.List;

Build and run your app.

Build and run


Running App


Clone this wiki locally


Back | FazBrowse Home | New Git URL