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 @@ -7,19 +7,15 @@ package info.appdev.charting.buffer
</T> */
abstract class AbstractBuffer<T>(size: Int) {
/** index in the buffer */
@JvmField
protected var index: Int = 0

/** float-buffer that holds the data points to draw, order: x,y,x,y,... */
@JvmField
val buffer: FloatArray

/** animation phase x-axis */
@JvmField
protected var phaseX: Float = 1f

/** animation phase y-axis */
@JvmField
protected var phaseY: Float = 1f

/** indicates from which x-index the visible data begins */
Expand Down
15 changes: 2 additions & 13 deletions chartLib/src/main/kotlin/info/appdev/charting/buffer/BarBuffer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,22 @@ open class BarBuffer(size: Int, dataSetCount: Int, containsStacks: Boolean) : Ab
protected var dataSetIndex: Int = 0
protected var dataSetCount: Int = 1

@JvmField
protected var containsStacks: Boolean = false

@JvmField
protected var inverted: Boolean = false
var inverted: Boolean = false

/** width of the bar on the x-axis, in values (not pixels) */
@JvmField
protected var barWidth: Float = 1f
var barWidth: Float = 1f

init {
this.dataSetCount = dataSetCount
this.containsStacks = containsStacks
}

fun setBarWidth(barWidthGiven: Float) {
this.barWidth = barWidthGiven
}

fun setDataSet(index: Int) {
this.dataSetIndex = index
}

fun setInverted(invertedGiven: Boolean) {
this.inverted = invertedGiven
}

protected fun addBar(left: Float, top: Float, right: Float, bottom: Float) {
buffer[index++] = left
buffer[index++] = top
Expand Down
44 changes: 1 addition & 43 deletions chartLib/src/main/kotlin/info/appdev/charting/charts/Chart.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
* object that holds all data that was originally set for the chart, before
* it was modified or any filtering algorithms had been applied
*/
@JvmField
protected var mData: T? = null

/**
Expand Down Expand Up @@ -120,13 +119,11 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
/**
* the object representing the labels on the x-axis
*/
@JvmField
protected var mXAxis: XAxis = XAxis()

/**
* if true, touch gestures are enabled on the chart
*/
@JvmField
protected var mTouchEnabled: Boolean = true

/**
Expand Down Expand Up @@ -186,7 +183,6 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
/**
* object responsible for rendering the data
*/
@JvmField
protected var mRenderer: DataRenderer? = null

var highlighter: IHighlighter? = null
Expand All @@ -195,9 +191,7 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
/**
* Returns the ViewPortHandler of the chart that is responsible for the
* content area of the chart and its offsets and dimensions.
*/
/**
* object that manages the bounds and drawing constraints of the chart
* Object that manages the bounds and drawing constraints of the chart
*/
var viewPortHandler: ViewPortHandler = ViewPortHandler()
protected set
Expand Down Expand Up @@ -281,39 +275,6 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
this.legendRenderer = LegendRenderer(this.viewPortHandler, this.legend!!)
}

// public void initWithDummyData() {
// ColorTemplate template = new ColorTemplate();
// template.addColorsForDataSets(ColorTemplate.COLORFUL_COLORS,
// getContext());
//
// setColorTemplate(template);
// setDrawYValues(false);
//
// ArrayList<String> xVals = new ArrayList<String>();
// Calendar calendar = Calendar.getInstance();
// for (int i = 0; i < 12; i++) {
// xVals.add(calendar.getDisplayName(Calendar.MONTH, Calendar.SHORT,
// Locale.getDefault()));
// }
//
// ArrayList<DataSet> dataSets = new ArrayList<DataSet>();
// for (int i = 0; i < 3; i++) {
//
// ArrayList<Entry> yVals = new ArrayList<Entry>();
//
// for (int j = 0; j < 12; j++) {
// float val = (float) (Math.random() * 100);
// yVals.add(new Entry(val, j));
// }
//
// DataSet set = new DataSet(yVals, "DataSet " + i);
// dataSets.add(set); // add the datasets
// }
// // create a data object with the datasets
// ChartData data = new ChartData(xVals, dataSets);
// setData(data);
// invalidate();
// }
/**
* Sets a new data object for the chart. The data object contains all values
* and information needed for displaying.
Expand Down Expand Up @@ -574,7 +535,6 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
* @param dataIndex The data index to search in (only used in CombinedChartView currently)
* @param callListener Should the listener be called for this change
*/
@JvmOverloads
fun highlightValue(x: Float, dataSetIndex: Int, dataIndex: Int = -1, callListener: Boolean = true) {
highlightValue(x, Float.NaN, dataSetIndex, dataIndex, callListener)
}
Expand All @@ -601,7 +561,6 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
* @param dataSetIndex The dataset index to search in
* @param dataIndex The data index to search in (only used in CombinedChartView currently)
*/
@JvmOverloads
fun highlightValue(x: Float, y: Float, dataSetIndex: Int, dataIndex: Int = -1, callListener: Boolean = true) {
if (dataSetIndex < 0 || dataSetIndex >= mData!!.dataSetCount) {
highlightValue(null, callListener)
Expand Down Expand Up @@ -1221,7 +1180,6 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
* @param quality e.g. 50, min = 0, max = 100
* @return returns true if saving was successful, false if not
*/
@JvmOverloads
fun saveToGallery(
fileName: String,
subFolderPath: String? = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ abstract class AxisBase : ComponentBase() {
/**
* the number of entries the legend contains
*/
@JvmField
var entryCount: Int = 0

/**
Expand Down Expand Up @@ -215,19 +214,16 @@ abstract class AxisBase : ComponentBase() {
/**
* don't touch this direclty, use setter
*/
@JvmField
var mAxisMaximum: Float = 0f

/**
* don't touch this directly, use setter
*/
@JvmField
var mAxisMinimum: Float = 0f

/**
* the total range of values this axis covers
*/
@JvmField
var mAxisRange: Float = 0f

private var mAxisMinLabels = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ abstract class ComponentBase {
/**
* the offset in pixels this component has on the x-axis
*/
@JvmField
protected var mXOffset: Float = 5f

/**
* the offset in pixels this component has on the Y-axis
*/
@JvmField
protected var mYOffset: Float = 5f

/**
Expand All @@ -34,7 +32,6 @@ abstract class ComponentBase {
/**
* the text size of the labels
*/
@JvmField
protected var mTextSize: Float = 10f.convertDpToPixel()

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ class Description : ComponentBase() {
/**
* Sets the text to be shown as the description.
* Never set this to null as this will cause nullpointer exception when drawing with Android Canvas.
*
* @param text
*/
@JvmField
var text: String? = "Description Label"

/**
Expand Down
10 changes: 0 additions & 10 deletions chartLib/src/main/kotlin/info/appdev/charting/components/Legend.kt
Original file line number Diff line number Diff line change
Expand Up @@ -323,29 +323,19 @@ class Legend() : ComponentBase() {

var mTextWidthMax: Float = 0f

/**
* If this is set, then word wrapping the legend is enabled. This means the
* legend will not be cut off if too long.
*/
/**
* Should the legend word wrap? / this is currently supported only for:
* BelowChartLeft, BelowChartRight, BelowChartCenter. / note that word
* wrapping a legend takes a toll on performance. / you may want to set
* maxSizePercent when word wrapping, to set the point where the text wraps.
* / default: false
*/
/**
* flag that indicates if word wrapping is enabled
*/
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)

/**
* default constructor
*/
init {
this.mTextSize = 10f.convertDpToPixel()
this.mXOffset = 5f.convertDpToPixel()
Expand Down
31 changes: 0 additions & 31 deletions chartLib/src/main/kotlin/info/appdev/charting/data/ChartData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import info.appdev.charting.highlight.Highlight
import info.appdev.charting.interfaces.datasets.IDataSet
import timber.log.Timber
import java.io.Serializable
import java.util.Collections

/**
* Class that holds all relevant data that represents the chart. That involves at least one (or more) DataSets, and an array of x-values.
Expand Down Expand Up @@ -38,59 +37,29 @@ abstract class ChartData<T : IDataSet<out Entry>> : Serializable {
var xMin: Float = Float.MAX_VALUE
protected set


@JvmField
protected var mLeftAxisMax: Float = -Float.MAX_VALUE

@JvmField
protected var mLeftAxisMin: Float = Float.MAX_VALUE

@JvmField
protected var mRightAxisMax: Float = -Float.MAX_VALUE

@JvmField
protected var mRightAxisMin: Float = Float.MAX_VALUE

/**
* Returns all DataSet objects this ChartData object holds.
*/
/**
* array that holds all DataSets the ChartData object represents
*/
open var dataSets: MutableList<T>? = null
protected set

/**
* Default constructor.
*/
constructor() {
this.dataSets = ArrayList<T>()
}

/**
* Constructor taking single or multiple DataSet objects.
*/
constructor(vararg dataSets: T) {
this.dataSets = dataSets.toMutableList()
notifyDataChanged()
}

/**
* Created because Arrays.asList(...) does not support modification.
*/
private fun arrayToList(array: Array<T>): MutableList<T> {
val list: MutableList<T> = ArrayList()

Collections.addAll(list, *array)

return list
}

/**
* constructor for chart data
*
* @param sets the dataset array
*/
constructor(sets: MutableList<T>) {
this.dataSets = sets
notifyDataChanged()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import kotlin.math.abs
* LineChart, or the values of a specific group of bars in the BarChart).
*/
abstract class DataSet<T : Entry>(
@JvmField protected var mEntries: MutableList<T>?,
protected var mEntries: MutableList<T>?,
label: String = ""
) : BaseDataSet<T>(label), Serializable {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import timber.log.Timber

@SuppressLint("ParcelCreator")
class PieEntry : Entry {
@JvmField
var label: String? = null

constructor(value: Float) : super(0f, value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ class BarLineChartTouchListener(
}

val h = chart.getHighlightByTouchPoint(e.x, e.y)
performHighlight(h, e)
performHighlight(h)

return super.onSingleTapUp(e)
}
Expand Down
Loading
Loading