mirror of
https://github.com/dzeiocom/charts.git
synced 2025-04-23 02:52:10 +00:00
fix: grouped barchart not displaying second bar if y is the same (#28)
This commit is contained in:
parent
4612fd7189
commit
890d474ab4
@ -1,10 +1,13 @@
|
||||
package com.dzeio.charts
|
||||
|
||||
import com.dzeio.charts.series.SerieInterface
|
||||
|
||||
/**
|
||||
* A Base entry for any charts
|
||||
*/
|
||||
data class Entry(
|
||||
var x: Double,
|
||||
var y: Float,
|
||||
var color: Int? = null
|
||||
var color: Int? = null,
|
||||
var serie: SerieInterface? = null
|
||||
)
|
||||
|
@ -52,7 +52,7 @@ class XAxis(
|
||||
}
|
||||
|
||||
override fun getPositionOnRect(entry: Entry, drawableSpace: RectF): Double {
|
||||
val result = drawableSpace.width() * (entry.x - x) / getDataWidth()
|
||||
val result = drawableSpace.left + drawableSpace.width() * (entry.x - x) / getDataWidth()
|
||||
if (view.type == ChartType.GROUPED) {
|
||||
val serie = view.series.find { it.entries.contains(entry) }
|
||||
val index = view.series.indexOf(serie)
|
||||
|
@ -65,7 +65,7 @@ class BarSerie(
|
||||
// calculated height in percent from 0 to 100
|
||||
var top = view.yAxis.getPositionOnRect(entry, drawableSpace)
|
||||
.coerceIn(drawableSpace.top, drawableSpace.bottom)
|
||||
var posX = drawableSpace.left + view.xAxis.getPositionOnRect(
|
||||
var posX = view.xAxis.getPositionOnRect(
|
||||
entry,
|
||||
drawableSpace
|
||||
).toFloat()
|
||||
|
@ -25,6 +25,12 @@ sealed class BaseSerie(
|
||||
override var yAxisPosition: YAxisPosition = YAxisPosition.RIGHT
|
||||
|
||||
override var entries: ArrayList<Entry> = arrayListOf()
|
||||
set(values) {
|
||||
for (value in values) {
|
||||
value.serie = this
|
||||
}
|
||||
field = values
|
||||
}
|
||||
|
||||
override fun getDisplayedEntries(): ArrayList<Entry> {
|
||||
val minX = view.xAxis.x
|
||||
|
@ -68,9 +68,10 @@ class LineSerie(
|
||||
entriesCurrentY[entry.x]!!.value = top
|
||||
}
|
||||
|
||||
val posX = (drawableSpace.left +
|
||||
view.xAxis.getPositionOnRect(entry, drawableSpace) +
|
||||
view.xAxis.getEntryWidth(drawableSpace) / 2f).toFloat()
|
||||
val posX = (
|
||||
view.xAxis.getPositionOnRect(entry, drawableSpace) +
|
||||
view.xAxis.getEntryWidth(drawableSpace) / 2f
|
||||
).toFloat()
|
||||
|
||||
// handle color recoloration
|
||||
val paint = Paint(linePaint)
|
||||
|
Loading…
x
Reference in New Issue
Block a user