-
Notifications
You must be signed in to change notification settings - Fork 87
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
CSS Defined Styles are lost #9
Comments
Yeah that is a lot easier. Wish I had seen svgsaver before trying to mess around with CGI scripts. For reference (as there aren't specific instructions here) I am making/testing visualisations in D3 and displaying them locally or on gist/ blocks. for the local work i was using the python SimpleHttpServer. for the download.pl script to work though you need to put download.pl in
I guess there is another way of installing these packages without using the cpan prompt, I have seen it and it looks messy, but tbh I don't really do perl. Anyway then you can do (for python 2.7, its different in python3):
Then you can download your svg, but yeah as all you are doing is ripping out the svg and pinging it back as a file all the css is missing. I guess you could get the css too and concatenate that to the start of the The svgsaver is much easier to deal with but will produce quite big svgs if you have a large number of elements as all the elements are individually styled, instead of copying the css across, which I think you can do for svgs. something like:
Though this will actually modify the DOM which i guess is bad and also you wont get the correct css if you are using an
Anyway it was all very interesting. Are there plans to get SvgSaver onto a CDN? |
Yes, right now I think one problem with copying the style element as you have shown is it will miss styles like this, since the container elements are not serialized.
|
One trouble with the XML serialization you are doing here is that CSS defined styles are lost. This is a problem I'm working on here: https://github.com/Hypercubed/svgsaver . If you include svgsaver in this project it might be as simple as replacing this line: https://github.com/agordon/d3export_demo/blob/master/index.html#L174 with
svgsaver.getHTML(svg)
.You might also eliminate the need for a server for downloading SVG and PNG (with some caveats)
The text was updated successfully, but these errors were encountered: