Error cause:

Echarts is not called when requesting json data

Solution:

(1) Put the above code in a function, and then call this function in onload

(2) Using jQuery method

<script>
			$(document).ready(function(){
				var chart = document.getElementById('chart');
				var chartData = echarts.init(chart);
	
			    chartData.setOption({
			        title: {
			            text: 'Asynchronous Data Loading Example'
			        },
			        tooltip: {},
			        legend: {
			            data: ['sales']},xAxis: {
			            data: []},yAxis: {},
			        series: [{
			            name: 'sales'.type: 'bar'.data: []}}); $.get('.. /js/data.json').done(function (data) {
					
					console.dir(data);
					// Fill in the data
				    chartData.setOption({
				        xAxis: {
				            data: data.categories
				        },
				        series: [{
				            name: 'sales'.data: data.data
				        }]
				    });
				
				});
				
				function eConsole(param) 
                {
                    console.dir(param);
                }
				
				chartData.on("click",eConsole);
			});
 
		</script>

Copy the code