Skip to content
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

width and height specification in svg-file #540

Closed
bo-ku-ra opened this issue Dec 27, 2022 · 12 comments · Fixed by #560
Closed

width and height specification in svg-file #540

bo-ku-ra opened this issue Dec 27, 2022 · 12 comments · Fixed by #560
Assignees
Labels
cli This issue is related to the CLI (cmd/d2) improvement Something can be better

Comments

@bo-ku-ra
Copy link
Contributor

The default output of d2.exe is specified as width and height.
If the svg file output by d2.exe is too wide or long, I would like to immediately display the entire figure in Edge (Chromium).
Is there such an option?


Contents of *.svg

<?xml version="1.0" encoding="utf-8"?>
<svg
style="background: white;"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="100%" height="100%" viewBox="-10 -10 1048 5796"><style type="text/css">
<![CDATA[
.shape {
shape-rendering: geometricPrecision;
stroke-linejoin: round;
}
.connection {

<snip>

@cyborg-ts cyborg-ts added this to D2 Dec 27, 2022
@alixander
Copy link
Collaborator

i think this is what you're suggesting: #16.

But I'm not sure. Could you explain more if it's different?

@bo-ku-ra
Copy link
Contributor Author

watch-mode;
I'm drawing a diagram now. no problem.

my suggestion;
The diagram(svg-file) is a finished product .
I email it.
my colleagues will be able to view it easily.

@nhooyr
Copy link
Contributor

nhooyr commented Dec 28, 2022

So when you open the .svg, Edge isn't showing you the full svg and it's clipped until you zoom out/scroll?

I guess we could add a script in the .svg to take care of this.

@bo-ku-ra
Copy link
Contributor Author

yes.

Edge/Chrome for Windows
CTRL + '-' : zoom out (min 25%)
CTRL + '+' : zoom in (max 500%)
I looked for just the right magnification.

please add the script. I hope so.

@alixander alixander added this to the 0.1.4 milestone Dec 28, 2022
@alixander alixander added cli This issue is related to the CLI (cmd/d2) improvement Something can be better labels Dec 28, 2022
@github-project-automation github-project-automation bot moved this to Done in D2 Dec 30, 2022
@nhooyr nhooyr reopened this Dec 30, 2022
@nhooyr
Copy link
Contributor

nhooyr commented Dec 30, 2022

@berniexie #560 (comment) doesn't fix this. The standalone svg needs to resize too and needs a simlar script embedded.

@berniexie
Copy link
Contributor

@berniexie #560 (comment) doesn't fix this. The standalone svg needs to resize too and needs a simlar script embedded.

@nhooyr but how would we know what to resize it to with no browser? Isn't the whole point of svg that it looks good at any size

@nhooyr
Copy link
Contributor

nhooyr commented Dec 30, 2022

@berniexie So you can embed a js script directly into the svg so that when the svg is opened, the js runs. The earliest version of d2 --watch used to use no html and just serve an svg with the js embedded directly.

@bo-ku-ra
Copy link
Contributor Author

i am drawing the diagram when I execute watch-mode.
v0.1.4 changes to default magnification every reloading.
i suffer this specification. Especialy i draw big diagrams.
please keep the original magnification in watch-mode. (same v0.1.3)

@nhooyr
Copy link
Contributor

nhooyr commented Dec 31, 2022

Yea I guess we only want to zoom on the initial load and not for every update thereafter.

@bo-ku-ra
Copy link
Contributor Author

bo-ku-ra commented Jan 6, 2023

i can't use v0.1.4 when i'm drawing the big diagrams because of this issue.
should i use v0.1.3?
how i can avoid it on v0.1.4?

@nhooyr
Copy link
Contributor

nhooyr commented Jan 6, 2023

I would suggest using v0.1.3 or building from master as @berniexie has fixed it.
See https://github.com/terrastruct/d2/blob/master/docs/INSTALL.md#source-release

And you can wait until the next release of course.

@nhooyr nhooyr closed this as completed Jan 6, 2023
@alixander
Copy link
Collaborator

we'll cut 0.1.5 with this fix in the next few days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli This issue is related to the CLI (cmd/d2) improvement Something can be better
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants