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 @@ -16,7 +16,7 @@ import info.appdev.chartexample.notimportant.DemoBase
import info.appdev.charting.components.XAxis.XAxisPosition
import info.appdev.charting.data.BarData
import info.appdev.charting.data.BarDataSet
import info.appdev.charting.data.BarEntry
import info.appdev.charting.data.BarEntryFloat
import info.appdev.charting.interfaces.datasets.IBarDataSet
import info.appdev.charting.utils.ColorTemplate

Expand Down Expand Up @@ -62,13 +62,13 @@ class AnotherBarActivity : DemoBase(), OnSeekBarChangeListener {
binding.tvXMax.text = binding.seekBarX.progress.toString()
binding.tvYMax.text = binding.seekBarY.progress.toString()

val values = ArrayList<BarEntry>()
val values = ArrayList<BarEntryFloat>()
val sampleValues = getValues(100)

for (i in 0..<binding.seekBarX.progress) {
val multi = (binding.seekBarY.progress + 1).toFloat()
val `val` = (sampleValues[i]!!.toFloat() * multi) + multi / 3
values.add(BarEntry(i.toFloat(), `val`))
values.add(BarEntryFloat(i.toFloat(), `val`))
}

val set1: BarDataSet
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/kotlin/info/appdev/chartexample/BarChartActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import info.appdev.charting.components.YAxis.AxisDependency
import info.appdev.charting.components.YAxis.YAxisLabelPosition
import info.appdev.charting.data.BarData
import info.appdev.charting.data.BarDataSet
import info.appdev.charting.data.BarEntry
import info.appdev.charting.data.Entry
import info.appdev.charting.data.BarEntryFloat
import info.appdev.charting.data.EntryFloat
import info.appdev.charting.formatter.IAxisValueFormatter
import info.appdev.charting.highlight.Highlight
import info.appdev.charting.interfaces.datasets.IBarDataSet
Expand Down Expand Up @@ -122,17 +122,17 @@ class BarChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelect
private fun setData(count: Int, range: Float) {
val start = 1f

val values = ArrayList<BarEntry>()
val values = ArrayList<BarEntryFloat>()
val sampleValues = getValues(100)

var i = start.toInt()
while (i < start + count) {
val `val` = (sampleValues[i]!!.toFloat() * (range + 1))

if (`val` * 100 < 25) {
values.add(BarEntry(i.toFloat(), `val`, ResourcesCompat.getDrawable(resources, R.drawable.star, null)))
values.add(BarEntryFloat(i.toFloat(), `val`, ResourcesCompat.getDrawable(resources, R.drawable.star, null)))
} else {
values.add(BarEntry(i.toFloat(), `val`))
values.add(BarEntryFloat(i.toFloat(), `val`))
}
i++
}
Expand Down Expand Up @@ -281,10 +281,10 @@ class BarChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelect

private val onValueSelectedRectF = RectF()

override fun onValueSelected(entry: Entry, highlight: Highlight) {
override fun onValueSelected(entryFloat: EntryFloat, highlight: Highlight) {
val bounds = onValueSelectedRectF
binding.chart1.getBarBounds(entry as BarEntry, bounds)
val position = binding.chart1.getPosition(entry, AxisDependency.LEFT)
binding.chart1.getBarBounds(entryFloat as BarEntryFloat, bounds)
val position = binding.chart1.getPosition(entryFloat, AxisDependency.LEFT)

Timber.i("bounds $bounds")
Timber.i("position = $position")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import info.appdev.charting.components.AxisBase
import info.appdev.charting.components.Legend
import info.appdev.charting.data.BarData
import info.appdev.charting.data.BarDataSet
import info.appdev.charting.data.BarEntry
import info.appdev.charting.data.Entry
import info.appdev.charting.data.BarEntryFloat
import info.appdev.charting.data.EntryFloat
import info.appdev.charting.formatter.IAxisValueFormatter
import info.appdev.charting.formatter.LargeValueFormatter
import info.appdev.charting.highlight.Highlight
Expand Down Expand Up @@ -110,19 +110,19 @@ class BarChartActivityMultiDataset : DemoBase(), OnSeekBarChangeListener, OnChar
binding.tvXMax.text = String.format(Locale.ENGLISH, "%d-%d", startYear, endYear)
binding.tvYMax.text = binding.seekBarY.progress.toString()

val values1 = ArrayList<BarEntry>()
val values2 = ArrayList<BarEntry>()
val values3 = ArrayList<BarEntry>()
val values4 = ArrayList<BarEntry>()
val values1 = ArrayList<BarEntryFloat>()
val values2 = ArrayList<BarEntryFloat>()
val values3 = ArrayList<BarEntryFloat>()
val values4 = ArrayList<BarEntryFloat>()

val randomMultiplier = binding.seekBarY.progress * 100000f
val sampleValues = getValues(100 + 2)

for (i in startYear..<endYear) {
values1.add(BarEntry(i.toFloat(), (sampleValues[i - startYear]!!.toFloat() * randomMultiplier)))
values2.add(BarEntry(i.toFloat(), (sampleValues[i - startYear + 1]!!.toFloat() * randomMultiplier)))
values3.add(BarEntry(i.toFloat(), (sampleValues[i - startYear + 2]!!.toFloat() * randomMultiplier)))
values4.add(BarEntry(i.toFloat(), (sampleValues[i - startYear]!!.toFloat() * randomMultiplier)))
values1.add(BarEntryFloat(i.toFloat(), (sampleValues[i - startYear]!!.toFloat() * randomMultiplier)))
values2.add(BarEntryFloat(i.toFloat(), (sampleValues[i - startYear + 1]!!.toFloat() * randomMultiplier)))
values3.add(BarEntryFloat(i.toFloat(), (sampleValues[i - startYear + 2]!!.toFloat() * randomMultiplier)))
values4.add(BarEntryFloat(i.toFloat(), (sampleValues[i - startYear]!!.toFloat() * randomMultiplier)))
}

val set1: BarDataSet
Expand Down Expand Up @@ -247,8 +247,8 @@ class BarChartActivityMultiDataset : DemoBase(), OnSeekBarChangeListener, OnChar

override fun onStopTrackingTouch(seekBar: SeekBar?) = Unit

override fun onValueSelected(entry: Entry, highlight: Highlight) {
Timber.i("Selected: $entry, dataSet: ${highlight.dataSetIndex}")
override fun onValueSelected(entryFloat: EntryFloat, highlight: Highlight) {
Timber.i("Selected: $entryFloat, dataSet: ${highlight.dataSetIndex}")
}

override fun onNothingSelected() = Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import info.appdev.charting.components.Legend
import info.appdev.charting.components.Legend.LegendForm
import info.appdev.charting.data.BarData
import info.appdev.charting.data.BarDataSet
import info.appdev.charting.data.BarEntry
import info.appdev.charting.data.BarEntryFloat
import info.appdev.charting.utils.loadBarEntriesFromAssets

class BarChartActivitySinus : DemoBase(), OnSeekBarChangeListener {

private lateinit var dataSinus: MutableList<BarEntry>
private lateinit var dataSinus: MutableList<BarEntryFloat>

private lateinit var binding: ActivityBarchartSinusBinding

Expand Down Expand Up @@ -87,7 +87,7 @@ class BarChartActivitySinus : DemoBase(), OnSeekBarChangeListener {
}

private fun setData(count: Int) {
val entries = ArrayList<BarEntry>()
val entries = ArrayList<BarEntryFloat>()

for (i in 0..<count) {
entries.add(dataSinus[i])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import info.appdev.charting.components.AxisBase
import info.appdev.charting.components.XAxis.XAxisPosition
import info.appdev.charting.data.BarData
import info.appdev.charting.data.BarDataSet
import info.appdev.charting.data.BarEntry
import info.appdev.charting.data.Entry
import info.appdev.charting.data.BarEntryFloat
import info.appdev.charting.data.EntryFloat
import info.appdev.charting.formatter.IAxisValueFormatter
import info.appdev.charting.formatter.IValueFormatter
import info.appdev.charting.utils.ViewPortHandler
Expand Down Expand Up @@ -87,15 +87,15 @@ class BarChartPositiveNegative : DemoBase() {
}

private fun setData(dataList: MutableList<Data>) {
val values = ArrayList<BarEntry>()
val values = ArrayList<BarEntryFloat>()
val colors: MutableList<Int> = ArrayList()

val green = Color.rgb(110, 190, 102)
val red = Color.rgb(211, 74, 88)

for (i in dataList.indices) {
val d = dataList[i]
val entry = BarEntry(d.xValue, d.yValue)
val entry = BarEntryFloat(d.xValue, d.yValue)
values.add(entry)

// specific colors
Expand Down Expand Up @@ -136,7 +136,7 @@ class BarChartPositiveNegative : DemoBase() {
private class ValueFormatter : IValueFormatter {
private val mFormat: DecimalFormat = DecimalFormat("######.0")

override fun getFormattedValue(value: Float, entry: Entry?, dataSetIndex: Int, viewPortHandler: ViewPortHandler?): String {
override fun getFormattedValue(value: Float, entryFloat: EntryFloat?, dataSetIndex: Int, viewPortHandler: ViewPortHandler?): String {
return mFormat.format(value.toDouble())
}
}
Expand Down
20 changes: 10 additions & 10 deletions app/src/main/kotlin/info/appdev/chartexample/BubbleChartActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import info.appdev.charting.components.Legend
import info.appdev.charting.components.XAxis
import info.appdev.charting.data.BubbleData
import info.appdev.charting.data.BubbleDataSet
import info.appdev.charting.data.BubbleEntry
import info.appdev.charting.data.Entry
import info.appdev.charting.data.BubbleEntryFloat
import info.appdev.charting.data.EntryFloat
import info.appdev.charting.highlight.Highlight
import info.appdev.charting.interfaces.datasets.IBubbleDataSet
import info.appdev.charting.listener.OnChartValueSelectedListener
Expand Down Expand Up @@ -82,29 +82,29 @@ class BubbleChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSel
binding.tvXMax.text = count.toString()
binding.tvYMax.text = range.toString()

val values1 = ArrayList<BubbleEntry>()
val values2 = ArrayList<BubbleEntry>()
val values3 = ArrayList<BubbleEntry>()
val values1 = ArrayList<BubbleEntryFloat>()
val values2 = ArrayList<BubbleEntryFloat>()
val values3 = ArrayList<BubbleEntryFloat>()
val sampleValues = getValues(100)

for (i in 0..<count) {
values1.add(
BubbleEntry(
BubbleEntryFloat(
i.toFloat(),
(sampleValues[i + 1]!! * range).toFloat(),
(sampleValues[i]!!.toFloat() * range),
ResourcesCompat.getDrawable(resources, R.drawable.star, null)
)
)
values2.add(
BubbleEntry(
BubbleEntryFloat(
i.toFloat(),
(sampleValues[i + 2]!! * range).toFloat(),
(sampleValues[i + 1]!!.toFloat() * range),
ResourcesCompat.getDrawable(resources, R.drawable.star, null)
)
)
values3.add(BubbleEntry(i.toFloat(), (sampleValues[i]!! * range).toFloat(), (sampleValues[i + 2]!!.toFloat() * range)))
values3.add(BubbleEntryFloat(i.toFloat(), (sampleValues[i]!! * range).toFloat(), (sampleValues[i + 2]!!.toFloat() * range)))
}

// create a dataset and give it a type
Expand Down Expand Up @@ -211,8 +211,8 @@ class BubbleChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSel
saveToGallery(binding.chart1, "BubbleChartActivity")
}

override fun onValueSelected(entry: Entry, highlight: Highlight) {
Timber.i("Value: ${entry.y}, xIndex: ${entry.x}, DataSet index: ${highlight.dataSetIndex}")
override fun onValueSelected(entryFloat: EntryFloat, highlight: Highlight) {
Timber.i("Value: ${entryFloat.y}, xIndex: ${entryFloat.x}, DataSet index: ${highlight.dataSetIndex}")
}

override fun onNothingSelected() = Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import info.appdev.charting.components.XAxis.XAxisPosition
import info.appdev.charting.components.YAxis.AxisDependency
import info.appdev.charting.data.CandleData
import info.appdev.charting.data.CandleDataSet
import info.appdev.charting.data.CandleEntry
import info.appdev.charting.data.CandleEntryFloat

class CandleStickChartActivity : DemoBase(), OnSeekBarChangeListener {

Expand Down Expand Up @@ -74,7 +74,7 @@ class CandleStickChartActivity : DemoBase(), OnSeekBarChangeListener {

binding.chart1.resetTracking()

val values = ArrayList<CandleEntry>()
val values = ArrayList<CandleEntryFloat>()
val sampleValues = getValues(100)

for (i in 0..<progress) {
Expand All @@ -90,7 +90,7 @@ class CandleStickChartActivity : DemoBase(), OnSeekBarChangeListener {
val even = i % 2 == 0

values.add(
CandleEntry(
CandleEntryFloat(
i.toFloat(), `val` + high,
`val` - low,
if (even) `val` + open else `val` - open,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import info.appdev.charting.components.XAxis.XAxisPosition
import info.appdev.charting.components.YAxis
import info.appdev.charting.data.BarData
import info.appdev.charting.data.BarDataSet
import info.appdev.charting.data.BarEntry
import info.appdev.charting.data.BarEntryFloat
import info.appdev.charting.data.BubbleData
import info.appdev.charting.data.BubbleDataSet
import info.appdev.charting.data.BubbleEntry
import info.appdev.charting.data.BubbleEntryFloat
import info.appdev.charting.data.CandleData
import info.appdev.charting.data.CandleDataSet
import info.appdev.charting.data.CandleEntry
import info.appdev.charting.data.CandleEntryFloat
import info.appdev.charting.data.CombinedData
import info.appdev.charting.data.Entry
import info.appdev.charting.data.EntryFloat
import info.appdev.charting.data.LineData
import info.appdev.charting.data.LineDataSet
import info.appdev.charting.data.ScatterData
Expand Down Expand Up @@ -100,9 +100,9 @@ class CombinedChartActivity : DemoBase() {
private fun generateLineData(): LineData {
val d = LineData()

val entries = ArrayList<Entry>()
val entries = ArrayList<EntryFloat>()

for (index in 0..<sampleCount) entries.add(Entry(index + 0.5f, values[index]!!.toFloat() * 15 + 5))
for (index in 0..<sampleCount) entries.add(EntryFloat(index + 0.5f, values[index]!!.toFloat() * 15 + 5))

val set = LineDataSet(entries, "Line DataSet")
set.color = Color.rgb(240, 238, 70)
Expand All @@ -122,14 +122,14 @@ class CombinedChartActivity : DemoBase() {
}

private fun generateBarData(): BarData {
val entries1 = ArrayList<BarEntry>()
val entries2 = ArrayList<BarEntry>()
val entries1 = ArrayList<BarEntryFloat>()
val entries2 = ArrayList<BarEntryFloat>()

for (index in 0..<sampleCount) {
entries1.add(BarEntry(0f, values[index]!!.toFloat() * 25 + 25))
entries1.add(BarEntryFloat(0f, values[index]!!.toFloat() * 25 + 25))

// stacked
entries2.add(BarEntry(0f, floatArrayOf(values[index]!!.toFloat() * 13 + 12, values[index]!!.toFloat() * 13 + 12)))
entries2.add(BarEntryFloat(0f, floatArrayOf(values[index]!!.toFloat() * 13 + 12, values[index]!!.toFloat() * 13 + 12)))
}

val set1 = BarDataSet(entries1, "Bar 1")
Expand Down Expand Up @@ -162,11 +162,11 @@ class CombinedChartActivity : DemoBase() {
private fun generateScatterData(): ScatterData {
val d = ScatterData()

val entries = ArrayList<Entry>()
val entries = ArrayList<EntryFloat>()

var index = 0f
while (index < sampleCount) {
entries.add(Entry(index + 0.25f, values[(index * 2).roundToInt()]!!.toFloat() * 10 + 55))
entries.add(EntryFloat(index + 0.25f, values[(index * 2).roundToInt()]!!.toFloat() * 10 + 55))
index += 0.5f
}

Expand All @@ -183,11 +183,11 @@ class CombinedChartActivity : DemoBase() {
private fun generateCandleData(): CandleData {
val d = CandleData()

val entries = ArrayList<CandleEntry>()
val entries = ArrayList<CandleEntryFloat>()

var index = 0
while (index < sampleCount) {
entries.add(CandleEntry(index + 1f, 90f, 70f, 85f, 75f))
entries.add(CandleEntryFloat(index + 1f, 90f, 70f, 85f, 75f))
index += 2
}

Expand All @@ -205,12 +205,12 @@ class CombinedChartActivity : DemoBase() {
private fun generateBubbleData(): BubbleData {
val bd = BubbleData()

val entries = ArrayList<BubbleEntry>()
val entries = ArrayList<BubbleEntryFloat>()

for (index in 0..<sampleCount) {
val y = values[index]!!.toFloat() * 10 + 105
val size = values[index]!!.toFloat() * 100 + 105
entries.add(BubbleEntry(index + 0.5f, y, size))
entries.add(BubbleEntryFloat(index + 0.5f, y, size))
}

val set = BubbleDataSet(entries, "Bubble DataSet")
Expand Down
Loading
Loading