Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions tensorboard/plugins/scalar/tf_scalar_dashboard/tf-scalar-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@
title="Fit domain to data"
></paper-icon-button>
<template is="dom-if" if="[[showDownloadLinks]]">
<paper-menu-button on-paper-dropdown-open="_updateDownloadLink">
<paper-menu-button
on-paper-dropdown-open="_updateDownloadLink"
on-paper-dropdown-close="_removeDownloadLink">
<paper-icon-button
class="dropdown-trigger"
slot="dropdown-trigger"
Expand Down Expand Up @@ -314,11 +316,13 @@
},
_updateDownloadLink() {
const svgStr = this.$$('tf-line-chart-data-loader').exportAsSvgString();
// The SVG code string may include hash characters, such as an
// attribute `clipPath="url(#foo)"`. Thus, we base64-encode the
// data so that such a hash is not interpreted as a fragment
// specifier, truncating the SVG. (See issue #1874.)
this.$$('#svgLink').href = `data:image/svg+xml;base64,${btoa(svgStr)}`;
const bytes = new TextEncoder().encode(svgStr);
const blob = new Blob([bytes], {type: 'image/svg+xml'});
this.$$('#svgLink').setAttribute('href', URL.createObjectURL(blob));
},
_removeDownloadLink() {
URL.revokeObjectURL(this.$$('#svgLink').href);
this.$$('#svgLink').removeAttribute('href');
},
_runsFromData(data) {
return data.map((datum) => datum.run);
Expand Down