Commit c4eb8c34 authored by Leo Gordon's avatar Leo Gordon
Browse files

backward-compatible way to configure box colours through the JSON config (omit...

backward-compatible way to configure box colours through the JSON config (omit category to get an empty frame)
parent f42bf84b
...@@ -70,8 +70,9 @@ ...@@ -70,8 +70,9 @@
"Accu" : { "Colour" : "darkgreen" } "Accu" : { "Colour" : "darkgreen" }
}, },
"Box" : { "Box" : {
"ColourScheme" : "blues9", "Semaphore" : { "ColourScheme" : "blues9", "ColourOffset" : 1 },
"ColourOffset" : 1 "MainPipeline" : { "ColourScheme" : "pastel19", "ColourOffset" : 3 },
"OtherPipeline" : { "ColourScheme" : "pastel19", "ColourOffset" : 8 }
}, },
"DisplayStats" : "barchart", "DisplayStats" : "barchart",
......
...@@ -240,9 +240,9 @@ sub build { ...@@ -240,9 +240,9 @@ sub build {
$self->graph->cluster_2_nodes( \%cluster_2_nodes ); $self->graph->cluster_2_nodes( \%cluster_2_nodes );
$self->graph->main_pipeline_name( $main_pipeline->hive_pipeline_name ); $self->graph->main_pipeline_name( $main_pipeline->hive_pipeline_name );
$self->graph->semaphore_bgcolour( [$self->config_get('Box', 'ColourScheme'), $self->config_get('Box', 'ColourOffset')] ); $self->graph->semaphore_bgcolour( [$self->config_get('Box', 'Semaphore', 'ColourScheme'), $self->config_get('Box', 'Semaphore', 'ColourOffset')] );
$self->graph->main_pipeline_bgcolour( ['pastel19', 3] ); $self->graph->main_pipeline_bgcolour( [$self->config_get('Box', 'MainPipeline', 'ColourScheme'), $self->config_get('Box', 'MainPipeline', 'ColourOffset')] );
$self->graph->other_pipeline_bgcolour( ['pastel19', 8] ); $self->graph->other_pipeline_bgcolour( [$self->config_get('Box', 'OtherPipeline', 'ColourScheme'), $self->config_get('Box', 'OtherPipeline', 'ColourOffset')] );
} }
return $self->graph(); return $self->graph();
......
...@@ -87,11 +87,12 @@ sub other_pipeline_bgcolour { ...@@ -87,11 +87,12 @@ sub other_pipeline_bgcolour {
sub display_subgraph { sub display_subgraph {
my ($self, $cluster_name, $depth) = @_; my ($self, $cluster_name, $depth) = @_;
my $box_colour = $depth my $box_colour_pair = $depth
? $self->semaphore_bgcolour ? $self->semaphore_bgcolour
: ( $cluster_name eq $self->main_pipeline_name) : ( $cluster_name eq $self->main_pipeline_name)
? $self->main_pipeline_bgcolour ? $self->main_pipeline_bgcolour
: $self->other_pipeline_bgcolour; : $self->other_pipeline_bgcolour;
my ($colour_scheme, $colour_offset) = $box_colour_pair && @$box_colour_pair;
my $prefix = "\t" x $depth; my $prefix = "\t" x $depth;
my $text = ''; my $text = '';
...@@ -100,14 +101,16 @@ sub display_subgraph { ...@@ -100,14 +101,16 @@ sub display_subgraph {
# uncomment the following line to see the cluster names: # uncomment the following line to see the cluster names:
# $text .= $prefix . "\tlabel=\"$cluster_name\";\n"; # $text .= $prefix . "\tlabel=\"$cluster_name\";\n";
if($colour_scheme) {
$text .= $prefix . "\tstyle=filled;\n"; $text .= $prefix . "\tstyle=filled;\n";
if(ref($box_colour)) { # it must be a (scheme,offset) pair arrayref:
my ($colour_scheme, $colour_offset) = @$box_colour; if(defined($colour_offset)) {
$text .= $prefix . "\tcolorscheme=$colour_scheme;\n"; $text .= $prefix . "\tcolorscheme=$colour_scheme;\n";
$text .= $prefix . "\tcolor=".($depth+$colour_offset).";\n"; $text .= $prefix . "\tcolor=".($depth+$colour_offset).";\n";
} else { # it's just a simple colour: } else { # it's just a simple colour:
$text .= $prefix . "\tcolor=${box_colour};\n"; $text .= $prefix . "\tcolor=${colour_scheme};\n";
} }
} # otherwise just draw a black frame around the subgraph
foreach my $node_name ( @{ $self->cluster_2_nodes->{ $cluster_name } || [] } ) { foreach my $node_name ( @{ $self->cluster_2_nodes->{ $cluster_name } || [] } ) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment