Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Stats Refresh] When charts have no data, show grey bars #11876

Closed
ScoutHarris opened this issue Jun 6, 2019 · 4 comments
Closed

[Stats Refresh] When charts have no data, show grey bars #11876

ScoutHarris opened this issue Jun 6, 2019 · 4 comments

Comments

@ScoutHarris
Copy link
Contributor

ScoutHarris commented Jun 6, 2019

Currently, when the charts are empty, they show nothing. They should show short grey bars like Android does.

This applies to:

  • Latest Post Summary
  • Period Overview
  • Post Stats Overview

Examples:

iOS:
ios_empty_chart

Android:
android_empty_chart

From @planarvoid in a Slack conversation - "I’m just showing gradient columns with max value of 1. grey to white."

@ScoutHarris ScoutHarris added this to the 12.6 ❄️ milestone Jun 6, 2019
@ScoutHarris ScoutHarris self-assigned this Jun 6, 2019
@ScoutHarris ScoutHarris added this to To do in Full Stats Refresh via automation Jun 6, 2019
@planarvoid
Copy link

I'm not sure if it helps in any way but this is the code that build the empty data set on Android

private fun buildEmptyDataSet(context: Context, count: Int): BarDataSet {
        val emptyValues = (0 until count).map { index -> BarEntry(index.toFloat(), 1f, "empty") }
        val dataSet = BarDataSet(emptyValues, "Empty")
        dataSet.setGradientColor(
                ContextCompat.getColor(
                        context,
                        R.color.primary_50
                ), ContextCompat.getColor(
                context,
                android.R.color.transparent
        )
        )
        dataSet.formLineWidth = 0f
        dataSet.setDrawValues(false)
        dataSet.isHighlightEnabled = false
        dataSet.highLightAlpha = 255
        return dataSet
    }

The value of all the columns is 1F, the color goes from primary_50 to transparent. Let me know if something's not clear!

@ScoutHarris
Copy link
Contributor Author

Thanks @planarvoid ! I'm sure this will come in handy.

@ScoutHarris
Copy link
Contributor Author

In the iOS version of the Charts, bar gradients have not been implemented. With #11887 , light grey bars were added to empty charts while we figure out if we can do gradients.

There are two outstanding PRs attempting to do so in the library, but both are over a year old, and are build off of older version of the library:
ChartsOrg/Charts#3225
ChartsOrg/Charts#3533

There are two (rather old) issues that may be useful if we decide to attempt this ourselves.
ChartsOrg/Charts#2722 - user modified the library's BarChartRenderer directly.
ChartsOrg/Charts#2515 - user added a CAGradientLayer to all the bars (with a few gotchas).

@ScoutHarris
Copy link
Contributor Author

ScoutHarris commented Jul 25, 2019

With these changes, we're now showing grey bars:
#11887
#11971

As stated previously, bar gradients were not implemented in the iOS Charts library. And doing so manually will take a bit of effort.

I'm closing this as Done. If we really have to have gradient bars, we should discuss the effort vs benefit with another request.

Full Stats Refresh automation moved this from To do to Done Jul 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants