vega / vl-convert

Utilities for converting Vega-Lite specs from the command line and Python
BSD 3-Clause "New" or "Revised" License
100 stars 12 forks source link

FontSize = 0 issue vlc.vegalite_to_svg() #172

Closed michaelzwong closed 2 months ago

michaelzwong commented 3 months ago

I encountered an error when converting spec to svg with axes that have labelFontSize = 0. The error message indicates that there was a failure to locate text within an empty SVG element

vlc.vegalite_to_svg(vl_spec=vl_spec)

ERROR Error: Failed to locate text in SVG:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="100" height="100">
    <text x="20" y="50" font-size="0" font-family="sans-serif">000</text>
</svg>
{
  "layer": [
    {
      "encoding": {
        "x": {
          "axis": {
            "labelFontSize": 0
          }
        },
        "y": {
          "axis": {
            "labelFontSize": 0
          }
        }
      }
    }
  ]
}

The workaround was to set `axis: { "labels": False, "labelFontSize": 10 }

jonmmease commented 3 months ago

Thanks for the report and workaround @michaelzwong, this is something that we should fix in vl-convert, so going to re-open the issue for tracking.