val cannot be reassigned while trying to update Polyline - android

In the code below I get an error Val cannot be reassigned, I dont know how can I recreate the object ? i am new to kotlin and I am just trying to update a code that i found somewhere... trying to understand how to modify it.
I understand it is final and it is being called from another class like this
another class
val polyLine = RoadManager.buildRoadOverlay(road)
PanRoad = newRoad(
polyLine = polyLine,
colorRoad = colorRoad,
roadWidth = roadWidth,
showPoiMarker = showPoiMarker,
listInterestPoints = listInterestPoints,
)
I tried changin it to val to var like this var polyLine = RoadManager.buildRoadOverlay(road) still nothing.
Below is the class that is giving errors
private fun newRoad(
polyLine: Polyline,
colorRoad: Int?,
showPoiMarker: Boolean,
listInterestPoints: List<GeoPoint>,
roadWidth: Float,
bitmapIcon: Bitmap? = null,
): PanRoad {
print(message = "pannam createRoad called")
polyLine.setOnClickListener { _, _, eventPos ->
methodChannel.invokeMethod("receiveSinglePress", eventPos?.toHashMap())
true
}
/// set polyline color
val polygonPaint = Paint().apply {
color = Color.BLUE
style = Paint.Style.FILL
}
val outlinerPaint = Paint().apply {
color = Color.DKGRAY
style = Paint.Style.STROKE
strokeWidth = 2f
}
polyLine.outlinePaint = Paint().apply {
color = colorRoad ?: Color.GREEN
style = Paint.Style.STROKE
strokeWidth = 2f
strokeCap = Cap.ROUND
strokeJoin = Paint.Join.ROUND
}
val iconsRoads = customRoadMarkerIcon
when {
(iconsRoads.isEmpty() && bitmapIcon != null) -> {
iconsRoads[Constants.STARTPOSITIONROAD] = bitmapIcon
iconsRoads[Constants.MIDDLEPOSITIONROAD] = bitmapIcon
iconsRoads[Constants.ENDPOSITIONROAD] = bitmapIcon
}
iconsRoads.isNotEmpty() && bitmapIcon != null -> {
iconsRoads[Constants.MIDDLEPOSITIONROAD] = bitmapIcon
if (!iconsRoads.containsKey(Constants.STARTPOSITIONROAD)) {
iconsRoads[Constants.STARTPOSITIONROAD] = bitmapIcon
}
if (!iconsRoads.containsKey(Constants.ENDPOSITIONROAD)) {
iconsRoads[Constants.ENDPOSITIONROAD] = bitmapIcon
}
}
}
val PanRoad = PanRoad(
context,
map!!,
interestPoint = if (showPoiMarker) listInterestPoints else emptyList(),
showInterestPoints = showPoiMarker
)
PanRoad.let { roadF ->
if (showPoiMarker) {
roadF.markersIcons = iconsRoads
}
polyLine.outlinePaint.strokeWidth = roadWidth
roadF.road = polyLine
folderRoad.items.add(roadF)
}
return PanRoad
}
The error occurs at polyLine.outlinePaint

I assume the Polyline class you're working with is from org.osmdroid.views.overlay, which only provides a getOutlinePaint as can be seen in its JavaDoc. However, there is no setOutlinePaint. From Kotlins point of view outlinePaint is therefore a val which cannot be reassigned.
It think instead of reassigning the outlinePaint field you instead want to retrieve a reference to the Paint object stored in the field and modify it directly. Something like the following might work, however I'm unable to verify this at the moment.
val outlinePaint = polyLine.outlinePaint
outlinePaint.color = Color.GREEM
outlinePaint.style = Paint.Style.STROKE
or if using apply is preferred
polyLine.outlinePaint.apply {
color = Color.GREEM
style = Paint.Style.STROKE
}

Related

I have a line chart that I want to use to show temperature, but I want to show icons and time in x axis

what I want to achieve
what I have
I want to show icons on the xAxis above time but line chart takes icon and places them on the value where temperature is shown. I have searched a lot but could not find the answer. Any help would be appreciated. I have tried a lot of things but all in vein.
private fun setTempChart(hour: ArrayList<Hour>, id: String) {
val entries: MutableList<Entry> = ArrayList()
for (i in hour.indices) {
val code = hour[i].condition.code
val icon =
if (hour[i].is_day == 1) requireActivity().setIconDay(code) else requireActivity().setIconNight(
code
)
entries.add(Entry(i.toFloat(), sharedPreference.temp?.let {
hour[i].temp_c.setCurrentTemperature(
it
).toFloat()
}!!))
}
val dataSet = LineDataSet(entries, "")
dataSet.apply {
lineWidth = 0f
setDrawCircles(false)
setDrawCircleHole(false)
isHighlightEnabled = false
valueTextColor = Color.WHITE
setColors(Color.WHITE)
valueTextSize = 12f
mode = LineDataSet.Mode.CUBIC_BEZIER
setDrawFilled(true)
fillColor = Color.WHITE
valueTypeface = typeface
isDrawIconsEnabled
setDrawIcons(true)
valueFormatter = object : ValueFormatter() {
override fun getFormattedValue(value: Float): String {
return String.format(Locale.getDefault(), "%.0f", value)
}
}
}
val lineData = LineData(dataSet)
chart.apply {
description.isEnabled = false
axisLeft.setDrawLabels(false)
axisRight.setDrawLabels(false)
legend.isEnabled = false
axisLeft.setDrawGridLines(false)
axisRight.setDrawGridLines(false)
axisLeft.setDrawAxisLine(false)
axisRight.setDrawAxisLine(false)
setScaleEnabled(false)
data = lineData
setVisibleXRange(8f, 8f)
animateY(1000)
xAxis.apply {
setDrawAxisLine(false)
textColor = Color.WHITE
setDrawGridLines(false)
setDrawLabels(true)
position = XAxis.XAxisPosition.BOTTOM
textSize = 12f
valueFormatter = MyAxisFormatter(hour, id)
isGranularityEnabled = true
granularity = 1f
labelCount = entries.size
}
}
}
I am using MPAndroidChart library
There isn't a nice built-in way to draw icons like that, but you can do it by making a custom extension of the LineChartRenderer and overriding drawExtras. Then you can get your icons from R.drawable.X and draw them on the canvas wherever you want. There is some work to figure out where to put them to line up with the data points, but you can copy the logic from drawCircles to find that.
Example Custom Renderer
inner class MyRenderer(private val context: Context,
private val iconY: Float,
private val iconSizeDp: Float,
chart: LineDataProvider,
animator: ChartAnimator,
viewPortHandler: ViewPortHandler)
: LineChartRenderer(chart, animator, viewPortHandler) {
private var buffer: FloatArray = listOf(0f,0f).toFloatArray()
override fun drawExtras(c: Canvas) {
super.drawExtras(c)
val iconSizePx = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
iconSizeDp,
resources.displayMetrics
)
// get the icons you want to draw
val cloudy = ContextCompat.getDrawable(context, R.drawable.cloudy)
val sunny = ContextCompat.getDrawable(context, R.drawable.sunny)
if( cloudy == null || sunny == null ) {
throw RuntimeException("Missing drawables")
}
// Determine icon width in pixels
val w = iconSizePx
val h = iconSizePx
val dataSets = mChart.lineData.dataSets
val phaseY = mAnimator.phaseY
for(dataSet in dataSets) {
mXBounds.set(mChart, dataSet)
val boundsRange = mXBounds.range + mXBounds.min
val transformer = mChart.getTransformer(dataSet.axisDependency)
for(j in mXBounds.min .. boundsRange) {
val e = dataSet.getEntryForIndex(j) ?: break
buffer[0] = e.x
buffer[1] = iconY * phaseY
transformer.pointValuesToPixel(buffer)
if( !mViewPortHandler.isInBoundsRight(buffer[0])) {
break
}
if( !mViewPortHandler.isInBoundsLeft(buffer[0]) ||
!mViewPortHandler.isInBoundsY(buffer[1])) {
continue
}
// Draw the icon centered under the data point, but at a fixed
// vertical position. Here the icon "sits on top" of the
// specified iconY value
val left = (buffer[0]-w/2).roundToInt()
val right = (buffer[0]+w/2).roundToInt()
val top = (buffer[1]-h).roundToInt()
val bottom = (buffer[1]).roundToInt()
// Alternately, use this to center the icon at the
// "iconY" value
//val top = (buffer[1]-h/2).roundToInt()
//val bottom = (buffer[1]+h/2).roundToInt()
// Use whatever logic you want to select which icon
// to use at each position
val icon = if( e.y > 68f ) {
sunny
}
else {
cloudy
}
icon.setBounds(left, top, right, bottom)
icon.draw(c)
}
}
}
}
Using the Custom Renderer
val iconY = 41f
val iconSizeDp = 40f
chart.renderer = MyRenderer(this, iconY, iconSizeDp,
chart, chart.animator, chart.viewPortHandler)
(other formatting)
val chart = findViewById<LineChart>(R.id.chart)
chart.axisRight.isEnabled = false
val yAx = chart.axisLeft
yAx.setDrawLabels(false)
yAx.setDrawGridLines(false)
yAx.setDrawAxisLine(false)
yAx.axisMinimum = 40f
yAx.axisMaximum = 80f
val xAx = chart.xAxis
xAx.setDrawLabels(false)
xAx.position = XAxis.XAxisPosition.BOTTOM
xAx.setDrawGridLines(false)
xAx.setDrawAxisLine(false)
xAx.axisMinimum = 0.5f
xAx.axisMaximum = 5.5f
xAx.granularity = 0.5f
val x = listOf(0,1,2,3,4,5,6)
val y = listOf(60,65,66,70,65,50,55)
val e = x.zip(y).map { Entry(it.first.toFloat(), it.second.toFloat())}
val line = LineDataSet(e, "temp")
line.setDrawValues(true)
line.setDrawCircles(false)
line.circleRadius = 20f // makes the text offset up
line.valueTextSize = 20f
line.color = Color.BLACK
line.lineWidth = 2f
line.setDrawFilled(true)
line.fillColor = Color.BLACK
line.fillAlpha = 50
line.mode = LineDataSet.Mode.CUBIC_BEZIER
line.valueFormatter = object : ValueFormatter() {
override fun getFormattedValue(value: Float): String {
return "%.0f F".format(value)
}
}
chart.data = LineData(line)
chart.description.isEnabled = false
chart.legend.isEnabled = false
Gives the desired effect

Sceneform: GLB model not casting shadows

I created a ViewRenderable to go underneath my GLB model, but it doesn't seem to result in any shadow being cast on the viewRenderable.
What am I doing wrong?
class ShadowSelectionVisualizer : SelectionVisualizer {
private val footprintNode: Node = Node()
fun setFootprintRenderable(viewRenderable: ViewRenderable) {
val copyRenderable = viewRenderable.makeCopy()
copyRenderable.verticalAlignment = ViewRenderable.VerticalAlignment.CENTER
val rotation1: Quaternion = Quaternion.axisAngle(Vector3(1.0f, 0.0f, 0.0f), 90f)
footprintNode.renderable = copyRenderable
footprintNode.localRotation = rotation1
}
override fun applySelectionVisual(node: BaseTransformableNode) {
if (node.collisionShape is Box) {
val box: Box = node.collisionShape as Box
val vector3: Vector3 = box.size
(footprintNode.renderable as ViewRenderable).sizer = ViewSizer {
val bound = if (vector3.x > vector3.z) vector3.x else vector3.z
Vector3(bound, bound, 0.0f)
}
footprintNode.setParent(node)
}
}
override fun removeSelectionVisual(node: BaseTransformableNode?) {
footprintNode.setParent(null)
}
}
myModelRenderable.isShadowCaster = true
val selectionVisualizer = ShadowSelectionVisualizer()
val transformationSystem = TransformationSystem(resources.displayMetrics, selectionVisualizer)
ViewRenderable.builder()
.setView(
context, R.layout.shadow_receiver
)
.setRegistryId("someId.glb")
.build()
.thenAccept { viewRenderable: ViewRenderable ->
viewRenderable.isShadowCaster = false
viewRenderable.isShadowReceiver = true
selectionVisualizer.setFootprintRenderable(viewRenderable)
}
viewRenderable.isShadowCaster = false
Set this to true. More information here: https://developers.google.com/sceneform/reference/com/google/ar/sceneform/rendering/Renderable#isShadowCaster()

How to set mpandoroidchart's color in kotlin?

