最牛逼android上的图表库MpChart(二) 折线图
最近工作中,用到了mpchart图表库,现在分享受下mpchart图表库的各个图表在实际工作应用场景:
- 最牛逼android上的图表库MpChart(一) 介绍篇
- 最牛逼android上的图表库MpChart(二) 折线图
- 最牛逼android上的图表库MpChart(三) 条形图
- 最牛逼android上的图表库MpChart(四) 饼图
- 最牛逼android上的图表库MpChart(五) 泡泡图
使用mpchart jar包:mpandroidchartlibrary-2-1-6.jar
如果是在studio下,进行如下引用:
repositories {
maven { url “https://jitpack.io” }
}
dependencies {
compile ‘com.github.PhilJay:MPAndroidChart:v2.1.6’
}
MpChart折线图介绍
- LineChart类
- 使用哪些API
- setBackgroundColor(int color): Sets the background color that will cover the whole chart-view. In addition, a background-color can be set via .xml in the layout file.
- setDescription(String desc): Set a description text that appears in the bottom right corner of the chart.
- setDescriptionColor(int color): Sets the color of the description text.
- setDescriptionPosition(float x, float y): Sets a custom position for the description text in pixels on the screen.
- setDescriptionTypeface(Typeface t): Sets the Typeface used for drawing the description text.
- setDescriptionTextSize(float size): Sets the size of the description text in pixels, min 6f, max 16f.
- setNoDataTextDescription(String desc): Sets the text that should appear if the chart is empty.
- setDrawGridBackground(boolean enabled): If enabled, the background rectangle behind the chart drawing-area will be drawn.
- setGridBackgroundColor(int color): Sets the color the grid-background should be drawn with.
- setDrawBorders(boolean enabled): Enables / disables drawing the chart borders (lines surrounding the chart).
- setBorderColor(int color): Sets the color of the chart border lines.
- setBorderWidth(float width): Sets the width of the chart border lines in dp.
- setMaxVisibleValueCount(int count): Sets the number of maximum visible drawn value-labels - on the chart. This only takes affect when setDrawValues() is enabled.
MpChart折线图实例
- 布局文件
- Java代码