Skip to content

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


Create new project

Select API level


Select API level

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

Add Activity


Create new project

Customize Activity


Select API level

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 repository in your root build.gradle

Add the dependency and sync the project


Add the dependency in your project build.gradle and sync 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 repository in your root build.gradle

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


Add repository to the root build.gradle

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


Build and run

Running App


Running app