Skip to content

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

Closed

Description

@ScoutHarris

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."

Activity

  1. added this to the 12.6 ❄️ milestone on Jun 6, 2019
  2. self-assigned this
    on Jun 6, 2019
  3. planarvoid commented on Jun 7, 2019

    @planarvoid

    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!

  4. ScoutHarris commented on Jun 7, 2019

    @ScoutHarris
    ContributorAuthor

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

  5. removed this from the 12.6 ❄️ milestone on Jun 7, 2019
  6. ScoutHarris commented on Jun 12, 2019

    @ScoutHarris
    ContributorAuthor

    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).

  7. removed their assignment
    on Jun 12, 2019
  8. ScoutHarris commented on Jul 25, 2019

    @ScoutHarris
    ContributorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions