my ($cluster, $column_links) = @_;
'label' => "$db_team schema diagram: $cluster tables",
'fontsize' => 20,
$column_links
? ( 'rankdir' => 'LR', 'concentrate' => 'true', )
: ( 'splines' => 'ortho', ),
);
foreach my $table_name (sort keys %{$documentation->{$cluster}->{tables}}) {
}
my %clusters_to_draw = ($cluster => 1);
my %other_table_fields;
my @drawn_fks;
foreach my $table_name (sort keys %table_documentation) {
foreach my $fk (@{$table_documentation{$table_name}->{foreign_keys}}) {
if ($table_documentation{$table_name}->{category} eq $cluster) {
$other_table_fields{$fk->[1]}->{$fk->[2]} = 1;
$clusters_to_draw{ $table_documentation{$fk->[1]}->{category} } = 1;
push @drawn_fks, [$table_name, @$fk];
} elsif ($table_documentation{$fk->[1]}->{category} eq $cluster) {
$other_table_fields{$table_name}->{$fk->[0]} = 1;
$clusters_to_draw{ $table_documentation{$table_name}->{category} } = 1;
push @drawn_fks, [$table_name, @$fk];
}
}
}
foreach my $table_name (sort keys %other_table_fields) {
sub_table_box($graph, $table_name, $other_table_fields{$table_name} || {})
if $cluster ne $table_documentation{$table_name}->{category};
}
foreach my $fk (@drawn_fks) {
my $table_name = shift @$fk;
$graph->add_edge($table_name => $fk->[1],
'style' => 'dashed',
$column_links ? (
'from_port' => $fk->[0].':e',
'to_port' => $fk->[2].':w',
) : (),
);
}
foreach my $h (sort keys %clusters_to_draw) {
#next unless $h eq $cluster;
my $c =
blend_colors($documentation->{$h}->{colour},
'#FFFFFF', 0.8);
$graph->cluster_2_attributes()->{$cluster_id} = {
'cluster_label' => $h,
($h eq $cluster) ?
( 'style' => 'rounded,filled,noborder', 'fill_colour_pair' => ["#$c"], )
: ( 'style' => 'filled,noborder', 'fill_colour_pair' => ['white'] ),
};
my @cluster_nodes;
$graph->cluster_2_nodes()->{$cluster_id} = \@cluster_nodes;
foreach my $t (sort keys %{$documentation->{$h}->{tables}}) {
push @cluster_nodes, $t if (($h eq $cluster) || $other_table_fields{$t});
}
}
return $graph;
}