https://play.google.com/store/apps/details?id=com.xxmassdeveloper.mpchartexample
https://github.com/PhilJay/MPAndroidChart
https://github.com/PhilJay/MPAndroidChart/tree/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LineChart chart = (LineChart) findViewById(R.id.chart); | |
List<Entry> list = new ArrayList<Entry>(); | |
list.add(new Entry(100,200)); | |
list.add(new Entry(120,250)); | |
list.add(new Entry(130,210)); | |
LineDataSet ls = new LineDataSet(list, "company1"); | |
List<ILineDataSet> dataSets = new ArrayList<ILineDataSet>(); | |
dataSets.add(ls); | |
LineData data = new LineData(dataSets); | |
chart.setData(data); |
라인데이터 데이터 세팅과정은,
일단 LineChart 로 객체를 하나 만들고,
x와 y좌표를 담고있는 Entry를 가진 리스트를 하나 만든다.
다만 이 리스트들은 데이터종류 하나에 대한 설명인데 콤보차트나 ㄹㅏ인ㅡ의 경우는 여러개의 설명해야할 데이터가 또 여러개있을수있다.
위의경우는 company1 만 존재하지만, company2도 존재할수 있으므로, 이를담는
LineDataSet에 또 담는다.
이를 최종적으로 LineData에 담아 보여준다.
'모바일 > Android' 카테고리의 다른 글
Groovy를 이용한 안드로이드 플러그인 개발. (0) | 2017.01.11 |
---|---|
InfalteException (0) | 2017.01.04 |
1.1 안드로이드 깨달음 (0) | 2017.01.01 |
깨달음 (2016.12.30) (0) | 2016.12.29 |
TOUCH_EXPLORATION_ENABLED 관련 (0) | 2016.12.29 |