1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title>
</head> <body> <div id="main" style="width: 600px;height: 400px;margin: 10% auto"></div> <script type="application/json" src="data.json"></script> <script type="application/javascript" src="res/js/jQuery/jquery.js"></script> <script type="application/javascript" src="res/js/echarts/echarts.min.js"></script>
<script> $(document).ready(function (){ const myChart = echarts.init(document.getElementById('main'));
const option = { title: { text:'' }, tooltip: {}, legend: { data: [] }, xAxis: { data: [] }, yAxis: {}, series: [{ name: '', type: '', data: [] } ] };
myChart.setOption(option);
$.getJSON('data.json').done(function (data){ myChart.setOption({ title: { text:data.text }, tooltip: {}, legend: { data: data.legend }, xAxis: { data: data.xAxis }, yAxis: {}, series: [{ name: data.series[0].name, type: data.series[0].type, data: data.series[0].data } ] }) })
}) </script>
</body> </html>
|