I want to set my chart's data color
So, I found that MPAndroidchart, but example was made Java, not Kotlin.
This is my Kotlin source. How can I change colors?
In Addition, I want to make Label in Bar chart below the bar (Like first picture), And Piechart
Please help me.. T_T
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_result)
val tabHost = findViewById<TabHost>(R.id.TabHost)
tabHost.setup()
//종합 탭 소스
val tabSpecTotal = tabHost.newTabSpec("Total").setIndicator("종합")
tabSpecTotal.setContent(R.id.total)
//남녀 성비 그래프
sexRateChart.setUsePercentValues(true)
sexRateChart.description.setEnabled(false)
sexRateChart.setExtraOffsets(5f, 10f, 5f, 5f)
sexRateChart.dragDecelerationFrictionCoef = 0.95f
sexRateChart.isDrawHoleEnabled = false
sexRateChart.setHoleColor(Color.BLACK)
sexRateChart.transparentCircleRadius = 61f
val sexValues = ArrayList<PieEntry>() // 데이터 삽입
sexValues.add(PieEntry(63f,"남성"))
sexValues.add(PieEntry(37f,"여성"))
sexRateChart.animateY(2000, Easing.EaseInOutCubic) //애니메이션 효과 설정
val sexDataSet = PieDataSet(sexValues, "성별")
sexDataSet.sliceSpace = 3f
sexDataSet.selectionShift = 2f
val sexData = PieData((sexDataSet))
sexData.setValueTextSize(10f)
sexData.setValueTextColor(Color.BLACK)
sexRateChart.setData(sexData)
sexRateChart.invalidate()
//남녀 성비 끝
//연령대 막대그래프
ageRateChart.setExtraOffsets(5f, 10f, 5f, 5f)
val ageValues = ArrayList<BarEntry>()
ageValues.add(BarEntry(0f, 10f, "10대"))
ageValues.add(BarEntry(1f, 30f, "20대"))
ageValues.add(BarEntry(2f, 50f, "30대"))
ageValues.add(BarEntry(3f, 30f, "40대"))
ageValues.add(BarEntry(4f, 40f, "50대"))
ageValues.add(BarEntry(5f, 5f, "60대 이상"))
ageRateChart.animateY(4000, Easing.EaseInOutCubic)
val ageDataSet = BarDataSet(ageValues, "연령대")
ageDataSet.setColors(intArrayOf(R.color.red1, R.color.red2, R.color.red3, R.color.red4), Context)
val ageData = BarData(ageDataSet)
ageData.barWidth = 1f
ageRateChart.data = ageData
ageRateChart.setFitBars(true)
ageRateChart.invalidate()
//연령대 막대그래프 끝
Result of code :
You can set colors with fills
val startColor1 = ContextCompat.getColor(this, android.R.color.holo_orange_light)
val startColor2 = ContextCompat.getColor(this, android.R.color.holo_blue_light)
val startColor3 = ContextCompat.getColor(this, android.R.color.holo_orange_light)
val startColor4 = ContextCompat.getColor(this, android.R.color.holo_green_light)
val startColor5 = ContextCompat.getColor(this, android.R.color.holo_red_light)
val gradientFills: MutableList<Fill> = ArrayList()
with(gradientFills) {
add(Fill(startColor1))
add(Fill(startColor2))
add(Fill(startColor3))
add(Fill(startColor4))
add(Fill(startColor5))
}
val ageDataSet = BarDataSet(ageValues, "연령대")
ageDataSet.fills = gradientFills
And Label with ValueFormatter
ageRateChart.xAxis.apply {
position = XAxisPosition.BOTTOM
setDrawGridLines(false)
granularity = 1f
valueFormatter = object : ValueFormatter() {
override fun getAxisLabel(value: Float, axis: AxisBase?): String {
return (value * 10 + 10).toString() + "대"
}
}
}

MPAndroidChart LineChart labels on axis disappear when fragment is resumed

