Dashboards dual axis

hhaaland
New Contributor

Hi!

I am using AI/BI dashboards with dual y-axis. If I have Axis Range set to Default, it is not very good at auto-scaling.  See attached example - notice the huge amount of dead space

hhaaland_0-1794391222974.png

I could of course chose custom range to get better result, but then if the data changes, then all or parts of the curves disappear since the range would be fixed.

Do you know how to achieve better auto-scaling with dual-axis?

Valeria_Koz_DBX
Databricks Employee
Databricks Employee

Hi @hhaaland,

Current documentation on the AI/BI dashboards with dual y-axis states that axis range has three options:

  1. Default ("Use an automatic range")
  2. Per facet, which only applies to faceted charts
  3. Custom ("Set fixed Minimum and Maximum values")
  • There's no "include zero" toggle, and the docs don't say whether you can fill in only Minimum and leave Maximum blank.
    • Log (Symmetric) doesn't help, and internally there's a known report of log axes still starting at 0.
    • Custom Viz uses Vega-Lite, and the docs' own example uses "scale": {"zero": false}.

So, I don't think Default can do better on its own. The automatic range starts at zero, and the only other options are Per facet (for faceted charts) and Custom, which fixes both ends. A few ways around it:

  1. Custom Viz (currently in Public Preview). Under Advanced visualisation, pick Custom Viz, add your date and two measures in Fields, and paste a Vega-Lite spec. "zero": false lets each axis fit its own data, and "resolve" keeps the two axes independent, so it still rescales when the data changes:
    1. {
        "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
        "data": {"name": "databricks_query"},
        "width": "container",
        "height": "container",
        "config": {"autosize": {"type": "fit", "contains": "padding"}},
        "layer": [
          {
            "mark": {"type": "line", "color": "#00A972"},
            "encoding": {
              "x": {"field": "date", "type": "temporal"},
              "y": {"field": "series_a", "type": "quantitative",
                    "scale": {"zero": false}, "axis": {"title": "Series A"}}
            }
          },
          {
            "mark": {"type": "line", "color": "#FF3621"},
            "encoding": {
              "x": {"field": "date", "type": "temporal"},
              "y": {"field": "series_b", "type": "quantitative",
                    "scale": {"zero": false}, "axis": {"title": "Series B", "orient": "right"}}
            }
          }
        ],
        "resolve": {"scale": {"y": "independent"}}
      }
      
    2. Replace date, series_a and series_b with the Name of each field in the Fields section. Keep "data": {"name": "databricks_query"} as it is: that's how the chart picks up your dataset. More examples are in the docs: Custom visualizations.
  2. If you stay with the built-in chart, set a Custom range on each axis separately (kebab menu next to Left Y axis / Right Y axis). Leave a margin above and below your usual values so new data doesn't fall outside the range.
  3. Check whether you need two axes. In your screenshot both lines sit around 0.45. If they're the same unit, one axis makes the gap between them easier to read.

A native "don't start at zero" option would be the cleaner fix, so it's worth raising as an idea through the Ideas Portal too.

View solution in original post