This is code for creating dataset for Line chart.
private fun setUpChartData() {
val mainEntries = listOf(
Entry(1f, 20f),
Entry(6f, 28f),
Entry(11f, 26f),
Entry(16f, 35f),
Entry(21f, 30f),
Entry(25f, 40f),
Entry(31f, 48f)
)
val mainDataSet = LineDataSet(mainEntries, "Main").apply {
setColor(R.color.red, 255) // Not working. Just example
lineWidth = 2f
highlightLineWidth = 2f
highLightColor = themeColor(R.attr.bg_dark_blue)
setDrawCircles(true)
circleRadius = 3f
setDrawCircleHole(false)
setCircleColor(themeColor(R.attr.states_red))
setDrawValues(false)
setDrawHorizontalHighlightIndicator(false)
setDrawVerticalHighlightIndicator(true)
mode = LineDataSet.Mode.CUBIC_BEZIER
}
val avgEntries = listOf(
Entry(1f, 5f),
Entry(6f, 18f),
Entry(11f, 20f),
Entry(16f, 30f),
Entry(21f, 38f),
Entry(25f, 43f),
Entry(31f, 55f)
)
val avgDataSet = LineDataSet(avgEntries, "Avg").apply {
setColor(R.color.red, (0.3 * 255).toInt()) // Not working. Just example
lineWidth = 2f
enableDashedLine(10f, 8f, 0f)
setDrawCircles(false)
setDrawValues(false)
setDrawHorizontalHighlightIndicator(false)
setDrawVerticalHighlightIndicator(false)
mode = LineDataSet.Mode.CUBIC_BEZIER
}
mBinding.chart.apply {
data = LineData(mainDataSet, avgDataSet)
animateX(800, Easing.EaseInOutCubic)
invalidate()
}
}
Above in setColor, I want to set alpha to avg dataset. But the alpha also set to main dataset. What is the issue here?
This is code for creating dataset for Line chart.
Above in setColor, I want to set alpha to avg dataset. But the alpha also set to main dataset. What is the issue here?
What I want
What the code does