none
做图表一个页面放了多个SL,有很大的延迟 RRS feed

  • 常规讨论

  • 用Visifire做了4个单独的sl程序放在页面上,每次加载都会卡住页面鼠标也不能动,影响展示效果,为了测试我在界面加了个按钮 属性是隐藏的,然后在图表UpdateLayout后让按钮显示出来,发现按钮很快就显示了 但是图表要等很长时间才显示出来。 然后放一个的时候发现按钮是和图表一起显示的,卡的时间是1秒,放2个卡的时间是2秒,放了4个卡的时间是4秒。怀疑是4个sl是同步加载的 有什么办法异步加载吗?还是说有其他什么原因?

    谢谢!

    2011年9月20日 9:47

全部回复

  • 数据是怎么取的?通信?
    2011年9月21日 2:45
  • 传进去的数据

     ,是处理数据慢的吗

      #region 构造函数
            public MainPage()
            {
                    InitializeComponent();
                         MenuScale();//缩放右键菜单
                App.Current.Host.Content.FullScreenChanged += new EventHandler(Content_FullScreenChanged);//全屏
              
                //双击
                this.G1_vcChartColumn.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(G1_vcChartColumn_MouseLeftButtonDown);
                
                Col_Source = new List<StatData>();
                 
                HtmlDocument doc = HtmlPage.Document;
                HtmlElement elem = doc.GetElementById("PersonCheck");
                string s = elem.GetAttribute("value");
              
           
          this.Dispatcher.BeginInvoke(() => { MyBinding(s); DataBinding(); });
    
            }
    
    
    //解析数据
            public string Year = "";
            public string Month = "";
    
    
            private void MyBinding(string s)
            {
                XDocument XDoc = XDocument.Parse(s);
              
                Col_Source.Clear();
                List<string> StatName = new List<string>();
                List<int> TotalNumber = new List<int>();
                List<string> UserName = new List<string>();
                List<string> StatType = new List<string>();
                List<string> Year = new List<string>();
                List<string> Month = new List<string>();
    
    
                #region oracle
                var Elementos = from n in XDoc.Descendants("TOTALNUMBER") select n;
                foreach (var Element in Elementos)
                {
                    TotalNumber.Add(int.Parse(Element.Value));
                }
    
                var Elementoss = from nn in XDoc.Descendants("USERNAME") select nn;
                foreach (var Element in Elementoss)
                {
                    UserName.Add(Element.Value);
                }
    
                var Elementosss = from nnn in XDoc.Descendants("STATNAME") select nnn;
                foreach (var Element in Elementosss)
                {
                    StatName.Add(Element.Value);
                }
    
                var Elementossss = from nnnn in XDoc.Descendants("STATTYPE") select nnnn;
                foreach (var Element in Elementossss)
                {
                    StatType.Add(Element.Value);
                }
    
                var Elementos5 = from n5 in XDoc.Descendants("YEAR") select n5;
                foreach (var Element in Elementos5)
                {
                    Year.Add(Element.Value);
                }
    
                var Elementos6 = from n6 in XDoc.Descendants("MONTH") select n6;
                foreach (var Element in Elementos6)
                {
                    Month.Add(Element.Value);
                }
                #endregion
                if (TotalNumber.Count == UserName.Count && TotalNumber.Count == StatName.Count && TotalNumber.Count != 0)
                {
                    for (int j = 0; j < TotalNumber.Count; j++)
                    {
                        Col_Source.Add(new StatData
                        {
                            StatType = StatType[j],
                            StatName = StatName[j],
                            TotalNumber = TotalNumber[j],
                            UserName = UserName[j],
                            Year = Year[j],
                            Month = Month[j]
                        });
                    }
                }
                else
                {
                    if (StatName.Count > 0)
                    {
                        for (int j = 0; j < StatName.Count; j++)
                        {
                            Col_Source.Add(new StatData
                            {
                                StatType = StatType[j],
                                StatName = StatName[j],
                                TotalNumber = 0,
                                UserName = "",
                                Month = "0",
                                Year = "0",
                            });
                        }
                    }
                               }
                
    
       
           
            }
    
           
    
         
            //DataBinding 数据绑定
            private void DataBinding()
            {
    
    
                this.G1_vcChartColumn.Series.Clear();
                this.G1_vcChartColumn.Titles.Clear();
                this.G1_vcChartColumn.UpdateLayout();
               
                int CurrentMonth = DateTime.Now.Month;
                Previous_ThreeMonth = CurrentMonth - 3 > 0 ? (CurrentMonth - 3) : (CurrentMonth + 9);
                Previous_TwoMonth = CurrentMonth - 2 > 0 ? (CurrentMonth - 2) : (CurrentMonth + 10);
                Previous_OneMonth = CurrentMonth - 1 > 0 ? (CurrentMonth - 1) : (CurrentMonth + 11);
    
    
             
                //选出各个月份的数据
                Previous_ThreeData = (from Item in Col_Source
                                      where decimal.Parse(Item.Month) == Previous_ThreeMonth
                                      select Item).ToList<StatData>();
                Previous_TwoData = (from Item in Col_Source
                                    where decimal.Parse(Item.Month) == Previous_TwoMonth
                                    select Item).ToList<StatData>();
                Previous_OneData = (from Item in Col_Source
                                    where decimal.Parse(Item.Month) == Previous_OneMonth
                                    select Item).ToList<StatData>();
                
                InitialChartData(Previous_ThreeData,1);
               
                InitialChartData(Previous_TwoData,2);
                
                InitialChartData(Previous_OneData,3);
                
    
           
    
                #region 标题
    
                Title title = new Title();
                title.Text = "最近三月个人审批统计";
                title.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                title.FontWeight = FontWeights.Bold;
                title.FontSize = StaticPars.TitleFontSize ;
                this.G1_vcChartColumn.Titles.Add(title);
    
                Title SecondTitle = new Title();
                SecondTitle.Text = "<笔数>";
                SecondTitle.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                SecondTitle.Margin = new System.Windows.Thickness(-3, 0, 0, 0);
                SecondTitle.FontSize = 9;
                this.G1_vcChartColumn.Titles.Add(SecondTitle);
                #endregion
    
                #region  x轴,y轴,字体
                for (int i = 0; i < this.G1_vcChartColumn.AxesX.Count; i++)
                {
                    (this.G1_vcChartColumn.AxesX[i] as Axis).AxisLabels.Rows = 1;
                    (this.G1_vcChartColumn.AxesX[i] as Axis).AxisLabels.FontFamily = new FontFamily("Simsun");
                    (this.G1_vcChartColumn.AxesX[i] as Axis).AxisLabels.FontSize = 8;
                    (this.G1_vcChartColumn.AxesX[i] as Axis).AxisLabels.FontWeight = FontWeights.Light;
                }
    
                for (int i = 0; i < this.G1_vcChartColumn.AxesY.Count; i++)
                {
                    (this.G1_vcChartColumn.AxesY[i] as Axis).AxisLabels.FontFamily = new FontFamily("Simsun");
                    (this.G1_vcChartColumn.AxesY[i] as Axis).AxisLabels.FontSize = 7;
                    (this.G1_vcChartColumn.AxesY[i] as Axis).AxisLabels.FontWeight = FontWeights.Medium;
                    (this.G1_vcChartColumn.AxesY[i] as Axis).AxisLabels.Opacity = 0.6;
              
                }
                #endregion
             
                #region 柱子宽度
    
                this.G1_vcChartColumn.DataPointWidth = 3.5; //柱子宽度
    
                #endregion
    
                #region  图例是否显示
                for (int i = 0; i < G1_vcChartColumn.Legends.Count; i++)
                {
                    this.G1_vcChartColumn.Legends[i].FontSize = 9;
                    this.G1_vcChartColumn.Legends[i].MaxHeight = 16;
                    this.G1_vcChartColumn.Legends[i].Enabled = true;
                    this.G1_vcChartColumn.Legends[i].HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                }
                #endregion
    
    
                #region colorsets
    
                #region colorset 1
                ColorSet cs1 = new ColorSet();
                cs1.Id = "colorset1";
                cs1.Brushes.Add(new SolidColorBrush(Colors.Cyan));
                cs1.Brushes.Add(new SolidColorBrush(Colors.Green));
                G1_vcChartColumn.ColorSets.Add(cs1);
                #endregion
    
                #region colorset 2
                ColorSet cs2 = new ColorSet();
                cs2.Id = "colorset2";
                cs2.Brushes.Add(new SolidColorBrush(Colors.Green));
                cs2.Brushes.Add(new SolidColorBrush(Colors.Blue));
                G1_vcChartColumn.ColorSets.Add(cs2);
                #endregion
    
                #region colorset 3
                ColorSet cs3 = new ColorSet();
                cs3.Id = "colorset3";
                cs3.Brushes.Add(new SolidColorBrush(Colors.Orange));
                cs3.Brushes.Add(new SolidColorBrush(Colors.Blue));
                G1_vcChartColumn.ColorSets.Add(cs3);
                #endregion
    
                #region colorset 4
                ColorSet cs4 = new ColorSet();
                cs4.Id = "colorset4";
                cs4.Brushes.Add(new SolidColorBrush(Colors.Blue));
                cs4.Brushes.Add(new SolidColorBrush(Colors.Orange));
                G1_vcChartColumn.ColorSets.Add(cs4);
                #endregion
    
                #endregion 
                this.G1_vcChartColumn.ScrollingEnabled = false;
                this.G1_vcChartColumn.AnimationEnabled = false;
                this.G1_vcChartColumn.IndicatorEnabled = false;
                this.G1_vcChartColumn.ZoomingEnabled = false;
                this.G1_vcChartColumn.UpdateLayout();
    
            }
    
         
            private void InitialChartData(List<StatData> col_data,double m)
            {
    
    
             
                DataSeries ds1 = new DataSeries();
                ds1.RenderAs = Visifire.Charts.RenderAs.Column;
                
                col_data = col_data.OrderBy(col => int.Parse(col.StatType)).ToList<StatData>();
    
                  if (col_data.Count > 0)
                {
                    ds1.LegendText = col_data[0].Year + "年" + col_data[0].Month + "月";
                }
                else
                    ds1.LegendText = "暂无此月信息";
    
                for (int i = 0; i < col_data.Count; i++)
                {
                    //第一组数据为 总数 退回数,超过七天未审批
    
                   
                    switch (col_data[i].StatType)
                    {
                        case "01":
                            ds1.DataPoints.Add(new DataPoint()
                            {
                                AxisXLabel = col_data[i].StatName,
                                ToolTipText = col_data[0].Month + "月" + col_data[i].StatName + ":" + (double)col_data[i].TotalNumber,
                                YValue = (double)col_data[i].TotalNumber,
    
                            }); break;
    
                        case "02":
                            ds1.DataPoints.Add(new DataPoint
                            {
    
                                AxisXLabel = col_data[i].StatName,
                                ToolTipText = col_data[0].Month + "月" + col_data[i].StatName + ":" + (double)col_data[i].TotalNumber,
                                YValue = (double)col_data[i].TotalNumber,
    
                            }); break;
    
                        case "03":
                            ds1.DataPoints.Add(new DataPoint
                            {
                                AxisXLabel = col_data[i].StatName,  
                                YValue = (double)col_data[i].TotalNumber,
                                ToolTipText = col_data[0].Month + "月" + col_data[i].StatName + ":" + (double)col_data[i].TotalNumber,
                              
    
                            });
                            break;
                        case "04":
                            ds1.DataPoints.Add(new DataPoint
                            {
    
                                AxisXLabel = col_data[i].StatName,
                                ToolTipText = col_data[0].Month + "月" + col_data[i].StatName + ":" + (double)col_data[i].TotalNumber,
                                YValue = (double)col_data[i].TotalNumber,
    
                            }); break;
                        case "05":
                            ds1.DataPoints.Add(new DataPoint
                            {
                                AxisXLabel=col_data[i].StatName,
                                ToolTipText = col_data[0].Month + "月" + col_data[i].StatName + ":" + (double)col_data[i].TotalNumber,
                                YValue = (double)col_data[i].TotalNumber,
    
                            });
                            break;
    
                    }
                   
    
                }
    
    
                this.G1_vcChartColumn.Series.Add(ds1);
          
    
    
            }
    
    
    
    

    2011年9月21日 5:55
  • 你好,

    visifire 控件属于第三方控件,所以你还是在visifire论坛上提问比较合适:

    http://www.visifire.com/forums/


    Daoping Liu - MSFT
    2011年9月22日 2:17
    版主
  • 你的XML是怎么取得的? 如果是同步处理 卡界面是肯定的 N多foreach

    2011年9月22日 7:20