I have a problem updating the data in a chart. When I change the settings and come back to this fragment or when I go out of the app and come back, the chart apparently changes its size and hide the labels in its axis. However, if I navigate through the app and come back, the chart is displaying well.
Screenshot of correct display
Screenshot of axis labels disappearing
My context is the following:
I have a fragment where I observe the viewmodel in onViewCreated. When the data is successfully retrieved, I update the chart. I have tried also to make a flag to make sure that the call to set up the chart is only called once, but that doesn't work either. So the problem is not related to how many times this call is made.
viewModel.forecast.observe(viewLifecycleOwner, Observer { resource ->
if (resource != null && resource.status.isSuccessful()){
ChartUtilities.setUpChart(
viewModel.forecastOfNextHours().subList(0, 9),
binding.lineChart,
"Temperature of the next 24 hours",
isMetric
)
}
In ChartUtilities.kt:
object ChartUtilities {
fun setUpChart(list: List<ForecastListItem>, lineChart: LineChart, label: String, isMetric: Boolean){
//lineChart.clear()
val (values, yValues, xAxisValues) = fillData(list, isMetric)
val data = configureDataSet(values, label)
customSettings(lineChart, data, xAxisValues, yValues)
//lineChart.notifyDataSetChanged()
}
private fun configureDataSet(
values: ArrayList<Entry>,
label: String
): LineData {
val set1 = LineDataSet(values, label)
set1.axisDependency = YAxis.AxisDependency.LEFT
set1.color = ColorTemplate.getHoloBlue()
set1.valueTextColor = ColorTemplate.getHoloBlue()
set1.lineWidth = 4.0f
set1.setDrawCircles(false)
set1.setDrawValues(false)
set1.fillAlpha = 65
set1.fillColor = Color.RED
set1.highLightColor = Color.rgb(244, 117, 117)
set1.setDrawCircleHole(false)
set1.mode = LineDataSet.Mode.HORIZONTAL_BEZIER
// create a data object with the data sets
val data = LineData(set1)
data.setValueTextColor(Color.WHITE)
data.setValueTextSize(9f)
return data
}
private fun fillData(list: List<ForecastListItem>, isMetric: Boolean): Triple<ArrayList<Entry>, ArrayList<Double>, ArrayList<String>> {
val values = ArrayList<Entry>()
val yValues = ArrayList<Double>()
val xAxisValues = arrayListOf<String>()
list.forEachIndexed { index, forecastItem ->
xAxisValues.add(forecastItem.getHourOfDay())
var temperature = forecastItem.getTemperature()!!
if (!isMetric)
temperature = WeatherUtils.celsiusToFahrenheit(temperature)
yValues.add(temperature)
values.add(Entry(index.toFloat(), temperature.toFloat()))
}
return Triple(values, yValues, xAxisValues)
}
private fun customSettings(chart: LineChart, data: LineData, xAxisValues: ArrayList<String>, yAxisValues: ArrayList<Double>){
chart.data = data
customChart(chart)
customLegend(chart)
customXAxis(chart, xAxisValues)
customYAxis(chart, yAxisValues)
val rightAxis = chart.axisRight
rightAxis.isEnabled = false
}
private fun customChart(chart: LineChart) {
chart.description.isEnabled = false
chart.setTouchEnabled(false)
//chart.dragDecelerationFrictionCoef = 0.9f
// enable scaling and dragging
chart.isDragEnabled = false
chart.setScaleEnabled(false)
chart.setDrawGridBackground(false)
chart.isHighlightPerDragEnabled = true
// set an alternative background color
chart.setBackgroundResource(R.color.colorPrimaryDark)
chart.setViewPortOffsets(0f, 0f, 0f, 0f)
}
private fun customLegend(chart: LineChart) {
val l = chart.legend
l.isEnabled = true
l.verticalAlignment = Legend.LegendVerticalAlignment.TOP
l.textColor = Color.WHITE
}
private fun customXAxis(
chart: LineChart,
xAxisValues: ArrayList<String>
) {
val xAxis = chart.xAxis
xAxis.position = XAxis.XAxisPosition.BOTTOM
xAxis.textSize = 12f
xAxis.setDrawAxisLine(true)
xAxis.setDrawGridLines(false)
xAxis.textColor = Color.WHITE
//xAxis.setCenterAxisLabels(true)
xAxis.setAvoidFirstLastClipping(false)
xAxis.granularity = 2f // three hours
xAxis.axisMaximum = xAxisValues.size.toFloat()
xAxis.labelCount = xAxisValues.size
xAxis.valueFormatter = IndexAxisValueFormatter(xAxisValues)
xAxis.isEnabled = true
}
private fun customYAxis(
chart: LineChart,
yAxisValues: ArrayList<Double>
) {
val leftAxis = chart.axisLeft
leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART)
leftAxis.textColor = Color.WHITE
leftAxis.setDrawGridLines(true)
leftAxis.isGranularityEnabled = true
leftAxis.axisMinimum = yAxisValues.min()?.minus(10)?.toFloat()!!
leftAxis.axisMaximum = yAxisValues.max()?.plus(10)?.toFloat()!!
leftAxis.yOffset = -9f
leftAxis.isEnabled = true
}
}
I realise this is a very late answer, but I had exactly the same issue and stumbled upon your question. I'd intermittently see the axes disappear when scrolling between different charts (I had them in a RecyclerView).
I solved it by deleting the following line, which I see you also have in your code:
chart.setViewPortOffsets(0, 0, 0, 0);
The javadoc for that method says that we should avoid manually setting it unless we know what we're doing (which I don't!).
I also found that increasing the values to the following worked for me:
chart.setViewPortOffsets(60, 0, 50, 60);

