created function that return array of three arrays with 24 values between 0 and 100 for testing dashboard

community
michael.mead 7 years ago
parent 9f9ab8dd39
commit ba2cffd038

@ -16,19 +16,30 @@ dashboard = {
},
initChartist: function(){
function make_array() {
triple_array = [];
for (i=0;i<3;i++){
myarray = Array.from({length: 24}, () => Math.floor(Math.random() * 100))
triple_array.push(myarray)
}
return triple_array
}
// monitoring apps chart
var getData = $.get('/1/app/usage/trend');
getData.done(function(results) {
var data = JSON.parse(results);
console.log('data...',data);
if ($.isEmptyObject(data)){
console.log('data is empty, setting testing values.');
data = [[1,2,3,4,5], [2,5,7,9], [1,3,4,6,8,9]]
var app_usage_trend = JSON.parse(results);
if ($.isEmptyObject(app_usage_trend)){
console.log('app_usage_trend is empty, setting testing values.');
app_usage_trend = [];
random_array = make_array();
app_usage_trend = random_array
}
console.log('data', data);
// monitoring apps chart
var dataChart = {
labels: ['24','23','22','21','20','19','18','17','16','15','14','13','12','11','10','9','8','7','6','5','4','3','2','1' ],
series: data //[[1,2,3], [4,5,6], [1,2,3,5] ] // TODO: Check the order, the graph is by index not name.
series: app_usage_trend //TODO: Check the order, the graph is by index not name.
};
dataChartArray = dataChart.series;
@ -66,10 +77,10 @@ dashboard = {
Chartist.Line('#chartHours', dataChart, optionsChart, responsiveChart);
// cpu and memory --------------------------
// cpu and memory usage--------------------------
var data = {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
series: [[1,2,3,4], [5,6,7]]
series: make_array()
};
@ -94,18 +105,23 @@ dashboard = {
Chartist.Line('#chartActivity', data, options, responsiveOptions);
// var getStatus = $.get('1/get/summary/app_status');
// getStatus.done(function(results) {
// var data = JSON.parse(results)
// let getStatusList = []
// getStatusList.push(data.idle)
// getStatusList.push(data.crash)
// getStatusList.push(data.running)
// Chartist.Pie('#chartPreferences', {
// labels: getStatusList,
// series: getStatusList
// },{donut:true});
// }) /// end getStatus
//app status pie chart, idle, running, crash
var getStatus = $.get('1/app/status');
getStatus.done(function(results) {
var pie_chart = JSON.parse(results);
if ($.isEmptyObject(pie_chart)){
console.log('pie_chart is empty, setting testing values.');
app_status = [1,2,3]
}
// var app_status = [];
// app_status.push(pie_chart.idle);
// app_status.push(pie_chart.crash);
// app_status.push(pie_chart.running);
Chartist.Pie('#chartPreferences', {
labels: app_status,
series: app_status
},{donut:true});
}) /// end getStatus
})
},
// End chartist function

Loading…
Cancel
Save