MPandroidGraph not showing data in fragment, only blue circle

I tried to put a pie chart in a fragment but I can not figure out how to get it to show data. If it were working right it would show red and green but it is blue. From everything I can find I am doing it all correctly but all it does is show a blue pie chart.

I initially couldnt figure out how to get access to the view class in a fragment so I could find the pie chart but I figured that out, and this is what it gave me.

I tried changing the parameters in the PieEntry and nothing I did fixed it

wrong behavior

In my fragment_first.xml file, I have this

<com.github.mikephil.charting.charts.PieChart
        android:id="@+id/PieChartBaby"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_marginStart="16dp"
        android:layout_marginLeft="16dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

In the FirstFragment.kt I have

class FirstFragment() : Fragment() {

    private var _binding: FragmentFirstBinding? = null
    lateinit var pieChartHandler: PieChartHandler
    val debugTag = "FirstFragment_DEBUG"
    // This property is only valid between onCreateView and
    // onDestroyView.
    private val binding get() = _binding!!

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        _binding = FragmentFirstBinding.inflate(inflater, container, false)
        pieChartHandler = PieChartHandler(binding.root)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        binding.buttonFirst.setOnClickListener {
            findNavController().navigate(R.id.action_FirstFragment_to_SecondFragment)
        }

        pieChartHandler.generatePieData(3445.0f, 6000.0f)
        pieChartHandler.triggerAnimate()

    }

    fun goToNextView() {
        findNavController().navigate(R.id.action_FirstFragment_to_SecondFragment)
    }

    override fun onDestroyView() {
        super.onDestroyView()
        _binding = null
    }
}

and I am using a non activity class that handles all the pie chart stuff

class PieChartHandler(view: View){
    val view = view
    val debugTag = "PieChartHandler_DEBUG"
    var pieChart = view.findViewById<PieChart>(R.id.PieChartBaby)
    val currentStepsText = view.findViewById<TextView>(R.id.currentStepsText)
    val stepsGoalText = view.findViewById<TextView>(R.id.stepGoalText)
    
    fun generatePieData(steps: Float, goal: Float) {
        Log.d(debugTag, "Generating pie chart data... Steps: $steps, goal $goal")
        val pieElements = ArrayList<PieEntry>()
        val pieColors = ArrayList<Int>()
        if (steps <= goal) {
//          if goal has not been met, calculate normally
            pieElements.add(PieEntry(steps, ""))
            pieElements.add(PieEntry(goal - steps, ""))
        } else {
//          if goal has been met, set red to none to avoid weird pie chart
            pieElements.add(PieEntry(steps, ""))
            pieElements.add(PieEntry(0f, ""))
        }
        pieColors.add(R.color.good_green)
        pieColors.add(R.color.to_go_red)

        val pieDataSet = PieDataSet(pieElements, "")
        pieDataSet.colors = pieColors
        val pieData = PieData(pieDataSet)
        pieData.setValueTextSize(0f)
        pieChart.data = pieData
        pieChart.invalidate()

        currentStepsText.text = pieElements[0].toString()
        stepsGoalText.text = pieElements[1].toString()

        formatPieData()
    }

    private fun formatPieData() {
        pieChart.setUsePercentValues(false)
        pieChart.setDrawMarkers(false)
        pieChart.isDrawHoleEnabled = true
        pieChart.setHoleColor(R.color.design_default_color_background)
        pieChart.holeRadius = 70f
        pieChart.description.isEnabled = false
        pieChart.setDrawEntryLabels(false)
        pieChart.legend.isEnabled = false
    }

    fun triggerAnimate() {
        Log.d(debugTag, "Pie chart animation triggered")
        pieChart.animateY(1000, com.github.mikephil.charting.animation.Easing.EaseInOutQuad)
    }
}

Does anyone have any idea where I went wrong?

Edit: moving formatPieData() before setting the pieChart.data did not work

Answer

the mistake was to use the R class to call R.color.{color}

if you use Color.parseColor("#color") it works correctly

this took entirely too long to figure out

i need a break