How to create line graph dynamically like this image

Line Graph
I have 5 dynamic data which is giving +1 or -1 as result, if the result is +1 then graph direction is towards up and if the result is -1 then graph direction is towards downward.
Image in your question is not available to view but i can put a sample for how to draw a line chart in your android app easily.
First -as mentioned in comment- you can use MPAndroidChart. You can add it to your project like following:
implementation "com.github.PhilJay:MPAndroidChart:v3.0.3"
Here's a sample default line chart implementation which i use in my personal projects.
open class DefaultLineChart #JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0)
: LineChart(context, attrs, defStyle) {
init {
setupChart()
}
private fun setupChart() {
// Init Description
val description = Description().apply {
isEnabled = false
}
setDescription(description)
// Init GridBackground
setGridBackgroundColor(android.R.color.white)
setDrawGridBackground(true)
// Init Borders
setDrawBorders(true)
setBorderColor(android.R.color.black)
setBorderWidth(1f)
// Init Other Properties
setPinchZoom(false)
isDoubleTapToZoomEnabled = false
isDragEnabled = true
setNoDataText(context.getString(R.string.info_text_no_content))
setScaleEnabled(true)
// Init Legend
val legend = legend.apply {
isEnabled = false
}
// Init xAxis
val xAxis = xAxis.apply {
isEnabled = true
setCenterAxisLabels(false)
gridColor = android.R.color.white
setAvoidFirstLastClipping(false)
setDrawLimitLinesBehindData(true)
position = XAxis.XAxisPosition.BOTTOM
}
// Init leftAxis
val leftAxis = axisLeft.apply {
axisMinimum = 0f
setDrawAxisLine(false)
setDrawZeroLine(true)
setDrawGridLines(true)
gridColor = android.R.color.black
axisLineColor = android.R.color.black
}
val rightAxis = axisRight.apply {
isEnabled = false
}
}
fun setChartTitle(title: String) {
val description = Description().apply {
text = title
isEnabled = true
}
setDescription(description)
}
}
You can add it to your xml layout like below:
<path_to_your_class.DefaultLineChart
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_marginTop="16dp"/>
Finally you can draw your chart like following code:
fun bindDefaultLineChart(chartView: LineChart,
marketValues: List<MarketVal>?,
label: String?) {
if (marketValues == null) {
return
}
val yValues = ArrayList<Entry>()
var maxCount: Long = 0
for (marketValue in marketValues) {
val entry = Entry(marketValue.dateTime.toFloat(),
marketValue.transactionNumber.toFloat())
yValues.add(entry)
if (marketValue.transactionNumber > maxCount) {
maxCount = marketValue.transactionNumber.toLong()
}
}
val xAxis = chartView.xAxis
val xAxisFormatter = ChartValueDateFormatter(Constants.DEFAULT_DATE_FORMAT)
xAxis.valueFormatter = xAxisFormatter
chartView.axisLeft.apply {
axisMaximum = (maxCount + MAX_CHAR_Y_AXIS_ADDITION).toFloat()
valueFormatter = NonFloatValueFormatter()
}
val dataSet = LineDataSet(yValues, label).apply {
axisDependency = YAxis.AxisDependency.LEFT
color = ContextCompat.getColor(chartView.context, R.color.colorAccent)
formLineWidth = 2f
setDrawIcons(true)
setDrawValues(false)
}
val lineData = LineData(dataSet)
chartView.data = lineData
}
}
You can find example implementation from here.

Categories

Resources