
@{
    ViewData["Title"] = "仓库历史冗余分析数据";
    Layout = "~/Pages/Shared/_MainLayout.cshtml";
}

<div class="row">
    <div class="col-sm-12">

        <div id="chart-contain" style="width:100%;height:550px;">

        </div>
    </div>
</div>

@section scripts{
    <script src="~/js/echarts.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            getData();
        })

        function getData() {
            $.submit({
                type:'POST',
                url: '@Url.Content("~/Reports/Warehouse/WHRedundancyChartJson")',
                paramData: 'warehousecode=@(ViewBag.warehousecode)&day=@(ViewBag.day)&col=@(ViewBag.col)',
                func: function (result) {
                    if (result) {
                        showChart('@Html.Raw(ViewBag.warehousename)'+'仓库冗余前两个月的数据', result.col, result.val);
                    }
                }
            })
        }

        function showChart(title,category,vals) {
            option = {
                title: {
                    text: title
                },
                tooltip: {
                    trigger: 'axis'
                },
                legend: {
                    data: ['@Html.Raw(ViewBag.colname)']
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                toolbox: {
                    feature: {
                        saveAsImage: {}
                    }
                },
                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    data: category
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        name: '@Html.Raw(ViewBag.colname)',
                        type: 'line',
                        stack: '总量',
                        data: vals
                    }
                ]
            };

            // 基于准备好的dom，初始化echarts实例
            var myChart = echarts.init(document.getElementById('chart-contain'));
            // 使用刚指定的配置项和数据显示图表。
            myChart.setOption(option);
        }

    </script>
}

