question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Independent Y axes for dual axis wrapped facet and nested fields breaks axis layout

See original GitHub issue

Hello,

My requirement is to get dual axis charts in wrapped facet as in below link.

https://vega.github.io/editor/#/url/vega-lite/N4IgJAzgxgFgpgWwIYgFwhgF0wBwqgegIDc4BzJAOjIEtMYBXAI0poHsDp5kTykBaADZ04JACyUAVhDYA7EABoQAEySYUqUAwBOgtCrVICTJLrgBPKTPkBfJQDMkUOJjSh7NOIOX6IIxSCY5jhw+mzayjSySHp2IM6ymHDaaJjaDHBKUGyCDAiyEGgATEoQIVBuIIJI5sloANqgyNoA1vomKUpwstmRsmSV5pVIZGTafEn6CHCRSPIOnt765os+SkEh+gCODHOYdGo0pAHQMaGaIABeyWxojoIQcDZxAB6VHl4+6MSmnkEBG3OIHCfRiJ3CrnQ-DecWygnC71WyzgpgBwSBsjYCCiYOediapja6GEslCXR6bD6AwuQwuIzGEyBEDyAQ+S3QK0+aM26B2ewO+2OpSgZ0q120t1Q90ezyUbwubK+IB+2j+Q3W6LCERxelKEP00JAsJyCIuP1yQIAxAAGW12o3PAC6SnGMkExwup0E51AtJAUWUcBCskDiSNSiQLxohRp+gDQe6odceJdcDdHtAXp9IHl-pDCfzYaUfvjwaT4ZAkejgzj+bL3WTxtkHmpoA6w2EZHk6ASSRSeKAA

I have used the same code with my data , but wasn’t getting independent Y axes for dual charts :

image

code :

{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "data": {
    "url": {
      "%context%": true,
      "index": "index_paincure_0709",
      "body": {
        "size": 10000,
        "_source": ["Media_Type", "Unit_Key_Message", "Readability"]
      }
    },
    "format": {"property": "hits.hits"}
  },
  "facet": {"field": "_source.Media_Type", "type": "ordinal", "title": ""},
  "center": true,
  "columns": 2,
  "spec": {
    "layer": [
      {
        "mark": "bar",
        "encoding": {
          "y": {
            "aggregate": "sum",
            "field": "_source.Readability",
            "type": "quantitative",
            "scale": {"zero": false}
          },
          "x": {
            "field": "_source.Unit_Key_Message",
            "type": "ordinal",
            "sort": "-x",
            "title": ""
          }
        }
      },
      {
        "mark": "line",
        "encoding": {
          "y": {
            "aggregate": "count",
            "field": "_source.Unit_Key_Message",
            "type": "quantitative",
            "scale": {"zero": false}
          },
          "x": {
            "field": "_source.Unit_Key_Message",
            "type": "ordinal",
            "sort": "-x",
            "title": ""
          },
          "color": {"value": "#000000"}
        }
      }
    ],
    "resolve": {"scale": {"y": "independent"}, "axis": {"y": "independent"}}
  },
  "resolve": {
    "scale": {"x": "independent", "y": "independent"},
    "axis": {"y": "independent"}
  },
  "config": {"bar": {"align": "center"}}
}

Data ( Result of JSON.stringify(VEGA_DEBUG.vegalite_spec ) is attached in the file

asset_data.txt

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
domoritzcommented, Mar 8, 2021

Thanks. It looks like it works if we flatten the fields so the problem seems to be with the nested access.

Open the Chart in the Vega Editor.

1reaction
domoritzcommented, Mar 7, 2021

I see. Nested fields a are sometimes tricky to handle since Vega always fattens outputs. Can you create a minimal example that shows the issue so we can fix it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Independent Y axes for dual axis wrapped facet - Elastic Discuss
Hello,. My requirement is to get dual axis charts in wrapped facet as in below link. vega.github.io · Editor/IDE for Vega and Vega-Lite....
Read more >
Facets • ggh4x - GitHub Pages
This package offers two extensions to the vanilla facet_wrap() and facet_grid() that give you more control of the placement of axes at the...
Read more >
Add Axes for Multiple Measures in Views - Tableau Help
Create individual axes for each measure. Blend two measures to share an axis. Add dual axes where there are two independent axes layered...
Read more >
How to use facets with a dual y-axis ggplot - Stack Overflow
The only restriction is that the relationship between the two axes is equal for all facets. Share.
Read more >
observablehq/plot: A concise API for exploratory data ... - GitHub
(Plot does not currently support dual-axis charts, which are not advised.) ... label position offset (in pixels; default 0, typically for facet axes);...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found