-
-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider exporting SVG versions of charts #2564
Comments
Just one data point: for "Number of Wasm responses" graph, SVG version passed via SVGOMG would amount to 5.43 KB gzipped, whereas current PNG version results in 41.88 KB after optimizations - 7.7x size difference, not to mention better scaling. |
AVIF still not got enough browser support meaning we'd need PNG support anyway so doesn't save us much to be worth it IMHO. Would further increase the size of this repo (which is already nearly a Gig!) I do like SVG for fidelity, but problem is automating that. We've (just this year!) got a nice process to pull out the PNG from the published sheets URL, but looks like that (example) doesn't give you the menu option to export as SVG, so can't use that 😞 Doing it manually for every sheet, then having to redo it, instead of using the PNG script we have, for every edit, is just a big pain. And getting something like Puppeteer to do that in the script, when we have multiple charts in each tab, is difficult as how can it know which charts to select and now. That's why the current script does it based on publish URL where there's only one chart. The other option is to just use (very optimised) PNGs? As shown above they may be "good enough" and I did question the value of the heavy, heavy sheet embeds previously in #826 |
I've briefly looked at downloaded URLs when clicked through "Download as SVG". Here's the general spreadsheet URL:
Here's the SVG export URL:
And here's URL we use right now in iframe:
By cross-referencing those with each other, it's clear that in SVG export URL:
All in all, it seems fairly easy to automate generation of such SVG URL out of all the embed URLs we already have. |
Looks like we can even remove
|
Now you're getting me excited!!! Cause at the very least that would save us the compression step. Now if we could just replicate the hover effects (basically the only bit of interactivity the embeds give us) then we could serve JUST the SVG. Time to dig up that SVG book on my bookshelf I've been meaning to find time to dig through... |
Hehe, good luck :) I'd send a PR myself at least for the initial step of using SVG instead of PNG, but there's so little time and so much to do 😅 |
PNG vs SVG export:
Am I missing something? @tunetheweb @RReverser Otherwise, here is an option how we could migrate to generated SVG charts:
{{ figure_markup(
image="cmp-services.svg",
caption="Most common Consent Management Platform (CMP) services.",
description="Bar chart showing the most common CMP services. The CMP service CookieYes was found on 2.0% desktop and 2.1% mobile sites respectively, the Osano service on 1.4% and 1.4%, OneTrust on 1.2% and 0.9%, Cookiebot on 1.0% and 0.8%, Cookie Notice on 0.6% and 0.6%, iubenda on 0.5% and 0.5%, Complianz on 0.5% and 0.5%, Moove GDPR Consent on 0.4% and 0.4%, Quantcast Choice on 0.4% and 0.4%, and finally Borlabs Cookie was present on 0.2% and 0.3% sites.",
sql_file="number_of_websites_using_each_cmp.sql",
id="fig-1",
chart_config={
chartType: "BarChart",
dataSourceUrl:
"https://docs.google.com/spreadsheets/d/1iJqj3g0VEjpmjzvtX6VLeRehE7LDQGcw6lOadxGxkjk/gviz/tq?gid=2107042211&range=G2:I12",
options: {
title: "Most common CMP services",
subtitle: "Web Almanac 2022: Privacy",
height: 371,
vAxis: {
title: "CMP service"
},
hAxis: {
title: "Percentage of pages"
}
}
}
)
}} It could look something like this: https://glitch.com/edit/#!/mahogany-transparent-dracopelta I think preparing charts in markdown instead of Google Sheets may help make a smoother transition between analysis and content. |
@RReverser had a great idea to look into the Download As > SVG feature of charts in Google Sheets. SVGs don't have the same rasterization issues as the PNGs exported from Sheets.
We should investigate whether switching from PNGs to SVGs would simplify the workflow at all or if there are any UX benefits like smaller file sizes or improved scalability.
One potential that would require a lot more work but could significantly improve both the workflow and UX would be to add our own interactivity to the SVGs with JS and CSS. That way we wouldn't need static fallbacks from embedded charts and we can use one figure for all use cases (desktop, mobile, print, reduced data, CORS).
I considered i18n as a potential benefit of SVGs but @RReverser pointed out that the text may be transformed into paths and not easily translated.
The text was updated successfully, but these errors were encountered: