MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

Remove Legend default keyword “Stack” from MpAndroidChart

Open RajithRaj opened this issue 5 years ago • 1 comments

I am using MpAndroidChart library for android. I am able to give different colors for the region below and above the limit line. but I am getting a keyword "Stack" in the legend(please check the attached screenshot). Without a limit line everything working perfectly. But if I am using limit line (red for region right of the limit line and green for another side ) I am getting two legends and the keyword "Stack" is appending along with the legend.

if (yAxisValue != null) {

var progressData = progressLayoutData

val barDatasets: MutableList<IBarDataSet> = java.util.ArrayList()

for (yValues in yAxisValue) {

val entries: MutableList<BarEntry> = java.util.ArrayList()
var i = 0f
var isHaveLimitLine = false
val colorList: MutableList<Int> = java.util.ArrayList()
for (value in yValues?.dataSet) {

    if(progressData?.limitLine!=null && progressData?.limitLine!=0) {
        if (value > progressData?.limitLine ?: 0) {

            var differenceValue = value?.toFloat() - progressData?.limitLine?.toFloat()!!
            entries.add(BarEntry(i, floatArrayOf(progressData?.limitLine?.toFloat()!!, differenceValue)))
            colorList.add(fhuiManager?.getParsedColor(yValues?.color,context))
            colorList.add(fhuiManager?.getParsedColor(progressData?.limitExceedColor ?: "#FE2020",context))
        } else {
            colorList.add(fhuiManager?.getParsedColor(yValues?.color,context))
            entries.add(BarEntry(i, value?.toFloat()))
        }
        isHaveLimitLine = true
    }else{
        entries.add(BarEntry(i, value?.toFloat()))
    }
    i++
}
val barDataSet = BarDataSet(entries, "" + yValues?.datasetName)
if(isHaveLimitLine)
    barDataSet?.colors = colorList
else
    barDataSet?.color = fhuiManager?.getParsedColor(yValues?.color,context)
barDataSet?.setDrawValues(false)

// add to line data set
barDatasets?.add(barDataSet)

} chart_issue

RajithRaj avatar Sep 04 '20 08:09 RajithRaj

@RajithRaj Have you found any solution?

arunSriramulaWYH avatar Nov 22 '24 11:11 arunSriramulaWYH