Пример #1
0
        public ActionResult getChartInfo(RequestData data)
        {
            var dtData = MonitorData.GetMonitorData("", DateTime.Parse(Request.QueryString["startTime"]), DateTime.Parse(Request.QueryString["endTime"]), "C", Request.QueryString["Companyid"], Request.QueryString["selectData"], "GasItem,WaterItem");

            StringBuilder x = new StringBuilder();
            List <KeyValuePair <string, string> > y = new List <KeyValuePair <string, string> >();
            StringBuilder y1  = new StringBuilder();
            StringBuilder y2  = new StringBuilder();
            StringBuilder y3  = new StringBuilder();
            StringBuilder y4  = new StringBuilder();
            StringBuilder y5  = new StringBuilder();
            StringBuilder y6  = new StringBuilder();
            StringBuilder y7  = new StringBuilder();
            StringBuilder y8  = new StringBuilder();
            StringBuilder y9  = new StringBuilder();
            StringBuilder y10 = new StringBuilder();

            string bg  = dtData.Rows[0]["DATA_TIME"].ToString();
            string end = dtData.Rows[dtData.Rows.Count - 1]["DATA_TIME"].ToString();


            foreach (DataRow row in dtData.Rows)
            {
                x.Append("'" + row["DATA_TIME"].ToString() + "',");


                y1.Append("'" + row["a34013_PFL_Value"].ToString() + "',");
                y2.Append("'" + row["a21026_PFL_Value"].ToString() + "',");
                y3.Append("'" + row["a21002_PFL_Value"].ToString() + "',");
                y4.Append("'" + row["flowgas_Value"].ToString() + "',");
                y5.Append("'" + row["a19001_Value"].ToString() + "',");

                y6.Append("'" + row["a01012_Value"].ToString() + "',");
                y7.Append("'" + row["a01013_Value"].ToString() + "',");
                y8.Append("'" + row["w01018_PFL_Value"].ToString() + "',");
                y9.Append("'" + row["w21003_PFL_Value"].ToString() + "',");
                y10.Append("'" + row["flowwater_Value"].ToString() + "',");
            }
            if (x.Length > 0)
            {
                x = x.Remove(x.Length - 1, 1);
            }
            if (y1.Length > 0)
            {
                y1 = y1.Remove(y1.Length - 1, 1);
            }
            if (y2.Length > 0)
            {
                y2 = y2.Remove(y2.Length - 1, 1);
            }
            if (y3.Length > 0)
            {
                y3 = y3.Remove(y3.Length - 1, 1);
            }
            if (y4.Length > 0)
            {
                y4 = y4.Remove(y4.Length - 1, 1);
            }
            if (y5.Length > 0)
            {
                y5 = y5.Remove(y5.Length - 1, 1);
            }
            if (y6.Length > 0)
            {
                y6 = y6.Remove(y6.Length - 1, 1);
            }
            if (y7.Length > 0)
            {
                y7 = y7.Remove(y7.Length - 1, 1);
            }
            if (y8.Length > 0)
            {
                y8 = y8.Remove(y8.Length - 1, 1);
            }
            if (y9.Length > 0)
            {
                y9 = y9.Remove(y9.Length - 1, 1);
            }
            if (y10.Length > 0)
            {
                y10 = y10.Remove(y10.Length - 1, 1);
            }
            y.Add(new KeyValuePair <string, string>("烟尘", y1.ToString()));
            y.Add(new KeyValuePair <string, string>("二氧化硫", y2.ToString()));
            y.Add(new KeyValuePair <string, string>("氮氧化物", y3.ToString()));
            y.Add(new KeyValuePair <string, string>("废气流量", y4.ToString()));
            y.Add(new KeyValuePair <string, string>("含氧量", y5.ToString()));
            y.Add(new KeyValuePair <string, string>("烟气温度", y6.ToString()));
            y.Add(new KeyValuePair <string, string>("烟气压力", y7.ToString()));
            y.Add(new KeyValuePair <string, string>("化学需氧量", y8.ToString()));
            y.Add(new KeyValuePair <string, string>("氨氮", y9.ToString()));
            y.Add(new KeyValuePair <string, string>("废水流量", y10.ToString()));



            return(Json(EChartsHelper.GetBaseChart_zhu(x.ToString(), y, "", "厘米", "'烟尘','二氧化硫','氮氧化物','废气流量','含氧量','烟气温度','烟气压力','化学需氧量','氨氮','废水流量'", " ", "bar", getChartInfo_ping(data), bg, end, false, false)));
        }
