🏠 back to Observable

Vega-Lite: x-axis title not displayed on chart with generated data and fold transform

The second chart in notebook Vega-Lite Chart Visualization of the Sin Function’s Taylor Series is not displaying its title.

It appears related to the fold transform and updating of the view with Vega’s change method.

Any ideas or workarounds?

Solution: Stabilize quantitative axis that are being updated via a dynamic stream of data.

The issue can best be illustrated with the following notebook from the Vega-Lite tutorial:
Vega-Lite with Streaming Data Updates.

  • The encoding for the x channel in the notebook is ordinal; because it is a bar chart:

    vl.x().fieldO(‘x’).axis({labelAngle: 0})

  • Making it quantitative (to illustrate the problem) will remove the x axis title, only when it is dynamically updated:

    vl.x().fieldQ(‘x’).axis({labelAngle: 0})

  • Solution is to stabilize the scale for quantitative encodings:

    vl.x().fieldQ(‘x’).axis({labelAngle: 0}).scale({domain: [0, 10]})