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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.github.mikephil.charting.interfaces.dataprovider

import com.github.mikephil.charting.data.BubbleData

interface BubbleDataProvider : BarLineScatterCandleBubbleDataProvider {
val bubbleData: BubbleData?
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.github.mikephil.charting.interfaces.dataprovider

import com.github.mikephil.charting.data.CandleData

interface CandleDataProvider : BarLineScatterCandleBubbleDataProvider {
val candleData: CandleData?
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.github.mikephil.charting.interfaces.dataprovider

import com.github.mikephil.charting.data.CombinedData

interface CombinedDataProvider : LineDataProvider, BarDataProvider, BubbleDataProvider, CandleDataProvider, ScatterDataProvider {
val combinedData: CombinedData?
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.github.mikephil.charting.interfaces.dataprovider

import com.github.mikephil.charting.data.ScatterData

interface ScatterDataProvider : BarLineScatterCandleBubbleDataProvider {
val scatterData: ScatterData?
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ open class BubbleChartRenderer(
override fun drawData(canvas: Canvas) {
val bubbleData = dataProvider.bubbleData

for (set in bubbleData.dataSets) {
if (set.isVisible) drawDataSet(canvas, set)
bubbleData?.dataSets?.forEach { set ->
if (set.isVisible)
drawDataSet(canvas, set)
}
}

Expand Down Expand Up @@ -194,15 +195,18 @@ open class BubbleChartRenderer(
val phaseY = animator.phaseY

for (high in indices) {
val set = bubbleData.getDataSetByIndex(high.dataSetIndex)
val set = bubbleData?.getDataSetByIndex(high.dataSetIndex)

if (set == null || !set.isHighlightEnabled) continue
if (set == null || !set.isHighlightEnabled)
continue

val bubbleEntry = set.getEntryForXValue(high.x, high.y)!!

if (bubbleEntry.y != high.y) continue
if (bubbleEntry.y != high.y)
continue

if (!isInBoundsX(bubbleEntry, set)) continue
if (!isInBoundsX(bubbleEntry, set))
continue

val trans = dataProvider.getTransformer(set.axisDependency)

Expand All @@ -215,9 +219,7 @@ open class BubbleChartRenderer(

// calculate the full width of 1 step on the x-axis
val maxBubbleWidth = abs((sizeBuffer[2] - sizeBuffer[0]).toDouble()).toFloat()
val maxBubbleHeight = abs(
(viewPortHandler.contentBottom() - viewPortHandler.contentTop()).toDouble()
).toFloat()
val maxBubbleHeight = abs((viewPortHandler.contentBottom() - viewPortHandler.contentTop()).toDouble()).toFloat()
val referenceSize = min(maxBubbleHeight.toDouble(), maxBubbleWidth.toDouble()).toFloat()

pointBuffer[0] = bubbleEntry.x
Expand All @@ -237,9 +239,11 @@ open class BubbleChartRenderer(
|| !viewPortHandler.isInBoundsBottom(pointBuffer[1] - shapeHalf)
) continue

if (!viewPortHandler.isInBoundsLeft(pointBuffer[0] + shapeHalf)) continue
if (!viewPortHandler.isInBoundsLeft(pointBuffer[0] + shapeHalf))
continue

if (!viewPortHandler.isInBoundsRight(pointBuffer[0] - shapeHalf)) break
if (!viewPortHandler.isInBoundsRight(pointBuffer[0] - shapeHalf))
break

val originalColor = set.getColorByIndex(bubbleEntry.x.toInt())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ open class CandleStickChartRenderer(
override fun drawData(canvas: Canvas) {
val candleData = dataProvider.candleData

for (set in candleData.dataSets) {
if (set.isVisible) drawDataSet(canvas, set)
candleData?.dataSets?.forEach { set ->
if (set.isVisible)
drawDataSet(canvas, set)
}
}

Expand Down Expand Up @@ -208,77 +209,78 @@ open class CandleStickChartRenderer(
override fun drawValues(canvas: Canvas) {
// if values are drawn
if (isDrawingValuesAllowed(dataProvider)) {
val dataSets = dataProvider.candleData.dataSets
dataProvider.candleData?.let {

for (i in dataSets.indices) {
val dataSet = dataSets[i]
if (dataSet.entryCount == 0) {
continue
}
if (!shouldDrawValues(dataSet) || dataSet.entryCount < 1) {
continue
}
for (i in it.dataSets.indices) {
val dataSet = it.dataSets[i]
if (dataSet.entryCount == 0) {
continue
}
if (!shouldDrawValues(dataSet) || dataSet.entryCount < 1) {
continue
}

// apply the text-styling defined by the DataSet
applyValueTextStyle(dataSet)
// apply the text-styling defined by the DataSet
applyValueTextStyle(dataSet)

val trans = dataProvider.getTransformer(dataSet.axisDependency)
val trans = dataProvider.getTransformer(dataSet.axisDependency)

xBounds.set(dataProvider, dataSet)
xBounds.set(dataProvider, dataSet)

val positions = trans!!.generateTransformedValuesCandle(
dataSet, animator.phaseX, animator.phaseY, xBounds.min, xBounds.max
)
val positions = trans!!.generateTransformedValuesCandle(
dataSet, animator.phaseX, animator.phaseY, xBounds.min, xBounds.max
)

val yOffset = 5f.convertDpToPixel()
val yOffset = 5f.convertDpToPixel()

val iconsOffset = MPPointF.getInstance(dataSet.iconsOffset)
iconsOffset.x = iconsOffset.x.convertDpToPixel()
iconsOffset.y = iconsOffset.y.convertDpToPixel()
val iconsOffset = MPPointF.getInstance(dataSet.iconsOffset)
iconsOffset.x = iconsOffset.x.convertDpToPixel()
iconsOffset.y = iconsOffset.y.convertDpToPixel()

var j = 0
while (j < positions.size) {
val x = positions[j]
val y = positions[j + 1]
var j = 0
while (j < positions.size) {
val x = positions[j]
val y = positions[j + 1]

if (!viewPortHandler.isInBoundsRight(x)) break
if (!viewPortHandler.isInBoundsRight(x)) break

if (!viewPortHandler.isInBoundsLeft(x) || !viewPortHandler.isInBoundsY(y)) {
j += 2
continue
}

val entry = dataSet.getEntryForIndex(j / 2 + xBounds.min)!!

if (dataSet.isDrawValues) {
drawValue(
canvas,
dataSet.valueFormatter,
entry.high,
entry,
i,
x,
y - yOffset,
dataSet.getValueTextColor(j / 2)
)
}
if (!viewPortHandler.isInBoundsLeft(x) || !viewPortHandler.isInBoundsY(y)) {
j += 2
continue
}

if (entry.icon != null && dataSet.isDrawIcons) {
val icon = entry.icon
val entry = dataSet.getEntryForIndex(j / 2 + xBounds.min)!!

icon?.let {
Utils.drawImage(
if (dataSet.isDrawValues) {
drawValue(
canvas,
it,
(x + iconsOffset.x).toInt(),
(y + iconsOffset.y).toInt()
dataSet.valueFormatter,
entry.high,
entry,
i,
x,
y - yOffset,
dataSet.getValueTextColor(j / 2)
)
}

if (entry.icon != null && dataSet.isDrawIcons) {
val icon = entry.icon

icon?.let {
Utils.drawImage(
canvas,
it,
(x + iconsOffset.x).toInt(),
(y + iconsOffset.y).toInt()
)
}
}
j += 2
}
j += 2
}

MPPointF.recycleInstance(iconsOffset)
MPPointF.recycleInstance(iconsOffset)
}
}
}
}
Expand All @@ -289,7 +291,7 @@ open class CandleStickChartRenderer(
val candleData = dataProvider.candleData

for (high in indices) {
val set = candleData.getDataSetByIndex(high.dataSetIndex)
val set = candleData?.getDataSetByIndex(high.dataSetIndex)

if (set == null || !set.isHighlightEnabled) continue

Expand Down
Loading
Loading