frontend/static/js/script.js
//function to render the charts in the modal
function to render the charts in the modal
function to render the charts in the modal
function createChartinModal(title, labels, backgroundColor, chartsData, chartType, displayLegend) {
	var ctx = $('#modal-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"
		},
	}
	modalChart = new Chart(ctx, {
		type: chartType,
		data: data,
		options: options
	});
}
function createChartinModal ( title , labels , backgroundColor , chartsData , chartType , displayLegend ) { var ctx = $ ( '#modal-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" } , } modalChart = new Chart ( ctx , { type : chartType , data : data , options : options } ) ; }
function to render the charts in the modal
function to render the charts in the modal
//if you want to display the charts in modal, make sure you have configured the modal in index.html //create the context that will draw the charts over the canvas in the "#modal-chart" div of the modal // 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/