You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.5 KiB
60 lines
1.5 KiB
package com.whitefish.app.ext
|
|
|
|
import android.graphics.Color
|
|
import com.github.mikephil.charting.charts.BarChart
|
|
import com.github.mikephil.charting.charts.LineChart
|
|
import com.github.mikephil.charting.components.XAxis
|
|
|
|
fun LineChart.clearDraw(){
|
|
setBackgroundColor(Color.TRANSPARENT)
|
|
setTouchEnabled(false)
|
|
isDragEnabled = false
|
|
setScaleEnabled(false)
|
|
|
|
//隐藏背景线
|
|
xAxis.setDrawGridLines(false)
|
|
axisLeft.setDrawGridLines(false)
|
|
axisRight.setDrawGridLines(false)
|
|
setGridBackgroundColor(Color.TRANSPARENT)
|
|
|
|
//隐藏坐标轴
|
|
xAxis.isEnabled = false
|
|
axisLeft.isEnabled = false
|
|
axisRight.isEnabled = false
|
|
|
|
//禁用图例
|
|
legend.isEnabled = false
|
|
description.isEnabled = false
|
|
}
|
|
|
|
fun BarChart.clearDraw(){
|
|
setBackgroundColor(Color.TRANSPARENT)
|
|
setTouchEnabled(false)
|
|
isDragEnabled = false
|
|
setScaleEnabled(false)
|
|
|
|
//隐藏背景线
|
|
xAxis.setDrawGridLines(false)
|
|
axisLeft.setDrawGridLines(false)
|
|
axisRight.setDrawGridLines(false)
|
|
setGridBackgroundColor(Color.TRANSPARENT)
|
|
|
|
//隐藏坐标轴
|
|
xAxis.isEnabled = false
|
|
axisLeft.isEnabled = false
|
|
axisRight.isEnabled = false
|
|
|
|
//禁用图例
|
|
legend.isEnabled = false
|
|
description.isEnabled = false
|
|
}
|
|
|
|
fun BarChart.customStyle(count:Int){
|
|
xAxis.position = XAxis.XAxisPosition.BOTTOM
|
|
xAxis.setCenterAxisLabels(true)
|
|
xAxis.setAxisMinimum(0f)
|
|
xAxis.setAxisMaximum(count.toFloat())
|
|
xAxis.setLabelCount(count)
|
|
xAxis.granularity = 0.1F
|
|
xAxis.isGranularityEnabled = true
|
|
}
|