|
|
@@ -9,6 +9,7 @@ import com.github.mikephil.charting.components.YAxis
|
|
|
import com.github.mikephil.charting.data.Entry
|
|
|
import com.github.mikephil.charting.data.LineData
|
|
|
import com.github.mikephil.charting.data.LineDataSet
|
|
|
+import com.yingyang.workbenches.R
|
|
|
import com.yingyang.workbenches.adapter.BrainAbilityTypeAdapter
|
|
|
import com.yingyang.workbenches.databinding.FragmentBrainAbilityBinding
|
|
|
import com.yingyang.workbenches.entity.VariationTendencyByTypeBean
|
|
|
@@ -59,22 +60,18 @@ class BrainAbilityFragment :
|
|
|
if (it.isNullOrEmpty().not()) {
|
|
|
variationTendencyByTypeBean.addAll(it!!)
|
|
|
val lineData = LineData()
|
|
|
- it.forEach {
|
|
|
+ for (index in it.indices) {
|
|
|
xType.clear()
|
|
|
- if (it.value.isNullOrEmpty().not()) {
|
|
|
+ if (it[index].value.isNullOrEmpty().not()) {
|
|
|
val list = ArrayList<Entry>()
|
|
|
- for (i in it.value.indices) {
|
|
|
- xType.add(it.value[i].time)
|
|
|
- val entry = Entry(i.toFloat(), it.value[i].mentalEnergyVal)
|
|
|
+ for (i in it[index].value.indices) {
|
|
|
+ xType.add(it[index].value[i].time)
|
|
|
+ val entry = Entry(i.toFloat(), it[index].value[i].mentalEnergyVal)
|
|
|
list.add(entry)
|
|
|
}
|
|
|
//两个参数
|
|
|
val lineDataSet = LineDataSet(list, "")
|
|
|
- if (TextUtils.equals("定向力", it.name)) {
|
|
|
- lineDataSet.color = Color.RED
|
|
|
- } else {
|
|
|
- lineDataSet.color = Color.BLUE
|
|
|
- }
|
|
|
+ setColor(index, lineDataSet)
|
|
|
lineDataSet.setDrawCircleHole(false)
|
|
|
lineDataSet.setDrawCircles(false)
|
|
|
lineDataSet.mode = LineDataSet.Mode.CUBIC_BEZIER
|
|
|
@@ -90,6 +87,35 @@ class BrainAbilityFragment :
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 设置线条颜色
|
|
|
+ */
|
|
|
+ private fun setColor(index: Int, lineDataSet: LineDataSet) {
|
|
|
+ when (index) {
|
|
|
+ 0 -> {
|
|
|
+ lineDataSet.color = resources.getColor(R.color.color_FFFF710C)
|
|
|
+ }
|
|
|
+ 1 -> {
|
|
|
+ lineDataSet.color = resources.getColor(R.color.color_FF0CABFF)
|
|
|
+ }
|
|
|
+ 2 -> {
|
|
|
+ lineDataSet.color = resources.getColor(R.color.color_FF22C0D5)
|
|
|
+ }
|
|
|
+ 3 -> {
|
|
|
+ lineDataSet.color = resources.getColor(R.color.color_FF1BB639)
|
|
|
+ }
|
|
|
+ 4 -> {
|
|
|
+ lineDataSet.color = resources.getColor(R.color.color_FFD70CFF)
|
|
|
+ }
|
|
|
+ 5 -> {
|
|
|
+ lineDataSet.color = resources.getColor(R.color.color_FFFF2B2B)
|
|
|
+ }
|
|
|
+ else -> {
|
|
|
+ lineDataSet.color = resources.getColor(R.color.color_FF821EFF)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private fun initLineChart() {
|
|
|
//设置线状图不显示描述
|
|
|
binding.lineChart.description = null
|