Comments (17)
I’m sorry, I’m afraid I don’t understand exactly what you are saying or trying to accomplish here. When I have some time I will try to render the diagram that results from this code and see if that helps, but it will probably have to wait until after work.
from bytefield-svg.
I am certainly willing to believe there is some interaction that I haven’t properly accounted for yet, though! I extended several things in different directions recently without spending enough time in a hammock thinking about how they might affect each other. I am sure we can find a good solution though. 😄
from bytefield-svg.
Basically, I am trying to change the row height after drawing a row.
This needs to happen after advancing to the next row, but before drawing the first box on the next row.
I can do that with an explicit next-row, and then redefine the height, but that looses the automatic row heading on the first row.
from bytefield-svg.
Yeah, I guessed it was the auto-headers that were probably involved. Those were a cool feature I snuck in later on. Does manually adding the first row header in that circumstance solve it for now, or does that lead to other problems in later rows? One option might be to add a :next-row-height
attribute you could pass to draw-box
, and it would apply it after it called next-row
internally, but would have no effect if the box wasn’t the start of a new row. Any way you slice it, I can’t shield diagram authors from all of the complexity here.
from bytefield-svg.
Manually adding the first doesn’t update the next header. I suppose this is not a big issue since I am auto generating my diagrams.
What I was trying to do was figuring out if I could call the auto header drawing/update function manually, but I am a bit lost on this and my clojure experience is pretty much 2 days old 😉
from bytefield-svg.
This is the part where I didn’t understand what you meant, but after work when I have time to experiment with your sample code I’ll get there. Thanks for raising this.
from bytefield-svg.
…actually, snuck a little time at lunch to try it and see the problem. Ok, now I can look at the code and try to remember how all that stuff works. 😄
from bytefield-svg.
Ok, the problem is that next-row
is low level and doesn’t take part in the box counting and address updating. One quick and dirty alternative is to add this line after you call next-row
, where you are setting row-height
back down:
(swap! diagram-state update :address + 16)
But that is not a great answer. If you could call auto-advance-row
instead of next-row
before drawing the first box on the second row, it would take care of drawing both headers for you and updating the address of the current row. But it would draw both headers using the current row height, so the new row’s header would be in the wrong place. And that function is private because of such concerns, so you can’t call it without hackery anyway. I think the only convenient answer will be adding support for setting a new row height by passing an attribute to draw-box
like I was thinking above.
from bytefield-svg.
Except, that shortcut ends up not drawing either of the first row two labels, ugh. Yes, this is going to need internal support to be usable. Either passing :next-row-height
as an attribute to draw-box
, or having another global setting, like :standard-row-height
which the row height gets reset to whenever an auto-advance happens, in case the current row was temporarily set to something different. I think that would be more surprising and confusing than the draw-box
attribute, so I am leaning towards that approach.
from bytefield-svg.
Ok, I have a solution, @lorrden although I forgot to tag this issue in the commit, c22daf5
With this change in place, if you tweak your source like this:
(def row-height 60)
(draw-column-headers)
(draw-box "version" {:span 3})
(draw-box (text "type" {:writing-mode "vertical-rl"}) {:span 1})
(draw-box "dfh" {:span 1})
(draw-box "apid" {:span 11})
(draw-box "seq. flags" {:span 2 :next-row-height 30})
(draw-box "sequence count" {:span 14})
(draw-box "packet length" {:span 16})
(draw-box "shf" {:span 1})
(draw-box "pusvers" {:span 3})
(draw-box "ack" {:span 4})
(draw-box "service type" {:span 8})
(draw-box "service subtype" {:span 8})
(draw-gap)
(draw-box "packet error control" {:span 16})
It produces a diagram like https://deepsymmetry.org/images/test-next-row-height.svg
The documentation is updated in the draw-box attributes and at the bottom of the vertical text section.
Is there any way you can run from source to see if it is working for you? Or are you going to have to wait until I do another release, along with whatever other tool chain you are using?
from bytefield-svg.
I tried to clone and build myself, but I ran into classpath issues when shadow-cljs is launched :(
Clojure is installed via apt-get on my Debian machine.
I think I will wait for the next release.
from bytefield-svg.
Thanks for trying, and sorry to hear that. I’ll push a release to npm today, you should at least be able to swap that in to your tool chain by messing with your node modules folder until whatever parent project is updated. I can always do more as you identify other areas for improvement.
from bytefield-svg.
All right, release 1.4.2 has been published, @lorrden
from bytefield-svg.
Whoops! I had to quickly replace it with release 1.4.3 because I had forgotten to build a release version before publishing, and discovered the problem when trying to build a new release of asciidoctor-bytefield which used it. But asciidoctor-bytefield 1.2.0 has been published now as well.
from bytefield-svg.
@lorrden could you let me know if this has been addressed in a way that works for you? If I don’t hear anything i will close the issue for inactivity, but confirmation would be appreciated.
from bytefield-svg.
Yes, it is working great. Sorry for not closing the ticket.
from bytefield-svg.
Glad to hear it, thanks!
from bytefield-svg.
Related Issues (20)
- Consider an option to set the viewport HOT 2
- Add support for bit fields HOT 5
- Pull in some useful functions from other namespaces
- Omit XML processing structures for generating HTML embedded SVG
- Declare the namespaces in the <svg> HOT 8
- Support rotation of box labels HOT 6
- defattrs should call eval-attribute-spec
- Long boxes HOT 11
- Add more examples HOT 3
- Set svg background HOT 4
- Allow boxes-per-row > 16 HOT 4
- CLI Error - Could Not Resolve Symbol: Address HOT 2
- Support automatic dark mode HOT 4
- Add draw-column-headers Function in bytefield-svg HOT 3
- Box borders should be more flexible HOT 1
- draw-box should auto advance rows
- Have draw-gap handle labels and finishing previous row
- Small/vertical draw-gap function HOT 10
- Support padding to a particular address
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bytefield-svg.