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

Binning shows a "null" label when there is only 1 bin #4717

Closed
chris-canipe opened this issue Mar 12, 2019 · 3 comments
Closed

Binning shows a "null" label when there is only 1 bin #4717

chris-canipe opened this issue Mar 12, 2019 · 3 comments
Labels

Comments

@chris-canipe
Copy link
Contributor

Binning shows a "null" label when there is only one bin.

Vega Editor example

Screen Shot 2019-03-12 at 10 24 49 AM

{
  "$schema": "https://vega.github.io/schema/vega-lite/v3.0.0-rc12.json",
  "mark": "bar",
  "encoding": {
    "x": {"aggregate": "count", "field": "*", "type": "quantitative"},
    "y": {
      "bin": true,
      "field": "value",
      "type": "nominal"
    }
  },
  "data": {
    "values": [
      {
        "value": "1"
      }
    ]
  }
}

It works properly if additional data is added that will result in 2 or more bins:

Screen Shot 2019-03-12 at 10 30 14 AM

{
  "$schema": "https://vega.github.io/schema/vega-lite/v3.0.0-rc12.json",
  "mark": "bar",
  "encoding": {
    "x": {"aggregate": "count", "field": "*", "type": "quantitative"},
    "y": {
      "bin": true,
      "field": "value",
      "type": "nominal"
    }
  },
  "data": {
    "values": [
      {
        "value": "1"
      },
      {
        "value": "2"
      }
    ]
  }
}
@kanitw
Copy link
Member

kanitw commented Mar 14, 2019

The problem is caused by the extent to the bin transform.

A workaround is to change the extent signal to account for one value case:

if(bin_maxbins_10_value_extent[0] ===bin_maxbins_10_value_extent[1], [bin_maxbins_10_value_extent[0], bin_maxbins_10_value_extent[0]*1.1], bin_maxbins_10_value_extent)

@kanitw
Copy link
Member

kanitw commented Mar 15, 2019

Instead of writing crazy signals in Vega-Lite, I think we better fix this in Vega. Will send a PR.

@domoritz
Copy link
Member

Closing in favor of vega/vega#1700.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants