AppDevNext / AndroidChart

A fork from dead upstream with a lot of merged pull requests from upstream. Including Espresso tests and screenshot tests
Other
102 stars 15 forks source link

Rounded Horizontal Bar Chart not rendering colors for split bar entries #259

Open KevinAlvarez-JaJa opened 1 month ago

KevinAlvarez-JaJa commented 1 month ago

Im trying to program a spending limit with rounded corners and my current chart is this:

image

I use a horizontal bar chart which is split into spent and remaining, assigned values here:

val barChart = HorizontalBarChart(LocalContext.current)
val entries = listOf(
    BarEntry(0f, floatArrayOf(spent, remaining))
)
val dataSet = BarDataSet(entries, "").apply {
    colors = listOf(spentColor, Color.rgb(64, 64, 64)) // Spent color and remaining color
    valueTextColor = Color.WHITE
    valueTextSize = 16f
    setDrawValues(false) // Hide the value labels on the bars
}

However, when setting the renderer like here:

renderer = RoundedHorizontalBarChartRenderer(this, ChartAnimator(), ViewPortHandler())
(renderer as RoundedHorizontalBarChartRenderer).setRoundedPositiveDataSetRadius(20f) // Set the corner radius 

as needed

image

The bar chart is loaded in as I can highlight it however there is no color at all, it is the same color as the background (commenting out setting the custom renderer fixes this)

I think the RoundedHorizontalBarChartRenderer doesn't work with split bar charts. If this is not the case if someone can let me know what I am doing wrong, if it is the case then I would be happy to give a go fixing it.

hannesa2 commented 1 month ago

The change comes from here https://github.com/PhilJay/MPAndroidChart/pull/5420 and I recommend to start to debug

KevinAlvarez-JaJa commented 1 month ago

The change comes from here PhilJay#5420 and I recommend to start to debug

I have been debugging and I just wanted to ask if there are any example uses of either of the rounded bar chart renderers (apart from the pie chart renderer), as I have not found any working use cases? It would help a lot if I knew the intended way to use the custom renderer of the bar charts.

hannesa2 commented 1 month ago

I made at least a sample https://github.com/AppDevNext/AndroidChart/pull/239/commits/3bc194d7e12ab83ada2e28c44ee44a34abfd1085#diff-d5e9f4a0673a80af653d3221b0e4e8830ec3dfabdf090f6deca92eb75b74a9c0

containing screenshot tests as well https://github.com/AppDevNext/AndroidChart/pull/239/commits/814de5e7c833749f694532c74aae79a661332194