Skip to content

Commit

Permalink
drawflame: Apply line break for multiple subtitles
Browse files Browse the repository at this point in the history
Signed-off-by: Peace Lee <iipeace5@gmail.com>
  • Loading branch information
iipeace committed Sep 27, 2021
1 parent 16bec91 commit 22c6171
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions guider/guider.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__credits__ = "Peace Lee"
__license__ = "GPLv2"
__version__ = "3.9.8"
__revision__ = "210926"
__revision__ = "210927"
__maintainer__ = "Peace Lee"
__email__ = "iipeace5@gmail.com"
__repository__ = "https://github.com/iipeace/guider"
Expand Down Expand Up @@ -5230,7 +5230,9 @@ def printProgress(current=0, dest=0):
def writeFlamegraph(path, samples, title, depth=20):
# flamegraph from https://github.com/rbspy/rbspy/tree/master/src/ui/flamegraph.rs #
# fixed font size: 12, bar height: 15 #
height = 15*depth+100
barHeight = 15
titleHeight = (title.count('<tspan ')+1)*barHeight
height = barHeight*depth+100+titleHeight
width = "1"
flameCode = ('''<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
Expand Down Expand Up @@ -5694,8 +5696,8 @@ def writeFlamegraph(path, samples, title, depth=20):
<text id="unzoom" class="hide" x="10" y="24.00">Reset Zoom (ESC)</text>
<text id="search" x="1090" y="24.00">Search (F3)</text>
<text id="matched" x="1090" y="213.00"></text>
<svg id="frames" x="10" y="20" width="%s">
''' % (height, '\r\n%s' % title if title else '', width)
<svg id="frames" x="10" y="%s" width="%s">
''' % (height, '\r\n%s' % title if title else '', titleHeight, width)

# complete code for flamegraph #
finalCode = flameCode + attrCode + samples + '\n</svg></svg>'
Expand Down Expand Up @@ -6571,7 +6573,7 @@ def getData(self, noTimeout=True):
output = output[0]

# composite packets #
data = data + output
data += output

if not output:
break
Expand Down Expand Up @@ -56767,9 +56769,7 @@ def drawFlame(inputFile=None, callList={}, title=''):
continue

# add a new title #
if title:
title += '\n'
title += newTitle
title += '<tspan x="0" dy="1.2em">%s</tspan>' % newTitle

# merge samples #
for sample, cnt in sampleList.items():
Expand Down

0 comments on commit 22c6171

Please sign in to comment.