2
votes

I'm currently using PlantUML to design my database's ERD. All's well, the diagram is complete, but I'm trying to add a background color to my entities, to dintinguish them in their respective schemas.

I'm thinking of a backgroung color for the entities, or maybe a colored rectangle that holds the entities within it.

I tried using skinparam with the name of the entity, with its alias...

skinparam entity {
  backgroundColor<<usr>> DarkOrchid
}
skinparam entity {
  backgroundColor<<User>> DarkOrchid
}

None of these work... Can anybody help?

Thanks

========= EDIT

As requested, a small example:

'==========='
'auth schema'
entity "User" as usr {
  *id : number <<PK>>
  --
  password: varchar
  salt: varchar
  role: number <<FK>>
  last_login_at : datetime
  is_active : boolean
}

entity "User Role" as url {
  *id : number <<PK>>
  --
  name: varchar
  clearance_lvl: text
  is_active : boolean
}

'====================='
'personnel data schema'

entity "Professor" as prof {
  *id : number <<PK>>
  --
  name: varchar
  office: integer
  user_id: number <<FK>>
  wage: number
  last_login_at : datetime
  is_active : boolean
}

entity "Student" as stu {
  *id : number <<PK>>
  --
  name: varchar
  semester: text
  user_id: number <<FK>>
  specialization: text
  is_active : boolean
}

usr ||--o{ url
prof ||--|| usr
stu ||--|| usr

This generates the following diagram:

default diagram

And I want to see something like this:

colored diagram

Or at least somthing like this:

background rectangle diagram

1
Can you please add a small complete example that shows your problem?albert
Added visual aids and the example diagram. Is it clear what I'm looking for here? I thought this would have a simple solution, but I'm really struggling haha ThanksPstr

1 Answers

3
votes

The entity object uses the skinparams of class ! So, you would have to say skinparam class instead of skinparam entity to change the background color of your entities.

To apply a certain background color to a selection of entities, you would have to add a stereotype to them so that they can be identified by the skinparam class command. For example, you could add <<personnel>> to the Professor and Student entities and BackgroundColor<<personnel>> to skinparam class.

This should fulfill the requirements of your first example:

skinparam  class {
    BackgroundColor<<personnel>> #A9DCDF
}


'==========='
'auth schema'
entity "User" as usr {
  *id : number <<PK>>
  --
  password: varchar
  salt: varchar
  role: number <<FK>>
  last_login_at : datetime
  is_active : boolean
}

entity "User Role" as url {
  *id : number <<PK>>
  --
  name: varchar
  clearance_lvl: text
  is_active : boolean
}

'====================='
'personnel data schema'

entity "Professor" as prof <<personnel>> {
  *id : number <<PK>>
  --
  name: varchar
  office: integer
  user_id: number <<FK>>
  wage: number
  last_login_at : datetime
  is_active : boolean
}

entity "Student" as stu <<personnel>> {
  *id : number <<PK>>
  --
  name: varchar
  semester: text
  user_id: number <<FK>>
  specialization: text
  is_active : boolean
}

usr ||--o{ url
prof ||--|| usr
stu ||--|| usr

To implement your second example, you could wrap your entities into packages and apply a different background directly as part of the package statement.

'==========='
'auth schema'
package "auth schema" #B4A7E5 {
entity "User" as usr {
}

entity "User Role" as url {
}
}

'====================='
'personnel data schema'
package "personnel data schema" #A9DCDF {
entity "Professor" as prof <<person>> {
}

entity "Student" as stu <<person>> {
}

usr ||--o{ url
prof ||--|| usr
stu ||--|| usr