Charting - Set the Graph GridLines Fixed

元气小坏坏 提交于 2019-12-24 23:19:55

问题


    val set1: LineDataSet     
    set1 = LineDataSet(values, "Player Form Graph")
    set1.color = Color.GREEN
    set1.setCircleColor(Color.GREEN)
    set1.lineWidth = 3f
    set1.circleRadius = 6f
    set1.circleHoleRadius = 3f
    set1.setDrawCircleHole(true)
    set1.disableDashedLine()
    set1.valueTextSize = 16f
    set1.setDrawFilled(true)
    set1.fillColor = Color.DKGRAY
    set1.formLineWidth = 6f
    set1.formLineDashEffect = DashPathEffect(floatArrayOf(10f, 5f), 0f)
    set1.formSize = 16f

setUpGraph Function:

private fun setUpGraph() {
    binding.chart1.setDrawGridBackground(false)

    // no description text
    binding.chart1.description.isEnabled = false

    // enable touch gestures
    binding.chart1.setTouchEnabled(true)

    // enable scaling and dragging
    binding.chart1.isDragEnabled = false
    binding.chart1.setScaleEnabled(false)

    // if disabled, scaling can be done on x- and y-axis separately
    binding.chart1.setPinchZoom(false)

    // set an alternative background color
    // binding.chart1.setBackgroundColor(Color.GRAY);

    // create a custom MarkerView (extend MarkerView) and specify the layout
    // to use for it
    val mv = MyMarkerView(activity, R.layout.custom_marker_view)
    mv.chartView = binding.chart1 // For bounds control
    binding.chart1.marker = mv // Set the marker to the chart

    val leftAxis = binding.chart1.axisLeft
    Log.d("Lucy", xAxisHigh.toString())
    leftAxis.axisMaximum = xAxisHigh.toFloat()
    leftAxis.axisMinimum = 0f
    leftAxis.axisLineWidth = 2f
    leftAxis.textColor = Color.WHITE
    leftAxis.setDrawZeroLine(false)


    // limit lines are drawn behind data (and not on top)
    leftAxis.setDrawLimitLinesBehindData(true)


    binding.chart1.axisRight.isEnabled = false
    val xAxis = binding.chart1.xAxis
    xAxis.textColor = Color.YELLOW
//xAxis.mAxisMaximum = 7f

    // add data

    binding.chart1.animateX(2500)
    //binding.chart1.invalidate();

    // get the legend (only possible after setting data)
    val l = binding.chart1.legend

    // modify the legend ...
    l.form = Legend.LegendForm.LINE
}

来源:https://stackoverflow.com/questions/58412330/charting-set-the-graph-gridlines-fixed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!