aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/tensorboard/components/tf-event-dashboard/tf-event-dashboard.html
blob: 63087c45e15171538fa3d4fbf31f1fbf6bcf343c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="tf-run-selector.html">
<link rel="import" href="tf-x-type-selector.html">
<link rel="import" href="../tf-color-scale/tf-color-scale.html">
<link rel="import" href="../tf-categorizer/tf-categorizer.html">
<link rel="import" href="tf-line-chart.html">
<link rel="import" href="../tf-collapsable-pane/tf-collapsable-pane.html">
<link rel="import" href="../iron-collapse/iron-collapse.html">
<link rel="import" href="../paper-icon-button/paper-icon-button.html">
<link rel="import" href="../tf-imports/lodash.html">
<link rel="import" href="../tf-dashboard-common/tf-dashboard.html">
<link rel="import" href="../tf-backend/tf-backend.html">

<!--
tf-event-dashboard is a complete frontend that loads runs from a backend,
and creates chart panes that display data for those runs.

It provides a categorizer, run selector, and x type selector, by which the user
can customize how data is organized and displayed.

Each chart has a button that can toggle whether it is "selected"; selectedRuns
charts are larger.

Organizationally, the #plumbing div contains components that have no concrete
manifestation and just effect data bindings or data loading. The #sidebar contains
shared controls like the tf-categorizer, tf-run-selector, and tf-x-type-selector.
The #center div contains tf-line-charts embedded inside tf-collapsable-panes.
-->
<dom-module id="tf-event-dashboard">
  <template>
    <div id="plumbing">
      <tf-color-scale
        id="colorScale"
        runs="[[runs]]"
        out-color-scale="{{colorScale}}"
      ></tf-color-scale>
    </div>

    <tf-dashboard-layout>
      <div class="sidebar">
        <div class="sidebar-section">
          <tf-categorizer
            id="categorizer"
            tags="[[_visibleTags]]"
            categories="{{categories}}"
          ></tf-categorizer>
          <paper-checkbox
            id="download-option"
            checked="{{_showDownloadLinks}}"
          >Data download links</paper-checkbox>
        </div>
        <div class="sidebar-section">
          <tf-x-type-selector
            id="xTypeSelector"
            out-x-type="{{xType}}"
          ></tf-x-type-selector>
        </div>
        <div class="sidebar-section">
          <tf-run-selector
            id="runSelector"
            runs="[[runs]]"
            color-scale="[[colorScale]]"
            out-selected="{{selectedRuns}}"
          ></tf-run-selector>
        </div>
      </div>
      <div class="center">
        <tf-no-data-warning
          data-type="scalar"
          show-warning="[[dataNotFound]]"
        ></tf-no-data-warning>
        <template is="dom-repeat" items="[[categories]]">
          <tf-collapsable-pane name="[[item.name]]" count="[[item.tags.length]]">
            <div class="layout horizontal wrap">
              <template is="dom-repeat" items="[[item.tags]]" as="tag">
                <div class="card">
                  <span class="card-title">[[tag]]</span>
                  <div class="card-content">
                    <tf-line-chart
                      tag="[[tag]]"
                      data-provider="[[dataProvider]]"
                      id="chart"
                      selected-runs="[[validRuns(tag, selectedRuns.*, run2tag.*)]]"
                      x-type="[[xType]]"
                      color-scale="[[colorScale]]"
                      on-keyup="toggleSelected"
                      tabindex="2"
                    ></tf-line-chart>
                    <paper-icon-button
                      class="expand-button"
                      shift$="[[_showDownloadLinks]]"
                      icon="fullscreen"
                      on-tap="toggleSelected"
                    ></paper-icon-button>
                  </div>
                  <template is="dom-if" if="[[_showDownloadLinks]]">
                    <div class="card-bottom-row">
                      <tf-downloader
                        selected-runs="[[selectedRuns]]"
                        tag="[[tag]]"
                        url-fn="[[scalarUrl]]"
                        run-to-tag="[[run2tag]]"
                      >
                      </tf-downloader>
                    </div>
                  </template>
                </div>
              </template>
            </div>
          </tf-collapsable-pane>
        </template>
      </div>
    </tf-dashboard-layout>

    <style include="dashboard-style"></style>

  </template>

  <script>
    Polymer({
      is: "tf-event-dashboard",
      behaviors: [
        TF.Dashboard.ReloadBehavior("tf-line-chart"),
        TF.Backend.Behavior,
      ],
      properties: {
        dataType: {value: "scalar"},
        router: Object,
        scalarUrl: {
          type: Function,
          computed: "_getScalarUrl(router)",
        },
        _visibleTags: {
          type: Array,
          computed: "_getVisibleTags(selectedRuns.*, run2tag.*)"
        },
        _showDownloadLinks: {
          type: Boolean,
          notify: true,
          value: TF.URIStorage.getBooleanInitializer('_showDownloadLinks',
              false),
          observer: '_showDownloadLinksObserver'
        },
        colorScale: {
          type: Object,
          notify: true,
        },
      },
      attached: function() {
        this.async(function() {
          this.fire("rendered");
        });
      },
      observers: ['redraw(_showDownloadLinks)'],
      redraw: function(_showDownloadLinks) {
        var els = this.getElementsByTagName("tf-line-chart");
        for (var i=0; i<els.length; i++) {
          els[i].redraw();
        }
      },
      _getVisibleTags: function() {
        var keys = this.selectedRuns;
        var dict = this.run2tag;
        return _.union.apply(null, keys.map(function(k) {return dict[k]}));
      },
      _getScalarUrl: function() {
        return this.router.scalars;
      },
      _showDownloadLinksObserver: TF.URIStorage.getBooleanObserver(
          '_showDownloadLinks', false),
      toggleSelected: function(e) {
        var currentTarget = Polymer.dom(e.currentTarget);
        var parentDiv = currentTarget.parentNode.parentNode;
        parentDiv.classList.toggle("selected");
        var chart = currentTarget.previousElementSibling;
        if (chart) {
          chart.redraw();
        }
      },
      validRuns: function(tag, runsChange, run2tagChange) {
        var _this = this;
        var result = this.selectedRuns.filter(function(r) {
          return _this.run2tag[r] && _this.run2tag[r].indexOf(tag) !== -1;
        });
        return result;
      },
    });
  </script>
</dom-module>