Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package info.appdev.charting.buffer
import info.appdev.charting.interfaces.datasets.IBarDataSet
import kotlin.math.abs

open class BarBuffer(size: Int, dataSetCount: Int, containsStacks: Boolean) : AbstractBuffer<IBarDataSet?>(size) {
open class BarBuffer(size: Int, dataSetCount: Int, containsStacks: Boolean) : AbstractBuffer<IBarDataSet>(size) {
protected var dataSetIndex: Int = 0
protected var dataSetCount: Int = 1

Expand Down Expand Up @@ -42,13 +42,13 @@ open class BarBuffer(size: Int, dataSetCount: Int, containsStacks: Boolean) : Ab
'}'
}

override fun feed(data: IBarDataSet?) {
val size = (data?.entryCount ?: 0) * phaseX
override fun feed(data: IBarDataSet) {
val size = data.entryCount * phaseX
val barWidthHalf = barWidth / 2f

var i = 0
while (i < size) {
val e = data?.getEntryForIndex(i)
val e = data.getEntryForIndex(i)

if (e == null) {
i++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import info.appdev.charting.interfaces.datasets.IBarDataSet
import kotlin.math.abs

class HorizontalBarBuffer(size: Int, dataSetCount: Int, containsStacks: Boolean) : BarBuffer(size, dataSetCount, containsStacks) {
override fun feed(data: IBarDataSet?) {
val size = (data?.entryCount ?: 0) * phaseX
override fun feed(data: IBarDataSet) {
val size = data.entryCount * phaseX
val barWidthHalf = barWidth / 2f

var i = 0
while (i < size) {
val e = data?.getEntryForIndex(i)
val e = data.getEntryForIndex(i)

if (e == null) {
i++
Expand Down
6 changes: 3 additions & 3 deletions chartLib/src/main/kotlin/info/appdev/charting/charts/Chart.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import kotlin.math.abs
import kotlin.math.max

@Suppress("unused")
abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBaseProvider {
abstract class Chart<T : ChartData<out IDataSet<out Entry>>> : ViewGroup, IBaseProvider {
/**
* Returns true if log-output is enabled for the chart, fals if not.
*/
Expand Down Expand Up @@ -1167,7 +1167,7 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
/**
* tasks to be done after the view is setup
*/
var jobs: ArrayList<Runnable?> = ArrayList()
var jobs: ArrayList<Runnable> = ArrayList()
protected set

fun removeViewportJob(job: Runnable?) {
Expand All @@ -1182,7 +1182,7 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
* Either posts a job immediately if the chart has already setup it's
* dimensions or adds the job to the execution queue.
*/
fun addViewportJob(job: Runnable?) {
fun addViewportJob(job: Runnable) {
if (viewPortHandler.hasChartDimens()) {
post(job)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ class Legend() : ComponentBase() {
*/
var isWordWrapEnabled: Boolean = false

val calculatedLabelSizes: MutableList<FSize?> = ArrayList<FSize?>(16)
val calculatedLabelBreakPoints: MutableList<Boolean?> = ArrayList<Boolean?>(16)
val calculatedLineSizes: MutableList<FSize?> = ArrayList<FSize?>(16)
val calculatedLabelSizes: MutableList<FSize> = ArrayList(16)
val calculatedLabelBreakPoints: MutableList<Boolean> = ArrayList(16)
val calculatedLineSizes: MutableList<FSize> = ArrayList(16)

init {
this.mTextSize = 10f.convertDpToPixel()
Expand Down Expand Up @@ -454,7 +454,7 @@ class Legend() : ComponentBase() {
if (label != null) {
calculatedLabelSizes.add(labelpaint.calcTextSize(label))
requiredWidth += if (drawingForm) formToTextSpace + formSize else 0f
requiredWidth += calculatedLabelSizes.get(i)!!.width
requiredWidth += calculatedLabelSizes.get(i).width
} else {
calculatedLabelSizes.add(FSize.getInstance(0f, 0f))
requiredWidth += if (drawingForm) formSize else 0f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ open class Entry : BaseEntry, Parcelable, Serializable {

companion object {
@JvmField
val CREATOR: Parcelable.Creator<Entry?> = object : Parcelable.Creator<Entry?> {
val CREATOR: Parcelable.Creator<Entry> = object : Parcelable.Creator<Entry> {
override fun createFromParcel(source: Parcel): Entry {
return Entry(source)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package info.appdev.charting.data

import info.appdev.charting.highlight.Highlight
import info.appdev.charting.interfaces.datasets.IRadarDataSet
import java.util.Arrays

/**
* Data container for the RadarChart.
Expand All @@ -13,7 +12,7 @@ class RadarData : ChartData<IRadarDataSet> {
*
* @param labels
*/
var labels: MutableList<String?>? = null
var labels: MutableList<String>? = null

constructor() : super()

Expand All @@ -23,11 +22,9 @@ class RadarData : ChartData<IRadarDataSet> {

/**
* Sets the labels that should be drawn around the RadarChart at the end of each web line.
*
* @param labels
*/
fun setLabels(vararg labels: String?) {
this.labels = Arrays.asList<String?>(*labels)
fun setLabels(vararg labels: String) {
this.labels = mutableListOf(*labels)
}

override fun getEntryForHighlight(highlight: Highlight): Entry? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,13 @@ open class LegendRenderer(
else
entry.formSize.convertDpToPixel()

if (i < calculatedLabelBreakPoints.size && calculatedLabelBreakPoints[i] == true) {
if (i < calculatedLabelBreakPoints.size && calculatedLabelBreakPoints[i]) {
posX = originPosX
posY += labelLineHeight + labelLineSpacing
}

if (posX == originPosX && horizontalAlignment == LegendHorizontalAlignment.CENTER && lineIndex < calculatedLineSizes.size) {
calculatedLineSizes[lineIndex]?.let { fSize ->
calculatedLineSizes[lineIndex].let { fSize ->
posX += (if (direction == LegendDirection.RIGHT_TO_LEFT)
fSize.width
else
Expand All @@ -326,12 +326,12 @@ open class LegendRenderer(
if (drawingForm) posX += if (direction == LegendDirection.RIGHT_TO_LEFT) -formToTextSpace else formToTextSpace

if (direction == LegendDirection.RIGHT_TO_LEFT)
posX -= calculatedLabelSizes[i]?.width ?: 0f
posX -= calculatedLabelSizes[i].width

drawLabel(canvas, posX, posY + labelLineHeight, entry.label)

if (direction == LegendDirection.LEFT_TO_RIGHT)
posX += calculatedLabelSizes[i]?.width ?: 0f
posX += calculatedLabelSizes[i].width

posX += if (direction == LegendDirection.RIGHT_TO_LEFT) -xEntrySpace else xEntrySpace
} else posX += if (direction == LegendDirection.RIGHT_TO_LEFT) -stackSpace else stackSpace
Expand Down
Loading