ECHARTS如何获取后台数据

时间:2022-11-15 00:27:57
 require(
            [
                'echarts',
'echarts/chart/line',
'echarts/chart/pie',
                'echarts/chart/bar' // 使用柱状图就加载bar模块,按需加载
            ],
            function (ec) {
                // 基于准备好的dom,初始化echarts图表
                var myChart = ec.init(document.getElementById('echart')); 
                myChart.showLoading({  
                text : "图表数据正在努力加载...",  
                effect :'ring',//'spin' | 'bar' | 'ring' | 'whirling' | 'dynamicLine' | 'bubble'  
                textStyle : {fontSize : 20 }  
 });
                var option = {
title:{
text:'财务对比图',
x:80
},
                    tooltip: {
                        show: true
                    },
                    legend: {
                        data:['计划','实际']
                    },
toolbox: {
show : true,
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false},
magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
restore : {show: true},
saveAsImage : {show: true}
}
},
calculable : true,

                    xAxis : [
                        {
                            type : 'category',
                            data : ["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"]
                        }
                    ],
                    yAxis : [
                        {
                            type : 'value'
                        }
                    ],
                    series : [
                        {
                            "name":"计划",
                            "type":"bar",
                            "data":[100, 100, 100, 10, 10, 20,190,30,12,50,52,66]
                        },
{
                    "name":"实际",
                            "type":"line",
                            "data":[15, 50, 40, 10, 10, 20,190,30,12,40,52,66]
                        }
                    ]
                };
//option.series.data=$.makeArray(result);
        
                // 为echarts对象加载数据 
                myChart.setOption(option); 
myChart.hideLoading(); 
            }
        ); 


其中以下代码希望通过AJAX获取到。使用JS和ASP该如何做呢 
series : [
                        {
                            "name":"计划",
                            "type":"bar",
                            "data":[100, 100, 100, 10, 10, 20,190,30,12,50,52,66]
                        },
                        {
                            "name":"实际",
                            "type":"line",
                            "data":[15, 50, 40, 10, 10, 20,190,30,12,40,52,66]
                        }
                    ]

2 个解决方案

#1


#2


我是用的echarts+js+asp
ASP如何处理并返回json数据这块遇到问题了
引用 1 楼 Ragin 的回复:
echarts

#1


#2


我是用的echarts+js+asp
ASP如何处理并返回json数据这块遇到问题了
引用 1 楼 Ragin 的回复:
echarts