Пример #2
0
        /// <summary>
        /// 构建图表数据
        /// </summary>
        /// <param name="sourceTable"></param>
        /// <param name="itemInfoList"></param>
        /// <param name="dataFrom"></param>
        /// <returns></returns>
        private string EChartData(DataTable sourceTable, List <ItemInfo> itemInfoList, string dataFrom)
        {
            StringBuilder x = new StringBuilder();                                                     //X轴
            List <KeyValuePair <string, string> > y     = new List <KeyValuePair <string, string> >(); //y轴
            List <KeyValuePair <string, string> > yLine = new List <KeyValuePair <string, string> >(); //Y轴水平线
            StringBuilder legend = new StringBuilder();                                                //图例
            Dictionary <string, StringBuilder> dictY     = new Dictionary <string, StringBuilder>();
            Dictionary <string, StringBuilder> dictLineY = new Dictionary <string, StringBuilder>();

            itemInfoList.ForEach(item => {
                legend.Append(string.Format(",'{0}{1}'", item.TITLE, item.CHILD_TITLE));
                dictY.Add(string.Format("{0}{1}", item.TITLE, item.CHILD_TITLE), new StringBuilder());
                dictLineY.Add(string.Format("{0}{1}", item.TITLE, item.CHILD_TITLE), new StringBuilder());
            });
            string startTime  = "";
            string endTime    = "";
            string dateFormat = "hour" == dataFrom ? "dd-HH" : "MM-dd";

            if (sourceTable.Rows.Count > 0)
            {
                if ("hour" == dataFrom)
                {
                    startTime = DateTime.Parse(StringHelper.DynamicToString(sourceTable.Rows[0]["DATA_TIME"])).ToString(dateFormat);
                    endTime   = DateTime.Parse(StringHelper.DynamicToString(sourceTable.Rows[sourceTable.Rows.Count - 1]["DATA_TIME"])).ToString(dateFormat);
                }
                else if ("day" == dataFrom)
                {
                    startTime = DateTime.Parse(StringHelper.DynamicToString(sourceTable.Rows[0]["DATA_TIME"])).ToString(dateFormat);
                    endTime   = DateTime.Parse(StringHelper.DynamicToString(sourceTable.Rows[sourceTable.Rows.Count - 1]["DATA_TIME"])).ToString(dateFormat);
                }
            }
            for (int i = 0; i < sourceTable.Rows.Count; i++)
            {
                DataRow row = sourceTable.Rows[i];
                x.Append(",'" + DateTime.Parse(StringHelper.DynamicToString(row["DATA_TIME"])).ToString(dateFormat) + "'");
                itemInfoList.ForEach(item => {
                    string key   = string.Format("{0}{1}", item.TITLE, item.CHILD_TITLE);
                    object value = row[string.Format("{0}_{1}_Value", item.CODE, item.CHILD_CODE)];
                    dictY[key].Append(string.Format(",'{0}'", StringHelper.DynamicToString(value)));
                    if (i == 0)//均值只用一个值
                    {
                        object valueAvg = row[string.Format("{0}_{1}_Value_Avg", item.CODE, item.CHILD_CODE)];
                        dictLineY[key].Append(string.Format("'{0}'", StringHelper.DynamicToString(valueAvg)));
                    }
                });
            }
            //移除前面的逗号
            dictY.Keys.ToList().ForEach(key => {
                if (dictY[key].Length > 0)
                {
                    string value = dictY[key].Remove(0, 1).ToString();
                    y.Add(new KeyValuePair <string, string>(key, value));
                }
            });
            dictLineY.Keys.ToList().ForEach(key => {
                if (dictLineY[key].Length > 0)
                {
                    string value = dictLineY[key].ToString();
                    yLine.Add(new KeyValuePair <string, string>(key, value));
                }
            });
            if (x.Length > 0)
            {
                x = x.Remove(0, 1);
            }
            if (legend.Length > 0)
            {
                legend = legend.Remove(0, 1);
            }
            return(EChartsHelper.GetBaseChart_zhu(x.ToString(), y, "", "", legend.ToString(), " ", "line", yLine, startTime, endTime, false, false));
        }
