[Vuejs]-Django vue js & Highcharts asynchronously fetching data from JSON

1👍

Case is closed. I’m able to achieve it by playing with vue js life cycle hooks. However it still slow enough to load the page. need(4 to 7 seconds) but it works. Here is my template.

<!DOCTYPE html>
<html>
<head>
	<title>Using Vue Axios</title>
	<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
	<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
	<script src="https://code.highcharts.com/highcharts.src.js"></script>
</head>
<body>
	<div id="app">[[dataTitanic]]</div>
	<h1>The Chart Is Shown Below : </h1>
	<div id="container"></div>
	<script type="text/javascript">
		var url = "{% url 'async_chart_data' %}";
		var app = new Vue({
			delimiters : ['[[',']]'],
			el : '#app',
			data(){
				return {
					dataTitanic : null,
				}
			},
			mounted(){
				axios
				  .get(url)
				  .then(response => (this.dataTitanic = response['data']))
			},
			beforeUpdate(){
				Highcharts.chart('container',this.dataTitanic)
			}
		})
	</script>
</body>
</html>

Leave a comment