Skip to content

Commit

Permalink
Merge pull request #254 from Urgau/text-anchor
Browse files Browse the repository at this point in the history
Use text-anchor instead of hardcoded offsets
  • Loading branch information
jonhoo authored Jul 26, 2022
2 parents 2f74fe5 + 7385d4f commit 58ac796
Show file tree
Hide file tree
Showing 46 changed files with 194 additions and 145 deletions.
3 changes: 2 additions & 1 deletion src/flamegraph/flamegraph.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#search { opacity:0.1; cursor:pointer; }
#matched { text-anchor:end; }
#search { text-anchor:end; opacity:0.1; cursor:pointer; }
#search:hover, #search.show { opacity:1; }
#subtitle { text-anchor:middle; font-color:rgb(160,160,160); }
#unzoom { cursor:pointer; }
Expand Down
4 changes: 2 additions & 2 deletions src/flamegraph/flamegraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ function init(evt) {

// Keep search elements at a fixed distance from right edge.
var svgWidth = svg.width.baseVal.value;
searchbtn.attributes.x.value = svgWidth - xpad - 100;
matchedtxt.attributes.x.value = svgWidth - xpad - 100;
searchbtn.attributes.x.value = svgWidth - xpad;
matchedtxt.attributes.x.value = svgWidth - xpad;
};
window.addEventListener('resize', function() {
update_for_width_change();
Expand Down
4 changes: 2 additions & 2 deletions src/flamegraph/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ text {{ font-family:{}; font-size:{}px; fill:rgb(0,0,0); }}
svg,
&mut buf,
TextItem {
x: Dimension::Pixels(image_width as usize - super::XPAD - 100),
x: Dimension::Pixels(image_width as usize - super::XPAD),
y: (opt.font_size * 2) as f64,
text: "Search".into(),
extra: vec![("id", "search")],
Expand All @@ -255,7 +255,7 @@ text {{ font-family:{}; font-size:{}px; fill:rgb(0,0,0); }}
svg,
&mut buf,
TextItem {
x: Dimension::Pixels(image_width as usize - super::XPAD - 100),
x: Dimension::Pixels(image_width as usize - super::XPAD),
y: (style_options.imageheight - (opt.ypad2() / 2)) as f64,
text: " ".into(),
extra: iter::once(("id", "matched")),
Expand Down
9 changes: 5 additions & 4 deletions tests/data/flamegraph/austin/flame.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions tests/data/flamegraph/colors/async-profiler-java.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions tests/data/flamegraph/colors/deterministic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions tests/data/flamegraph/colors/java.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions tests/data/flamegraph/colors/js.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions tests/data/flamegraph/differential/diff-negated.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions tests/data/flamegraph/differential/diff.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions tests/data/flamegraph/factor/factor-2.5.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions tests/data/flamegraph/flamechart/flame.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions tests/data/flamegraph/grey-frames/grey-frames.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions tests/data/flamegraph/inverted/inverted.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions tests/data/flamegraph/nameattr/nameattr.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions tests/data/flamegraph/narrow-blocks/narrow-blocks.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions tests/data/flamegraph/options/colordiffusion.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 58ac796

Please sign in to comment.