<!DOCTYPE html>
<html style="height: 100%">
   <head>
       <meta charset="utf-8">
   </head>
<?php
ini_set('error_reporting', E_ALL);
include_once "inc/getData.inc.php";
$day_st='20180101';
$day_end=date('Ymd');
$data=getIndexData('000001.SH',$day_st,$day_end);
$data1=getIndexData('399001.SZ',$day_st,$day_end);
$legend=array('上证综指','深证成指');
?>
   <body style="height: 100%; margin: 0">
       <div id="container" style="height: 400px;width: 1000px"></div>
       <script type="text/javascript" src="../js/echarts.min.js"></script>
       <script type="text/javascript" src="../js/echarts-gl.min.js"></script>
       <script type="text/javascript" src="../js/ecStat.min.js"></script>
       <script type="text/javascript" src="../js/dataTool.min.js"></script>
       <script type="text/javascript" src="../js/simplex.js"></script>
       <script type="text/javascript" src="../js/grey.js"></script>
       <script type="text/javascript">
var dom = document.getElementById("container");
var myChart = echarts.init(dom,'grey');
var app = {};
option = null;
legend = <?php echo json_encode($legend);?>;
option = {
    title: {
        text: '历史数据折线图',
        subtext:"双轴显示",
        textAlign:'center',
        left:'50%'
    },
    tooltip: {
        trigger: 'axis'
    },
    legend: {
        data:legend,
        right:'20'
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    toolbox: {
        feature: {
            saveAsImage: {}
        }
    },
    xAxis: {
        type: 'category',
        //type: 'time',
        boundaryGap: false,
        data: <?php echo json_encode($data['tDate']); ?>
    },
    yAxis: [{
        type: 'value',
        name:legend[0], //图列
        show:true
    },
    {
        type:'value',
        name:legend[1],  //图例
        //scale:true,     //true 不强制包含0刻度
        boundaryGap:false,
        show:true
    }],
    series: [
        {
            name:legend[0],
            type:'line',
            yAxisIndex:0,
            data:<?php echo json_encode($data['idx']); ?>
        },
        {
            name:legend[1],
            type:'line',
            yAxisIndex:1,
            data:<?php echo json_encode($data1['idx']); ?>
        }
    ]
};
;
if (option && typeof option === "object") {
    myChart.setOption(option, true);
}
       </script>
   </body>
</html>