图表:WebChartControl

#region 画统计图
        /// <summary>
        /// 画统计图
        /// </summary>
        private void LoadWebChartControl()
        {
            this.WebChartControl1.Series.Clear();
            var sql = string.Format("{0} and ({1}) order by TimeTypeValue asc", GetSql_Chart(), string.IsNullOrEmpty(AspxGridViewPagger1.FilterSql) ? "1=1" : AspxGridViewPagger1.FilterSql);
            var data = Support.DBHelper.GetDataBySql(sql).ExecuteTable();
            WebChartControl1.Visible = data.Rows.Count >0;
            WebChartControl_Div.Visible = data.Rows.Count > 0;
            List<OrderStatics> listOrderStatics = new List<OrderStatics>();
            List<string> listTime = new List<string>();
            for (int i = 0; i < data.Rows.Count; i++)
            {
                listOrderStatics.Add(new OrderStatics()
                {
                    ChartName = data.Rows[i]["StaticObjValue"].ToString(),
                    ChartX = data.Rows[i]["TimeTypeValue"].ToString(),
                    ChartY = Tool.StringUnit.ToDecimal(data.Rows[i]["moneY"])
                });
                listTime.Add(data.Rows[i]["TimeTypeValue"].ToString());
            }
            List<string> listStaticObjValue = new List<string>();
            listOrderStatics.ForEach(o =>
            {
                if (!listStaticObjValue.Contains(o.ChartName))
                {
                    listStaticObjValue.Add(o.ChartName);
                }
            });
          
            foreach (var objValue in listStaticObjValue)
            {
                #region MyRegion
                var series_name = string.Empty;
                switch (StaObj)
                {
                    case "SellerID"://业务员
                        series_name = GetSellerName(objValue);
                        break;
                    case "ShopName"://店铺
                        series_name = GetShopCName(objValue);
                        break;
                    case "ShippingAgent"://货代
                        series_name = objValue;
                        break;
                }
                Series series = new Series(series_name, ViewType.Line);
                List<OrderStatics> listOrderStaticsItem = listOrderStatics.Where(z => z.ChartName == objValue).OrderBy(o => o.ChartX).ToList();
                foreach (var item in listOrderStaticsItem)
                {
                    series.Points.Add(new SeriesPoint(item.ChartX, item.ChartY));
                }

                //设置标题
              //  var title = new ChartTitle()
              //  WebChartControl1.Titles.Clear();
                //WebChartControl1.Titles.Add(title);
                series.Label.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent;//设置数值显示为百分比
                //series.Label.PointOptions.PointView = PointView.ArgumentAndValues; //设置参数值
                series.ArgumentScaleType = ScaleType.Auto;//设置x坐标显示类型(Qualitative:定性的)
                WebChartControl1.BinaryStorageMode = BinaryStorageMode.Session;
                this.WebChartControl1.Series.Add(series);
                #endregion
            }
        }
      
        #endregion
  <dxchartsui:WebChartControl ID="WebChartControl1" runat="server" Width="1260" Height="300"
                                    ShowLoadingPanelImage="True">
                                </dxchartsui:WebChartControl>

 

posted on 2014-07-25 17:48  朝着  阅读(560)  评论(0编辑  收藏  举报