Skip to content

Commit 4997765

Browse files
authored
Fix downloaded graph PNGs to make them not tiny (#371)
Summary: In the graph dashboard, we attempt to set the size of the download canvas according to the scene size. However, the syntax that we use to do this is no longer supported by d3v4 ([source]), and so this ends up doing nothing. Simply changing the syntax fixes the bug. Fixes #88. [source]: d3/d3#2793 Test Plan: Launch the graph explorer, and click "Download PNG" at left. Before this patch, this always resulted in a 300×150 px image. Now, it results in an image whose size is properly determined by the contents of the graph. wchargin-branch: fix-graph-png-size
1 parent 615eccd commit 4997765

File tree

1 file changed

+5
-4
lines changed
  • tensorboard/plugins/graph/tf_graph_common

1 file changed

+5
-4
lines changed

tensorboard/plugins/graph/tf_graph_common/minimap.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,11 @@ export class Minimap {
222222

223223
// Download canvas width and height are multiples of the style width and
224224
// height in order to increase pixel density of the PNG for clarity.
225-
d3.select(this.downloadCanvas).style(
226-
<any>{ width: sceneSize.width, height: sceneSize.height });
227-
d3.select(this.downloadCanvas).attr(
228-
<any>{ width: sceneSize.width * 3, height: sceneSize.height * 3 });
225+
const downloadCanvasSelection = d3.select(this.downloadCanvas);
226+
downloadCanvasSelection.style('width', sceneSize.width);
227+
downloadCanvasSelection.style('height', sceneSize.height);
228+
downloadCanvasSelection.attr('width', 3 * sceneSize.width);
229+
downloadCanvasSelection.attr('height', 3 * sceneSize.height);
229230

230231
if (this.translate != null && this.zoom != null) {
231232
// Update the viewpoint rectangle shape since the aspect ratio of the

0 commit comments

Comments
 (0)