1 /*******************************************************************************
2 * Copyright (c) 2017 Rajesh Kudaka <4k.rajesh@gmail.com>
3 * Copyright (c) 2018 Intel Corporation.
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Apache License, Version 2.0
7 * which accompanies this distribution, and is available at
8 * http://www.apache.org/licenses/LICENSE-2.0
9 ******************************************************************************/
13 function create_tree(jstree_data)
15 $('#data_selector').jstree({
16 plugins: ['checkbox'],
32 function create_table(table_data, timestamps)
34 var tab, tr, td, tn, tbody, keys, key, curr_data, val;
36 tab = document.getElementsByTagName('table')[0];
37 tbody = document.createElement('tbody');
38 // create table headings using timestamps
39 tr = document.createElement('tr');
40 td = document.createElement('td');
41 tn = document.createTextNode('Timestamps');
44 for (var k = 0; k < timestamps.length; k++) {
45 td = document.createElement('td');
46 tn = document.createTextNode(timestamps[k]);
50 tbody.appendChild(tr);
52 keys = Object.keys(table_data);
53 for (var i = 0; i < keys.length; i++) {
55 tr = document.createElement('tr');
56 td = document.createElement('td');
57 tn = document.createTextNode(key);
60 // add each piece of data as its own column
61 curr_data = table_data[key];
62 for (var j = 0; j < curr_data.length; j++) {
64 td = document.createElement('td');
65 tn = document.createTextNode(val === None ? '' : val);
69 tbody.appendChild(tr);
71 tab.appendChild(tbody);
76 // delete rows of the table
77 var tab = document.getElementsByTagName('table')[0];
78 for (var i = tab.rows.length - 1; i >= 0; i--) {
83 function create_graph(cnvGraph, timestamps)
85 return new Chart(cnvGraph, {
114 animationDuration: 0,
126 responsiveAnimationDuration: 0,
127 maintainAspectRatio: false,
132 function update_graph(objGraph, datasets)
136 '#228B22', // ForestGreen
137 '#FF8C00', // DarkOrange
138 '#00008B', // DarkBlue
139 '#FF00FF', // Fuchsia
140 '#9ACD32', // YellowGreen
142 '#4169E1', // RoyalBlue
144 '#20B2AA', // LightSeaGreen
145 '#8A2BE2', // BlueViolet
151 {s: 'triangle', r: 4},
153 {s: 'rectRot', r: 5},
156 datasets.forEach(function(d, i) {
157 var color = colors[i % colors.length];
158 var point = points[i % points.length];
159 d.borderColor = color;
160 d.backgroundColor = color;
161 d.pointStyle = point.s;
162 d.pointRadius = point.r;
163 d.pointHoverRadius = point.r + 1;
165 objGraph.data.datasets = datasets;