Skip to content

Commit

Permalink
add --subtitle option for second level title
Browse files Browse the repository at this point in the history
  • Loading branch information
brendangregg committed Aug 17, 2017
1 parent cef340b commit fad6bf7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions flamegraph.pl
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,14 @@
my $titleinverted = "Icicle Graph"; # " "
my $searchcolor = "rgb(230,0,230)"; # color for search highlighting
my $notestext = ""; # embedded notes in SVG
my $subtitletext = ""; # second level title (optional)
my $help = 0;

sub usage {
die <<USAGE_END;
USAGE: $0 [options] infile > outfile.svg\n
--title TEXT # change title text
--subtitle TEXT # second level title (optional)
--width NUM # width of image (default 1200)
--height NUM # height of each frame (default 16)
--minwidth NUM # omit smaller functions (default 0.1 pixels)
Expand Down Expand Up @@ -162,6 +164,7 @@ sub usage {
'fontwidth=f' => \$fontwidth,
'minwidth=f' => \$minwidth,
'title=s' => \$titletext,
'subtitle=s' => \$subtitletext,
'nametype=s' => \$nametype,
'countname=s' => \$countname,
'nameattr=s' => \$nameattrfile,
Expand All @@ -181,6 +184,7 @@ sub usage {
# internals
my $ypad1 = $fontsize * 4; # pad top, include title
my $ypad2 = $fontsize * 2 + 10; # pad bottom, include labels
my $ypad3 = $fontsize * 2 + 1; # pad top, include subtitle (optional)
my $xpad = 10; # pad lefm and right
my $framepad = 1; # vertical padding for frames
my $depthmax = 0;
Expand Down Expand Up @@ -675,6 +679,7 @@ sub flow {

# draw canvas, and embed interactive JavaScript program
my $imageheight = ($depthmax * $frameheight) + $ypad1 + $ypad2;
$imageheight += $ypad3 if $subtitletext ne "";
my $im = SVG->new();
$im->header($imagewidth, $imageheight);
my $inc = <<INC;
Expand Down Expand Up @@ -1014,6 +1019,9 @@ sub flow {
$im->colorAllocate(200, 200, 200),
);
$im->stringTTF($black, $fonttype, $fontsize + 5, 0.0, int($imagewidth / 2), $fontsize * 2, $titletext, "middle");
if ($subtitletext ne "") {
$im->stringTTF($black, $fonttype, $fontsize, 0.0, int($imagewidth / 2), $fontsize * 4, $subtitletext, "middle");
}
$im->stringTTF($black, $fonttype, $fontsize, 0.0, $xpad, $imageheight - ($ypad2 / 2), " ", "", 'id="details"');
$im->stringTTF($black, $fonttype, $fontsize, 0.0, $xpad, $fontsize * 2,
"Reset Zoom", "", 'id="unzoom" onclick="unzoom()" style="opacity:0.0;cursor:pointer"');
Expand Down

0 comments on commit fad6bf7

Please sign in to comment.