One diagram, many views
Draw a system once and show just the part each section needs.
What it shows
Draw a diagram once and show the parts of it that each section needs.
What you learn
A named diagram, views that frame part of it, showing a view elsewhere with from, states that change a diagram step by step, a block drawn once and placed many times.
Try this
- Press Edit on the first diagram, drag the Card payments box lower, and "Behind the counter" shows it in its new place.
- In the screens diagram, add
use screen as four name=Four seats=40andoffice -> four.gate, and a fourth screen appears.
How a booking works at the Regent
Everything between a film-goer picking a seat on their phone and sitting in it.
Front-of-house guide3 screens, 364 seats11 shows a dayDoors open 20 minutes before
Each section of this guide zooms in on one part of the picture above.
The film-goer's side
A film-goer meets three things: the app, the scanner at the door and their seat. They pick the 19:30 showing of The Last Orchard, choose seat F7 and pay £11.50. The e-ticket arrives on their phone a few seconds later.
If someone says their ticket never came, look in the app under My bookings before you sell them another seat.
Behind the counter
The booking service holds the seat first, then takes the money, then sends the e-ticket. A seat held for ten minutes without payment goes back on sale by itself.
Screen 2 between shows
A screen turns round in 18 minutes. Step through it with the bar under the diagram.
The three screens
Each screen has a ticket check and a door. A screen is drawn once, as a block, and placed three times, each with its own name and number of seats.
How it's made
The first diagram is the only full drawing on this page. Its first line, diagram booking, gives it a name, and its two view lines each frame a part of it with a position and a size.
- A view somewhere else is a block of one line:
from booking view front. Change the first diagram, and every view of it follows. - States are named sets of changes, such as
state cleaning { … }. Each line inside says what is different there: a colour, a new text, a box hidden or moved. Thesteplines show one state each. - A block is drawn once between
block screen { … }. Eachuse screen as two name=Two seats=96places a copy, and{name}and{seats}inside it take that copy's values.
Try it yourself
- Press Edit on the first diagram and drag the Card payments box lower. "Behind the counter" shows it in its new place.
- In the first diagram, change
"Regent app"to"Regent website". The film-goer's side follows. - Change
from booking view backtofrom booking view front. That section now shows the other part. - In the screens diagram, add
use screen as four name=Four seats=40andoffice -> four.gate. A fourth screen appears with its own ticket check and door.
Next: Diagrams that move makes links and switches move; Custom diagram shapes draws shapes of your own.
~~~ selfscribe
# Lesson: Draw a diagram once and show the parts of it that each section needs.
# You learn: a named diagram, views that frame part of it, showing a view elsewhere with `from`, states that change a diagram step by step, a block drawn once and placed many times.
# Try this: press Edit on the first diagram, drag the Card payments box lower, and "Behind the counter" shows it in its new place.
# Try this: in the screens diagram, add `use screen as four name=Four seats=40` and `office -> four.gate`, and a fourth screen appears.
# summary: Draw a system once and show just the part each section needs.
# category: diagrams
# tags: document, advanced, work, ideas
# uses: diagram, animation
use markdown
set title One diagram, many views
set style sans wide
set heading-font Fraunces
# ---- Colours, each with its shade for dark pages ----------------------------------------
palette
velvet #9f1239 dark #fda4af
tint color-mix(in srgb, var(--velvet) 10%, transparent)
# ---- "> a line": the line under the title, in the guide's own voice ----------------------
line > _ -> p.lede { margin: -0.3em 0 0.9em; font-size: 1.15em; line-height: 1.5; opacity: 0.82 } as lede
# ---- "facts a | b | c": the cinema at a glance, as tags in a row -------------------------
line facts _ -> p.facts split "|" span.fact { display: flex; flex-wrap: wrap; gap: 0.4em; margin: 0 0 1.4em } as facts
class fact { padding: 0.2em 0.75em; border-radius: 999px; background: var(--tint); color: var(--velvet); font: 600 0.82em/1.6 var(--doc-font-ui) }
# ---- ```flow ... ```: a diagram, drawn by the flow plugin -------------------------------
# Everything inside the block (nodes, links, views, states, steps, blocks) is the plugin's own text.
block ``` flow ... ``` -> flow verbatim
~~~
# How a booking works at the Regent
> Everything between a film-goer picking a seat on their phone and sitting in it.
```flow
diagram booking "Booking a seat"
node viewer "Film-goer" :person at 0,0
node app "Regent app" at 200,0
node api "Booking service" :service at 490,0
node seats "Seat plan\n364 seats" :database at 750,-70
node pay "Card payments" :cloud at 750,70
node ticket "E-ticket\non the phone" :document at 490,180
node scanner "Door scanner" at 200,180
node screen "Screen 2\nrow F, seat 7" color=purple at 0,180
viewer -> app "picks the 19:30" moving
app -> api "seat F7" moving
api -> seats "holds F7"
api -> pay "takes £11.50" moving=slow
api -> ticket "sends" moving
ticket -> scanner "shown at the door" moving
scanner -> screen "in at 19:10" moving
view front "The film-goer's side" at -40,-40 size 370x300
view back "Behind the counter" at 480,-110 size 470x370
```
facts Front-of-house guide | 3 screens, 364 seats | 11 shows a day | Doors open 20 minutes before
Each section of this guide zooms in on one part of the picture above.
## The film-goer's side
A film-goer meets three things: the app, the scanner at the door and their seat. They pick the 19:30 showing of *The Last Orchard*, choose seat F7 and pay £11.50. The e-ticket arrives on their phone a few seconds later.
```flow maxwidth:500px align:center
from booking view front
```
If someone says their ticket never came, look in the app under **My bookings** before you sell them another seat.
## Behind the counter
The booking service holds the seat first, then takes the money, then sends the e-ticket. A seat held for ten minutes without payment goes back on sale by itself.
```flow maxwidth:600px align:center
from booking view back
set moving=on
```
## Screen 2 between shows
A screen turns round in 18 minutes. Step through it with the bar under the diagram.
```flow
set direction=LR
node house "House lights" :lamp at 0,0
node projector "Projector:\nThe Last Orchard" color=purple at 140,-10
node doors "Doors shut" at 360,0
node usher "Usher" :person at 540,0
node board "Now showing: The Last Orchard, 17:00" at 140,120
node crew "Cleaning crew" :person at 540,120
doors -> usher
state film "During the film" {
house color=grey
crew hidden
}
state cleaning "After the credits" {
house color=yellow
projector "Projector:\nloading Paper Moons" color=grey
crew shown
board "Cleaning: back in 15 minutes"
}
state seating "Doors open" {
house color=yellow
projector "Projector:\nadverts and trailers" color=orange
doors "Doors open" color=green
crew hidden
usher at 540,60
board "Now seating: Paper Moons, 19:30"
}
step "16:55 · The film is on, and the crew waits outside": state=film
step "18:52 · The credits end: lights up, the crew goes in": state=cleaning
step "19:10 · Doors open for the next show": state=seating
```
## The three screens
Each screen has a ticket check and a door. A screen is drawn once, as a block, and placed three times, each with its own name and number of seats.
```flow
diagram screens "The three screens"
set direction=LR
block screen "Screen {name}, {seats} seats" name=One seats=212 {
node gate "Ticket check" :decision
node door "Door to Screen {name}"
gate -> door "ticket ok" moving
}
node office "Booking service" :service
use screen as one
use screen as two name=Two seats=96
use screen as three name=Three seats=56
office -> one.gate
office -> two.gate
office -> three.gate
```
## How it's made
The first diagram is the only full drawing on this page. Its first line, `diagram booking`, gives it a name, and its two `view` lines each frame a part of it with a position and a size.
- **A view somewhere else** is a block of one line: `from booking view front`. Change the first diagram, and every view of it follows.
- **States** are named sets of changes, such as `state cleaning { … }`. Each line inside says what is different there: a colour, a new text, a box hidden or moved. The `step` lines show one state each.
- **A block** is drawn once between `block screen { … }`. Each `use screen as two name=Two seats=96` places a copy, and `{name}` and `{seats}` inside it take that copy's values.
## Try it yourself
1. Press Edit on the first diagram and drag the Card payments box lower. "Behind the counter" shows it in its new place.
2. In the first diagram, change `"Regent app"` to `"Regent website"`. The film-goer's side follows.
3. Change `from booking view back` to `from booking view front`. That section now shows the other part.
4. In the screens diagram, add `use screen as four name=Four seats=40` and `office -> four.gate`. A fourth screen appears with its own ticket check and door.
**Next:** *Diagrams that move* makes links and switches move; *Custom diagram shapes* draws shapes of your own.