File: graph.template.html

package info (click to toggle)
blender 5.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 329,128 kB
  • sloc: cpp: 2,489,823; python: 349,859; ansic: 261,364; xml: 2,103; sh: 999; javascript: 317; makefile: 193
file content (173 lines) | stat: -rw-r--r-- 6,457 bytes parent folder | download
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
<html>
<head>
  <title>Benchmarks</title>
  <meta charset="UTF-8">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
  <style type="text/css">
    body                    { margin: 20px; font-size: 16px; color: #333; }
    a                       { text-decoration: none; color: #06b; }
    h2                      { color: #222; font-size: 1.4em; }
    h3                      { color: #555; font-size: 1.2em; }
    h4                      { color: #888; font-size: 1.0em; }
    .nav-tabs               { font-size: 1.2em; }
    .tab-content            { margin: 20px 20px; }
    /* Tricks to make chart load with proper width while hidden. */
    .tab-content>.tab-pane  { height: 1px; overflow: hidden; display: block; visibility: hidden; }
    .tab-content>.active    { height: auto; overflow: auto; visibility: visible; }
  </style>
  <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
  <script>
    google.charts.load('current', {'packages':['line', 'bar']});
    google.charts.setOnLoadCallback(draw_charts);

    function transposeDataTable(dt)
    {
      /* Swap rows and columns. Bar and line charts expect different layouts,
       * with this function we can use the same data source for both. */
      var ndt = new google.visualization.DataTable;
      ndt.addColumn('string',dt.getColumnLabel(0));
      for(var x=1; x<dt.getNumberOfColumns(); x++) {
          ndt.addRow([dt.getColumnLabel(x)]);
      }
      for(var x=0; x<dt.getNumberOfRows(); x++) {
          ndt.addColumn('number', dt.getValue(x,0));
          for(var y=1; y<dt.getNumberOfColumns(); y++) {
              ndt.setValue(y-1, x+1, dt.getValue(x,y));
              ndt.setFormattedValue(y-1, x+1, dt.getFormattedValue(x,y));
          }
      }
      return ndt;
    }

    function drawChart(chartsQueue, index) {
      index = index || 0;
      if (index === chartsQueue.length)
        return;

      var chartData = chartsQueue[index];
      var chart;

      if (chartData.chart_type == 'line') {
        chart = new google.charts.Line(document.getElementById(chartData.id));
      } else {
        chart = new google.charts.Bar(document.getElementById(chartData.id));
      }

      google.visualization.events.addOneTimeListener(chart, 'ready', function() {
        /* Auto scale chart elements to display full SVG. */
        var allSvg = document.getElementsByTagName("svg");
        for (var svgIndex = 0; svgIndex < allSvg.length; svgIndex++) {
          allSvg[svgIndex].setAttribute('height', allSvg[svgIndex].getBBox().height);
        }

        drawChart(chartsQueue, index + 1);
      });

      chart.draw(chartData.data, chartData.options);
    }

    function draw_charts()
    {
      /* Load JSON data. */
      var json_data = %JSON_DATA%;

      /* Clear contents. */
      charts_nav_elem = document.getElementById("charts-nav");
      charts_content_elem = document.getElementById("charts-content");
      while(charts_nav_elem.firstChild) {
        charts_nav_elem.removeChild(charts_nav_elem.firstChild);
      }
      while(charts_content_elem.firstChild) {
        charts_content_elem.removeChild(charts_content_elem.firstChild);
      }

      var chartsQueue = [];

      /* Prepare UI and charts queue for each device. */
      for (var i = 0; i < json_data.length; i++)
      {
        benchmark = json_data[i];

        tab_name = benchmark['name'].split(" ")[0];
        tab_id = "benchmark-" + tab_name;
        tab_div = document.getElementById(tab_id);

        if (!tab_div) {
          /* Create tab button. */
          li_nav = document.createElement('li');
          li_nav.class = "nav-item";
          charts_nav_elem.appendChild(li_nav);

          button_nav = document.createElement('button');
          button_nav.id = tab_id + "-tab";
          button_nav.classList.add("nav-link");
          button_nav.setAttribute("data-bs-toggle", "tab");
          button_nav.setAttribute("data-bs-target", "#" + tab_id);
          button_nav.setAttribute("type", "button");
          button_nav.setAttribute("role", "tab");
          button_nav.setAttribute("aria-controls", tab_id);
          button_nav.appendChild(document.createTextNode(tab_name))
          li_nav.appendChild(button_nav);

          /* Create chart container div. */
          tab_div = document.createElement('div');
          tab_div.id = tab_id;
          tab_div.classList.add("tab-pane");
          tab_div.setAttribute("aria-labelledby", button_nav.id);
          charts_content_elem.appendChild(tab_div)

          if (i == 0) {
            button_nav.classList.add("active");
            tab_div.classList.add('show');
            tab_div.classList.add('active');
          }
        }

        /* Create title. */
        subtitle_h3 = document.createElement('h3');
        subtitle_h3.appendChild(document.createTextNode(benchmark['name']));
        tab_div.appendChild(subtitle_h3);
        subtitle_h4 = document.createElement('h4');
        subtitle_h4.appendChild(document.createTextNode(benchmark['device']));
        tab_div.appendChild(subtitle_h4);

        /* Create chart div. */
        chart_div = document.createElement('div');
        chart_div.id = "chart-" + i;
        tab_div.appendChild(chart_div)

        /* Chart drawing options. */
        var options = {
          pointsVisible: true,
          pointSize: 2.5,
          height: 500,
        };

        /* Prepare chart data for queue. */
        var data = new google.visualization.DataTable(benchmark["data"]);
        var chartData = {
          id: chart_div.id,
          data: benchmark['chart_type'] == 'line' ? data : transposeDataTable(data),
          options: options,
          chart_type: benchmark['chart_type']
        };

        chartsQueue.push(chartData);
      }

      /* Start drawing charts sequentially. */
      drawChart(chartsQueue, 0);
    }
  </script>
</head>
<body>
  <h1>Benchmarks</h1>

  <ul class="nav nav-tabs" id="charts-nav" role="tablist">
  </ul>
  <div class="tab-content" id="charts-content">
  </div>

  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</body>
</html>