Пример #3
0
        public ActionResult getChartInfo(RequestData data)
        {
            var dtData = MonitorData.GetMonitorData("", DateTime.Parse(Request.QueryString["startTime"]), DateTime.Parse(Request.QueryString["endTime"]), "C", Request.QueryString["Companyid"], Request.QueryString["selectData"], "VOCsItem");

            StringBuilder x = new StringBuilder();
            List <KeyValuePair <string, string> > y = new List <KeyValuePair <string, string> >();
            StringBuilder y1  = new StringBuilder();
            StringBuilder y2  = new StringBuilder();
            StringBuilder y3  = new StringBuilder();
            StringBuilder y4  = new StringBuilder();
            StringBuilder y5  = new StringBuilder();
            StringBuilder y6  = new StringBuilder();
            StringBuilder y7  = new StringBuilder();
            string        bg  = dtData.Rows[0]["DATA_TIME"].ToString();
            string        end = dtData.Rows[dtData.Rows.Count - 1]["DATA_TIME"].ToString();


            foreach (DataRow row in dtData.Rows)
            {
                x.Append("'" + row["DATA_TIME"].ToString() + "',");


                y1.Append("'" + row["a25005_PFL_Value"].ToString() + "',");
                y2.Append("'" + row["a24088_PFL_Value"].ToString() + "',");
                y3.Append("'" + row["a25002_PFL_Value"].ToString() + "',");
                y4.Append("'" + row["flowvocs_Value"].ToString() + "',");

                y5.Append("'" + row["a01001_Value"].ToString() + "',");
                y6.Append("'" + row["a01002_Value"].ToString() + "',");
                y7.Append("'" + row["a25003_PFL_Value"].ToString() + "',");
            }
            if (x.Length > 0)
            {
                x = x.Remove(x.Length - 1, 1);
            }
            if (y1.Length > 0)
            {
                y1 = y1.Remove(y1.Length - 1, 1);
            }
            if (y2.Length > 0)
            {
                y2 = y2.Remove(y2.Length - 1, 1);
            }
            if (y3.Length > 0)
            {
                y3 = y3.Remove(y3.Length - 1, 1);
            }
            if (y4.Length > 0)
            {
                y4 = y4.Remove(y4.Length - 1, 1);
            }
            if (y5.Length > 0)
            {
                y5 = y5.Remove(y5.Length - 1, 1);
            }
            if (y6.Length > 0)
            {
                y6 = y6.Remove(y6.Length - 1, 1);
            }
            if (y7.Length > 0)
            {
                y7 = y7.Remove(y7.Length - 1, 1);
            }
            y.Add(new KeyValuePair <string, string>("二甲苯", y1.ToString()));
            y.Add(new KeyValuePair <string, string>("非甲烷总烃", y2.ToString()));
            y.Add(new KeyValuePair <string, string>("苯", y3.ToString()));
            y.Add(new KeyValuePair <string, string>("流量", y4.ToString()));
            y.Add(new KeyValuePair <string, string>("温度", y5.ToString()));
            y.Add(new KeyValuePair <string, string>("湿度", y6.ToString()));
            y.Add(new KeyValuePair <string, string>("甲苯", y7.ToString()));
            ;



            return(Json(EChartsHelper.GetBaseChart_zhu(x.ToString(), y, "", "厘米", "'二甲苯','非甲烷总烃','苯','流量','温度','湿度','甲苯'", " ", "bar", getChartInfo_ping(data), bg, end, false, false)));
        }