RFR: 6682: Flamegraph gets cutoff when resized horizontally to increase the width

Alex Macdonald aptmac at openjdk.java.net
Fri Jan 31 17:59:28 UTC 2020

On Fri, 31 Jan 2020 17:30:38 GMT, Miroslav Wengner <mwengner at openjdk.org> wrote:

>> Hi!
>> This PR addresses JMC-6682 [[0]](https://bugs.openjdk.java.net/browse/JMC-6682), in which the flamegraph can be cutoff when resizing to increase the width.
>> The issue is that the `d3-flame-graph` `width()` function updates the labels, but not the overall `svg` width. As a result, increasing the width of the container will cause the graph dimensions to increase, but the `svg width` stays the same as its initialized value, so clipping can occur. I've raised this as an issue in the upstream repo [[1]](https://github.com/spiermar/d3-flame-graph/issues/146), but altering the width can be done via `css`. If the `svg width` is set to `100%`, then it will fill the `chart` div, and the flamegraph will be displayed in its entirety. This width change also removes excess whitespace that results from resizing the chart smaller, and centers the chart in the view. I included a `css` file for the width value, because placing it in the template html was causing Eclipse to error when reading the html. Does the css file require a license header? I can add one if so.
>> There are also two other changes here, but I can remove this if desired. The first being that Eclipse kept throwing NPEs when trying to open `flameviewColoring.js`, because it couldn't find the file unless the path wasn't specified to be `src/main/js/[..]`. The second is that the chart container was a SWT `SashForm`, but this could have been a `Composite` because we aren't doing anything with the sash (unless that was a future usage type of thing).
>> [0] https://bugs.openjdk.java.net/browse/JMC-6682
>> [1] https://github.com/spiermar/d3-flame-graph/issues/146
>> Before:
>> ![before-gif](https://user-images.githubusercontent.com/10425301/73555530-ce0d3800-441b-11ea-8e17-7ba33a95a133.gif)
>> After:
>> ![fixed-gif](https://user-images.githubusercontent.com/10425301/73555525-cbaade00-441b-11ea-84e3-3085690e1c0f.gif)
> I've fixed it in my PR 6677 too, I didn't know about this ticket. There will be few minor conflicts on the javascript side.
> Have you also tested resizing the main JMC window, more than initiated default size ?

> I've fixed it in my PR 6677 too, I didn't know about this ticket. There will be few minor conflicts on the javascript side.

Ah fair enough, I didn't realize it was also included in 6677. I had opened the ticket after searching JIRA and not finding an existing one.

Your PR fixes the increasing width issue, but when shrinking it still seems to keep excess whitespace to the right of the chart because the SVG doesn't resize to be smaller; the `svg width=100%` used in this PR would address that.

I can close this PR and make reference on the bug that it'll get closed by #43 .


PR: https://git.openjdk.java.net/jmc/pull/44

More information about the jmc-dev mailing list