MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

Horizontal grid-lines are not working

Open rigo-ptz opened this issue 8 years ago • 2 comments

Hi!

It seems that horizontal lines are not working on some screens (for ex: sony c6903, samsung gt-p3100, both 5.1.1) or on API22.

I have next settings for the chart:

with (lineChart) {
            legend.isEnabled = false
            description = null
            
            xAxis.setDrawAxisLine(true)
            xAxis.setDrawGridLines(false)
            xAxis.setDrawLabels(false)
            xAxis.position = XAxis.XAxisPosition.BOTTOM
            xAxis.axisMinimum = 0f
            xAxis.axisLineWidth = 1.asDpToPx().toFloat()
            xAxis.axisLineColor = R.color.diagramGrid.asColor()
    
            axisLeft.setDrawAxisLine(false)
            axisLeft.setDrawGridLines(false)
            axisLeft.setDrawLabels(false)
            axisLeft.axisMinimum = 0f
            axisLeft.isEnabled = false
            
            axisRight.setDrawAxisLine(false)
            axisRight.setDrawLabels(false)
            axisRight.setDrawGridLines(true)
            axisRight.textColor = Color.TRANSPARENT
            axisRight.axisLineColor = R.color.diagramGrid.asColor()
            axisRight.gridColor = R.color.diagramGrid.asColor()
            axisRight.gridLineWidth = 1.asDpToPx().toFloat()
            axisRight.textSize = 11f
            axisRight.axisMinimum = 0f
            axisRight.setLabelCount(5, true)
            axisRight.setValueFormatter { value, axis ->
                if (value - floor(value) == 0f)
                    String.format("%1$.0f", value)
                else
                    String.format("%1$.1f", value)
            }
    
            setPinchZoom(false)
            isDoubleTapToZoomEnabled = false
            setScaleEnabled(false)
            isDoubleTapToZoomEnabled = false
            isDragEnabled = false
        }

Data is set in this way:

        lineChart.axisRight.axisMinimum = 0f
        lineChart.axisRight.axisMaximum = lineData.yMax + step
        lineChart.axisLeft.axisMinimum = 0f
        lineChart.axisLeft.axisMaximum = lineData.yMax + step
    
        lineChart.axisLeft.isGranularityEnabled = true
        lineChart.axisRight.isGranularityEnabled = true
        lineChart.axisLeft.granularity = step
        lineChart.axisRight.granularity = step
        
        lineChart.data = lineData
        lineChart.invalidate()

Grids work great on nexus 5x with 8.1 and on samsung galaxy a5 with 7.0.

rigo-ptz avatar Feb 26 '18 11:02 rigo-ptz

Seems that this is happening with vertical grid lines, too. Grid lines are displayed properly on Galaxy S5. But do not work on Xiaomi and emulator images (and probably many more devices). If somebody could give advice it's highly appreciated! device-2018-03-05-132006_edited screenshot_2018-03-05-13-20-45_edited

milkiway avatar Mar 05 '18 10:03 milkiway

Hey there! This issue is fairly old, and may no longer apply to the current library version. I'm closing this in order to clean up the issue tracker. The repository has been inactive for a long time and old issues may have existing answers or are no longer valid.

I've been working diligently to get to as many issues as I can, but I can no longer spend time writing a unique answer to each issue. This is especially true if that issue may no longer be applicable. If you think this was done by mistake, please search through all open and closed issues first, and then create a new one using the templates.

This is a copied and pasted response, and has been put on many other issues. So please, don't take this personally.


I will say this: @rigo-ptz in your posted code you have deliberately disabled labels and gridlines for all axes except the right, obviously they won't be drawn!

As for you, @milkiway, without any code there is absolutely no way to tell what is going on.

almic avatar May 13 '18 07:05 almic