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
@@ -0,0 +1,46 @@
package info.appdev.charting.data

import android.annotation.SuppressLint
import android.graphics.drawable.Drawable
import kotlin.math.abs

/**
* High-precision bubble entry that stores x, y and size as Double, extending [BubbleEntryFloat]
* so it works seamlessly in the existing bubble chart rendering pipeline.
* Use [xDouble], [yDouble] and [sizeDouble] for full-precision access.
*/
@SuppressLint("ParcelCreator")
open class BubbleEntryDouble : BubbleEntryFloat {

var xDouble: Double = 0.0
var yDouble: Double = 0.0
var sizeDouble: Double = 0.0

override var x: Float
get() = xDouble.toFloat()
set(value) { xDouble = value.toDouble() }

override var y: Float
get() = yDouble.toFloat()
set(value) { yDouble = value.toDouble() }

constructor(x: Double, y: Double, size: Double) : super(x.toFloat(), y.toFloat(), size.toFloat()) {
xDouble = x; yDouble = y; sizeDouble = size
this.size = size.toFloat()
}

constructor(x: Double, y: Double, size: Double, data: Any?) : super(x.toFloat(), y.toFloat(), size.toFloat(), data) {
xDouble = x; yDouble = y; sizeDouble = size
this.size = size.toFloat()
}

constructor(x: Double, y: Double, size: Double, icon: Drawable?) : super(x.toFloat(), y.toFloat(), size.toFloat(), icon) {
xDouble = x; yDouble = y; sizeDouble = size
this.size = size.toFloat()
}

override fun copy(): BubbleEntryDouble = BubbleEntryDouble(xDouble, yDouble, sizeDouble, data)

override fun toString(): String = "BubbleEntryDouble xDouble=$xDouble yDouble=$yDouble sizeDouble=$sizeDouble"
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.graphics.drawable.Drawable
* chart implementation: Copyright 2015 Pierre-Marc Airoldi Licensed under Apache License 2.0
*/
@SuppressLint("ParcelCreator")
class BubbleEntryFloat : EntryFloat {
open class BubbleEntryFloat : EntryFloat {
/**
* Returns the size of this entry (the size of the bubble).
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package info.appdev.charting.data

import android.annotation.SuppressLint
import android.graphics.drawable.Drawable
import kotlin.math.abs

/**
* High-precision candle entry that stores all OHLC values as Double, extending [CandleEntryFloat]
* so it works seamlessly in the existing candlestick chart rendering pipeline.
* Use [xDouble], [highDouble], [lowDouble], [openDouble], [closeDouble] for full-precision access.
*/
@SuppressLint("ParcelCreator")
open class CandleEntryDouble : CandleEntryFloat {

var xDouble: Double = 0.0
var highDouble: Double = 0.0
var lowDouble: Double = 0.0
var openDouble: Double = 0.0
var closeDouble: Double = 0.0

override var x: Float
get() = xDouble.toFloat()
set(value) { xDouble = value.toDouble() }

constructor(
x: Double, shadowH: Double, shadowL: Double, open: Double, close: Double
) : super(x.toFloat(), shadowH.toFloat(), shadowL.toFloat(), open.toFloat(), close.toFloat()) {
xDouble = x; highDouble = shadowH; lowDouble = shadowL; openDouble = open; closeDouble = close
this.high = shadowH.toFloat(); this.low = shadowL.toFloat()
this.open = open.toFloat(); this.close = close.toFloat()
}

constructor(
x: Double, shadowH: Double, shadowL: Double, open: Double, close: Double, data: Any?
) : super(x.toFloat(), shadowH.toFloat(), shadowL.toFloat(), open.toFloat(), close.toFloat(), data) {
xDouble = x; highDouble = shadowH; lowDouble = shadowL; openDouble = open; closeDouble = close
this.high = shadowH.toFloat(); this.low = shadowL.toFloat()
this.open = open.toFloat(); this.close = close.toFloat()
}

constructor(
x: Double, shadowH: Double, shadowL: Double, open: Double, close: Double, icon: Drawable?
) : super(x.toFloat(), shadowH.toFloat(), shadowL.toFloat(), open.toFloat(), close.toFloat(), icon) {
xDouble = x; highDouble = shadowH; lowDouble = shadowL; openDouble = open; closeDouble = close
this.high = shadowH.toFloat(); this.low = shadowL.toFloat()
this.open = open.toFloat(); this.close = close.toFloat()
}

constructor(
x: Double, shadowH: Double, shadowL: Double, open: Double, close: Double, icon: Drawable?, data: Any?
) : super(x.toFloat(), shadowH.toFloat(), shadowL.toFloat(), open.toFloat(), close.toFloat(), icon, data) {
xDouble = x; highDouble = shadowH; lowDouble = shadowL; openDouble = open; closeDouble = close
this.high = shadowH.toFloat(); this.low = shadowL.toFloat()
this.open = open.toFloat(); this.close = close.toFloat()
}

/** Overall range between shadow-high and shadow-low at full precision. */
val shadowRangeDouble: Double get() = abs(highDouble - lowDouble)

/** Body size at full precision. */
val bodyRangeDouble: Double get() = abs(openDouble - closeDouble)

override fun copy(): CandleEntryDouble =
CandleEntryDouble(xDouble, highDouble, lowDouble, openDouble, closeDouble, data)

override fun toString(): String =
"CandleEntryDouble xDouble=$xDouble highDouble=$highDouble lowDouble=$lowDouble openDouble=$openDouble closeDouble=$closeDouble"
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import kotlin.math.abs
* Subclass of Entry that holds all values for one entry in a CandleStickChart.
*/
@SuppressLint("ParcelCreator")
class CandleEntryFloat : EntryFloat {
open class CandleEntryFloat : EntryFloat {
/**
* Returns the upper shadows highest value.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package info.appdev.charting.data

import android.annotation.SuppressLint
import android.graphics.drawable.Drawable
import timber.log.Timber

/**
* High-precision pie entry that stores the value as Double, extending [PieEntryFloat]
* so it works seamlessly in the existing pie chart rendering pipeline.
* Use [valueDouble] for full-precision access.
* Pie entries have no meaningful x-axis value.
*/
@SuppressLint("ParcelCreator")
open class PieEntryDouble : PieEntryFloat {

var valueDouble: Double = 0.0

override var y: Float
get() = valueDouble.toFloat()
set(value) { valueDouble = value.toDouble() }

@get:Deprecated("")
@set:Deprecated("")
@Suppress("DEPRECATION")
override var x: Float
get() {
Timber.i("Pie entries do not have x values")
return super.x
}
set(x) {
super.x = x
Timber.i("Pie entries do not have x values")
}

constructor(value: Double) : super(value.toFloat()) { valueDouble = value }

constructor(value: Double, data: Any?) : super(value.toFloat(), data) { valueDouble = value }

constructor(value: Double, icon: Drawable?) : super(value.toFloat(), icon) { valueDouble = value }

constructor(value: Double, icon: Drawable?, data: Any?) : super(value.toFloat(), icon, data) { valueDouble = value }

constructor(value: Double, label: String?) : super(value.toFloat(), label) { valueDouble = value }

constructor(value: Double, label: String?, data: Any?) : super(value.toFloat(), label, data) { valueDouble = value }

constructor(value: Double, label: String?, icon: Drawable?) : super(value.toFloat(), label, icon) { valueDouble = value }

constructor(value: Double, label: String?, icon: Drawable?, data: Any?) : super(value.toFloat(), label, icon, data) { valueDouble = value }

/** Full-precision value (same as [valueDouble]). */
val valuePrecise: Double get() = valueDouble

override fun copy(): PieEntryDouble = PieEntryDouble(valueDouble, label, data)

override fun toString(): String = "PieEntryDouble valueDouble=$valueDouble label=$label"
}


Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.graphics.drawable.Drawable
import timber.log.Timber

@SuppressLint("ParcelCreator")
class PieEntryFloat : EntryFloat {
open class PieEntryFloat : EntryFloat {
var label: String? = null

constructor(value: Float) : super(0f, value)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package info.appdev.charting.data

import android.annotation.SuppressLint

/**
* High-precision radar entry that stores the value as Double, extending [RadarEntryFloat]
* so it works seamlessly in the existing radar chart rendering pipeline.
* Use [valueDouble] for full-precision access.
* Radar entries have no meaningful x-axis value.
*/
@SuppressLint("ParcelCreator")
open class RadarEntryDouble : RadarEntryFloat {

var valueDouble: Double = 0.0

override var y: Float
get() = valueDouble.toFloat()
set(value) { valueDouble = value.toDouble() }

@get:Deprecated("")
@set:Deprecated("")
@Suppress("DEPRECATION")
override var x: Float
get() = super.x
set(x) { super.x = x }

constructor(value: Double) : super(value.toFloat()) { valueDouble = value }

constructor(value: Double, data: Any?) : super(value.toFloat(), data) { valueDouble = value }

/** Full-precision value (same as [valueDouble]). */
val valuePrecise: Double get() = valueDouble

override fun copy(): RadarEntryDouble = RadarEntryDouble(valueDouble, data)

override fun toString(): String = "RadarEntryDouble valueDouble=$valueDouble"
}


Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package info.appdev.charting.data
import android.annotation.SuppressLint

@SuppressLint("ParcelCreator")
class RadarEntryFloat : EntryFloat {
open class RadarEntryFloat : EntryFloat {
constructor(value: Float) : super(0f, value)

constructor(value: Float, data: Any?) : super(0f, value, data)
Expand Down
Loading