Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create Pyramid Chart in android?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 492
    Comment on it

    This tutorial will help you to create a Pyramid chart in android. In this process, pyramid chart shapes look like triangle and divided into multiple sections. Each Sections represent value of entity from provided data set. Follow below steps to complete process.

     

    Step1- Add Library to Project as dependency

    Open app's build.gradle file and put following code.

    repositories {
        maven {
            url 'https://dl.bintray.com/sj/maven/'
        }
    }
    
    dependencies {
        compile 'com.numetriclabz.numandroidcharts:numandroidcharts:1.0.6'
    }

     

    Step2- Add chart layout

    To add pyramid chart layout, open main_activity.xml file and put this code

     
    <com.numetriclabz.pyramidchart.PyramidChart
        android:layout_width="wrap_content"
        android:layout_height="500dp"
        android:id="@+id/pyramid"/>
    
    

    Step3- Create a MainActivity

    Now, create MainActivity class and Initialize Chart in Activity.

     
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            PyramidChart pyramidChart = (PyramidChart) findViewById(R.id.pyramid);
    
            List<ChartData> values = new ArrayList<>();
    
            values.add(new ChartData("log out", 400));
            values.add(new ChartData("unique session", 500));
            values.add(new ChartData("unique visitors", 1000));
            values.add(new ChartData("unique visits", 2000));
            values.add(new ChartData("visits", 3000));
    
            pyramidChart.setData(values);
        }
    }
    
    

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: