<?php
#查询个股价格对应机构持仓的数量
include_once "../inc/getBasic.inc.php";
include_once "../inc/getData.inc.php";

$ts_code=ts_code_conv($_REQUEST['ts_code']);
$ts_name = tscodeToName($ts_code);
include_once "../html/headChart.php"; //required after $ts_code and $ts_name

$day_st=($_REQUEST['s']=='')?'2012-01-01':$_REQUEST['s'];
$day_end=($_REQUEST['e']=='')?date('Y-m-d'):$_REQUEST['e'];
#item:  f9:持股数 f10:持股额 f11:占总股本比例 f12:占流通股比例 
$item = ($_REQUEST['item']=='')?'f9':$_REQUEST['item'];

switch($item){
    case 'f9':
    case 'F9':
        $unit = ' - 万股';
        $item_name = "持股数";
        break;
    case 'f10':
    case 'F10':
        $unit = ' - 万元';
        $item_name = "持股金额";
        break;
    case 'f11':
    case 'F11':
        $unit = ' - %';
        $item_name = "总股本股比例";
        break;
    case 'f12':
    case 'F12':
        $unit = ' - %';
        $item_name = "流通股比例";
        break;
    default:
        $unit = '';  
}
$data = getStockHist($ts_code,$day_st,$day_end);
$lx = ''; //define null var avoid error
$data2 = getIhDataByStock($ts_code,$item,$lx,$day_st,$day_end);

#var_dump($data2['data']);
$subtext_ext = "Max: ".$data2['data_max'];
$subtext_ext .= ", Min: ".$data2['data_min'];
$subtext_ext .= ", Average: ".$data2['data_avg'];
$subtext_ext .= ", Recent: ".$data2['data_last'];

$legend=array('不复权股价','深证成指',$item_name);
#$value=json_encode($data['data']);
?>

<script type="text/javascript">
window.chartConfig = {
    data: <?php echo json_encode($data['data']); ?>,
    data2: <?php echo json_encode($data2['data']); ?>,
    legend: <?php echo json_encode($legend);?>,
    unit: '<?php echo $unit; ?>',
    title: '<?php echo $ts_name.'('.$ts_code.')'; ?>',
    subtitle: '<?php echo $subtext_ext; ?>'
};

</script>
<script type="text/javascript" src="../js/chartSix.js?ver=3.141"></script>
   </body>
</html>