How to change label orientation in state diagrams?

+1 vote
asked Jan 4 in Question / help by Alex

Is there a way to adjust the way the labels are oriented along the edges of the diagram? When the diagram is dense with content, it can at times be difficult to interpret it correctly. In this example, you can see that "arrived to next station" is close to 2 edges and it is not immediately clear which of them it refers to:

title Trolleybus states
hide empty description
skinparam ArrowFontSize 10
[*] --> T_off_route : start
state T_off_route

state "Trolleybus off route" as T_off_route {
  state Offline
  state Dispatched
  Offline --> Dispatched

state T_on_route
state "Trolleybus on route" as T_on_route {
  state ArrivedToStation
  state DepartedFromStation
  state CompletedSegment
  state SkippedStation
  ArrivedToStation --> DepartedFromStation  : left station
  DepartedFromStation --> CompletedSegment  : covered first segment
  CompletedSegment --> CompletedSegment  : drive for 1min
  CompletedSegment --> ArrivedToStation  : arrived to next station
  CompletedSegment --> SkippedStation  : deviated from route
  SkippedStation -Left-> T_off_route  : ε
  ArrivedToStation:- recalculate segment length\n- publish "arrival <stationID>"
  DepartedFromStation: publish "departed <stationID>"
  CompletedSegment: publish "completed segment"
  SkippedStation: publish "skipped <stationID>


state T_off_radar

state "Trolleybus off-radar" as T_off_radar {
  state LocationOutdated
  state CompletelyLost
  LocationOutdated --> CompletelyLost  : no data for 5min
  CompletelyLost: publish "<RTU_ID> is lost"

T_off_route --> T_on_route : Arrive to an\n initial station
T_on_route --> T_off_route : Go off-route\n or taken down\n by dispatcher
T_on_route --> T_off_radar : No data for 20s
T_off_radar --> T_off_route: ε


I didn't find a skinparam that would allow me to align the labels to the edges themselves, they're always horizontal.

Can this be accomplished in principle? What alternatives are there, besides manually editing the resulting SVG?

1 Answer

0 votes
answered Jan 4 by Serge Wenger Work (10,130 points)
edited Jan 4 by Serge Wenger Work

I have the 2 following workarounds. (color and new line). It is not fully what you want, but i can help sometimes:

CompletedSegment -[#Blue,thickness=2]-> ArrivedToStation:<color:Blue>arrived to\n<color:Blue>next station