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.

Update SVG output to play nice with SVG optimizers?

See original GitHub issue

Sorry for a vague subject, but I am just not too intimately familiar with vega and just use it in one context only.

As you can see the graph is blank.

Inspecting the SVG markup the columns are still there, they are just not painted and thus blend in with the background.

Script that generates the graph: https://github.com/moltar/typescript-runtime-type-benchmarks/blob/master/graph.ts

Generated SVG Diff: https://github.com/moltar/typescript-runtime-type-benchmarks/commit/09db33972f1f6e1f87d1db4a72b5c9e4cd88ee08#diff-a9316fd460d64045bb8190f11727bcd9

Visual Diff: https://github.com/moltar/typescript-runtime-type-benchmarks/commit/13cc94a74312eff42f980a9f2e7fe5a30a00230a?short_path=a9316fd#diff-a9316fd460d64045bb8190f11727bcd9

Any ideas?

Thanks.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
moltarcommented, May 23, 2020

@jheer wow Jeff, this is a huge fix. Thank you!

1reaction
jheercommented, May 21, 2020

It looks like your SVG file is not the SVG exported by Vega, but a modified version run through an SVG optimizer (I see SVGO being used in your script). It looks like SVGO is stripping out the fill color from text marks. Apparently it is assuming that since black is normally the default fill color it is safe to remove, but in this case that is not true due to conflicts with the internal stylesheet. For the bar marks, it looks like it is moving the fill color to the parent group element, but the path elements for the bars no longer inherit this value, again due to the stylesheet.

We can consider modifying the internal stylesheet further to help avoid issues like this. Nevertheless this looks like a possible bug in the optimizer, as it appears to be oblivious to the existence of an internal stylesheet.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tools for Optimizing SVG | CSS-Tricks
This is our straight-to-the-point list of SVG optimizing tools across a number of categories. They are all largely based around SVGO, ...
Read more >
8 tricks for SVG optimization - UX Collective
Here are some tricks that can save us time when manipulating SVG code on our projects. ... be productive, and think more critically...
Read more >
An Optimized SVG Workflow - YouTube
From SVG optimization to base64 encoding, these methods are designed with performance in mind. If you fine folks know of newer/better ...
Read more >
How to create, clean up, and optimize an SVG [ A ... - YouTube
Once we export the SVG our work isn't done though, we still need to do a bit of cleanup of the file, and...
Read more >
How to optimize and reduce the file size of SVG images
For instance, Illustrator automatically adds export notes to SVGs that ... I find this easier than doing this work by hand or choosing...
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