在 android MP Chart 内的多个数据集中隐藏一个数据集标签

Hide a data set label in multiple datasets inside android MP Chart

我正在用两个数据集画折线图和圆圈(表示当前进度)。当我尝试将两个数据集添加到同一个图表时,标签也在图表底部绘制了两次。 我想隐藏"当前进度"

val set1 = LineDataSet(mValues, "F1: Before Intersection Analysis")
            set1.enableDashedLine(10f, 5f, 0f)
            set1.color = Color.BLACK
            set1.lineWidth = 1f
set1.setDrawValues(false)
            set1.setDrawIcons(false)
            set1.setDrawCircles(false)
            set1.mode = LineDataSet.Mode.CUBIC_BEZIER
            set1.setDrawCircleHole(false)
set1.formLineWidth = 5f
            set1.formLineDashEffect = DashPathEffect(floatArrayOf(0f, 0f), 0f)
            set1.formSize = 15f
..
val set2 = LineDataSet(mValues, "current progress")
            set2.setDrawCircles(true)
            set2.setCircleColor(Color.BLACK)
            set2.circleRadius = 5f
            set2.color = Color.BLACK
            set2.setDrawCircleHole(false)
            //set2.setDrawValues(false)

            val dataSets: ArrayList<ILineDataSet> = ArrayList()
            dataSets.add(set1) // add the data sets
            dataSets.add(set2) // add the data sets

            // create a data object with the data sets
            val data = LineData(dataSets)
            if (binding.gaussionChart.data != null) {
                binding.gaussionChart.data.isHighlightEnabled = false
            }

            // set data
            binding.gaussionChart.data = data
            //binding.gaussionChart.legend.isEnabled = false

最后加上三行代码找到了解决办法

val set1 = LineDataSet(mLineData, "")
set1.formLineWidth = 0f
set1.formSize = 0f