<div id="myChart" style="width:400px;height:300px;margin:auto;"></div> <script type="text/javascript"> var myChart = echarts.init(document.getElementById('myChart')); $.get('http://api.lwpoor.cn/echarts/getjson').done(function (resule) { //resule = JSON.parse(resule);//把string字符串转换为json数组 myChart.setOption({ title: { text: '异步数据加载示例' }, tooltip: {}, legend: { data:['销量'] }, xAxis: { data: resule.Result.name }, yAxis: {}, series: [{ name: '销量', type: 'bar', data: resule.Result.value }] }); }); </script>
{"State":1,"Message":"成功","Result":{"name":["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"],"value":[5,20,36,10,10,20]}}