PhilJay / MPAndroidChart

A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.
Other
37.67k stars 9.02k forks source link

Remove Legend default keyword “Stack” from MpAndroidChart #4991

Open RajithRaj opened 4 years ago

RajithRaj commented 4 years ago

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 = 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

arunSriramulaWYH commented 1 week ago

@RajithRaj Have you found any solution?