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(){ 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'); var getData = $.get('/1/app/usage/trend');
getData.done(function(results) { getData.done(function(results) {
var data = JSON.parse(results); var app_usage_trend = JSON.parse(results);
console.log('data...',data); if ($.isEmptyObject(app_usage_trend)){
if ($.isEmptyObject(data)){ console.log('app_usage_trend is empty, setting testing values.');
console.log('data is empty, setting testing values.'); app_usage_trend = [];
data = [[1,2,3,4,5], [2,5,7,9], [1,3,4,6,8,9]] random_array = make_array();
app_usage_trend = random_array
} }
console.log('data', data);
// monitoring apps chart
var dataChart = { 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' ], 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; dataChartArray = dataChart.series;
@ -66,10 +77,10 @@ dashboard = {
Chartist.Line('#chartHours', dataChart, optionsChart, responsiveChart); Chartist.Line('#chartHours', dataChart, optionsChart, responsiveChart);
// cpu and memory -------------------------- // cpu and memory usage--------------------------
var data = { var data = {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], 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); Chartist.Line('#chartActivity', data, options, responsiveOptions);
// var getStatus = $.get('1/get/summary/app_status'); //app status pie chart, idle, running, crash
// getStatus.done(function(results) { var getStatus = $.get('1/app/status');
// var data = JSON.parse(results) getStatus.done(function(results) {
// let getStatusList = [] var pie_chart = JSON.parse(results);
// getStatusList.push(data.idle) if ($.isEmptyObject(pie_chart)){
// getStatusList.push(data.crash) console.log('pie_chart is empty, setting testing values.');
// getStatusList.push(data.running) app_status = [1,2,3]
// Chartist.Pie('#chartPreferences', { }
// labels: getStatusList, // var app_status = [];
// series: getStatusList // app_status.push(pie_chart.idle);
// },{donut:true}); // app_status.push(pie_chart.crash);
// }) /// end getStatus // app_status.push(pie_chart.running);
Chartist.Pie('#chartPreferences', {
labels: app_status,
series: app_status
},{donut:true});
}) /// end getStatus
}) })
}, },
// End chartist function // End chartist function

Loading…
Cancel
Save