<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ManHoursStatistics.aspx.cs" Inherits="FineUIPro.Web.ManHours.ManHoursStatistics" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>人工时统计</title>
    <script src="../Scripts/jquery-3.6.4.js"></script>
    <script src="../res/echarts/echarts.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <f:PageManager ID="PageManager1" runat="server" AutoSizePanelID="Panel1" />
        <f:Panel ID="Panel1" CssClass="blockpanel" Margin="20px" runat="server" ShowBorder="false" ShowHeader="false" Layout="Region">
            <Items>
                <f:Panel runat="server" ID="panelLeftRegion" RegionPosition="Left" RegionSplit="true" EnableCollapse="false"
                    Width="280px" Title="部门人员" ShowBorder="true" ShowHeader="false"
                    BodyPadding="5px" Collapsed="false" AutoScroll="true">
                    <Toolbars>
                        <f:Toolbar ID="Toolbar1" Position="Top" runat="server" ToolbarAlign="Left">
                            <Items>
                                <f:TextBox ID="txtUserName" runat="server" Label="UserName" EmptyText="query condition" AutoPostBack="true"
                                    OnTextChanged="TextBox_TextChanged" Width="240px" LabelWidth="80px" LabelAlign="Right">
                                </f:TextBox>
                            </Items>
                        </f:Toolbar>
                    </Toolbars>
                    <Items>
                        <f:Tree ID="tvUser" Width="250px" ShowHeader="false" Title="Role" Collapsed="true"
                            AutoLeafIdentification="true" runat="server" EnableIcons="true" Expanded="true" EnableSingleClickExpand="true" OnNodeCommand="tvUser_NodeCommand">
                            <Listeners>
                                <f:Listener Event="nodeselect" Handler="onTree1NodeSelect" />
                            </Listeners>
                        </f:Tree>
                    </Items>
                </f:Panel>
                <f:Panel runat="server" ID="panelCenterRegion" RegionPosition="Center" AutoScroll="true"
                    Title="中间面板" ShowBorder="false" ShowHeader="false" BodyPadding="1px">
                    <Items>
                        <f:Form runat="server" ShowHeader="false" ShowBorder="false">
                            <Items>
                                <f:FormRow ColumnWidths="60% 40%">
                                    <Items>
                                        <f:Panel ID="Panel2" Title="面板1" RegionPosition="Left" runat="server" BodyPadding="1px"
                                            ShowBorder="false" ShowHeader="false">
                                            <Items>
                                                <f:Grid ID="Grid1" ShowBorder="true" ShowHeader="false" Title="人工时计划" EnableCollapse="true"
                                                    AllowColumnLocking="true" EnableColumnLines="true" runat="server" BoxFlex="1" DataKeyNames="EProjectId" DataIDField="EProjectId" AllowCellEditing="true" SortDirection="DESC"
                                                    EnableSummary="true" SummaryPosition="Flow" AllowSorting="true" SortField="ProjectControl_JobNo" Height="350px" EnableRowSelectEvent="true" OnRowSelect="Grid1_RowSelect">
                                                    <Columns>
                                                        <f:RenderField Width="100px" ColumnID="ProjectControl_JobNo" DataField="ProjectControl_JobNo" EnableFilter="true"
                                                            SortField="JobNo" FieldType="String" HeaderText="Job No." HeaderTextAlign="Center" TextAlign="Left">
                                                        </f:RenderField>
                                                        <f:RenderField Width="150px" ColumnID="ProjectControl_JobTitle" DataField="ProjectControl_JobTitle"
                                                            FieldType="String" HeaderText="Title" HeaderTextAlign="Center" ExpandUnusedSpace="true">
                                                        </f:RenderField>
                                                        <f:RenderField Width="120px" ColumnID="ReceivedDate" DataField="ReceivedDate"
                                                            FieldType="Date" Renderer="Date" HeaderText="Received Date" HeaderTextAlign="Center">
                                                        </f:RenderField>
                                                        <f:RenderField Width="130px" ColumnID="ManHours" DataField="ManHours"
                                                            FieldType="String" HeaderText="ManHours(Plan)" HeaderTextAlign="Center">
                                                        </f:RenderField>
                                                        <f:RenderField Width="100px" ColumnID="Hours" DataField="Hours" SortField="Hours"
                                                            FieldType="String" HeaderText="ManHours(Actual)" HeaderTextAlign="Center">
                                                        </f:RenderField>
                                                    </Columns>
                                                    <Listeners>
                                                        <f:Listener Event="rowselect" Handler="onRowselect" />
                                                    </Listeners>
                                                </f:Grid>
                                            </Items>
                                        </f:Panel>
                                        <f:Panel ID="Panel3" Title="面板2" BoxFlex="1" RegionPosition="Left" Margin="0" runat="server"
                                            BodyPadding="1px" ShowBorder="false" ShowHeader="false">
                                            <Items>
                                                <f:Grid ID="Grid2" ShowBorder="true" ShowHeader="false" Title="人工时计划" EnableCollapse="true"
                                                    AllowColumnLocking="true" EnableColumnLines="true"
                                                    AllowPaging="false" IsDatabasePaging="false" PageSize="15" OnPageIndexChange="Grid2_PageIndexChange" EnableSummary="true" SummaryPosition="Flow"
                                                    runat="server" BoxFlex="1" DataKeyNames="DateMonth" AllowCellEditing="true" AllowSorting="true" SortField="DateMonth" SortDirection="DESC" Height="350px">
                                                    <Columns>
                                                        <f:RenderField Width="100px" ColumnID="DateMonth" DataField="DateMonth" EnableFilter="true"
                                                            SortField="DateMonth" FieldType="String" HeaderText="Month" HeaderTextAlign="Center" TextAlign="Left">
                                                        </f:RenderField>
                                                        <f:RenderField Width="100px" ColumnID="TaskPlan" DataField="TaskPlan"
                                                            FieldType="String" HeaderText="Task Planed" HeaderTextAlign="Center">
                                                        </f:RenderField>
                                                        <f:RenderField Width="100px" ColumnID="NoPlanned" DataField="NoPlanned"
                                                            FieldType="String" HeaderText="Task Actual" HeaderTextAlign="Center">
                                                        </f:RenderField>
                                                        <f:RenderField Width="100px" ColumnID="TaskActual" DataField="TaskActual"
                                                            FieldType="String" HeaderText="No Planned" HeaderTextAlign="Center">
                                                        </f:RenderField>
                                                    </Columns>
                                                </f:Grid>
                                            </Items>
                                        </f:Panel>
                                    </Items>
                                </f:FormRow>
                                <f:FormRow>
                                    <Items>
                                        <f:ContentPanel ID="ContentPanel1" CssClass="blockpanel" runat="server" BodyPadding="10px"
                                            ShowBorder="true" ShowHeader="true" Title="Work Load" EnableAjax="false">
                                            <asp:HiddenField ID="hidjson" runat="server" />
                                            <asp:HiddenField ID="ActualManHour" runat="server" />
                                            <asp:HiddenField ID="hidchildJson" runat="server" />
                                             <asp:HiddenField ID="hidTree1Node" runat="server" />
                                            <div id="divChart1" class="echartsdiv" style="height: 400px; min-width: 1000px; width: 1000px; overflow-x: scroll"></div>
                                            <div id="divChart2" class="echartsdiv" style="height: 400px; min-width: 1000px; width: 1000px; overflow-x: scroll; display: none"></div>
                                            <div id="divChart3" class="echartsdiv" style="height: 400px; min-width: 1000px; width: 1000px; overflow-x: scroll; display: none"></div>
                                            <%--   <div style="width:100%;height:20px;"></div>--%>
                                        </f:ContentPanel>
                                    </Items>
                                </f:FormRow>
                            </Items>
                        </f:Form>
                    </Items>
                </f:Panel>
            </Items>
        </f:Panel>
    </form>
    <script type="text/javascript">;
        // 返回false,来阻止浏览器右键菜单
        function onRowContextMenu(event, rowId) {
            F(menuID).show();  //showAt(event.pageX, event.pageY);
            return false;
        }

        function reloadGrid() {
            __doPostBack(null, 'reloadGrid');
        }

        var interval = 1500;
        $(function () {
            var json = $("#Panel1_panelCenterRegion_ctl00_ctl01_ContentPanel1_hidjson").val();

            var jsArr = eval(json);

            if (jsArr.length > 0) {

                divPieRecord(jsArr, interval);
            }
        });


        function onRowselect(event, nodeId) {
            var TreeValue = $("#Panel1_panelCenterRegion_ctl00_ctl01_ContentPanel1_hidTree1Node").val();
            var values = TreeValue.split('@')[0];
           
            if (values == "" || values == "D1") {
                $("#divChart2").hide();
                $("#divChart1").hide();
                $("#divChart3").show();
                 var HeadCount = $("#Panel1_panelCenterRegion_ctl00_ctl01_ContentPanel1_hidchildJson").val();
                 var json = $("#Panel1_panelCenterRegion_ctl00_ctl01_ContentPanel1_hidjson").val();
                 var jsArr = eval(json);
                divPieRecord3(jsArr, HeadCount);
             
            } else if (values == "UD") {
                $("#divChart2").show();
                $("#divChart1").hide();
                $("#divChart3").hide();
                 $.ajax({
                    url: "ManHoursStatisticsHandler.ashx",
                    type: "POST",
                    async: false,
                    data: { "sId": TreeValue },
                    dataType: "json",
                    success: function (data) {
                        if (data != null) {
                          divRecord(data,1);
                        }
                    }
                });
             
            }
            
        
        }



        function onTree1NodeSelect(event, nodeId) {
            $("#Panel1_panelCenterRegion_ctl00_ctl01_ContentPanel1_hidTree1Node").val(nodeId);
            var ss = nodeId.split('@');
            if (ss[0] == "UD") {//选择人员
                 $("#divChart2").show();
                $("#divChart1").hide();
                $("#divChart3").hide();
                 $.ajax({
                    url: "ManHoursStatisticsHandler.ashx",
                    type: "POST",
                    async: false,
                    data: { "sId": nodeId },
                    dataType: "json",
                    success: function (data) {
                        if (data != null) {
                          divRecord(data,1);
                        }
                    }
                });
            } else {
                $("#divChart1").show();
                $("#divChart2").hide();
                $("#divChart3").hide();
                $.ajax({
                    url: "ManHoursStatisticsHandler.ashx",
                    type: "POST",
                    async: false,
                    data: { "sId": nodeId },
                    dataType: "json",
                    success: function (data) {
                        if (data != null) {
                            divPieRecord(data, ss[0]);
                        }
                    }
                });

            }

        }

        function divPieRecord(jsArrData, intnum) {
            debugger
            var   ActualManHourMonthSet = $("#Panel1_panelCenterRegion_ctl00_ctl01_ContentPanel1_ActualManHour").val();
            var HeadCount = "";
            var jsArr = "";
            if (intnum == "D2") {
                HeadCount = jsArrData.SetJson;
                jsArr = jsArrData.json;
            } else {
                jsArr = jsArrData;
                HeadCount= $("#Panel1_panelCenterRegion_ctl00_ctl01_ContentPanel1_hidchildJson").val();
            }
            var jsons = eval(ActualManHourMonthSet);
            HeadCount = eval(HeadCount);
          
            var Legendata = '';
            var TaskPlan = '';
            var TaskActual = '';
            var NoPlanned = '';
            var ActualRate = '';
            var PlanedRate = "";
            var TargetRate = "";
            var tr = 0.85;
            for (var i = 0; i < jsArr.length; i++) {
                if (jsArr[i].DateMonth != "") {
                    var str = jsArr[i].DateMonth;
                    Legendata += "'" + jsArr[i].DateMonth + "',";
                    TaskPlan += "" + jsArr[i].TaskPlan + ",";
                    TaskActual += "" + jsArr[i].TaskActual + ",";
                    NoPlanned += "" + jsArr[i].NoPlanned + ",";
                    TargetRate += "" + tr + ",";
                    var tempHeardCount = null;
                    for (var j = 0; j < HeadCount.length; j++) {
                        if (HeadCount[j].Years + '' == str.substring(0, 4)) {
                            tempHeardCount = HeadCount[j];
                        }
                    }
                    var tempJsons = null;
                    for (var j = 0; j < jsons.length; j++) {
                        if (jsons[j].Years + '' == str.substring(0, 4)) {
                            tempJsons = jsons[j];
                        }
                    }
                    if (str.substring(4) == "01") {
                        if (tempJsons != null && tempJsons.Month1 != null && tempHeardCount != null && tempHeardCount.Month1 != null) {
                            ActualRate += "" + (jsArr[i].TaskActual + jsArr[i].NoPlanned) / (tempHeardCount.Month1 * tempJsons.Month1) + ",";
                            PlanedRate += "" + jsArr[i].TaskPlan / (tempHeardCount.Month1 * tempJsons.Month1) + ",";
                        } else {
                            ActualRate += "0,";
                            PlanedRate += "0,";
                        }
                    }
                    if (str.substring(4) == "02") {
                        if (tempJsons != null && tempJsons.Month2 != null && tempHeardCount != null && tempHeardCount.Month2 != null) {
                            ActualRate += "" + (jsArr[i].TaskActual + jsArr[i].NoPlanned) / (tempHeardCount.Month2 * tempJsons.Month2) + ",";
                            PlanedRate += "" + jsArr[i].TaskPlan / (tempHeardCount.Month2 * tempJsons.Month2) + ",";
                        } else {
                            ActualRate += "0,"; 
                            PlanedRate += "0,"; 
                        }
                    }
                    if (str.substring(4) == "03") {
                        if (tempJsons != null && tempJsons.Month3 != null && tempHeardCount != null && tempHeardCount.Month3 != null) {
                            ActualRate += "" + (jsArr[i].TaskActual + jsArr[i].NoPlanned) / (tempHeardCount.Month3 * tempJsons.Month3) + ",";
                            PlanedRate += "" + jsArr[i].TaskPlan / (tempHeardCount.Month3 * tempJsons.Month3) + ",";
                        } else {
                            ActualRate += "0,";
                            PlanedRate += "0,";
                        }
                    }
                    if (str.substring(4) == "04") {
                        if (tempJsons != null && tempJsons.Month4 != null && tempHeardCount != null && tempHeardCount.Month4!=null) {
                            ActualRate += "" + (jsArr[i].TaskActual + jsArr[i].NoPlanned) / (tempHeardCount.Month4 * tempJsons.Month4) + ",";
                            PlanedRate += "" + jsArr[i].TaskPlan / (tempHeardCount.Month4 * tempJsons.Month4) + ",";
                        } else {
                            ActualRate += "0,";
                            PlanedRate += "0,";
                        }
                    }
                    if (str.substring(4) == "05") {
                        if (tempJsons != null && tempJsons.Month5 != null && tempHeardCount != null && tempHeardCount.Month5 != null) {
                            ActualRate += "" + (jsArr[i].TaskActual + jsArr[i].NoPlanned) / (tempHeardCount.Month5 * tempJsons.Month5) + ",";
                            PlanedRate += "" + jsArr[i].TaskPlan / (tempHeardCount.Month5 * tempJsons.Month5) + ",";
                        } else {
                            ActualRate += "0,";
                            PlanedRate += "0,";
                        }
                    }
                    if (str.substring(4) == "06") {
                        if (tempJsons != null && tempJsons.Month6 != null && tempHeardCount != null && tempHeardCount.Month6 != null) {
                            ActualRate += "" + (jsArr[i].TaskActual + jsArr[i].NoPlanned) / (tempHeardCount.Month6 * tempJsons.Month6) + ",";
                            PlanedRate += "" + jsArr[i].TaskPlan / (tempHeardCount.Month6 * tempJsons.Month6) + ",";
                        } else {
                            ActualRate += "0,";
                            PlanedRate += "0,";
                        }
                    }
                    if (str.substring(4) == "07") {
                        if (tempJsons != null && tempJsons.Month7 != null && tempHeardCount != null && tempHeardCount.Month7 != null) {
                            ActualRate += "" + (jsArr[i].TaskActual + jsArr[i].NoPlanned) / (tempHeardCount.Month7 * tempJsons.Month7) + ",";
                            PlanedRate += "" + jsArr[i].TaskPlan / (tempHeardCount.Month7 * tempJsons.Month7) + ",";
                        } else {
                            ActualRate += "0,";
                            PlanedRate += "0,";
                        }
                    }
                    if (str.substring(4) == "08") {
                        if (tempJsons != null && tempJsons.Month8 != null && tempHeardCount != null && tempHeardCount.Month8 != null) {
                            ActualRate += "" + (jsArr[i].TaskActual + jsArr[i].NoPlanned) / (tempHeardCount.Month8 * tempJsons.Month8) + ",";
                            PlanedRate += "" + jsArr[i].TaskPlan / (tempHeardCount.Month8 * tempJsons.Month8) + ",";
                        } else {
                            ActualRate += "0,";
                            PlanedRate += "0,";
                        }
                    }
                    if (str.substring(4) == "09") {
                        if (tempJsons != null && tempJsons.Month9 != null && tempHeardCount != null && tempHeardCount.Month9 != null) {
                            ActualRate += "" + (jsArr[i].TaskActual + jsArr[i].NoPlanned) / (tempHeardCount.Month9 * tempJsons.Month9) + ",";
                            PlanedRate += "" + jsArr[i].TaskPlan / (tempHeardCount.Month9 * tempJsons.Month9) + ",";
                        } else {
                            ActualRate += "0,";
                            PlanedRate += "0,";
                        }
                    }
                    if (str.substring(4) == "10") {
                        if (tempJsons != null && tempJsons.Month10 != null && tempHeardCount != null && tempHeardCount.Month10 != null) {
                            ActualRate += "" + (jsArr[i].TaskActual + jsArr[i].NoPlanned) / (tempHeardCount.Month10 * tempJsons.Month10) + ",";
                            PlanedRate += "" + jsArr[i].TaskPlan / (tempHeardCount.Month10 * tempJsons.Month10) + ",";
                        } else {
                            ActualRate += "0,";
                            PlanedRate += "0,";
                        }
                    }
                    if (str.substring(4) == "11") {
                        if (tempJsons != null && tempJsons.Month11 != null && tempHeardCount != null && tempHeardCount.Month11 != null) {
                            ActualRate += "" + (jsArr[i].TaskActual + jsArr[i].NoPlanned) / (tempHeardCount.Month11 * tempJsons.Month11) + ",";
                            PlanedRate += "" + jsArr[i].TaskPlan / (tempHeardCount.Month11 * tempJsons.Month11) + ",";
                        } else {
                            ActualRate += "0,";
                            PlanedRate += "0,";
                        }
                    }
                    if (str.substring(4) == "12") {
                        if (tempJsons != null && tempJsons.Month12 != null && tempHeardCount != null && tempHeardCount.Month12 != null) {
                            ActualRate += "" + (jsArr[i].TaskActual + jsArr[i].NoPlanned) / (tempHeardCount.Month12 * tempJsons.Month12) + ",";
                            PlanedRate += "" + jsArr[i].TaskPlan / (tempHeardCount.Month12 * tempJsons.Month12) + ",";
                        } else {
                            ActualRate += "0,";
                            PlanedRate += "0,";
                        }
                    }


                }
            }
            Legendata = '[' + Legendata.substring(0, Legendata.length - 1) + ']';
            Legendata = eval(Legendata);

            TaskPlan = '[' + TaskPlan.substring(0, TaskPlan.length - 1) + ']';
            TaskPlan = eval(TaskPlan);

            TaskActual = '[' + TaskActual.substring(0, TaskActual.length - 1) + ']';
            TaskActual = eval(TaskActual);

            NoPlanned = '[' + NoPlanned.substring(0, NoPlanned.length - 1) + ']';
            NoPlanned = eval(NoPlanned);

            ActualRate = '[' + ActualRate.substring(0, ActualRate.length - 1) + ']';
            ActualRate = eval(ActualRate);

            PlanedRate = '[' + PlanedRate.substring(0, PlanedRate.length - 1) + ']';
            PlanedRate = eval(PlanedRate);

            TargetRate = '[' + TargetRate.substring(0, TargetRate.length - 1) + ']';
            TargetRate = eval(TargetRate);


            var dataT = [TaskPlan, TaskActual, NoPlanned, ActualRate, PlanedRate, TargetRate];
            dataT = eval(dataT);
            var myChart = echarts.init(document.getElementById('divChart1'));
            var colors = ['#675bba', '#5793f3', '#d14a61'];
            var option = {
                // color: colors,
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {            // 坐标轴指示器,坐标轴触发有效
                        type: 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
                    }
                },
                grid: {
                    left: '3%',
                    right: '10%',
                    bottom: '10%',
                    containLabel: true
                },
                //left: '10%',bottom:'35%',
                legend: {
                    data: ['New Task', 'Actual', 'Planned', 'Actual WorkLoad Rate', 'Planned WorkLoad Rate']
                },
                xAxis: [
                    {
                        type: 'category',
                        data: Legendata,
                        axisLabel: {
                            interval: 0,  //控制坐标轴刻度标签的显示间隔.设置成 0 强制显示所有标签。设置为 1,隔一个标签显示一个标签。设置为2,间隔2个标签。以此类推
                            rotate: -90,//倾斜度 -90 至 90 默认为0 
                            textStyle: {
                                //fontWeight:"bold",  //加粗
                                color: "#000000"   //黑色
                            },
                        },
                        axisTick: {
                            alignWithLabel: true
                        }
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        axisTick: {
                            inside: true
                        },
                        scale: true
                    }
                    , {
                        type: 'value',
                        name: '',
                        min: 0,
                        max: 1.5,
                        interval: 0.1,
                        axisLabel: {
                            formatter: '{value}'
                        }
                    }
                ],
                series: [
                    {
                        name: 'New Task',
                        type: 'bar',
                        barWidth: '20%',
                        data: dataT[2],

                        itemStyle: {
                            normal: {
                                color: '#5793f3'
                            }
                        }
                    },
                    {
                        name: 'Actual',
                        type: 'bar',
                        barWidth: '20%',
                        data: dataT[1],
                        itemStyle: {
                            normal: {
                                color: '#675bba'
                                // color: '#675bba'
                            }
                        }
                    },
                    {
                        name: 'Planned',
                        type: 'bar',
                        barWidth: '20%',
                        data: dataT[0],
                        itemStyle: {
                            normal: {
                                // color: '#675bba'
                                color: '#d14a61'
                            }
                        }
                    },
                    {//'#675bba', '#5793f3', '#d14a61'
                        name: 'Actual WorkLoad Rate',
                        type: 'line',
                        yAxisIndex: 1,
                        data: dataT[3],
                        itemStyle: {
                            normal: {
                                color: '#ff0000'
                            }
                        }
                    },
                    {
                        name: 'Planned WorkLoad Rate',
                        type: 'line',
                        yAxisIndex: 1,
                        data: dataT[4],
                        itemStyle: {
                            normal: {
                                color: '#077023'
                            }
                        }
                    },
                    {
                        name: 'Target workload rate',
                        type: 'line',
                        yAxisIndex: 1,
                        data: dataT[5],
                        itemStyle: {
                            normal: {
                                color: '#d14a61'
                            }
                        }
                    }
                ]
            };
            myChart.setOption(option);
        }

        function divRecord(jsArrData, intnum) {
            var  ActualManHourMonthSet = $("#Panel1_panelCenterRegion_ctl00_ctl01_ContentPanel1_ActualManHour").val();
            jsArr = jsArrData.json;
            var jsons = eval(ActualManHourMonthSet);
            var Legendata = '';
            var ActualRate = '';
            var PlanedRate = "";
            var TargetRate = "";
            var tr = 0.85;
            for (var i = 0; i < jsArr.length; i++) {
                if (jsArr[i].DateMonth != "") {
                    var str = jsArr[i].DateMonth;
                    Legendata += "'" + jsArr[i].DateMonth + "',";
                    TargetRate += "" + tr + ",";
                    if (str.substring(4) == "01") {
                        if (jsons[0].Month1 != null) {
                            ActualRate += "" + ((jsArr[i].TaskActual + jsArr[i].NoPlanned) / (1 * jsons[0].Month1)).toFixed(2) + ",";
                            PlanedRate += "" + (jsArr[i].TaskPlan / (1* jsons[0].Month1)).toFixed(2) + ",";
                        }
                    }
                    if (str.substring(4) == "02") {
                        if (jsons[0].Month2 != null) {
                            ActualRate += "" + ((jsArr[i].TaskActual + jsArr[i].NoPlanned) / (1 * jsons[0].Month2)).toFixed(2) + ",";
                            PlanedRate += "" + (jsArr[i].TaskPlan / (1 * jsons[0].Month2)).toFixed(2) + ",";
                        }
                    }
                    if (str.substring(4) == "03") {
                        if (jsons[0].Month3 != null) {
                            ActualRate += "" + ((jsArr[i].TaskActual + jsArr[i].NoPlanned) / (1 * jsons[0].Month3)).toFixed(2) + ",";
                            PlanedRate += "" + (jsArr[i].TaskPlan / (1 * jsons[0].Month3)).toFixed(2) + ",";
                        }
                    }
                    if (str.substring(4) == "04") {
                        if (jsons[0].Month4 != null) {
                            ActualRate += "" + ((jsArr[i].TaskActual + jsArr[i].NoPlanned) / (jsArr[i].UserNum * jsons[0].Month4)).toFixed(2) + ",";
                            PlanedRate += "" + (jsArr[i].TaskPlan / (1 * jsons[0].Month4)).toFixed(2) + ",";
                        }
                    }
                    if (str.substring(4) == "05") {
                        if (jsons[0].Month5 != null) {
                            ActualRate += "" + ((jsArr[i].TaskActual + jsArr[i].NoPlanned) / (1 * jsons[0].Month5)).toFixed(2) + ",";
                            PlanedRate += "" + (jsArr[i].TaskPlan / (1 * jsons[0].Month5)).toFixed(2) + ",";
                        }
                    }
                    if (str.substring(4) == "06") {
                        if (jsons[0].Month6 != null) {
                            ActualRate += "" + ((jsArr[i].TaskActual + jsArr[i].NoPlanned) / (1 * jsons[0].Month6)).toFixed(2) + ",";
                            PlanedRate += "" + (jsArr[i].TaskPlan / (1 * jsons[0].Month6)).toFixed(2)+ ",";
                        }
                    }
                    if (str.substring(4) == "07") {
                        if (jsons[0].Month7 != null) {
                            ActualRate += "" + ((jsArr[i].TaskActual + jsArr[i].NoPlanned) / (1 * jsons[0].Month7)).toFixed(2) + ",";
                            PlanedRate += "" + (jsArr[i].TaskPlan / (1 * jsons[0].Month7)).toFixed(2) + ",";
                        }
                    }
                    if (str.substring(4) == "08") {
                        if (jsons[0].Month8 != null) {
                            ActualRate += "" + ((jsArr[i].TaskActual + jsArr[i].NoPlanned) / (1 * jsons[0].Month8)).toFixed(2) + ",";
                            PlanedRate += "" + (jsArr[i].TaskPlan / (1 * jsons[0].Month8)).toFixed(2) + ",";
                        }
                    }
                    if (str.substring(4) == "09") {
                        if (jsons[0].Month9 != null) {
                            ActualRate += "" + ((jsArr[i].TaskActual + jsArr[i].NoPlanned) / (1 * jsons[0].Month9)).toFixed(2) + ",";
                            PlanedRate += "" + (jsArr[i].TaskPlan / (1 * jsons[0].Month9)).toFixed(2) + ",";
                        }
                    }
                    if (str.substring(4) == "10") {
                        if (jsons[0].Month10 != null) {
                            ActualRate += "" + ((jsArr[i].TaskActual + jsArr[i].NoPlanned) / (1 * jsons[0].Month10)).toFixed(2) + ",";
                            PlanedRate += "" + (jsArr[i].TaskPlan / (1 * jsons[0].Month10)).toFixed(2) + ",";
                        }
                    }
                    if (str.substring(4) == "11") {
                        if (jsons[0].Month11 != null) {
                            ActualRate += "" + ((jsArr[i].TaskActual + jsArr[i].NoPlanned) / (1 * jsons[0].Month11)).toFixed(2) + ",";
                            PlanedRate += "" + (jsArr[i].TaskPlan / (1 * jsons[0].Month11)).toFixed(2) + ",";
                        }
                    }
                    if (str.substring(4) == "12") {
                        if (jsons[0].Month12 != null) {
                            ActualRate += "" + ((jsArr[i].TaskActual + jsArr[i].NoPlanned) / (1 * jsons[0].Month12)).toFixed(2) + ",";
                            PlanedRate += "" + (jsArr[i].TaskPlan / (1 * jsons[0].Month12)).toFixed(2) + ",";
                        }
                    }


                }
             }
            Legendata = '[' + Legendata.substring(0, Legendata.length - 1) + ']';
            Legendata = eval(Legendata);

            ActualRate = '[' + ActualRate.substring(0, ActualRate.length - 1) + ']';
            ActualRate = eval(ActualRate);

            PlanedRate = '[' + PlanedRate.substring(0, PlanedRate.length - 1) + ']';
            PlanedRate = eval(PlanedRate);

            TargetRate = '[' + TargetRate.substring(0, TargetRate.length - 1) + ']';
            TargetRate = eval(TargetRate);


            var dataT = [ActualRate, PlanedRate, TargetRate];
            dataT = eval(dataT);
            var myChart = echarts.init(document.getElementById('divChart2'));
            var option = {
                // color: colors,
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {            // 坐标轴指示器,坐标轴触发有效
                        type: 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
                    }
                },
                grid: {
                    left: '3%',
                    right: '10%',
                    bottom: '10%',
                    containLabel: true
                },
                //left: '10%',bottom:'35%',
                legend: {
                    data: ['Actual WorkLoad Rate', 'Planned WorkLoad Rate','Target workload rate']
                },
                xAxis: [
                    {
                        type: 'category',
                        data: Legendata,
                        axisLabel: {
                            interval: 0,  //控制坐标轴刻度标签的显示间隔.设置成 0 强制显示所有标签。设置为 1,隔一个标签显示一个标签。设置为2,间隔2个标签。以此类推
                            rotate: -90,//倾斜度 -90 至 90 默认为0 
                            textStyle: {
                                //fontWeight:"bold",  //加粗
                                color: "#000000"   //黑色
                            },
                        },
                        axisTick: {
                            alignWithLabel: true
                        }
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        axisTick: {
                            inside: true
                        },
                        scale: true
                    }
                ],
                series: [
                    {
                        name: 'Actual WorkLoad Rate',
                        type: 'line',
                        data: dataT[0],
                        itemStyle: {
                            normal: {
                                color: '#ff0000'
                            }
                        }
                    },
                    {
                        name: 'Planned WorkLoad Rate',
                        type: 'line',
                        data: dataT[1],
                        itemStyle: {
                            normal: {
                                color: '#077023'
                            }
                        }
                    },
                    {
                        name: 'Target workload rate',
                        type: 'line',
                        data: dataT[2],
                        itemStyle: {
                            normal: {
                                color: '#d14a61'
                            }
                        }
                    }
                ]
            };
            myChart.setOption(option);
        }


         function divPieRecord3(jsArr,HeadCount) {
            var  ActualManHourMonthSet = $("#Panel1_panelCenterRegion_ctl00_ctl01_ContentPanel1_ActualManHour").val();
            var jsons = eval(ActualManHourMonthSet);
            HeadCount = eval(HeadCount);
            var Legendata = '';
            var TaskPlan = '';
            var TaskActual = '';
            var NoPlanned = '';
            var ActualRate = '';
            var PlanedRate = "";
            var TargetRate = "";
            var tr = 0.85;
            for (var i = 0; i < jsArr.length; i++) {
                if (jsArr[i].DateMonth != "") {
                    var str = jsArr[i].DateMonth;
                    Legendata += "'" + jsArr[i].DateMonth + "',";
                    TaskPlan += "" + jsArr[i].TaskPlan + ",";
                    TaskActual += "" + jsArr[i].TaskActual + ",";
                    NoPlanned += "" + jsArr[i].NoPlanned + ",";
                    TargetRate += "" + tr + ",";
                    if (str.substring(4) == "01") {
                        if (jsons[0].Month1 != null) {
                            ActualRate += "" + jsArr[i].TaskActual / (HeadCount[0].Month1 * jsons[0].Month1) + ",";
                            PlanedRate += "" + jsArr[i].NoPlanned / (HeadCount[0].Month1 * jsons[0].Month1) + ",";
                        }
                    }
                    if (str.substring(4) == "02") {
                        if (jsons[0].Month2 != null) {
                            ActualRate += "" + jsArr[i].TaskActual / (HeadCount[0].Month2 * jsons[0].Month2) + ",";
                            PlanedRate += "" + jsArr[i].NoPlanned / (HeadCount[0].Month2 * jsons[0].Month2) + ",";
                        }
                    }
                    if (str.substring(4) == "03") {
                        if (jsons[0].Month3 != null) {
                            ActualRate += "" + jsArr[i].TaskActual  / (HeadCount[0].Month3 * jsons[0].Month3) + ",";
                            PlanedRate += "" + jsArr[i].NoPlanned / (HeadCount[0].Month3 * jsons[0].Month3) + ",";
                        }
                    }
                    if (str.substring(4) == "04") {
                        if (jsons[0].Month4 != null) {
                            ActualRate += "" + jsArr[i].TaskActual  / (HeadCount[0].Month4 * jsons[0].Month4) + ",";
                            PlanedRate += "" + jsArr[i].NoPlanned / (HeadCount[0].Month4 * jsons[0].Month4) + ",";
                        }
                    }
                    if (str.substring(4) == "05") {
                        if (jsons[0].Month5 != null) {
                            ActualRate += "" + jsArr[i].TaskActual / (HeadCount[0].Month5 * jsons[0].Month5) + ",";
                            PlanedRate += "" + jsArr[i].NoPlanned / (HeadCount[0].Month5 * jsons[0].Month5) + ",";
                        }
                    }
                    if (str.substring(4) == "06") {
                        if (jsons[0].Month6 != null) {
                            ActualRate += "" + jsArr[i].TaskActual  / (HeadCount[0].Month6 * jsons[0].Month6) + ",";
                            PlanedRate += "" + jsArr[i].NoPlanned / (HeadCount[0].Month6 * jsons[0].Month6) + ",";
                        }
                    }
                    if (str.substring(4) == "07") {
                        if (jsons[0].Month7 != null) {
                            ActualRate += "" + jsArr[i].TaskActual  / (HeadCount[0].Month7 * jsons[0].Month7) + ",";
                            PlanedRate += "" + jsArr[i].NoPlanned / (HeadCount[0].Month7 * jsons[0].Month7) + ",";
                        }
                    }
                    if (str.substring(4) == "08") {
                        if (jsons[0].Month8 != null) {
                            ActualRate += "" + jsArr[i].TaskActual  / (HeadCount[0].Month8 * jsons[0].Month8) + ",";
                            PlanedRate += "" + jsArr[i].NoPlanned / (HeadCount[0].Month8 * jsons[0].Month8) + ",";
                        }
                    }
                    if (str.substring(4) == "09") {
                        if (jsons[0].Month9 != null) {
                            ActualRate += "" + jsArr[i].TaskActual / (HeadCount[0].Month9 * jsons[0].Month9) + ",";
                            PlanedRate += "" + jsArr[i].NoPlanned / (HeadCount[0].Month9 * jsons[0].Month9) + ",";
                        }
                    }
                    if (str.substring(4) == "10") {
                        if (jsons[0].Month10 != null) {
                            ActualRate += "" + jsArr[i].TaskActual  / (HeadCount[0].Month10 * jsons[0].Month10) + ",";
                            PlanedRate += "" + jsArr[i].NoPlanned / (HeadCount[0].Month10 * jsons[0].Month10) + ",";
                        }
                    }
                    if (str.substring(4) == "11") {
                        if (jsons[0].Month11 != null) {
                            ActualRate += "" + jsArr[i].TaskActual / (HeadCount[0].Month11 * jsons[0].Month11) + ",";
                            PlanedRate += "" + jsArr[i].NoPlanned / (HeadCount[0].Month11 * jsons[0].Month11) + ",";
                        }
                    }
                    if (str.substring(4) == "12") {
                        if (jsons[0].Month12 != null) {
                            ActualRate += "" + jsArr[i].TaskActual  / (HeadCount[0].Month12 * jsons[0].Month12) + ",";
                            PlanedRate += "" + jsArr[i].NoPlanned / (HeadCount[0].Month12 * jsons[0].Month12) + ",";
                        }
                    }


                }
            }
            Legendata = '[' + Legendata.substring(0, Legendata.length - 1) + ']';
            Legendata = eval(Legendata);

            TaskPlan = '[' + TaskPlan.substring(0, TaskPlan.length - 1) + ']';
            TaskPlan = eval(TaskPlan);

            TaskActual = '[' + TaskActual.substring(0, TaskActual.length - 1) + ']';
            TaskActual = eval(TaskActual);

            NoPlanned = '[' + NoPlanned.substring(0, NoPlanned.length - 1) + ']';
            NoPlanned = eval(NoPlanned);

            ActualRate = '[' + ActualRate.substring(0, ActualRate.length - 1) + ']';
            ActualRate = eval(ActualRate);

            PlanedRate = '[' + PlanedRate.substring(0, PlanedRate.length - 1) + ']';
            PlanedRate = eval(PlanedRate);

            TargetRate = '[' + TargetRate.substring(0, TargetRate.length - 1) + ']';
            TargetRate = eval(TargetRate);


            var dataT = [TaskPlan, TaskActual, NoPlanned, ActualRate, PlanedRate, TargetRate];
            dataT = eval(dataT);
            var myChart = echarts.init(document.getElementById('divChart3'));
            var colors = ['#675bba', '#5793f3', '#d14a61'];
            var option = {
                // color: colors,
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {            // 坐标轴指示器,坐标轴触发有效
                        type: 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
                    }
                },
                grid: {
                    left: '3%',
                    right: '10%',
                    bottom: '10%',
                    containLabel: true
                },
                //left: '10%',bottom:'35%',
                legend: {
                    data: ['New Task', 'Actual', 'Planned', 'Actual WorkLoad Rate', 'Planned WorkLoad Rate']
                },
                xAxis: [
                    {
                        type: 'category',
                        data: Legendata,
                        axisLabel: {
                            interval: 0,  //控制坐标轴刻度标签的显示间隔.设置成 0 强制显示所有标签。设置为 1,隔一个标签显示一个标签。设置为2,间隔2个标签。以此类推
                            rotate: -90,//倾斜度 -90 至 90 默认为0 
                            textStyle: {
                                //fontWeight:"bold",  //加粗
                                color: "#000000"   //黑色
                            },
                        },
                        axisTick: {
                            alignWithLabel: true
                        }
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        axisTick: {
                            inside: true
                        },
                        scale: true
                    }
                    , {
                        type: 'value',
                        name: '',
                        min: 0,
                        max: 1.5,
                        interval: 0.1,
                        axisLabel: {
                            formatter: '{value}'
                        }
                    }
                ],
                series: [
                    {
                        name: 'New Task',
                        type: 'bar',
                        barWidth: '20%',
                        data: dataT[2],

                        itemStyle: {
                            normal: {
                                color: '#5793f3'
                            }
                        }
                    },
                    {
                        name: 'Actual',
                        type: 'bar',
                        barWidth: '20%',
                        data: dataT[1],
                        itemStyle: {
                            normal: {
                                color: '#675bba'
                                // color: '#675bba'
                            }
                        }
                    },
                    {
                        name: 'Planned',
                        type: 'bar',
                        barWidth: '20%',
                        data: dataT[0],
                        itemStyle: {
                            normal: {
                                // color: '#675bba'
                                color: '#d14a61'
                            }
                        }
                    },
                    {//'#675bba', '#5793f3', '#d14a61'
                        name: 'Actual WorkLoad Rate',
                        type: 'line',
                        yAxisIndex: 1,
                        data: dataT[3],
                        itemStyle: {
                            normal: {
                                color: '#ff0000'
                            }
                        }
                    },
                    {
                        name: 'Planned WorkLoad Rate',
                        type: 'line',
                        yAxisIndex: 1,
                        data: dataT[4],
                        itemStyle: {
                            normal: {
                                color: '#077023'
                            }
                        }
                    },
                    {
                        name: 'Target workload rate',
                        type: 'line',
                        yAxisIndex: 1,
                        data: dataT[5],
                        itemStyle: {
                            normal: {
                                color: '#d14a61'
                            }
                        }
                    }
                ]
            };
            myChart.setOption(option);
        }
    </script>
</body>
</html>