static/js/script.js
//function to create the charts & render it to the canvas
function to create the charts & render it to the canvas
function to create the charts & render it to the canvas
function createChart(title, labels, backgroundColor, chartsData, chartType, displayLegend) {
	var html = '<div class="chart-container"> <span class="modal-trigger" id="expand" title="expand" href="#modal1"><i class="fa fa-external-link" aria-hidden="true"></i></span> <canvas id="chat-chart" ></canvas> </div> <div class="clearfix"></div>'
	$(html).appendTo('.chats');
	var ctx = $('#chat-chart');
	var data = {
		labels: labels,
		datasets: [{
			label: title,
			backgroundColor: backgroundColor,
			data: chartsData,
			fill: false
		}]
	};
	var options = {
		title: {
			display: true,
			text: title
		},
		layout: {
			padding: {
				left: 5,
				right: 0,
				top: 0,
				bottom: 0
			}
		},
		legend: {
			display: displayLegend,
			position: "right",
			labels: {
				boxWidth: 5,
				fontSize: 10
			}
		}
	}
	chatChart = new Chart(ctx, {
		type: chartType,
		data: data,
		options: options
	});
	scrollToBottomOfResults();
}
function createChart ( title , labels , backgroundColor , chartsData , chartType , displayLegend ) { var html = '<div class="chart-container"> <span class="modal-trigger" id="expand" title="expand" href="#modal1"><i class="fa fa-external-link" aria-hidden="true"></i></span> <canvas id="chat-chart" ></canvas> </div> <div class="clearfix"></div>' $ ( html ) . appendTo ( '.chats' ) ; var ctx = $ ( '#chat-chart' ) ; var data = { labels : labels , datasets : [ { label : title , backgroundColor : backgroundColor , data : chartsData , fill : false } ] } ; var options = { title : { display : true , text : title } , layout : { padding : { left : 5 , right : 0 , top : 0 , bottom : 0 } } , legend : { display : displayLegend , position : "right" , labels : { boxWidth : 5 , fontSize : 10 } } } chatChart = new Chart ( ctx , { type : chartType , data : data , options : options } ) ; scrollToBottomOfResults ( ) ; }
function to create the charts & render it to the canvas
function to create the charts & render it to the canvas
//create the ".chart-container" div that will render the charts in canvas as required by charts.js, // for more info. refer: https://www.chartjs.org/docs/latest/getting-started/usage.html //create the context that will draw the charts over the canvas in the ".chart-container" div // Once you have the element or context, instantiate the chart-type by passing the configuration, //for more info. refer: https://www.chartjs.org/docs/latest/configuration/ //draw the chart by passing the configuration