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 @@ -29,7 +29,7 @@ open class BarChartRenderer(
protected var barRect: RectF = RectF()

@JvmField
protected var barBuffers: Array<BarBuffer?>? = null
protected var barBuffers: MutableList<BarBuffer?> = mutableListOf()

@JvmField
protected var shadowPaint: Paint
Expand Down Expand Up @@ -57,19 +57,20 @@ open class BarChartRenderer(

override fun initBuffers() {
val barData = chart.barData
barBuffers = arrayOfNulls(barData.dataSetCount)

for (i in barBuffers!!.indices) {
val set = barData.getDataSetByIndex(i)
barBuffers!![i] = BarBuffer(
set.entryCount * 4 * (if (set.isStacked) set.stackSize else 1),
barData.dataSetCount, set.isStacked
barBuffers = mutableListOf()

barData.dataSets.forEach {
barBuffers.add(
BarBuffer(
it.entryCount * 4 * (if (it.isStacked) it.stackSize else 1),
barData.dataSetCount, it.isStacked
)
)
}
}

override fun drawData(c: Canvas) {
if (barBuffers == null) {
if (barBuffers.size == 0) {
initBuffers()
}

Expand Down Expand Up @@ -155,7 +156,7 @@ open class BarChartRenderer(
}

// initialize the buffer
val buffer = barBuffers!![index]!!.apply {
val buffer = barBuffers[index]!!.apply {
setPhases(phaseX, phaseY)
setDataSet(index)
setInverted(chart.isInverted(dataSet.axisDependency))
Expand Down Expand Up @@ -286,7 +287,7 @@ open class BarChartRenderer(
}

// get the buffer
val buffer = barBuffers!![i]
val buffer = barBuffers[i]

val phaseY = animator.phaseY

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ open class HorizontalBarChartRenderer(
) : BarChartRenderer(chart, animator, viewPortHandler) {
override fun initBuffers() {
val barData = chart.barData
barBuffers = arrayOfNulls(barData.dataSetCount)
barBuffers = arrayOfNulls<HorizontalBarBuffer>(barData.dataSetCount).toMutableList()

for (i in barBuffers!!.indices) {
for (i in barBuffers.indices) {
val set = barData.getDataSetByIndex(i)
barBuffers!![i] = HorizontalBarBuffer(
barBuffers[i] = HorizontalBarBuffer(
set.entryCount * 4 * (if (set.isStacked) set.stackSize else 1),
barData.dataSetCount, set.isStacked
)
Expand Down Expand Up @@ -97,7 +97,7 @@ open class HorizontalBarChartRenderer(
}

// initialize the buffer
val buffer = barBuffers!![index]!!
val buffer = barBuffers[index]!!
buffer.setPhases(phaseX, phaseY)
buffer.setDataSet(index)
buffer.setInverted(chart.isInverted(dataSet.axisDependency))
Expand Down Expand Up @@ -191,7 +191,7 @@ open class HorizontalBarChartRenderer(
val formatter = dataSet.valueFormatter

// get the buffer
val buffer = barBuffers!![i]!!
val buffer = barBuffers[i]!!

val phaseY = animator.phaseY

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected void drawDataSet(Canvas c, IBarDataSet dataSet, int index) {
}
}

BarBuffer buffer = barBuffers[index];
BarBuffer buffer = barBuffers.get(index);
buffer.setPhases(phaseX, phaseY);
buffer.setDataSet(index);
buffer.setInverted(chart.isInverted(dataSet.getAxisDependency()));
Expand Down
Loading