Skip to content

Commit 234c866

Browse files
committed
Format
1 parent 81efb42 commit 234c866

File tree

1 file changed

+79
-79
lines changed

1 file changed

+79
-79
lines changed

MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LineChartRenderer.kt

Lines changed: 79 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -274,113 +274,113 @@ open class LineChartRenderer(
274274
}
275275

276276
// more than 1 color
277-
if (dataSet.color > 1) {
278-
val numberOfFloats = pointsPerEntryPair * 2
277+
if (dataSet.color > 1) {
278+
val numberOfFloats = pointsPerEntryPair * 2
279279

280-
if (lineBuffer.size <= numberOfFloats)
281-
lineBuffer = FloatArray(numberOfFloats * 2)
280+
if (lineBuffer.size <= numberOfFloats)
281+
lineBuffer = FloatArray(numberOfFloats * 2)
282282

283-
val max = xBounds.min + xBounds.range
283+
val max = xBounds.min + xBounds.range
284284

285-
for (j in xBounds.min..<max) {
286-
var entry: Entry = dataSet.getEntryForIndex(j) ?: continue
285+
for (j in xBounds.min..<max) {
286+
var entry: Entry = dataSet.getEntryForIndex(j) ?: continue
287287

288-
lineBuffer[0] = entry.x
289-
lineBuffer[1] = entry.y * phaseY
288+
lineBuffer[0] = entry.x
289+
lineBuffer[1] = entry.y * phaseY
290290

291-
if (j < xBounds.max) {
292-
entry = dataSet.getEntryForIndex(j + 1)!!
291+
if (j < xBounds.max) {
292+
entry = dataSet.getEntryForIndex(j + 1)!!
293293

294-
if (dataSet.isDrawSteppedEnabled) {
295-
lineBuffer[2] = entry.x
296-
lineBuffer[3] = lineBuffer[1]
297-
lineBuffer[4] = lineBuffer[2]
298-
lineBuffer[5] = lineBuffer[3]
299-
lineBuffer[6] = entry.x
300-
lineBuffer[7] = entry.y * phaseY
301-
} else {
302-
lineBuffer[2] = entry.x
303-
lineBuffer[3] = entry.y * phaseY
304-
}
305-
} else {
306-
lineBuffer[2] = lineBuffer[0]
294+
if (dataSet.isDrawSteppedEnabled) {
295+
lineBuffer[2] = entry.x
307296
lineBuffer[3] = lineBuffer[1]
297+
lineBuffer[4] = lineBuffer[2]
298+
lineBuffer[5] = lineBuffer[3]
299+
lineBuffer[6] = entry.x
300+
lineBuffer[7] = entry.y * phaseY
301+
} else {
302+
lineBuffer[2] = entry.x
303+
lineBuffer[3] = entry.y * phaseY
308304
}
305+
} else {
306+
lineBuffer[2] = lineBuffer[0]
307+
lineBuffer[3] = lineBuffer[1]
308+
}
309309

310-
// Determine the start and end coordinates of the line, and make sure they differ.
311-
val firstCoordinateX = lineBuffer[0]
312-
val firstCoordinateY = lineBuffer[1]
313-
val lastCoordinateX = lineBuffer[numberOfFloats - 2]
314-
val lastCoordinateY = lineBuffer[numberOfFloats - 1]
310+
// Determine the start and end coordinates of the line, and make sure they differ.
311+
val firstCoordinateX = lineBuffer[0]
312+
val firstCoordinateY = lineBuffer[1]
313+
val lastCoordinateX = lineBuffer[numberOfFloats - 2]
314+
val lastCoordinateY = lineBuffer[numberOfFloats - 1]
315315

316-
if (firstCoordinateX == lastCoordinateX &&
317-
firstCoordinateY == lastCoordinateY
318-
) continue
316+
if (firstCoordinateX == lastCoordinateX &&
317+
firstCoordinateY == lastCoordinateY
318+
) continue
319319

320-
trans!!.pointValuesToPixel(lineBuffer)
320+
trans!!.pointValuesToPixel(lineBuffer)
321321

322-
if (!viewPortHandler.isInBoundsRight(firstCoordinateX)) break
323-
324-
// make sure the lines don't do shitty things outside
325-
// bounds
326-
if (!viewPortHandler.isInBoundsLeft(lastCoordinateX) || !viewPortHandler.isInBoundsTop(
327-
max(
328-
firstCoordinateY.toDouble(),
329-
lastCoordinateY.toDouble()
330-
).toFloat()
331-
) || !viewPortHandler.isInBoundsBottom(
332-
min(firstCoordinateY.toDouble(), lastCoordinateY.toDouble()).toFloat()
333-
)
334-
) continue
322+
if (!viewPortHandler.isInBoundsRight(firstCoordinateX)) break
335323

336-
// get the color that is set for this line-segment
337-
paintRender.color = dataSet.getColorByIndex(j)
324+
// make sure the lines don't do shitty things outside
325+
// bounds
326+
if (!viewPortHandler.isInBoundsLeft(lastCoordinateX) || !viewPortHandler.isInBoundsTop(
327+
max(
328+
firstCoordinateY.toDouble(),
329+
lastCoordinateY.toDouble()
330+
).toFloat()
331+
) || !viewPortHandler.isInBoundsBottom(
332+
min(firstCoordinateY.toDouble(), lastCoordinateY.toDouble()).toFloat()
333+
)
334+
) continue
338335

339-
canvas!!.drawLines(lineBuffer, 0, pointsPerEntryPair * 2, paintRender)
340-
}
341-
} else { // only one color per dataset
336+
// get the color that is set for this line-segment
337+
paintRender.color = dataSet.getColorByIndex(j)
342338

343-
if (lineBuffer.size < max(((entryCount) * pointsPerEntryPair).toDouble(), pointsPerEntryPair.toDouble()) * 2) lineBuffer = FloatArray(
344-
(max(((entryCount) * pointsPerEntryPair).toDouble(), pointsPerEntryPair.toDouble()) * 4).toInt()
345-
)
339+
canvas!!.drawLines(lineBuffer, 0, pointsPerEntryPair * 2, paintRender)
340+
}
341+
} else { // only one color per dataset
346342

347-
var e1: Entry?
348-
var e2: Entry?
343+
if (lineBuffer.size < max(((entryCount) * pointsPerEntryPair).toDouble(), pointsPerEntryPair.toDouble()) * 2) lineBuffer = FloatArray(
344+
(max(((entryCount) * pointsPerEntryPair).toDouble(), pointsPerEntryPair.toDouble()) * 4).toInt()
345+
)
349346

350-
e1 = dataSet.getEntryForIndex(xBounds.min)
347+
var e1: Entry?
348+
var e2: Entry?
351349

352-
if (e1 != null) {
353-
var j = 0
354-
for (x in xBounds.min..xBounds.range + xBounds.min) {
355-
e1 = dataSet.getEntryForIndex(if (x == 0) 0 else (x - 1))
356-
e2 = dataSet.getEntryForIndex(x)
350+
e1 = dataSet.getEntryForIndex(xBounds.min)
357351

358-
if (e1 == null || e2 == null) continue
352+
if (e1 != null) {
353+
var j = 0
354+
for (x in xBounds.min..xBounds.range + xBounds.min) {
355+
e1 = dataSet.getEntryForIndex(if (x == 0) 0 else (x - 1))
356+
e2 = dataSet.getEntryForIndex(x)
359357

360-
lineBuffer[j++] = e1.x
361-
lineBuffer[j++] = e1.y * phaseY
358+
if (e1 == null || e2 == null) continue
362359

363-
if (dataSet.isDrawSteppedEnabled) {
364-
lineBuffer[j++] = e2.x
365-
lineBuffer[j++] = e1.y * phaseY
366-
lineBuffer[j++] = e2.x
367-
lineBuffer[j++] = e1.y * phaseY
368-
}
360+
lineBuffer[j++] = e1.x
361+
lineBuffer[j++] = e1.y * phaseY
369362

363+
if (dataSet.isDrawSteppedEnabled) {
364+
lineBuffer[j++] = e2.x
365+
lineBuffer[j++] = e1.y * phaseY
370366
lineBuffer[j++] = e2.x
371-
lineBuffer[j++] = e2.y * phaseY
367+
lineBuffer[j++] = e1.y * phaseY
372368
}
373369

374-
if (j > 0) {
375-
trans!!.pointValuesToPixel(lineBuffer)
370+
lineBuffer[j++] = e2.x
371+
lineBuffer[j++] = e2.y * phaseY
372+
}
373+
374+
if (j > 0) {
375+
trans!!.pointValuesToPixel(lineBuffer)
376376

377-
val size = (max(((xBounds.range + 1) * pointsPerEntryPair).toDouble(), pointsPerEntryPair.toDouble()) * 2).toInt()
377+
val size = (max(((xBounds.range + 1) * pointsPerEntryPair).toDouble(), pointsPerEntryPair.toDouble()) * 2).toInt()
378378

379-
paintRender.color = dataSet.color
379+
paintRender.color = dataSet.color
380380

381-
canvas!!.drawLines(lineBuffer, 0, size, paintRender)
382-
}
381+
canvas!!.drawLines(lineBuffer, 0, size, paintRender)
383382
}
383+
}
384384
}
385385

386386
paintRender.pathEffect = null
@@ -542,7 +542,7 @@ open class LineChartRenderer(
542542
)
543543
}
544544

545-
if (entry.icon != null && dataSet.isDrawIcons) {
545+
if (entry.icon != null && dataSet.isDrawValues) {
546546
val icon = entry.icon
547547

548548
icon?.let {

0 commit comments

Comments
 (0)