ECharts 비동기식 데이터 가져오기

4957 단어 ECharts
"java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<html>
<head>
<meta charset="utf-8">
<title>Insert title heretitle>
<script type="text/javascript" src="static/js/jquery-3.1.1.min.js">script>
<script type="text/javascript" src="static/js/echarts.js">script>

head>
<body>
 <div id="main" style="width: 1000px;height:400px;">div>

<script>

var myChart = echarts.init(document.getElementById('main'));

//  
$.get("json_test").done(function(obj){
     var datas = JSON.parse(obj);// json json 
    console.log(datas.series[1]); 
    var dataNam=[];
    for(var i=0;iscript>   
body>
html>

백그라운드 코드
    @ResponseBody
    @RequestMapping("/json_test")
    public Object thisIsTest(){
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:/Users/Administrator/Desktop/test.json"),"utf-8"));

            try {

                StringBuilder sb = new StringBuilder();
                String data = null;
                while ((data = br.readLine())!=null) {
                    sb.append(data);
                }
                System.out.println(sb.toString());
                return sb.toString();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }



        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

좋은 웹페이지 즐겨찾기