Example #1
0
        public ChartLineUC(List<DataPointCollection> ListDataPoints, string[] zstr, string strtitle)
        {
            InitializeComponent();
            chartC.DataPointWidth = 2;
            Title title = new Title();
            title.Text = strtitle;
            chartC.Titles.Add(title);

            for (int i = 0; i < ListDataPoints.Count(); i++)
            {
                DataPointCollection dpc = ListDataPoints[i];
                chartC.Series[i].DataPoints = dpc;
                chartC.Series[i].LegendText = zstr[i];
                chartC.Series[i].ShowInLegend = true;
                chartC.Series[i].ToolTipText = string.Format("名ē§°ļ¼š#AxisXLabel {0}ę•°å€¼ļ¼š#YValue {0}", System.Environment.NewLine);
                chartC.Series[i].AutoFitToPlotArea = true;
                chartC.Series[i].LabelEnabled = false;
                chartC.Series[i].Bevel = false;
                chartC.Series[i].ShadowEnabled = true;
                chartC.Series[i].YValueFormatString = "######.## ";
                chartC.Series[i].LightingEnabled = true;
                chartC.Series[i].LabelText = " #AxisXLabel";
                chartC.Series[i].LabelFontSize = 13;
                chartC.Series[i].IncludePercentageInLegend = true;
            }
        }
Example #2
0
        //[Ignore, Bug("Visifire")]
        public void BackgroundDefaultValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;

            Common.CreateAndAddDefaultDataSeries(chart);

            Title title = new Title();
            chart.Titles.Add(title);
                 
            _isLoaded = false;
            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                Common.AssertBrushesAreEqual(new SolidColorBrush(Colors.Transparent), chart.Titles[0].Background);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
 //ęŸ±ēŠ¶å›¾
 private void barGraph_Click(object sender, RoutedEventArgs e)
 {
     graphContainer.Children.Clear();
     Chart chart = new Chart();
     chart.Watermark = false;
     chart.View3D = true;
     chart.Width = 300;
     chart.Height = 200;
     Title title = new Title();
     title.Text = "äŗŗ口ē±»åˆ«ē»Ÿč®”图";
     chart.Titles.Add(title);
     for (int i = 0; i < 8; i++)
     {
         DataSeries dataSeries = new DataSeries();
         dataSeries.ShowInLegend = false;
         dataSeries.RenderAs = RenderAs.Column;
         for (int loopIndex = 0; loopIndex < 3; loopIndex++)
         {
             DataPoint dataPoint = new DataPoint();
             dataPoint.AxisXLabel = pop[loopIndex];
             dataPoint.YValue = points[i, loopIndex];
             dataSeries.DataPoints.Add(dataPoint);
         }
         chart.Series.Add(dataSeries);
     }
     //å°†ęŸ±ēŠ¶å›¾ę·»åŠ åˆ° Grid ꎧ件仄å›ŗ定位ē½®
     graphContainer.VerticalAlignment = VerticalAlignment.Top;
     graphContainer.HorizontalAlignment = HorizontalAlignment.Left;
     graphContainer.Children.Add(chart);
 }
Example #4
0
        public void TestingTitleBackgroundPropertyChanged()
        {
            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 300;

            Common.CreateAndAddDefaultDataSeries(chart);

            Title title = new Title();
            title.Text = "Title1";
            title.FontSize = 15;
            title.VerticalAlignment = VerticalAlignment.Top;
            title.HorizontalAlignment = HorizontalAlignment.Center;
            title.Background = new SolidColorBrush(Colors.Magenta);
            chart.Titles.Add(title);

            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            TestPanel.Children.Add(chart);

            EnqueueConditional(() => { return _isLoaded; });
            EnqueueDelay(_sleepTime);

            title.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e)
                =>
            {
                Assert.AreEqual("Background", e.PropertyName);
            };

            EnqueueCallback(() => title.Background = new SolidColorBrush(Colors.Yellow));

            EnqueueTestComplete();
        }
        public ChartLineYearUC(string strtitle)
        {
            InitializeComponent();

            chartC.ZoomingEnabled = true;
            chartC.ZoomOutText = "čæ”回";
            chartC.ShowAllText = "退å‡ŗ";
            Title title = new Title();
            title.Text = strtitle;
            chartC.Titles.Add(title);
        }
Example #6
0
        private void initChart()
        {
            title = new Visifire.Charts.Title();
            Axis axisX = new Axis();         //图č”ØXč½“
            Axis axisY = new Axis();         //图č”ØYč½“

            axisX.Title = "ꗶ闓";              //ęØŖåę ‡å•ä½
            axisY.Title = "单位:xxx";          //ēŗµåę ‡å•ä½

            history_chart.Titles.Add(title); //ę·»åŠ ę ‡é¢˜
            history_chart.AxesX.Add(axisX);  //ę·»åŠ xč½“
            history_chart.AxesY.Add(axisY);  //ę·»åŠ yč½“
        }
        public ColumnSummary()
        {
            InitializeComponent();
            NeedRefreshData = true;
            Loaded += new RoutedEventHandler(ColumnSummary_Loaded);
            summaryTitle = new Title() { Text = string.Empty };
            ChartTitle = new Title() { Text = string.Empty };


            InitializeSeries();

            this.ChartTitle.Text = LocalizedStrings.GetLanguageInfoByKey("ColumnSummaryChartTitle");
            this.LineChart.Titles.Add(summaryTitle);
            this.LineChart.Titles.Add(ChartTitle);
        }
Example #8
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.UserControl = ((Apollo.TrafficRateRealtime)(target));
                return;

            case 2:
                this.LayoutRoot = ((System.Windows.Controls.Grid)(target));
                return;

            case 3:
                this.VisualStateGroup = ((System.Windows.VisualStateGroup)(target));
                return;

            case 4:
                this.GridOn = ((System.Windows.VisualState)(target));
                return;

            case 5:
                this.GridOff = ((System.Windows.VisualState)(target));
                return;

            case 6:
                this.grid1 = ((System.Windows.Controls.Grid)(target));
                return;

            case 7:
                this.CurRate = ((Visifire.Charts.Title)(target));
                return;

            case 8:
                this.Realtime = ((Visifire.Charts.DataSeries)(target));
                return;

            case 9:
                this.grid = ((System.Windows.Controls.Grid)(target));
                return;

            case 10:
                this.currentRate = ((System.Windows.Controls.Label)(target));
                return;
            }
            this._contentLoaded = true;
        }
Example #9
0
        private void initDeviceChart()
        {
            device_chart.Visibility = System.Windows.Visibility.Visible;
            title = new Visifire.Charts.Title();
            Axis axisX = new Axis();        //图č”ØXč½“
            Axis axisY = new Axis();        //图č”ØYč½“

            axisX.Title = "ꗶ闓";             //ęØŖåę ‡å•ä½
            axisY.Title = "单位:xxx";         //ēŗµåę ‡å•ä½

            device_chart.Titles.Add(title); //ę·»åŠ ę ‡é¢˜
            device_chart.AxesX.Add(axisX);  //ę·»åŠ xč½“
            device_chart.AxesY.Add(axisY);  //ę·»åŠ yč½“
            //dataSeries = new DataSeries() ;  //ę•°ę®ē³»åˆ—
            //dataSeries.RenderAs = RenderAs.Line;      //Spline : å¹³ę»‘ę›²ēŗæ Line : ꊘēŗæ
            //device_chart.Series.Add(dataSeries);
        }
        /// <summary>
        /// Function to create a chart
        /// </summary>
        public void CreateChart()
        {
            // Create a new instance of Chart
            Chart chart = new Chart();

            // Set the chart width and height
            //chart.Width = 500;
            //chart.Height = 300;

            // Create a new instance of Title
            Title title = new Title();

            // Set title property
            title.Text = "Visifire Sample Chart";

            // Add title to Titles collection
            chart.Titles.Add(title);

            // Create a new instance of DataSeries
            DataSeries dataSeries = new DataSeries();

            // Set DataSeries property
            dataSeries.RenderAs = RenderAs.Column;

            // Create a DataPoint
            DataPoint dataPoint;

            for (int i = 0; i < 5; i++) {
                // Create a new instance of DataPoint
                dataPoint = new DataPoint();

                // Set YValue for a DataPoint
                dataPoint.YValue = rand.Next(10, 100);

                // Add dataPoint to DataPoints collection
                dataSeries.DataPoints.Add(dataPoint);
            }

            // Add dataSeries to Series collection.
            chart.Series.Add(dataSeries);

            // Add chart to LayoutRoot
            LayoutRoot.Children.Add(chart);
        }
Example #11
0
        public Bubble3D1()
        {
            InitializeComponent();

             Chart chart = new Chart();

                // Create a new instance of Title
                Title title = new Title();

                // Set title property
                title.Text = "Election Result";

                // Add title to Titles collection
                chart.Titles.Add(title);

                DataPoint dataPoint;
                PhoneApplicationService.Current.State["GetTopEarnerList"] = GetDataByStatesJSONRequest.dataList;
                 getDataList = (List<DataByState>)PhoneApplicationService.Current.State["GetTopEarnerList"];
                    DataSeries dataSeries = new DataSeries();

                // Set DataSeries property
                dataSeries.RenderAs = RenderAs.Bubble;
                   for (int i = 0; i < getDataList.Count; i++)
                {
                    // Create a new instance of DataPoint
                    dataPoint = new DataPoint();

                    // Set YValue for a DataPoint
                    dataPoint.YValue = Convert.ToDouble(getDataList[i].votes);

                        dataPoint.AxisXLabel = getDataList[i].party;

                    // Add dataPoint to DataPoints collection.
                    dataSeries.DataPoints.Add(dataPoint);
                }

                // Add dataSeries to Series collection.
                   chart.Series.Add(dataSeries);

                // Add chart to LayoutRoot
                LayoutRoot.Children.Add(chart);
        }
Example #12
0
        void LoadChart()
        {
            chart.Titles.Clear();
            chart.Series.Clear();
            Visifire.Charts.Title title = new Visifire.Charts.Title();
            title.Text = "释义åøøē”Ø分åøƒå›¾";
            chart.Titles.Add(title);
            DataSeries dataSeries = new DataSeries();

            dataSeries.RenderAs     = RenderAs.Column;
            dataSeries.LabelEnabled = true;
            dataSeries.LabelStyle   = LabelStyles.OutSide;

            DataPoint dataPoint;

            for (int i = 0; i < 10; i++)
            {
                dataPoint            = new DataPoint();
                dataPoint.AxisXLabel = "å¼ äø‰ēš„分" + i;
                dataPoint.YValue     = i * 2;
                dataSeries.DataPoints.Add(dataPoint);
            }
            chart.Series.Add(dataSeries);
        }
        public CategorySummary()
        {
            InitializeComponent();
            NeedRefreshData = false;
            var currencySymbol = AppSetting.Instance.DefaultCurrency.GetCurrencyStringWithNameFirst();
            chartTitleForCount = LocalizedStrings.GetLanguageInfoByKey("{0}({1})", new string[] { "CategoryTitleForCount", "ItemUnit" });
            chartTitleForAmount = "{0}({1})".FormatWith(LocalizedStrings.GetLanguageInfoByKey("CategoryTitleForAmount"), currencySymbol);

            DataMapping dm_Name = new DataMapping() { MemberName = "AxisXLabel", Path = "Name" };
            DataMapping dm_Count = new DataMapping() { MemberName = "YValue", Path = DependentValuePathForCount };
            DataMapping dm_TotalAmount = new DataMapping() { MemberName = "YValue", Path = DependentValuePathForAmount };
            MappingForCount = new DataMappingCollection() { dm_Name, dm_Count };
            MappingForTotalAmount = new DataMappingCollection() { dm_Name, dm_TotalAmount };

            this.PieChart.Series[0].DataMappings = MappingForCount;

            this.PieChart.Series[0].LabelText = "#AxisXLabel, {0}#YValue".FormatWith(AppSetting.Instance.DefaultCurrency.GetCurrentString());

            ChartTitle = new Title() { Text = string.Empty };
            summaryTitle = new Title() { Text = string.Empty };
            this.PieChart.Titles.Add(summaryTitle);
            this.PieChart.Titles.Add(ChartTitle);
            SetChartTitle(DependentValuePathForCount);
        }
Example #14
0
        public void TestingTitleBackgroundPropertyChanged()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;

            Common.CreateAndAddDefaultDataSeries(chart);

            Title title = new Title();
            title.Text = "Title1";
            title.FontSize = 15;
            title.VerticalAlignment = VerticalAlignment.Top;
            title.HorizontalAlignment = HorizontalAlignment.Center;
            title.Background = new SolidColorBrush(Colors.Magenta);
            chart.Titles.Add(title);
      
            _isLoaded = false;
            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                title.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e)
                    =>
                {
                    Assert.AreEqual("Background", e.PropertyName);
                };

                title.Background = new SolidColorBrush(Colors.Yellow);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
Example #15
0
        private void initChart()
        {
            title = new Visifire.Charts.Title();
            Axis axisX = new Axis();               //图č”ØXč½“
            Axis axisY = new Axis();               //图č”ØYč½“

            axisX.Title = "ꗶ闓";                    //ęØŖåę ‡å•ä½
            axisY.Title = "单位:xxx";                //ēŗµåę ‡å•ä½

            real_time_cab_chart.Titles.Add(title); //ę·»åŠ ę ‡é¢˜
            real_time_cab_chart.AxesX.Add(axisX);  //ę·»åŠ xč½“
            real_time_cab_chart.AxesY.Add(axisY);  //ę·»åŠ yč½“
            dataSeries = new DataSeries[_cab.Devices.Count];
            for (int i = 0; i < _cab.Devices.Count; i++)
            {
                if (!_cab.Devices[i].Type.Equals("Pump"))
                {
                    dataSeries[i]            = new DataSeries(); //ę•°ę®ē³»åˆ—
                    dataSeries[i].RenderAs   = RenderAs.Line;    //Spline : å¹³ę»‘ę›²ēŗæ Line : ꊘēŗæ
                    dataSeries[i].LegendText = _cab.Devices[i].Type;
                    real_time_cab_chart.Series.Add(dataSeries[i]);
                }
            }
        }
Example #16
0
        /// <summary>
        /// Metodo de graficaciĆ³n.
        /// </summary>
        /// <returns></returns>
        public Chart Draw(params string[] filtros)
        {
            // Create a new instance of Chart
            Chart chart = new Chart();
            Dictionary<String, decimal?> Pdvs = new Dictionary<string, decimal?>();

            chart.AnimationEnabled = true;

            // Create a new instance of Title
            Title title = new Title();
            // Set title property
            title.Text = "Volumen";
            // Add title to Titles collection
            chart.Titles.Add(title);
            // Create a new instance of DataSeries
            DataSeries dataSeries = new DataSeries();
            // Set DataSeries property
            dataSeries.RenderAs = RenderAs.Line;
            // Create a new instance of DataSeries secundary
            DataSeries dataSeriesSecundary = new DataSeries();
            // Set DataSeries property
            dataSeriesSecundary.AxisYType = AxisTypes.Secondary;

            dataSeriesSecundary.Name = "PDVs DE CADENA";
            dataSeriesSecundary.Padding = new Thickness(30);
            dataSeriesSecundary.RenderAs = RenderAs.Line;
            dataSeriesSecundary.MarkerType = Visifire.Commons.MarkerTypes.Cross;
            dataSeriesSecundary.SelectionEnabled = true;
            dataSeriesSecundary.LineThickness = 3;
            //dataSeriesSecundary.ZIndex = 4;

            #region configuracion eje X
            // Creating AxisX
            Axis axisX = new Axis();
            // Date time standard format
            axisX.ValueFormatString = "000000";
            axisX.AxisOffset = 0.02;

            //axisX.IntervalType = IntervalTypes.Months;
            // To avoid auto skip
            //
            chart.AxesX.Add(axisX);
            #endregion

            // Create a DataPoint
            DataPoint dataPoint;
            #region consulta
            DataTable kpis;

            //Adicionando 2do eje
            //Orientation axisYOrientation = Orientation.Vertical;
            //Axis axisY = new Axis();
            //axisY._isAutoGenerated = true;
            //axisY.Chart = chart;
            //axisY.AxisOrientation = axisYOrientation;
            //axisY.AxisType = AxisTypes.Secondary;
            //axisY.PlotDetails = this;
            ////axisY.AxisRepresentation = AxisRepresentations.AxisY;
            //chart.InternalAxesY.Add(axisY);
            //chart.AxesY.Add(axisY);

            string ser = "-1111";
            try
            {
                kpis = new DataTable();
                Consultas consulta = new Consultas();
                kpis = consulta.SelectKPI_Volumen(filtros).Tables[0];
                consulta = null;
                string serAnt = "-5555";

                foreach (DataRow g in kpis.Rows)
                {
                    Decimal? y = g["QtySellOut"]!=DBNull.Value?(Decimal?)g["QtySellOut"]:null;
                    Decimal? y2 = g["QtyCPW"]!=DBNull.Value?(Decimal?)g["QtyCPW"]:null;
                    long x = (long)g["TimeId"];
                    ser = (string)g["ManufacturerCode"];
                    if (serAnt != ser)
                    {
                        if (serAnt != "-5555" )
                        {
                            chart.Series.Add(dataSeries);
                        }

                        // Create a new instance of DataSeries
                        dataSeries = new DataSeries();
                        // Set DataSeries property
                        dataSeries.RenderAs = RenderAs.Line;
                        dataSeries.MarkerType = Visifire.Commons.MarkerTypes.Circle;
                        dataSeries.SelectionEnabled = true;
                        dataSeries.LineThickness = 3;
                        dataSeries.Name = "CPW "+ser;
                        /*
                            // Create a new instance of DataSeries
                            //dataSeriesSecundary = new DataSeries();
                            // Set DataSeries property
                            dataSeriesSecundary.RenderAs = RenderAs.Line;
                            dataSeriesSecundary.Name = ser;
                            dataSeriesSecundary.MarkerType = Visifire.Commons.MarkerTypes.Circle;
                            dataSeriesSecundary.SelectionEnabled = true;
                            dataSeriesSecundary.LineThickness = 3;
                        */
                    }
                    // Create a new instance of DataPoint
                    dataPoint = new DataPoint();
                    // Set YValue for a DataPoint
                    dataPoint.AxisXLabel = x.ToString();
                    if (!ciclos.Contains(x.ToString())) ciclos.Add(x.ToString());
                    dataPoint.YValue = System.Convert.ToDouble(y);
                    // Add dataPoint to DataPoints collection.
                    dataSeries.DataPoints.Add(dataPoint);
                    //Almacenando los maximos de QtyCPW
                    if (!Pdvs.ContainsKey(x.ToString()))
                    {
                        Pdvs.Add(x.ToString(), y2);
                    }
                    else
                    {
                        decimal? value = Pdvs[x.ToString()];
                        if (y2 > value)
                        {
                            Pdvs.Remove(x.ToString());
                            Pdvs.Add(x.ToString(),y2);
                        }
                    }
                    /*
                    if (ser.Contains("PDV"))
                    {
                        // Create a new instance of DataPoint
                        dataPoint = new DataPoint();
                        // Set YValue for a DataPoint
                        if (x != null) dataPoint.AxisXLabel = x.ToString();
                        if (!ciclos.Contains(x.ToString()))  ciclos.Add(x.ToString());
                        //dataPoint.XValue = x;
                        dataPoint.YValue = System.Convert.ToDouble(y);
                        // Add dataPoint to DataPoints collection.
                        dataSeriesSecundary.DataPoints.Add(dataPoint);
                    }
                     */
                    serAnt = ser;
                }
            }
            catch (Exception Error)
            {
                throw (new Exception(Error.ToString()));
            }
            #endregion
            // Add dataSeries to Series collection.
            chart.Series.Add(dataSeries);
            //Llenando eje secundario
            foreach (string cicloTMP in ciclos)
            {
                // Create a new instance of DataPoint
                dataPoint = new DataPoint();
                // Set YValue for a DataPoint
                dataPoint.AxisXLabel = cicloTMP;
                //dataPoint.XValue = x;
                decimal? value = -111111111;
                if (Pdvs.ContainsKey(cicloTMP))
                {
                    value = Pdvs[cicloTMP];
                    dataPoint.YValue = System.Convert.ToDouble(value);
                }
                // Add dataPoint to DataPoints collection.
                dataSeriesSecundary.DataPoints.Add(dataPoint);

            }
            chart.Series.Add(dataSeriesSecundary);
            return chart;
        }
        private void Draw_btn_Click(object sender, RoutedEventArgs e)
        {
            // Null Exception
            if (this.RowData_Container.Count == 0)
            {
                MessageBox.Show("ęŸ„č©¢äøåˆ°é»žč³‡ę–™! č£½åœ–äø­ę–·...");
                MessageBox.Show("꜃äøęœƒę˜Æčح備åœØꙂ間ēƄ圍內äø¦ę²’ęœ‰äøŠē·š?");
                return;
            }

            // Default Initialize Value
            // Definition
            Double Data_Sum = 0;
            Double[] Range = new Double[2];
            Double Min = 0;
            Double Max = 0;

            // Chart
            Visifire.Charts.Chart chart = new Visifire.Charts.Chart();

            // Title
            Title title = new Visifire.Charts.Title() 
            { 
                FontSize = 22,
                VerticalAlignment = System.Windows.VerticalAlignment.Bottom 
            };
            

            foreach (var sensorData in this.RowData_Container)
            {
                // Get Current Sensor Detail Data
                int _index = this.RowData_Container.IndexOf(sensorData);
                List<string> _getSplit =
                    ((this.Waiting_lobby.Items[_index] as ListBoxItem).Content as string).Split('\n').ToList();
                
                string item_name = _getSplit[0].Split('(').ToList()[0].Trim();
                string item_unit = _getSplit[0].Split('(').ToList()[1].Trim().Split(')').ToList()[0];
                string plan_name = _getSplit[1].Trim(); 
                string group_name = _getSplit[2].Trim();

                // Sum
                Data_Sum += sensorData.Count;

                // Min & Max
                var min = sensorData.Min(s => s.Value);
                var max = sensorData.Max(s => s.Value);

                if (Range[0] > min)
                    Range[0] = min;
                else if (Range[0] == 0.0)
                    Range[0] = min;

                if (Range[1] < max)
                    Range[1] = max;

                if (Range[0] == Range[1])
                {
                    Range[0]--;
                    Range[1]++;
                }

                // DataSeries
                DataSeries dataSeries = new DataSeries();

                if (Data_Sum > 200)
                    dataSeries.RenderAs = RenderAs.QuickLine;
                else
                    dataSeries.RenderAs = RenderAs.Line;

               
                
                chart.Legends.Add(new Legend()
                {
                    Title = "圖例",
                    IsEnabled = false,
                    TitleBackground = null,
                    TitleFontSize = 22,
                    TitleFontColor = new SolidColorBrush(Colors.Black),
                    //Background = new SolidColorBrush(Colors.Black),
                    FontSize = 13,
                    MarkerSize = 20,
                    VerticalAlignment = VerticalAlignment.Top,
                    VerticalContentAlignment = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Right,
                    HorizontalContentAlignment = HorizontalAlignment.Right,
                    Background = new SolidColorBrush(Colors.White)
                });
                 
                
                
                //dataSeries.Color = new SolidColorBrush(Colors.White);
                //dataSeries.MarkerType = Visifire.Commons.MarkerTypes.Line;
                //dataSeries.LegendMarkerType = Visifire.Commons.MarkerTypes.Square;
                dataSeries.LineThickness = 2;
                dataSeries.LightingEnabled = true;
                dataSeries.LineStyle = LineStyles.Solid;
                dataSeries.SelectionEnabled = true;
                dataSeries.MovingMarkerEnabled = true;
                dataSeries.ShowInLegend = true; // Show Legend 
                dataSeries.IncludeDataPointsInLegend = false;
                //dataSeries.LegendText = item_name + '\n' + 
                //                        plan_name + '\n' + 
                //                        group_name;
                dataSeries.LegendText = item_name + '\n' +
                                        plan_name;

                // Due to data equal zero exception
                if (Data_Sum != 0)
                {
                    foreach (tblAIItem1HourLog data in sensorData)
                    {
                        // DataPoint
                        DataPoint dataPoint = new DataPoint();

                        if (this.Sensor_List.Items.Count == 1)
                        {
                            #region čح定Point大小ļ¼ŒéšØč³‡ę–™å¤šåÆ”ļ¼Œēø®ę”¾ć€‚

                            if (Data_Sum < 500)
                                dataPoint.MarkerSize = 5;
                            else if (Data_Sum < 1000)
                                dataPoint.MarkerSize = 4.5;
                            else if (Data_Sum < 1500)
                                dataPoint.MarkerSize = 4;
                            else if (Data_Sum < 2000)
                                dataPoint.MarkerSize = 3.5;
                            else if (Data_Sum < 2500)
                                dataPoint.MarkerSize = 3;
                            else if (Data_Sum < 3000)
                                dataPoint.MarkerSize = 2.5;
                            else if (Data_Sum < 3500)
                                dataPoint.MarkerSize = 2;
                            else if (Data_Sum < 4000)
                                dataPoint.MarkerSize = 1.5;
                            else if (Data_Sum < 4500)
                                dataPoint.MarkerSize = 1;
                            else
                                dataPoint.MarkerSize = 0.5;

                            #endregion čح定Point大小ļ¼ŒéšØč³‡ę–™å¤šåÆ”ļ¼Œēø®ę”¾ć€‚
                        }

                        // Value
                        dataPoint.YValue = data.Value;

                        // Label
                        dataPoint.AxisXLabel = string.Format("{0:MM/dd HH:mm}", data.Timestamp);

                        // Adding to dataseries
                        dataSeries.DataPoints.Add(dataPoint);
                    }

                    // DataSeries Tooltips
                    dataSeries.ToolTipText =
                        "ꄟēŸ„å™Ø锞型: " + item_name + '\n' +
                        "地區: " + plan_name + '\n' +
                        "ē¾¤ēµ„: " + group_name  + '\n' +
                        "Ꙃ間: #AxisXLabel" + "\n" +
                        "č³‡ę–™: #YValue " + item_unit;

                    // Adding
                    chart.Series.Add(dataSeries);
                }
            }

            #region Detail Information

            this.sum_tb.Text = "č³‡ę–™é‡: " + string.Format("{0:0.00}",Data_Sum);
            this.min_tb.Text = "ęœ€å°å€¼: " + string.Format("{0:0.00}", Range[0]);
            this.max_tb.Text = "ęœ€å¤§å€¼: " + string.Format("{0:0.00}", Range[1]);

            #endregion

            #region Final Chart Set

            // Chart Title
            //title.Text = "ꄟēŸ„å™Ø關čÆåˆ†ęžåœ–";
            title.Text = String.Format("{0:yyyy/MM/dd}", this.Start_Date) + "ļ½ž" + String.Format("{0:yyyy/MM/dd}", this.End_Date)
                              + " ꄟēŸ„å™Ø關čÆåˆ†ęžåœ–";

            //!++ Xč»ø
            Axis axisX = new Axis();
            axisX.AxisLabels = new AxisLabels();
            //axisX.AxisLabels.Enabled = false;
            axisX.AxisLabels.Enabled = true;
            axisX.AxisLabels.Angle = -90;
            axisX.Title = "Ꙃ間";

            //!++ Yč»ø
            Axis yaxis = new Axis();
            //yaxis.Opacity = 0;

            // Max & Min
            yaxis.AxisMaximum = Range[1];
            yaxis.AxisMinimum = Range[0];

            double _min = Convert.ToDouble(yaxis.AxisMinimum);
            double _max = Convert.ToDouble(yaxis.AxisMaximum);
            if (_max <= _min)
            {
                //MessageBox.Show("ē”¢ē”Ÿ ęœ€å¤§å€¼ < ęœ€å°å€¼ ēš„問锌");
                yaxis.AxisMaximum = _max = 1;
                yaxis.AxisMinimum = _min = 0;
            }

            // 加兄
            chart.AxesX.Add(axisX);
            chart.AxesY.Add(yaxis);
            chart.Titles.Add(title);

            //?+ Chart čح定
            chart.ToolBarEnabled = false;
            chart.ScrollingEnabled = true;
            chart.LightingEnabled = true;
            chart.IndicatorEnabled = true;
            chart.AnimationEnabled = true;
            chart.AnimatedUpdate = true;
            chart.ZoomingEnabled = true;
            chart.ShadowEnabled = true;
            chart.Theme = "Theme3";
            //chart.Height = this.Chart_sp.ActualHeight;
            Thickness tk = new Thickness() { Bottom = 1, Top = 1 };
            chart.Margin = tk;

            #endregion

            this.Chart_Grid.Children.Clear();
            this.Chart_Grid.Children.Add(chart);

            Button exportBtn = new Button() { Content = "圖ē‰‡" };
        }
Example #18
0
        /// <summary>
        /// Create labels for DataPoint
        /// </summary>
        /// <param name="dataPoint">DataPoint</param>
        /// <returns>Border</returns>
        private static Border CreateLabelForDataPoint(DataPoint dataPoint, Boolean isStreamLine, Int32 sliceIndex)
        {
            Title title = new Title()
            {
                IsNotificationEnable = false,
                Chart = dataPoint.Chart,
                Text = dataPoint.TextParser(dataPoint.LabelText),
                InternalFontSize = (Double)dataPoint.LabelFontSize,
                InternalFontColor = (isStreamLine && sliceIndex == 0) ? Chart.CalculateDataPointLabelFontColor(dataPoint.Chart as Chart, dataPoint, null, LabelStyles.OutSide) : Chart.CalculateDataPointLabelFontColor(dataPoint.Chart as Chart, dataPoint, dataPoint.LabelFontColor, (LabelStyles)dataPoint.LabelStyle),
                InternalFontFamily = dataPoint.LabelFontFamily,
                InternalFontStyle = (FontStyle)dataPoint.LabelFontStyle,
                InternalFontWeight = (FontWeight)dataPoint.LabelFontWeight,
                InternalBackground = dataPoint.LabelBackground
            };

            // If its a StreamLine funnel then default size of the Title should be a bit bigger 
            if (isStreamLine && sliceIndex == 0 && dataPoint.GetValue(DataPoint.LabelFontSizeProperty) == null && dataPoint.Parent.GetValue(DataPoint.LabelFontSizeProperty) == null)
            {
                title.InternalFontSize = 11.5;
            }

            title.CreateVisualObject(new ElementData() { Element = dataPoint });

            if (!(Boolean)dataPoint.LabelEnabled)
                title.Visual.Visibility = Visibility.Collapsed;

            return title.Visual;
        }
Example #19
0
        public void CreatePowerChart(string startDate, string endDate)
        {
            try
            {
                #region 功ēŽ‡å›¾č”Ø处ē†
                string chartTitle = string.Empty;
                string unit = string.Empty;
                ChartData chartData = null;
                try
                {
                    chartData = DataUtil.getPowerData(this.plantId, startDate, endDate);
                    if (chartData == null)
                    {
                        gidPowerChartContainer.Children.Clear();
                        Label l = new Label();
                        l.Content = "ę— ę•°ę®";
                        l.HorizontalAlignment = HorizontalAlignment.Center;
                        l.VerticalAlignment = VerticalAlignment.Center;
                        l.FontSize = 48;
                        gidPowerChartContainer.Children.Add(l);
                        return;
                    }
                }
                catch (Exception e2)
                {
                    Console.WriteLine(e2.StackTrace);
                    gidPowerChartContainer.Children.Clear();
                    Label l = new Label();
                    l.Content = "ę— ę•°ę®";
                    l.HorizontalAlignment = HorizontalAlignment.Center;
                    l.VerticalAlignment = VerticalAlignment.Center;
                    l.FontSize = 48;
                    gidPowerChartContainer.Children.Add(l);
                    return;
                }

                Chart chart = new Chart();
                ColorSet cs = new ColorSet();
                cs.Brushes.Add(new SolidColorBrush(Color.FromArgb(240, 252, 101, 6)));
                cs.Id = "colorSet1";
                chart.ColorSets.Add(cs);
                chart.ColorSet = "colorSet1";
                chart.BorderBrush = new SolidColorBrush(Color.FromArgb(155, 0, 0, 0));
                chart.Background = new SolidColorBrush(Color.FromArgb(1, 255, 255, 255));
                chart.View3D = false;
                chart.ScrollingEnabled = false;
                chart.CornerRadius = new CornerRadius(30);
                Title title = new Title();
                chart.Titles.Add(title);
                Axis axisX = new Axis();
                axisX.IntervalType = IntervalTypes.Number;
                axisX.Interval = 24;
                axisX.FontSize = 20;
                AxisLabels labels = new AxisLabels();
                axisX.AxisLabels = labels;
                labels.Angle = -45;
                labels.FontSize = 22;
                chart.AxesX.Add(axisX);

                Axis axisY = new Axis();
                axisY.Title = "kW";
                axisY.FontSize = 22;
                axisY.AxisMinimum = 0;
                axisY.TitleFontSize = 20;
                axisY.AxisType = AxisTypes.Primary;

                Axis axisY2 = new Axis();
                axisY2.Title = "W/掔";
                axisY2.FontSize = 22;
                axisY2.TitleFontSize = 20;
                axisY2.AxisMinimum = 0;
                axisY2.ValueFormatString = "0";
                axisY2.AxisType = AxisTypes.Secondary;

                labels = new AxisLabels();
                labels.FontSize = 22;
                axisY.AxisLabels = labels;
                chart.AxesY.Add(axisY);

                labels = new AxisLabels();
                labels.FontSize = 22;
                axisY2.AxisLabels = labels;
                chart.AxesY.Add(axisY2);

                Legend legend1 = new Legend();
                legend1.FontSize = 14;
                chart.Legends.Add(legend1);

                DataSeries dataSeries = new DataSeries();
                dataSeries.RenderAs = RenderAs.Area;
                dataSeries.XValueType = ChartValueTypes.Auto;
                DataPoint dataPoint;
                dataSeries.AxisYType = AxisTypes.Primary;
                dataSeries.LegendText = chartData.series[0].name;
                for (int i = 0; i < chartData.series[0].data.Count(); i++)
                {
                    dataPoint = new DataPoint();
                    //dataPoint.YValue = chartData.series[0].data[i] == null ? 0 : chartData.series[0].data[i].Value;
                    if (chartData.series[0].data[i] != null)
                        dataPoint.YValue = chartData.series[0].data[i].Value;
                    dataPoint.AxisXLabel = chartData.categories[i];
                    dataSeries.DataPoints.Add(dataPoint);
                }

                chart.Series.Add(dataSeries);
                //if(chartData.series)
                DataSeries dataSunSeries = new DataSeries();
                dataSunSeries.RenderAs = RenderAs.QuickLine;
                dataSunSeries.XValueType = ChartValueTypes.Auto;
                DataPoint sundataPoint;
                dataSunSeries.AxisYType = AxisTypes.Secondary;
                dataSunSeries.LegendText = chartData.series[1].name;
                dataSunSeries.Color = new SolidColorBrush(Color.FromRgb(23, 118, 184));
                dataSunSeries.LineThickness = 2;
                for (int i = 0; i < chartData.series[1].data.Count(); i++)
                {
                    sundataPoint = new DataPoint();
                    if (chartData.series[1].data[i] != null)
                        sundataPoint.YValue = chartData.series[1].data[i].Value;
                    //sundataPoint.AxisXLabel = chartData.categories[i];
                    dataSunSeries.DataPoints.Add(sundataPoint);
                }
                chart.Series.Add(dataSunSeries);
                double maxValue = dataSunSeries.DataPoints.Max(m => m.YValue);
                if (maxValue < 7 || maxValue.Equals(double.NaN))
                {
                    axisY2.AxisMaximum = 0;
                    axisY2.AxisMaximum = 7;
                    axisY2.Interval = 1;
                }
                gidPowerChartContainer.Children.Clear();
                gidPowerChartContainer.Children.Add(chart);
                #endregion
            }
            catch (Exception ee)
            {
                LogUtil.error("CreatePowerChart error:" + ee.StackTrace);
                throw ee;
            }
        }
Example #20
0
        /// <summary>
        /// ē»˜åˆ¶å‘ē”µé‡å›¾č”Ø
        /// </summary>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <param name="type">1:week 2:month</param>
        public void CreateEnergyChart(string startDate, string endDate, int type)
        {
            try
            {
                columnWidth = curPage == int.Parse(ConfigPara.MonthEnergyChartPage) ? 2 : 5;
                float maxValue = 0f;
                #region 发ē”µé‡å›¾č”Øę˜¾ē¤ŗ
                string chartTitle = string.Empty;
                string unit = string.Empty;
                string startDateStr = string.Format("{0}-{1}-{2}", startDate.Substring(0, 4), startDate.Substring(4, 2), startDate.Substring(6, 2));

                DateTime startDateTime = DateTime.Parse(startDateStr);
                IList<KeyValuePair<string, float?>> energyChartData;
                try
                {
                    energyChartData = DataUtil.getEnergyData(this.plantId, startDate, endDate, chartTitle, unit, out maxValue);
                    if (energyChartData == null)
                    {
                        gidEnergyChartContainer.Children.Clear();
                        Label l = new Label();
                        l.Content = "ę— ę•°ę®";
                        l.HorizontalAlignment = HorizontalAlignment.Center;
                        l.VerticalAlignment = VerticalAlignment.Center;
                        l.FontSize = 48;
                        gidEnergyChartContainer.Children.Add(l);
                        return;
                    }
                }
                catch (Exception e2)
                {
                    Console.WriteLine(e2.Message);
                    gidEnergyChartContainer.Children.Clear();
                    Label l = new Label();
                    l.Content = "ę— ę•°ę®";
                    l.HorizontalAlignment = HorizontalAlignment.Center;
                    l.VerticalAlignment = VerticalAlignment.Center;
                    l.FontSize = 48;
                    gidEnergyChartContainer.Children.Add(l);
                    return;
                }
                Chart energyChart = new Chart();
                ColorSet cs = new ColorSet();
                cs.Brushes.Add(new SolidColorBrush(Color.FromArgb(240, 252, 101, 6)));
                cs.Id = "colorSet1";

                energyChart.ColorSets.Add(cs);
                energyChart.ColorSet = "colorSet1";
                energyChart.BorderBrush = new SolidColorBrush(Color.FromArgb(155, 0, 0, 0));
                energyChart.Background = new SolidColorBrush(Color.FromArgb(1, 255, 255, 255));

                energyChart.View3D = false;
                energyChart.ScrollingEnabled = false;
                energyChart.CornerRadius = new CornerRadius(30);
                Title energTitle = new Title();
                energTitle.FontSize = 22;
                energyChart.Titles.Add(energTitle);
                Axis eaxis = new Axis();
                eaxis.IntervalType = IntervalTypes.Number;
                if (type == 2)
                    eaxis.Interval = 2;
                eaxis.TitleFontSize = 22;
                eaxis.FontSize = 22;

                AxisLabels elabels = new AxisLabels();
                elabels.FontSize = 22;
                eaxis.AxisLabels = elabels;

                elabels.Angle = -45;
                energyChart.AxesX.Add(eaxis);

                Axis eaxisY = new Axis();
                eaxisY.Title = "kWh";
                eaxisY.FontSize = 24;
                eaxisY.TitleFontSize = 22;
                elabels = new AxisLabels();
                elabels.FontSize = 22;
                eaxisY.AxisLabels = elabels;
                energyChart.AxesY.Add(eaxisY);

                DataSeries edataSeries = new DataSeries();
                edataSeries.RenderAs = RenderAs.Column;
                edataSeries.XValueType = ChartValueTypes.Auto;
                DataPoint edataPoint;
                double percent20 = maxValue * 0.02;
                for (int i = 0; i < energyChartData.Count; i++)
                {
                    edataPoint = new DataPoint();
                    edataPoint.AxisXLabel = startDateTime.AddDays(i).ToString("yy/MM/dd");
                    edataPoint.XValue = i;
                    edataPoint.YValue = (double)energyChartData[i].Value;
                    edataPoint.ToolTipText = string.Format("{0},{1}", edataPoint.AxisXLabel, energyChartData[i].Value);
                    if (edataPoint.YValue < percent20 && edataPoint.YValue > 0)
                        edataPoint.YValue = percent20;
                    edataSeries.DataPoints.Add(edataPoint);
                }
                energyChart.DataPointWidth = columnWidth;
                energyChart.Series.Add(edataSeries);
                gidEnergyChartContainer.Children.Clear();
                gidEnergyChartContainer.Children.Add(energyChart);
                #endregion
            }
            catch (Exception ee)
            {
                LogUtil.error("CreateEnergyChart error:" + ee.StackTrace);
                throw ee;
            }
        }
        /// <summary>
        /// Titlečµ‹å€¼
        /// </summary>
        /// <param name="c"></param>
        /// <param name="titleMsg"></param>
        private static void SetTitle(Chart c, string titleMsg)
        {
            // Create a new instance of Title
            Title title = new Title();

            // Set title property
            title.Text = titleMsg;

            // Add title to Titles collection
            c.Titles.Add(title);
        }
Example #22
0
        public Chart CreateChart(Stock stock)
        {
            Visifire.Charts.Chart visiChart = new Visifire.Charts.Chart();
            Visifire.Charts.Title title     = new Visifire.Charts.Title();

            title.Text = stock.Name;
            visiChart.Titles.Add(title);

            visiChart.Width  = 300;
            visiChart.Height = 200;

            Visifire.Charts.DataSeries dataSeriesClose = new Visifire.Charts.DataSeries();
            Visifire.Charts.DataSeries dataSeriesOpen  = new Visifire.Charts.DataSeries();
            Visifire.Charts.DataSeries dataSeriesLow   = new Visifire.Charts.DataSeries();
            Visifire.Charts.DataSeries dataSeriesHigh  = new Visifire.Charts.DataSeries();


            Visifire.Charts.DataPoint dataPointClose;
            Visifire.Charts.DataPoint dataPointOpen;
            Visifire.Charts.DataPoint dataPointLow;
            Visifire.Charts.DataPoint dataPointHigh;

            foreach (var stockVal in stock.values)
            {
                if (stockVal.Open.HasValue)
                {
                    dataPointOpen        = new DataPoint();
                    dataPointOpen.YValue = stockVal.Open.Value;
                    dataSeriesOpen.DataPoints.Add(dataPointOpen);
                }
                if (stockVal.High.HasValue)
                {
                    dataPointHigh        = new DataPoint();
                    dataPointHigh.YValue = stockVal.High.Value;
                    dataSeriesHigh.DataPoints.Add(dataPointHigh);
                }
                if (stockVal.Close.HasValue)
                {
                    dataPointClose        = new DataPoint();
                    dataPointClose.YValue = stockVal.Close.Value;
                    dataSeriesClose.DataPoints.Add(dataPointClose);
                }
                if (stockVal.Low.HasValue)
                {
                    dataPointLow        = new DataPoint();
                    dataPointLow.YValue = stockVal.Low.Value;
                    dataSeriesLow.DataPoints.Add(dataPointLow);
                }
            }

            if (dataSeriesLow.DataPoints.Count > 0)
            {
                dataSeriesLow.RenderAs = RenderAs.Line;
                dataSeriesLow.Name     = "Low";
                visiChart.Series.Add(dataSeriesLow);
            }
            if (dataSeriesHigh.DataPoints.Count > 0)
            {
                dataSeriesHigh.RenderAs = RenderAs.Line;
                dataSeriesHigh.Name     = "High";
                visiChart.Series.Add(dataSeriesHigh);
            }
            if (dataSeriesOpen.DataPoints.Count > 0)
            {
                dataSeriesOpen.RenderAs = RenderAs.Line;
                dataSeriesOpen.Name     = "Open";
                visiChart.Series.Add(dataSeriesOpen);
            }
            if (dataSeriesClose.DataPoints.Count > 0)
            {
                dataSeriesClose.RenderAs = RenderAs.Line;
                dataSeriesClose.Name     = "Close";
                visiChart.Series.Add(dataSeriesClose);
            }
            return(visiChart);
        }
Example #23
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.Tab = ((System.Windows.Controls.TabControl)(target));
                return;

            case 2:
                this.txtQueryKey = ((System.Windows.Controls.TextBox)(target));
                return;

            case 3:
                this.cbCondition = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 4:

            #line 34 "..\..\LinksExtracted.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btClear);

            #line default
            #line hidden
                return;

            case 5:
                this.rbOneMode = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 6:
                this.rbTwoMode = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 7:
                this.Rand10 = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 8:
                this.Rand20 = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 9:
                this.Rand50 = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 10:
                this.Rand100 = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 11:

            #line 57 "..\..\LinksExtracted.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Query);

            #line default
            #line hidden
                return;

            case 12:
                this.tbTotal = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 13:
                this.tbInclude = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 14:
                this.tbIncludeRate = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 15:

            #line 76 "..\..\LinksExtracted.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.ReturnQuery);

            #line default
            #line hidden
                return;

            case 16:
                this.tvKey = ((System.Windows.Controls.ListBox)(target));

            #line 97 "..\..\LinksExtracted.xaml"
                this.tvKey.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.tvKey_SelectionChanged);

            #line default
            #line hidden
                return;

            case 17:
                this.dgQueryResult = ((System.Windows.Controls.DataGrid)(target));
                return;

            case 18:
                this.MyChart = ((Visifire.Charts.Chart)(target));
                return;

            case 19:
                this.ChartTitle = ((Visifire.Charts.Title)(target));
                return;

            case 20:
                this.dataSeries = ((Visifire.Charts.DataSeries)(target));
                return;

            case 21:
                this.Paiming = ((Visifire.Charts.DataPoint)(target));
                return;

            case 22:
                this.noPaiming = ((Visifire.Charts.DataPoint)(target));
                return;

            case 23:
                this.pbQuery = ((System.Windows.Controls.ProgressBar)(target));
                return;
            }
            this._contentLoaded = true;
        }
Example #24
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.Tab = ((System.Windows.Controls.TabControl)(target));
                return;

            case 2:
                this.txtQueryKey = ((System.Windows.Controls.TextBox)(target));
                return;

            case 3:
                this.cbCondition = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 4:

            #line 35 "..\..\ConditionQuery.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btClear);

            #line default
            #line hidden
                return;

            case 5:
                this.rbOneMode = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 6:
                this.rbTwoMode = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 7:
                this.rbThreeMode = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 8:
                this.Rand10 = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 9:
                this.Rand20 = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 10:
                this.Rand50 = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 11:
                this.Rand100 = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 12:
                this.RandCustom = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 13:
                this.iudCustomBDPages = ((Xceed.Wpf.Toolkit.IntegerUpDown)(target));

            #line 61 "..\..\ConditionQuery.xaml"
                this.iudCustomBDPages.GotFocus += new System.Windows.RoutedEventHandler(this.iudCustomBDPages_GotFocus);

            #line default
            #line hidden
                return;

            case 14:
                this.chkSimulation = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 15:

            #line 72 "..\..\ConditionQuery.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btDelDomain);

            #line default
            #line hidden
                return;

            case 16:
                this.chkBaidu = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 17:
                this.chk360 = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 18:
                this.chkSogou = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 19:

            #line 85 "..\..\ConditionQuery.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Query);

            #line default
            #line hidden
                return;

            case 20:
                this.tbTotal = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 21:
                this.btReturn = ((System.Windows.Controls.Button)(target));

            #line 101 "..\..\ConditionQuery.xaml"
                this.btReturn.Click += new System.Windows.RoutedEventHandler(this.ReturnQuery);

            #line default
            #line hidden
                return;

            case 22:
                this.btAll = ((System.Windows.Controls.Button)(target));

            #line 109 "..\..\ConditionQuery.xaml"
                this.btAll.Click += new System.Windows.RoutedEventHandler(this.AllResult);

            #line default
            #line hidden
                return;

            case 23:
                this.btExport = ((System.Windows.Controls.Button)(target));

            #line 116 "..\..\ConditionQuery.xaml"
                this.btExport.Click += new System.Windows.RoutedEventHandler(this.ResultExport);

            #line default
            #line hidden
                return;

            case 24:
                this.NowKey = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 25:
                this.tvKey = ((System.Windows.Controls.ListBox)(target));

            #line 138 "..\..\ConditionQuery.xaml"
                this.tvKey.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.tvKey_SelectionChanged);

            #line default
            #line hidden
                return;

            case 26:
                this.dgQueryResult = ((System.Windows.Controls.DataGrid)(target));
                return;

            case 27:
                this.wbSimulation = ((System.Windows.Controls.WebBrowser)(target));

            #line 164 "..\..\ConditionQuery.xaml"
                this.wbSimulation.Navigated += new System.Windows.Navigation.NavigatedEventHandler(this.wbSimulation_Navigated);

            #line default
            #line hidden

            #line 164 "..\..\ConditionQuery.xaml"
                this.wbSimulation.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(this.wbSimulation_LoadCompleted);

            #line default
            #line hidden
                return;

            case 28:
                this.MyChart = ((Visifire.Charts.Chart)(target));
                return;

            case 29:
                this.ChartTitle = ((Visifire.Charts.Title)(target));
                return;

            case 30:
                this.dataSeries = ((Visifire.Charts.DataSeries)(target));
                return;

            case 31:
                this.Paiming = ((Visifire.Charts.DataPoint)(target));
                return;

            case 32:
                this.noPaiming = ((Visifire.Charts.DataPoint)(target));
                return;

            case 33:
                this.pbQuery = ((System.Windows.Controls.ProgressBar)(target));
                return;
            }
            this._contentLoaded = true;
        }
Example #25
0
        /// <summary>
        /// Metodo de graficaciĆ³n.
        /// </summary>
        /// <returns></returns>
        public Chart Draw(params string[] filtros)
        {
            // Create a new instance of Chart
            Chart chart = new Chart();

            chart.AnimationEnabled = true;
            // Create a new instance of Title
            Title title = new Title();
            // Set title property
            title.Text = "Switch Selling Por SKU";
            // Add title to Titles collection
            chart.Titles.Add(title);
            // Create a new instance of DataSeries
            DataSeries dataSeries = new DataSeries();
            // Set DataSeries property
            dataSeries.RenderAs = RenderAs.Column;
            // Create a DataPoint
            DataPoint dataPoint;
            #region consulta
            DataTable kpis;
            try
            {
                kpis = new DataTable();
                Consultas consulta = new Consultas();
                kpis = consulta.SelectKPI_SwitchSellingSKU(filtros).Tables[0];
                consulta = null;
                string serAnt = "-5555";
                string ser = "-1111";
                foreach (DataRow g in kpis.Rows)
                {
                    string x = (string)g["ProductSubfamilyDescription"];
                    long? y = g["NbrSwitchSelling"]!=DBNull.Value?(long?)g["NbrSwitchSelling"]:null;
                    ser = (string)g["IndustryLevel"];
                    //Creando las series
                    if (serAnt != ser)
                    {
                        if (serAnt != "-5555")
                        {
                            chart.Series.Add(dataSeries);
                        }
                        // Create a new instance of DataSeries
                        dataSeries = new DataSeries();
                        dataSeries.Name = ser;
                        // Set DataSeries property
                        dataSeries.RenderAs = RenderAs.Line;
                        dataSeries.MarkerType = Visifire.Commons.MarkerTypes.Circle;
                        dataSeries.SelectionEnabled = true;
                        dataSeries.LineThickness = 3;

                    }
                    // Create a new instance of DataPoint
                    dataPoint = new DataPoint();
                    // Set YValue for a DataPoint
                    if (x != null) dataPoint.AxisXLabel = x.ToString();
                    if (!ciclos.Contains(x.ToString()))  ciclos.Add(x.ToString());
                    dataPoint.YValue = System.Convert.ToDouble(y);
                    // Add dataPoint to DataPoints collection.
                    dataSeries.DataPoints.Add(dataPoint);
                    serAnt = ser;
                }
            }
            catch (Exception Error)
            {
                throw (new Exception(Error.ToString()));
            }
            #endregion
            // Add dataSeries to Series collection.
            chart.Series.Add(dataSeries);
            return chart;
        }
Example #26
0
        public void TestingTitlesCollectionChanged()
        {
            Chart chart = new Chart();

            Int32 titlesAdded = 0;

            chart.Background = new SolidColorBrush(Colors.LightGray);

            chart.Width = 400;
            chart.Height = 300;

            _isLoaded = false;

            Common.CreateAndAddDefaultDataSeries(chart);

            Title title = new Title();
            title.Text = "Title1";
            title.VerticalAlignment = VerticalAlignment.Top;
            title.HorizontalAlignment = HorizontalAlignment.Center;
            chart.Titles.Add(title);

            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            chart.Titles.CollectionChanged += (object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
                =>
            {
                if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
                {
                    titlesAdded += e.NewItems.Count;
                    Assert.AreEqual(1, e.NewItems.Count);
                }
            };

            title = new Title();
            title.Text = "Title2";
            title.VerticalAlignment = VerticalAlignment.Center;
            title.HorizontalAlignment = HorizontalAlignment.Right;
            chart.Titles.Add(title);

            title = new Title();
            title.Text = "Title3";
            title.VerticalAlignment = VerticalAlignment.Bottom;
            title.HorizontalAlignment = HorizontalAlignment.Center;
            chart.Titles.Add(title);

            title = new Title();
            title.Text = "Title4";
            title.VerticalAlignment = VerticalAlignment.Center;
            title.HorizontalAlignment = HorizontalAlignment.Left;
            chart.Titles.Add(title);

            title = new Title();
            title.Text = "Title5";
            title.VerticalAlignment = VerticalAlignment.Top;
            title.HorizontalAlignment = HorizontalAlignment.Stretch;
            title.Background = new SolidColorBrush(Colors.Gray);
            chart.Titles.Add(title);

            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
                Assert.AreEqual(4, titlesAdded);

            window.Dispatcher.InvokeShutdown();
            window.Close();

        }
Example #27
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.Tab = ((System.Windows.Controls.TabControl)(target));
                return;

            case 2:
                this.chkBaidu = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 3:
                this.chk360 = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 4:
                this.txtQueryKey = ((System.Windows.Controls.TextBox)(target));
                return;

            case 5:
                this.Rand10 = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 6:
                this.Rand20 = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 7:
                this.Rand50 = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 8:
                this.Rand100 = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 9:

            #line 47 "..\..\PlatformQuery.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btQuery);

            #line default
            #line hidden
                return;

            case 10:
                this.tbTotal = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 11:

            #line 64 "..\..\PlatformQuery.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.ReturnQuery);

            #line default
            #line hidden
                return;

            case 12:
                this.tvKey = ((System.Windows.Controls.ListBox)(target));

            #line 84 "..\..\PlatformQuery.xaml"
                this.tvKey.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.tvKey_SelectionChanged);

            #line default
            #line hidden
                return;

            case 13:
                this.dgQueryResult = ((System.Windows.Controls.DataGrid)(target));
                return;

            case 14:
                this.MyChart = ((Visifire.Charts.Chart)(target));
                return;

            case 15:
                this.ChartTitle = ((Visifire.Charts.Title)(target));
                return;

            case 16:
                this.dataSeries = ((Visifire.Charts.DataSeries)(target));
                return;

            case 17:
                this.pbQuery = ((System.Windows.Controls.ProgressBar)(target));
                return;
            }
            this._contentLoaded = true;
        }
Example #28
0
        /// <summary>
        /// Metodo de graficaciĆ³n.
        /// </summary>
        /// <returns></returns>
        public Chart Draw(params string[] filtros)
        {
            // Create a new instance of Chart
            Chart chart = new Chart();

            chart.AnimationEnabled = true;
            // Create a new instance of Title
            Title title = new Title();
            // Set title property
            title.Text = "Clientes ITO Vs Clientes UX";
            // Add title to Titles collection
            chart.Titles.Add(title);
            // Create a new instance of DataSeries
            DataSeries dataSeries = new DataSeries();
            // Set DataSeries property
            dataSeries.RenderAs = RenderAs.Line;
            dataSeries.MarkerType = Visifire.Commons.MarkerTypes.Circle;
            dataSeries.SelectionEnabled = true;
            dataSeries.LineThickness = 3;

            // Create a new instance of DataSeries2
            DataSeries dataSeries2 = new DataSeries();
            // Set DataSeries property
            dataSeries2.RenderAs = RenderAs.Line;
            dataSeries2.MarkerType = Visifire.Commons.MarkerTypes.Circle;
            dataSeries2.SelectionEnabled = true;
            dataSeries2.LineThickness = 3;

            #region configuracion eje X
            // Creating AxisX
            Axis axisX = new Axis();
            // Date time standard format
            axisX.ValueFormatString = "000000";
            // To avoid auto skip

            chart.AxesX.Add(axisX);
            #endregion

            // Create a DataPoint
            DataPoint dataPoint;
            #region consulta
            DataTable kpis;
            try
            {
                kpis = new DataTable();
                Consultas consulta = new Consultas();
                kpis = consulta.SelectKPI_Clientes_ITO_UX(filtros).Tables[0];
                consulta = null;
                foreach (DataRow g in kpis.Rows)
                {
                    long? y = g["NbrCustUX"]!=DBNull.Value?(long?)g["NbrCustUX"]:null;
                    long? y2 = g["NbrCustITO"]!=DBNull.Value?(long?)g["NbrCustITO"]:null;
                    long x = (long)g["TimeId"];
                    // Create a new instance of DataPoint
                    dataPoint = new DataPoint();
                    // Set YValue for a DataPoint
                    if (x != null) dataPoint.AxisXLabel = x.ToString();
                    if (!ciclos.Contains(x.ToString()))  ciclos.Add(x.ToString());
                    dataPoint.YValue = System.Convert.ToDouble(y);
                    // Add dataPoint to DataPoints collection.
                    dataSeries.DataPoints.Add(dataPoint);
                    dataSeries.Name = "Universo";
                    // Create a new instance of DataPoint
                    dataPoint = new DataPoint();
                    // Set YValue for a DataPoint
                    if (x != null) dataPoint.AxisXLabel = x.ToString();
                    if (!ciclos.Contains(x.ToString()))  ciclos.Add(x.ToString());
                    dataPoint.YValue = System.Convert.ToDouble(y2);
                    // Add dataPoint to DataPoints collection.
                    dataSeries2.DataPoints.Add(dataPoint);
                    dataSeries2.Name = "Itinerario";
                }
            }
            catch (Exception Error)
            {
                throw (new Exception(Error.ToString()));
            }
            #endregion
            // Add dataSeries to Series collection.
            chart.Series.Add(dataSeries);
            chart.Series.Add(dataSeries2);
            return chart;
        }
Example #29
0
        public void CreateChart(int valueid)
        {
            DataSeries dataSeries = new DataSeries();
            dataSeries.RenderAs = RenderAs.Spline;
            dataSeries.Color = new SolidColorBrush(Colors.White);
            dataSeries.LineThickness = 1;
            dataSeries.LightingEnabled = true;
            dataSeries.SelectionEnabled = false;
            dataSeries.MovingMarkerEnabled = true;

            //DataSeries dataSeries1 = new DataSeries();
            //dataSeries1.RenderAs = RenderAs.Spline;
            //dataSeries1.Color = new SolidColorBrush(Colors.Blue);
            //dataSeries1.LightingEnabled = true;
            //dataSeries1.SelectionEnabled = false;
            //dataSeries1.MovingMarkerEnabled = true;

            double max = 0;
            double min = 0;

            Title title = new Visifire.Charts.Title();
            Visifire.Charts.Chart chart = new Visifire.Charts.Chart();
            chart.Rendered += new EventHandler(chart_Rendered);
            int datacnt = 0;
            int datavalchk = 0;
            foreach (vwSensorValuesAndTC10MinDataLog data in db.vwSensorValuesAndTC10MinDataLogs)
            {
                if (datavalchk != 1)
                datavalchk = 1;
                DataPoint dataPoint = new DataPoint();
                tblSensor sensor = new tblSensor();
                dataPoint.MarkerSize = 5;
                //foreach (tblSensor_Values rule in db.tblSensor_Values)
                //{

                //    MessageBox.Show(initmean.ToString());
                //}

                double linethickness = 0.5, avg = 0, sigma = 0;/////////////
                /****************************/

                if (valueid == 1)
                {
                    avg = data.initmean0;
                    sigma = data.signama0;

                }
                else if (valueid == 2)
                {
                    avg = data.initmean1;
                    sigma = data.sigma1;

                }
                else if (valueid == 3)
                {
                    avg = data.initmean2;
                    sigma = data.sigma2;

                }

                if (status == "Normal")
                {
                    max = avg + (sigma * 4);
                    min = avg - (sigma * 4);
                    //datacnt++;
                }
                else if (status == "Range")
                {

                    if (valueid == 1)
                    {
                        max = (double)db.vwSensorValuesAndTC10MinDataLogs.Max(n => n.VALUE0);
                        min = (double)db.vwSensorValuesAndTC10MinDataLogs.Min(n => n.VALUE0);
                        avg = ((max + min)) / 2;
                        sigma = (max - min) / 6;

                    }
                    else if (valueid == 2)
                    {
                        max = (double)db.vwSensorValuesAndTC10MinDataLogs.Max(n => n.VALUE1);
                        min = (double)db.vwSensorValuesAndTC10MinDataLogs.Min(n => n.VALUE1);
                        avg = ((max + min)) / 2;
                        sigma = (max - min) / 6;
                    }
                    else if (valueid == 3)
                    {
                        max = (double)db.vwSensorValuesAndTC10MinDataLogs.Max(n => n.VALUE2);
                        min = (double)db.vwSensorValuesAndTC10MinDataLogs.Min(n => n.VALUE2);
                        avg = ((max + min)) / 2;
                        sigma = (max - min) / 6;
                    }
                    if (max == min)
                    {
                        sigma = max / 6;
                        max = avg + sigma * 3;
                        min = avg - sigma * 3;
                    }

                }
                /****************************/

                datacnt++;

                switch (valueid)
                {
                    case 1:
                        dataPoint.YValue = (double)data.VALUE0;
                        //dataPoint.AxisXLabel = data.TIMESTAMP.ToString("hh:mm:ss tt");
                        //dataPoint.AxisXLabel = data.TIMESTAMP.ToString("hh");
                        dataPoint.AxisXLabel = string.Format("{0:00}:{1:00}", data.TIMESTAMP.Hour, data.TIMESTAMP.Minute);
                        if (data.DEGREE == 0)
                        {
                            dataPoint.MarkerColor = new SolidColorBrush(Colors.Green);
                            //dataSeries.Color = new SolidColorBrush(Colors.Green);
                        }
                        if (data.DEGREE == 1)
                        {
                            dataPoint.MarkerColor = new SolidColorBrush(Colors.Yellow);
                            //dataSeries.Color = new SolidColorBrush(Colors.Yellow);
                        }
                        if (data.DEGREE == 2)
                        {
                            dataPoint.MarkerColor = new SolidColorBrush(Colors.Orange);
                            //dataSeries.Color = new SolidColorBrush(Colors.Orange);
                        }
                        if (data.DEGREE == 3)
                        {
                            dataPoint.MarkerColor = new SolidColorBrush(Colors.Red);
                            //dataSeries.Color = new SolidColorBrush(Colors.Red);
                        }
                        //data.EXECUTION_MODE
                        //max = (double)db.vwSensorValuesAndTC10MinDataLogs.Max(n => n.VALUE0);
                        //min = (double)db.vwSensorValuesAndTC10MinDataLogs.Min(n => n.VALUE0);
                        //max = data.initmean0 + (data.signama0) * 4;
                        //min = data.initmean0 - (data.signama0) * 4;
                        //Hour_MA = (double)db.GetTblRulesQuery();
                        title.Text = db.tblSensors.FirstOrDefault().SENSOR_NAME + "-Xč»ø";
                        if (datacnt == db.vwSensorValuesAndTC10MinDataLogs.Count)
                        {

                            //Isvalid = "Y";
                            chart.TrendLines.Add(new TrendLine() { Value = avg, LineColor = new SolidColorBrush(Colors.Green), LabelText = avg.ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                            chart.TrendLines.Add(new TrendLine() { Value = avg + (sigma * 1), LineColor = new SolidColorBrush(Colors.Yellow), LabelText = (avg + (sigma * 1)).ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                            chart.TrendLines.Add(new TrendLine() { Value = avg - (sigma * 1), LineColor = new SolidColorBrush(Colors.Yellow), LabelText = (avg - (sigma * 1)).ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                            chart.TrendLines.Add(new TrendLine() { Value = avg + (sigma * 2), LineColor = new SolidColorBrush(Colors.Orange), LabelText = (avg + (sigma * 2)).ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                            chart.TrendLines.Add(new TrendLine() { Value = avg - (sigma * 2), LineColor = new SolidColorBrush(Colors.Orange), LabelText = (avg - (sigma * 2)).ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                            chart.TrendLines.Add(new TrendLine() { Value = avg + (sigma * 3), LineColor = new SolidColorBrush(Colors.Red), LabelText = (avg + (sigma * 3)).ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                            chart.TrendLines.Add(new TrendLine() { Value = avg - (sigma * 3), LineColor = new SolidColorBrush(Colors.Red), LabelText = (avg - (sigma * 3)).ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                        }
                        break;
                    case 2:
                        dataPoint.YValue = (double)data.VALUE1;
                        //dataPoint.AxisXLabel = data.TIMESTAMP.ToString("hh:mm:ss tt");
                        //dataPoint.AxisXLabel = data.TIMESTAMP.ToString("hh");
                        dataPoint.AxisXLabel = string.Format("{0:00}:{1:00}", data.TIMESTAMP.Hour, data.TIMESTAMP.Minute);
                        if (data.DEGREE == 0)
                        {
                            dataPoint.MarkerColor = new SolidColorBrush(Colors.Green);
                            //dataSeries.Color = new SolidColorBrush(Colors.Green);
                        }
                        if (data.DEGREE == 1)
                        {
                            dataPoint.MarkerColor = new SolidColorBrush(Colors.Yellow);
                            //dataSeries.Color = new SolidColorBrush(Colors.Yellow);
                        }
                        if (data.DEGREE == 2)
                        {
                            dataPoint.Color = new SolidColorBrush(Colors.Orange);
                            //dataSeries.Color = new SolidColorBrush(Colors.Orange);
                        }
                        if (data.DEGREE == 3)
                        {
                            dataPoint.MarkerColor = new SolidColorBrush(Colors.Red);
                            //dataSeries.Color = new SolidColorBrush(Colors.Red);
                        }
                        //max = (double)db.vwSensorValuesAndTC10MinDataLogs.Max(n => n.VALUE1);
                        //min = (double)db.vwSensorValuesAndTC10MinDataLogs.Min(n => n.VALUE1);

                        title.Text = db.tblSensors.FirstOrDefault().SENSOR_NAME + "-Yč»ø";
                        if (datacnt == db.vwSensorValuesAndTC10MinDataLogs.Count)
                        {
                            //max = data.initmean1 + (data.sigma1) * 4;
                            //min = data.initmean1 - (data.sigma1) * 4;

                            chart.TrendLines.Add(new TrendLine() { Value = avg, LineColor = new SolidColorBrush(Colors.Green), LabelText = avg.ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                            chart.TrendLines.Add(new TrendLine() { Value = avg + (sigma * 1), LineColor = new SolidColorBrush(Colors.Yellow), LabelText = (avg + (sigma * 1)).ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                            chart.TrendLines.Add(new TrendLine() { Value = avg - (sigma * 1), LineColor = new SolidColorBrush(Colors.Yellow), LabelText = (avg - (sigma * 1)).ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                            chart.TrendLines.Add(new TrendLine() { Value = avg + (sigma * 2), LineColor = new SolidColorBrush(Colors.Orange), LabelText = (avg + (sigma * 2)).ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                            chart.TrendLines.Add(new TrendLine() { Value = avg - (sigma * 2), LineColor = new SolidColorBrush(Colors.Orange), LabelText = (avg - (sigma * 2)).ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                            chart.TrendLines.Add(new TrendLine() { Value = avg + (sigma * 3), LineColor = new SolidColorBrush(Colors.Red), LabelText = (avg + (sigma * 3)).ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                            chart.TrendLines.Add(new TrendLine() { Value = avg - (sigma * 3), LineColor = new SolidColorBrush(Colors.Red), LabelText = (avg - (sigma * 3)).ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                        }
                        break;
                    case 3:
                        dataPoint.YValue = (double)data.VALUE2;
                        //                        dataPoint.AxisXLabel = data.TIMESTAMP.ToString("hh:mm:ss tt");
                        //dataPoint.AxisXLabel = data.TIMESTAMP.ToString("hh");
                        dataPoint.AxisXLabel = string.Format("{0:00}:{1:00}", data.TIMESTAMP.Hour, data.TIMESTAMP.Minute);
                        if (data.DEGREE == 0)
                        {
                            dataPoint.MarkerColor = new SolidColorBrush(Colors.Green);
                            //dataSeries.Color = new SolidColorBrush(Colors.Green);
                        }
                        if (data.DEGREE == 1)
                        {
                            dataPoint.MarkerColor = new SolidColorBrush(Colors.Yellow);
                            //dataSeries.Color = new SolidColorBrush(Colors.Yellow);
                        }
                        if (data.DEGREE == 2)
                        {
                            dataPoint.MarkerColor = new SolidColorBrush(Colors.Orange);
                            //dataSeries.Color = new SolidColorBrush(Colors.Orange);
                        }
                        if (data.DEGREE == 3)
                        {
                            dataPoint.MarkerColor = new SolidColorBrush(Colors.Red);
                            //dataSeries.Color = new SolidColorBrush(Colors.Red);
                        }
                        //max = (double)db.vwSensorValuesAndTC10MinDataLogs.Max(n => n.VALUE2);
                        //min = (double)db.vwSensorValuesAndTC10MinDataLogs.Min(n => n.VALUE2);
                        //max = data.initmean2 + (data.sigma2) * 4;
                        //min = data.initmean2 - (data.sigma2) * 4;

                        if (db.tblSensors.FirstOrDefault().SENSOR_TYPE == "TILT")
                            title.Text = db.tblSensors.FirstOrDefault().SENSOR_NAME + "-ęŗ«åŗ¦";
                        else
                            title.Text = db.tblSensors.FirstOrDefault().SENSOR_NAME + "-Zč»ø";
                        if (datacnt == db.vwSensorValuesAndTC10MinDataLogs.Count)
                        {
                            chart.TrendLines.Add(new TrendLine() { Value = avg, LineColor = new SolidColorBrush(Colors.Green), LabelText = avg.ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                            chart.TrendLines.Add(new TrendLine() { Value = avg + (sigma * 1), LineColor = new SolidColorBrush(Colors.Yellow), LabelText = (avg + (sigma * 1)).ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                            chart.TrendLines.Add(new TrendLine() { Value = avg - (sigma * 1), LineColor = new SolidColorBrush(Colors.Yellow), LabelText = (avg - (sigma * 1)).ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                            chart.TrendLines.Add(new TrendLine() { Value = avg + (sigma * 2), LineColor = new SolidColorBrush(Colors.Orange), LabelText = (avg + (sigma * 2)).ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                            chart.TrendLines.Add(new TrendLine() { Value = avg - (sigma * 2), LineColor = new SolidColorBrush(Colors.Orange), LabelText = (avg - (sigma * 2)).ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                            chart.TrendLines.Add(new TrendLine() { Value = avg + (sigma * 3), LineColor = new SolidColorBrush(Colors.Red), LabelText = (avg + (sigma * 3)).ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                            chart.TrendLines.Add(new TrendLine() { Value = avg - (sigma * 3), LineColor = new SolidColorBrush(Colors.Red), LabelText = (avg - (sigma * 3)).ToString("#,0.0000"), LineStyle = LineStyles.Solid, LineThickness = linethickness, LabelFontColor = new SolidColorBrush(Colors.White) });
                        }
                        break;
                }

                //dataPoint.YValue = (double)data.VALUE0;
                dataSeries.DataPoints.Add(dataPoint);
                dataSeries.ToolTipText = "Ꙃ間:#AxisXLabelꙂ\nč³‡ę–™:#YValue";

            }

            if (datavalchk != 1)
                Isvalid = "N";
            else
                Isvalid = "Y";
            //double LastpointYValue0, LastpointYValue1, LastpointYValue2;
            //if (db.vwSensorValuesAndTC10MinDataLogs.Count != 0)
            //{
            //    LastpointYValue0 = (double)db.vwSensorValuesAndTC10MinDataLogs.Last().VALUE0;
            //    //LastpointYValue1 = (double)db.vwSensorValuesAndTC10MinDataLogs.Last().VALUE1;
            //    //LastpointYValue2 = (double)db.vwSensorValuesAndTC10MinDataLogs.Last().VALUE2;
            //}

            //DataPoint datapoint1 ;
            //datapoint1 = new DataPoint() ;
            //datapoint1.AxisXLabel = string.Format("{0:00}:{1:00}", db.vwSensorValuesAndTC10MinDataLogs.First().TIMESTAMP.Hour, db.vwSensorValuesAndTC10MinDataLogs.Last().TIMESTAMP.Minute);
            //datapoint1.XValue = 1;
            //datapoint1.YValue = (double)db.vwSensorValuesAndTC10MinDataLogs.Last().VALUE0;
            //dataSeries1.DataPoints.Add(datapoint1);
            //datapoint1 = new DataPoint();
            //datapoint1.AxisXLabel = string.Format("{0:00}:{1:00}", db.vwSensorValuesAndTC10MinDataLogs.Last().TIMESTAMP.Hour, db.vwSensorValuesAndTC10MinDataLogs.Last().TIMESTAMP.Minute);
            //datapoint1.XValue = db.vwSensorValuesAndTC10MinDataLogs.Count() ;
            //datapoint1.YValue = (double)db.vwSensorValuesAndTC10MinDataLogs.Last().VALUE0;
            ////{ AxisXLabel = string.Format("{0:00}:{1:00}", db.vwSensorValuesAndTC10MinDataLogs.Last().TIMESTAMP.Hour, db.vwSensorValuesAndTC10MinDataLogs.Last().TIMESTAMP.Minute), XValue = db.vwSensorValuesAndTC10MinDataLogs.Count - 1, YValue = (double)db.vwSensorValuesAndTC10MinDataLogs.Last().VALUE0 };
            //dataSeries1.DataPoints.Add(datapoint1);

            //chart.Series.Add(dataSeries1);

            //switch (valueid)
            //{
            //    case 0:
            //        chart = chart1;
            //        break;
            //}

            Axis yaxis = new Axis();
            yaxis.Opacity = 0;

            //yaxis.LineColor =new SolidColorBrush(Colors.Black);

            yaxis.AxisMaximum = max;
            yaxis.AxisMinimum = min;
            yaxis.Interval = (max - min) / 5;
            yaxis.ValueFormatString = "#,0.0000";
            yaxis.Grids.Add(new ChartGrid() { Enabled = false });//********1126**********
            chart.AxesY.Add(yaxis);

            Axis axisX = new Axis();

            //axisX.ValueFormatString = "hh:mm:ss tt";
            axisX.AxisLabels = new AxisLabels();
            //axisX.AxisLabels.Angle = -45;
            axisX.AxisLabels.Interval = 12;
            chart.AxesX.Add(axisX);

            chart.Titles.Add(title);

            chart.ScrollingEnabled = false;

            chart.IndicatorEnabled = true;
            chart.AnimationEnabled = true;
            chart.AnimatedUpdate = true;
            chart.ZoomingEnabled = true;
            chart.ShadowEnabled = true;
            chart.Series.Add(dataSeries);
            chart.Theme = "Theme3";
            chart.Height = LayoutRoot.ActualHeight / vcnt;
            Thickness tk = new Thickness()
            {
                Bottom = 1,
                Top = 1
            };
            chart.Margin = tk;
            //stackpanel.Orientation = Orientation.Horizontal;
            stackpanel.Children.Add(chart);
        }
Example #30
0
       /// <summary>
       /// Add Title visual to DrawingArea
       /// </summary>
       /// <param name="chart">Chart</param>
       /// <param name="title">Title to add</param>
       /// <param name="panel">Panel where title to be added</param>
       /// <param name="width">Available width for title</param>
       /// <param name="height">Available height for title</param>
        private void AddTitle(Chart chart, Title title, Panel panel, Double width, Double height)
        {
            Double tempFontSize = title.InternalFontSize;
            title.Chart = chart;

        RECREATE_TITLE:

            title.CreateVisualObject(new ElementData() { Element = title });

            Size size = Graphics.CalculateVisualSize(title.Visual);

            if (title.InternalVerticalAlignment == VerticalAlignment.Top || title.InternalVerticalAlignment == VerticalAlignment.Bottom
                || (title.InternalVerticalAlignment == VerticalAlignment.Center && title.InternalHorizontalAlignment == HorizontalAlignment.Center))
            {
                if (size.Width > width && (chart.ActualWidth - width) < width)
                {
                    if (title.InternalFontSize == 1)
                        goto OUT;

                    title.IsNotificationEnable = false;
                    title.InternalFontSize -= 1;
                    title.IsNotificationEnable = true;
                    goto RECREATE_TITLE;
                }
            }
            else
            {
                if (size.Height >= height || title.Height >= height)
                {
                    if (title.InternalFontSize == 1)
                        goto OUT;

                    title.IsNotificationEnable = false;
                    title.InternalFontSize -= 1;
                    title.IsNotificationEnable = true;
                    goto RECREATE_TITLE;
                }
            }
        OUT:

            title.IsNotificationEnable = false;
            title.InternalFontSize = tempFontSize;
            title.IsNotificationEnable = true;

            // Add title Visual as children of panel
            panel.Children.Add(title.Visual);
        }
Example #31
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.Tab = ((System.Windows.Controls.TabControl)(target));
                return;

            case 2:
                this.txtQueryKey = ((System.Windows.Controls.TextBox)(target));
                return;

            case 3:
                this.cbCondition = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 4:

            #line 35 "..\..\CreativeCollection.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btClear);

            #line default
            #line hidden
                return;

            case 5:
                this.rbNameMode = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 6:
                this.rbDomainMode = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 7:
                this.chkLeftRank = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 8:
                this.chkRightRank = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 9:
                this.iudRefreshNum = ((Xceed.Wpf.Toolkit.IntegerUpDown)(target));
                return;

            case 10:

            #line 66 "..\..\CreativeCollection.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btDelDomain);

            #line default
            #line hidden
                return;

            case 11:
                this.chkBaidu = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 12:
                this.chk360 = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 13:
                this.chkSogou = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 14:

            #line 79 "..\..\CreativeCollection.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Query);

            #line default
            #line hidden
                return;

            case 15:
                this.tbTotal = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 16:
                this.btReturn = ((System.Windows.Controls.Button)(target));

            #line 95 "..\..\CreativeCollection.xaml"
                this.btReturn.Click += new System.Windows.RoutedEventHandler(this.ReturnQuery);

            #line default
            #line hidden
                return;

            case 17:
                this.btAll = ((System.Windows.Controls.Button)(target));

            #line 103 "..\..\CreativeCollection.xaml"
                this.btAll.Click += new System.Windows.RoutedEventHandler(this.AllResult);

            #line default
            #line hidden
                return;

            case 18:
                this.btExport = ((System.Windows.Controls.Button)(target));

            #line 110 "..\..\CreativeCollection.xaml"
                this.btExport.Click += new System.Windows.RoutedEventHandler(this.ResultExport);

            #line default
            #line hidden
                return;

            case 19:
                this.NowKey = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 20:
                this.tvKey = ((System.Windows.Controls.ListBox)(target));

            #line 132 "..\..\CreativeCollection.xaml"
                this.tvKey.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.tvKey_SelectionChanged);

            #line default
            #line hidden
                return;

            case 21:
                this.dgQueryResult = ((System.Windows.Controls.DataGrid)(target));
                return;

            case 22:
                this.MyChart = ((Visifire.Charts.Chart)(target));
                return;

            case 23:
                this.ChartTitle = ((Visifire.Charts.Title)(target));
                return;

            case 24:
                this.dataSeries = ((Visifire.Charts.DataSeries)(target));
                return;

            case 25:
                this.Paiming = ((Visifire.Charts.DataPoint)(target));
                return;

            case 26:
                this.noPaiming = ((Visifire.Charts.DataPoint)(target));
                return;

            case 27:
                this.pbQuery = ((System.Windows.Controls.ProgressBar)(target));
                return;
            }
            this._contentLoaded = true;
        }
        // Flow 2
        private void Create_Chart()
        {
            // Default Initialize Value
            // Definition
            Double Data_Sum = 0;
            Double[] Range = new Double[2];
            Double Min = 0;
            Double Max = 0;

            // Chart
            Visifire.Charts.Chart chart = new Visifire.Charts.Chart();
            

            #region Chart Legend
            /*
            chart.Legends.Add(new Legend()
            {
                Title = "圖例",
                IsEnabled = false,
                TitleBackground = null,
                TitleFontSize = 22,
                TitleFontColor = new SolidColorBrush(Colors.Black),
                FontSize = 13,
                MarkerSize = 20,
                VerticalAlignment = VerticalAlignment.Top,
                VerticalContentAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right,
                HorizontalContentAlignment = HorizontalAlignment.Right,
                Background = new SolidColorBrush(Colors.White)
            });
            */
            #endregion

            // Title
            Visifire.Charts.Title title = new Visifire.Charts.Title()
            {
                FontSize = 22,
                VerticalAlignment = System.Windows.VerticalAlignment.Bottom
            };

            foreach (var _sensor in this.Compare_Collection)
            {
                string item_name = _sensor.ItemName;
                string item_unit = _sensor.Unit;
                string ER_name = _sensor.ERName;

                var rawData =
                    from n in this.DBContext.GetTblAIItem1HourLogQuery()
                    where n.ItemID == _sensor.ItemID &&
                          n.Timestamp >= this.Start_Date &&
                          n.Timestamp <= this.End_Date
                    orderby n.Timestamp ascending
                    select n;

                LoadOperation<tblAIItem1HourLog> lo_rawData
                    = this.DBContext.Load<tblAIItem1HourLog>(rawData);

                lo_rawData.Completed += (o_raw, e_raw) =>
                {
                    // Sum
                    Data_Sum += lo_rawData.Entities.Count();

                    if (Data_Sum != 0)
                    {
                        #region Range Min Max

                        // Min & Max
                        var min = lo_rawData.Entities.Min(s => s.Value);
                        var max = lo_rawData.Entities.Max(s => s.Value);

                        if (Range[0] > min)
                            Range[0] = min;
                        else if (Range[0] == 0.0)
                            Range[0] = min;

                        if (Range[1] < max)
                            Range[1] = max;

                        if (Range[0] == Range[1])
                        {
                            Range[0]--;
                            Range[1]++;
                        }

                        #endregion

                        #region Data Series

                        DataSeries dataSeries = new DataSeries();

                        if (Data_Sum > 200)
                            dataSeries.RenderAs = RenderAs.QuickLine;
                        else
                            dataSeries.RenderAs = RenderAs.Line;

                        dataSeries.LineThickness = 2;
                        dataSeries.LightingEnabled = true;
                        dataSeries.LineStyle = LineStyles.Solid;
                        dataSeries.SelectionEnabled = true;
                        dataSeries.MovingMarkerEnabled = true;
                        dataSeries.ShowInLegend = false; // Show Legend 
                        dataSeries.IncludeDataPointsInLegend = false;
                        dataSeries.LegendText = item_name + '\n' +
                                                ER_name;
                        #endregion

                        #region Adding DataPoints

                        foreach (tblAIItem1HourLog data in lo_rawData.Entities)
                        {
                            // DataPoint
                            DataPoint dataPoint = new DataPoint();

                            if (this._Compare_Collection.Count == 1)
                            {
                                #region čح定Point大小ļ¼ŒéšØč³‡ę–™å¤šåÆ”ļ¼Œēø®ę”¾ć€‚

                                if (Data_Sum < 500)
                                    dataPoint.MarkerSize = 5;
                                else if (Data_Sum < 1000)
                                    dataPoint.MarkerSize = 4.5;
                                else if (Data_Sum < 1500)
                                    dataPoint.MarkerSize = 4;
                                else if (Data_Sum < 2000)
                                    dataPoint.MarkerSize = 3.5;
                                else if (Data_Sum < 2500)
                                    dataPoint.MarkerSize = 3;
                                else if (Data_Sum < 3000)
                                    dataPoint.MarkerSize = 2.5;
                                else if (Data_Sum < 3500)
                                    dataPoint.MarkerSize = 2;
                                else if (Data_Sum < 4000)
                                    dataPoint.MarkerSize = 1.5;
                                else if (Data_Sum < 4500)
                                    dataPoint.MarkerSize = 1;
                                else
                                    dataPoint.MarkerSize = 0.5;

                                #endregion čح定Point大小ļ¼ŒéšØč³‡ę–™å¤šåÆ”ļ¼Œēø®ę”¾ć€‚
                            }

                            // Value
                            dataPoint.YValue = data.Value;

                            // Label
                            dataPoint.AxisXLabel = string.Format("{0:MM/dd HH:mm}", data.Timestamp);

                            // Adding to dataseries
                            dataSeries.DataPoints.Add(dataPoint);
                        }

                        #endregion

                        #region Tooltips

                        // DataSeries Tooltips
                        dataSeries.ToolTipText =
                            "ꄟēŸ„å™Ø锞型: " + item_name + '\n' +
                            "地區: " + ER_name + '\n' +
                            "Ꙃ間: #AxisXLabel" + "\n" +
                            "č³‡ę–™: #YValue " + item_unit;

                        #endregion

                        // Adding
                        chart.Series.Add(dataSeries);
                    }

                    #region Detail Information

                    string _data_Sum = "č³‡ę–™é‡: " + string.Format("{0:0.00}", Data_Sum);
                    this.sum_tb.Text = _data_Sum;
                    string _data_Min = "ęœ€å°å€¼: " + string.Format("{0:0.00}", Range[0]);
                    this.min_tb.Text = _data_Min;
                    string _data_Max = "ęœ€å¤§å€¼: " + string.Format("{0:0.00}", Range[1]);
                    this.max_tb.Text = _data_Max;

                    #endregion

                    #region Final Chart Set

                    // Chart Title
                    //title.Text = "ꄟēŸ„å™Ø關čÆåˆ†ęžåœ–";
                    title.Text = String.Format("{0:yyyy/MM/dd}", this.Start_Date) + "ļ½ž" + String.Format("{0:yyyy/MM/dd}", this.End_Date)
                                        + " ꄟēŸ„å™Ø關čÆåˆ†ęžåœ–";

                    //!++ Xč»ø
                    Axis axisX = new Axis();
                    axisX.AxisLabels = new AxisLabels();
                    //axisX.AxisLabels.Enabled = false;
                    axisX.AxisLabels.Enabled = true;
                    axisX.AxisLabels.Angle = -90;
                    axisX.Title = "Ꙃ間";

                    //!++ Yč»ø
                    Axis yaxis = new Axis();
                    //yaxis.Opacity = 0;

                    // Max & Min
                    yaxis.AxisMaximum = Range[1];
                    yaxis.AxisMinimum = Range[0];

                    double _min = Convert.ToDouble(yaxis.AxisMinimum);
                    double _max = Convert.ToDouble(yaxis.AxisMaximum);
                    if (_max <= _min)
                    {
                        //MessageBox.Show("ē”¢ē”Ÿ ęœ€å¤§å€¼ < ęœ€å°å€¼ ēš„問锌");
                        yaxis.AxisMaximum = _max = 1;
                        yaxis.AxisMinimum = _min = 0;
                    }

                    // 加兄
                    chart.AxesX.Add(axisX);
                    chart.AxesY.Add(yaxis);
                    chart.Titles.Add(title);

                    //?+ Chart čح定
                    chart.ToolBarEnabled = false;
                    chart.ScrollingEnabled = false;
                    chart.LightingEnabled = true;
                    chart.IndicatorEnabled = true;
                    chart.AnimationEnabled = true;
                    chart.AnimatedUpdate = true;
                    chart.ZoomingEnabled = false;
                    chart.ShadowEnabled = false;
                    chart.Theme = "Theme3";
                    //chart.Height = this.Chart_sp.ActualHeight;
                    Thickness tk = new Thickness() { Bottom = 1, Top = 1 };
                    chart.Margin = tk;

                    #endregion

                };
                this.DBContext.tblAIItem1HourLogs.Clear();

            }

            chart.Rendered += chart_Rendered;

            // Add chart into container
            this.Chart_Container.Children.Add(chart);
        }
Example #33
0
        public Chart Draw(params string[] filtros)
        {
            // Create a new instance of Chart
            Chart chart = new Chart();

            chart.AnimationEnabled = true;
            // Create a new instance of Title
            Title title = new Title();
            // Set title property
            title.Text = "DISTRIBUCION PDV GRUPO";
            // Add title to Titles collection
            chart.Titles.Add(title);
            // Create a new instance of DataSeries
            DataSeries dataSeries = new DataSeries();
            DataSeries dataSeriesSecundary = new DataSeries();
            // Set DataSeries property
            dataSeries.RenderAs = RenderAs.Line;
            #region configuracion eje X
            // Creating AxisX
            Axis axisX = new Axis();
            // Date time standard format
            axisX.ValueFormatString = "000000";
            // To avoid auto skip

            chart.AxesX.Add(axisX);
            #endregion
            // Create a DataPoint
            DataPoint dataPoint;
            #region consulta
            DataTable kpis;
            try
            {
                kpis = new DataTable();
                Consultas consulta = new Consultas();
                kpis = consulta.SelectKPI_DistibucionPDVGrupo(filtros).Tables[0];
                consulta = null;
                bool band1 = true;
                bool band2 = true;
                string serAnt = "-5555";
                string ser = "-1111";
                foreach (DataRow g in kpis.Rows)
                {

                    int? y = g["TotalClientes"] != DBNull.Value ? (int?)g["TotalClientes"] : null;
                    int x = (int)g["Ciclo"];
                    ser = (string)g["Segmentacion"];
                    ser = ser.ToUpper();
                    //--Condicion para el hueco se vaya a cero y no se corte la linea.
                    //if (y == null)
                    //    y = 0;
                    if (ser != "TOTAL MAYORISTAS")
                    { //Creando las series
                        if (serAnt != ser)
                        {
                            if (serAnt != "-5555")
                            {
                                chart.Series.Add(dataSeries);
                            }

                            // Create a new instance of DataSeries
                            dataSeries = new DataSeries();
                            dataSeries.Name = ser;
                            // Set DataSeries property
                            dataSeries.RenderAs = RenderAs.Line;
                            if (ser == "TIGRE")
                                dataSeries.MarkerType = Visifire.Commons.MarkerTypes.Diamond;
                            if (ser == "LOBO")
                                dataSeries.MarkerType = Visifire.Commons.MarkerTypes.Triangle;
                            if (ser == "AGUILA")
                                dataSeries.MarkerType = Visifire.Commons.MarkerTypes.Square;
                            if (ser == "COBRA")
                                dataSeries.MarkerType = Visifire.Commons.MarkerTypes.Cross;
                            if (ser == "PEZ")
                                dataSeries.MarkerType = Visifire.Commons.MarkerTypes.Line;
                            dataSeries.SelectionEnabled = true;
                            dataSeries.LineThickness = 3;
                            band1 = false;
                        }

                        // Create a new instance of DataPoint
                        dataPoint = new DataPoint();
                        // Set YValue for a DataPoint
                        if (x != null && y != null) dataPoint.AxisXLabel = x.ToString();
                        if (!ciclos.Contains(x.ToString())) ciclos.Add(x.ToString());
                        dataPoint.YValue = System.Convert.ToDouble(y);
                        // Add dataPoint to DataPoints collection.
                        dataSeries.DataPoints.Add(dataPoint);
                        serAnt = ser;

                    }
                    else
                    {
                        if (serAnt != ser)
                        {
                            //////////////dataseries secundario para segundo eje y
                            // Create a new instance of DataSeries secundary
                            // Set DataSeries property
                            dataSeriesSecundary.AxisYType = AxisTypes.Secondary;
                            dataSeriesSecundary.Name = "TOTAL MAYORISTAS";
                            dataSeriesSecundary.Padding = new Thickness(30);
                            dataSeriesSecundary.RenderAs = RenderAs.Line;
                            dataSeriesSecundary.MarkerType = Visifire.Commons.MarkerTypes.Circle;
                            dataSeriesSecundary.SelectionEnabled = true;
                            dataSeriesSecundary.LineThickness = 3;
                            //////////////////////////////////////////////
                            band2 = false;

                        }
                        dataPoint = new DataPoint();
                        if (x != null && y != null) dataPoint.AxisXLabel = x.ToString();
                        if (!ciclos.Contains(x.ToString())) ciclos.Add(x.ToString());
                        dataPoint.YValue = System.Convert.ToDouble(y);
                        dataSeriesSecundary.DataPoints.Add(dataPoint);
                        serAnt = ser;
                    }
                }
                // Add dataSeries to Series collection.
                if(band1!=true)
                    chart.Series.Add(dataSeries);
                if (band2 != true)
                    chart.Series.Add(dataSeriesSecundary);

                return chart;
            }
            catch (Exception Error)
            {
                throw (new Exception(Error.ToString()));
            }
            #endregion
        }
Example #34
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.buttonDig = ((System.Windows.Controls.Button)(target));

            #line 31 "..\..\KeyDig.xaml"
                this.buttonDig.Click += new System.Windows.RoutedEventHandler(this.btDig);

            #line default
            #line hidden
                return;

            case 2:
                this.buttonExport = ((System.Windows.Controls.Button)(target));

            #line 32 "..\..\KeyDig.xaml"
                this.buttonExport.Click += new System.Windows.RoutedEventHandler(this.btExport);

            #line default
            #line hidden
                return;

            case 3:
                this.sliderGrade = ((System.Windows.Controls.Slider)(target));
                return;

            case 4:
                this.IncludeKey = ((Xceed.Wpf.Toolkit.WatermarkTextBox)(target));
                return;

            case 5:
                this.cbBaidu = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 6:
                this.cb360 = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 7:
                this.cbSogou = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 8:
                this.pbQuery = ((System.Windows.Controls.ProgressBar)(target));
                return;

            case 9:
                this.txtQueryKey = ((Xceed.Wpf.Toolkit.WatermarkTextBox)(target));
                return;

            case 10:
                this.lbDigKey = ((System.Windows.Controls.ListView)(target));

            #line 71 "..\..\KeyDig.xaml"
                this.lbDigKey.AddHandler(System.Windows.Controls.Primitives.ButtonBase.ClickEvent, new System.Windows.RoutedEventHandler(this.GridViewColumnHeader_Click));

            #line default
            #line hidden
                return;

            case 11:
                this.gvKey = ((System.Windows.Controls.GridView)(target));
                return;

            case 12:
                this.MyChart = ((Visifire.Charts.Chart)(target));
                return;

            case 13:
                this.ChartTitle = ((Visifire.Charts.Title)(target));
                return;

            case 14:
                this.dataSeries = ((Visifire.Charts.DataSeries)(target));
                return;

            case 15:
                this.Baidu = ((Visifire.Charts.DataPoint)(target));
                return;

            case 16:
                this.So = ((Visifire.Charts.DataPoint)(target));
                return;

            case 17:
                this.Sogou = ((Visifire.Charts.DataPoint)(target));
                return;
            }
            this._contentLoaded = true;
        }
Example #35
0
        public void TextDefaultValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;

            Common.CreateAndAddDefaultDataSeries(chart);

            Title title = new Title();
            chart.Titles.Add(title);

            EnqueueDelay(_sleepTime);
            CreateAsyncTask(chart,
                () => Assert.AreEqual("", chart.Titles[0].Text));

            EnqueueTestComplete();
        }
Example #36
0
        /// <summary>
        /// Creates the visual element for the Axis
        /// </summary>
        /// <param name="Chart">Chart</param>
        internal void CreateVisualObject(Chart Chart)
        {
            IsNotificationEnable = false;
            AxisLabels.IsNotificationEnable = false;
            AxisLabels.Chart = Chart;

            if (AxisRepresentation == AxisRepresentations.AxisX)
                AxisLabels.ApplyStyleFromTheme(Chart, "AxisXLabels");
            else if (AxisRepresentation == AxisRepresentations.AxisY)
                AxisLabels.ApplyStyleFromTheme(Chart, "AxisYLabels");

            // Create visual elements
            Visual = new StackPanel() { Background = InternalBackground };

            AxisElementsContainer = new StackPanel();
            InternalStackPanel = new Canvas();
            ScrollViewerElement = new Canvas();
            AxisTitleElement = new Title();

            ApplyVisualProperty();
            ApplyTitleProperties();

            SetUpAxisManager();
            SetUpTicks();
            SetUpGrids();
            SetUpAxisLabels();

            // set the placement order based on the axis orientation
            switch (AxisOrientation)
            {
                case Orientation.Horizontal:
                    ApplyHorizontalAxisSettings();
                    _zeroBaseLinePosition = Graphics.ValueToPixelPosition(0, Width, InternalAxisMinimum, InternalAxisMaximum, 0);
                    
                    break;

                case Orientation.Vertical:
                    ApplyVerticalAxisSettings();
                    _zeroBaseLinePosition = Height - Graphics.ValueToPixelPosition(0, Height, InternalAxisMinimum, InternalAxisMaximum, 0);
                    
                    break;
            }

            IsNotificationEnable = true;
            AxisLabels.IsNotificationEnable = true;

            if (!(Boolean)this.Enabled)
            {
                Visual.Visibility = Visibility.Collapsed;
            }
        }
Example #37
0
        public void StressCreate()
        {
            System.Windows.Browser.HtmlPage.Plugin.SetStyleAttribute("height", "400px");

            Double totalDuration = 0;
            DateTime start = DateTime.UtcNow;

            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;

            _isLoaded = false;
            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            this.TestPanel.Children.Add(chart);

            Int32 i = 0;

            Random rand = new Random();
            Int32 numberOfTitles = 0;
       
            Canvas c = new Canvas();
            string msg = Common.AssertAverageDuration(100, 1, delegate
            {
                for (i = 0; i < 20; i++)
                {
                    Title title = new Title();
                    title.Background = new SolidColorBrush(Color.FromArgb((Byte)255, (Byte)rand.Next(0, 255), (Byte)rand.Next(0, 255), (Byte)rand.Next(0, 255)));
                    title.Text = "Title" + (i + 1);
                    title.VerticalAlignment = (VerticalAlignment)rand.Next(0, 3);
                    title.HorizontalAlignment = (HorizontalAlignment)rand.Next(0, 3);
                    chart.Titles.Add(title);
                    numberOfTitles++;
                }
            });

            EnqueueConditional(() => { return _isLoaded; });

            EnqueueCallback(() =>
            {
                DateTime end = DateTime.UtcNow;
                totalDuration = (end - start).TotalSeconds;
            });

            EnqueueCallback(() =>
            {
                _htmlElement1 = Common.GetDisplayMessageButton(_htmlElement1);
                _htmlElement1.SetStyleAttribute("width", "900px");
                _htmlElement1.SetProperty("value", numberOfTitles + " Titles are added. Click here to exit.");
                _htmlElement2 = Common.GetDisplayMessageButton(_htmlElement2);
                _htmlElement2.SetStyleAttribute("top", "540px");
                _htmlElement2.SetProperty("value", msg + " Total Chart Loading Time: " + totalDuration + "s");
                System.Windows.Browser.HtmlPage.Document.Body.AppendChild(_htmlElement1);
                System.Windows.Browser.HtmlPage.Document.Body.AppendChild(_htmlElement2);
            });

            EnqueueCallback(() =>
            {
                _htmlElement1.AttachEvent("onclick", new EventHandler<System.Windows.Browser.HtmlEventArgs>(this.TitleTest_OnClick));
            });
        }
Example #38
0
        /// <summary>
        /// Returns label for DataPoint
        /// </summary>
        /// <param name="dataPoint"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="isPositive"></param>
        /// <param name="markerLeft"></param> 
        /// <param name="markerTop"></param> 
        /// <param name="labelCanvas"></param> 
        /// <param name="IsSetPosition">Whether to set the position while creating it (in this function itself) </param>
        /// <returns>New position of the label</returns>
        private static Point CreateLabel4LineDataPoint(DataPoint dataPoint, Double width, Double height, Boolean isPositive,
            Double markerLeft, Double markerTop, ref Canvas labelCanvas, Boolean IsSetPosition)
        {
            Point retVal = new Point();

            if (dataPoint.LabelVisual != null)
            {
                Panel parent = dataPoint.LabelVisual.Parent as Panel;

                if (parent != null)
                    parent.Children.Remove(dataPoint.LabelVisual);
            }

            Chart chart = dataPoint.Chart as Chart;

            if (dataPoint.Faces == null || Double.IsNaN(dataPoint.InternalYValue))
                return retVal;

            if ((Boolean)dataPoint.LabelEnabled && !String.IsNullOrEmpty(dataPoint.LabelText))
            {
                LabelStyles autoLabelStyle = (LabelStyles)dataPoint.LabelStyle;

                Title tb = new Title()
                {
                    Text = dataPoint.TextParser(dataPoint.LabelText),
                    InternalFontFamily = dataPoint.LabelFontFamily,
                    InternalFontSize = dataPoint.LabelFontSize.Value,
                    InternalFontWeight = (FontWeight)dataPoint.LabelFontWeight,
                    InternalFontStyle = (FontStyle)dataPoint.LabelFontStyle,
                    InternalBackground = dataPoint.LabelBackground,
                    InternalFontColor = Chart.CalculateDataPointLabelFontColor(dataPoint.Chart as Chart, dataPoint, dataPoint.LabelFontColor, autoLabelStyle),
                    Padding = new Thickness(0.1, 0.1, 0.1, 0.1),
                    Tag = new ElementData() { Element = dataPoint }
                };

                tb.CreateVisualObject(new ElementData() { Element = dataPoint });

                Double labelLeft = 0;
                Double labelTop = 0;
                Double gap = 6;

                if (Double.IsNaN(dataPoint.LabelAngle) || dataPoint.LabelAngle == 0)
                {
                    SetLabelPosition4LineDataPoint(dataPoint, width, height, isPositive, markerLeft, markerTop, ref labelLeft, ref labelTop, gap, new Size(tb.TextBlockDesiredSize.Width, tb.TextBlockDesiredSize.Height));

                    retVal.X = labelLeft;
                    retVal.Y = labelTop;

                    if (IsSetPosition)
                    {
                        tb.Visual.SetValue(Canvas.LeftProperty, labelLeft);
                        tb.Visual.SetValue(Canvas.TopProperty, labelTop);
                    }

                    Double depth3D = chart.ChartArea.PLANK_DEPTH / chart.PlotDetails.Layer3DCount * (chart.View3D ? 1 : 0);

                    if (!dataPoint.IsLabelStyleSet && !dataPoint.Parent.IsLabelStyleSet)
                    {
                        if (isPositive)
                        {
                            if (labelTop < -depth3D)
                                autoLabelStyle = LabelStyles.Inside;
                        }
                        else
                        {
                            if (labelTop + tb.TextBlockDesiredSize.Height > chart.PlotArea.BorderElement.Height - depth3D + chart.ChartArea.PLANK_THICKNESS)
                                autoLabelStyle = LabelStyles.Inside;
                        }
                    }

                    if (autoLabelStyle != dataPoint.LabelStyle)
                    {
                        SetLabelPosition4LineDataPoint(dataPoint, width, height, isPositive, markerLeft, markerTop, ref labelLeft, ref labelTop, gap, new Size(tb.TextBlockDesiredSize.Width, tb.TextBlockDesiredSize.Height));

                        retVal.X = labelLeft;
                        retVal.Y = labelTop;

                        if (IsSetPosition)
                        {
                            tb.Visual.SetValue(Canvas.LeftProperty, labelLeft);
                            tb.Visual.SetValue(Canvas.TopProperty, labelTop);
                        }
                    }
                }
                else
                {
                    if (isPositive)
                    {
                        Point centerOfRotation = new Point(markerLeft,
                            markerTop - tb.TextBlockDesiredSize.Height / 2);
                        Double radius = dataPoint.Marker.MarkerSize.Height / 2 * dataPoint.Marker.ScaleFactor;
                        Double angle = 0;
                        Double angleInRadian = 0;

                        if (autoLabelStyle == LabelStyles.OutSide)
                        {
                            if (dataPoint.LabelAngle > 0 && dataPoint.LabelAngle <= 90)
                            {
                                angle = dataPoint.LabelAngle - 180;
                                angleInRadian = (Math.PI / 180) * angle;
                                radius += tb.TextBlockDesiredSize.Width;
                                angle = (angleInRadian - Math.PI) * (180 / Math.PI);
                                ColumnChart.SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                            else if (dataPoint.LabelAngle >= -90 && dataPoint.LabelAngle < 0)
                            {
                                angle = dataPoint.LabelAngle;
                                angleInRadian = (Math.PI / 180) * angle;
                                ColumnChart.SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                        }
                        else
                        {
                            centerOfRotation = new Point(markerLeft,
                                markerTop + dataPoint.Marker.MarkerSize.Height / 2);
                            if (dataPoint.LabelAngle >= -90 && dataPoint.LabelAngle < 0)
                            {
                                angle = 180 + dataPoint.LabelAngle;
                                angleInRadian = (Math.PI / 180) * angle;
                                radius += tb.TextBlockDesiredSize.Width + 3;
                                angle = (angleInRadian - Math.PI) * (180 / Math.PI);
                                ColumnChart.SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                            else if (dataPoint.LabelAngle > 0 && dataPoint.LabelAngle <= 90)
                            {
                                //radius += 3;
                                angle = dataPoint.LabelAngle;
                                angleInRadian = (Math.PI / 180) * angle;
                                ColumnChart.SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                        }
                    }
                    else
                    {
                        Point centerOfRotation = new Point();
                        Double radius = dataPoint.Marker.MarkerSize.Height / 2 * dataPoint.Marker.ScaleFactor;
                        Double angle = 0;
                        Double angleInRadian = 0;

                        if (autoLabelStyle == LabelStyles.OutSide)
                        {
                            centerOfRotation = new Point(markerLeft,
                                markerTop + dataPoint.Marker.MarkerSize.Height / 2);

                            if (dataPoint.LabelAngle >= -90 && dataPoint.LabelAngle < 0)
                            {
                                angle = 180 + dataPoint.LabelAngle;
                                angleInRadian = (Math.PI / 180) * angle;
                                radius += tb.TextBlockDesiredSize.Width;
                                angle = (angleInRadian - Math.PI) * (180 / Math.PI);
                                ColumnChart.SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                            else if (dataPoint.LabelAngle > 0 && dataPoint.LabelAngle <= 90)
                            {
                                angle = dataPoint.LabelAngle;
                                angleInRadian = (Math.PI / 180) * angle;
                                ColumnChart.SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                        }
                        else
                        {
                            centerOfRotation = new Point(markerLeft,
                                markerTop - dataPoint.Marker.MarkerSize.Height / 2);

                            if (dataPoint.LabelAngle > 0 && dataPoint.LabelAngle <= 90)
                            {
                                angle = dataPoint.LabelAngle - 180;
                                angleInRadian = (Math.PI / 180) * angle;
                                radius += tb.TextBlockDesiredSize.Width + 3;
                                angle = (angleInRadian - Math.PI) * (180 / Math.PI);
                                ColumnChart.SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                            else if (dataPoint.LabelAngle >= -90 && dataPoint.LabelAngle < 0)
                            {
                                //radius += 3;
                                angle = dataPoint.LabelAngle;
                                angleInRadian = (Math.PI / 180) * angle;
                                ColumnChart.SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                        }
                    }
                }

                if (autoLabelStyle != dataPoint.LabelStyle)
                {
                    tb.TextElement.Foreground = Chart.CalculateDataPointLabelFontColor(dataPoint.Chart as Chart, dataPoint, dataPoint.LabelFontColor, (dataPoint.InternalYValue <= 0 ? LabelStyles.OutSide : autoLabelStyle));
                }

                dataPoint.LabelVisual = tb.Visual;

                dataPoint.LabelVisual.Width = tb.TextBlockDesiredSize.Width;
                dataPoint.LabelVisual.Height = tb.TextBlockDesiredSize.Height;

                labelCanvas.Children.Add(tb.Visual);
            }

            return retVal;
        }
Example #39
0
        /// <summary>
        /// Apply font properties of the title of Legend
        /// </summary>
        /// <param name="title"></param>
        private void ApplyFontProperty(Title title)
        {
            if (TitleFontFamily != null)
                title.InternalFontFamily = TitleFontFamily;

            if (TitleFontSize != 0)
                title.InternalFontSize = TitleFontSize;

            if (TitleFontStyle != null)
                title.InternalFontStyle = TitleFontStyle;

            if (TitleFontWeight != null)
                title.InternalFontWeight = TitleFontWeight;

            if (!String.IsNullOrEmpty(Title))
                title.Text = GetFormattedMultilineText(Title);

            title.InternalFontColor = Charts.Chart.CalculateFontColor((Chart as Chart), Background, TitleFontColor, this.DockInsidePlotArea);
        }
Example #40
0
        /// <summary>
        /// Metodo de graficaciĆ³n.
        /// </summary>
        /// <returns></returns>
        public Chart Draw(params string[] filtros)
        {
            // Create a new instance of Chart
            Chart chart = new Chart();

            chart.AnimationEnabled = true;
            // Create a new instance of Title
            Title title = new Title();
            // Set title property
            title.Text = "Efectividad MDZ";
            // Add title to Titles collection
            chart.Titles.Add(title);
            // Create a new instance of DataSeries
            DataSeries dataSeries = new DataSeries();
            // Set DataSeries property
            dataSeries.RenderAs = RenderAs.Line;
            #region configuracion eje X
            // Creating AxisX
            Axis axisX = new Axis();
            // Date time standard format
            axisX.ValueFormatString = "000000";
            // To avoid auto skip

            chart.AxesX.Add(axisX);
            #endregion
            // Create a DataPoint
            DataPoint dataPoint;
            #region consulta
            DataTable kpis;
            try
            {
                kpis = new DataTable();
                Consultas consulta = new Consultas();
                kpis = consulta.SelectKPI_EfectividadMDZ(filtros).Tables[0];
                consulta = null;
                string serAnt = "-5555";
                string ser = "-1111";
                foreach (DataRow g in kpis.Rows)
                {
                    Decimal? y = g["EfectivenessByBrand"]!=DBNull.Value?(Decimal?)g["EfectivenessByBrand"]:null;
                    long x = (long)g["TimeId"];
                    ser = (string)g["ProductSubfamilyDescription"];
                    //Creando las series
                    if (serAnt != ser)
                    {
                        if (serAnt != "-5555")
                        {
                            chart.Series.Add(dataSeries);
                        }
                        // Create a new instance of DataSeries
                        dataSeries = new DataSeries();
                        dataSeries.Name = ser;
                        // Set DataSeries property
                        dataSeries.RenderAs = RenderAs.Line;
                        dataSeries.MarkerType = Visifire.Commons.MarkerTypes.Circle;
                        dataSeries.SelectionEnabled = true;
                        dataSeries.LineThickness = 3;

                    }
                    // Create a new instance of DataPoint
                    dataPoint = new DataPoint();
                    // Set YValue for a DataPoint
                    if (x != null) dataPoint.AxisXLabel = x.ToString();
                    if (!ciclos.Contains(x.ToString()))  ciclos.Add(x.ToString());
                    dataPoint.YValue = System.Convert.ToDouble(y);
                    // Add dataPoint to DataPoints collection.
                    dataSeries.DataPoints.Add(dataPoint);
                    serAnt = ser;
                }
            }
            catch (Exception Error)
            {
                throw (new Exception(Error.ToString()));
            }
            #endregion
            // Add dataSeries to Series collection.
            chart.Series.Add(dataSeries);
            return chart;
        }
Example #41
0
        /// <summary>
        /// Create visual object of the Legend
        /// </summary>
        internal void CreateVisualObject()
        {
            if (!(Boolean)Enabled)
            {
                Visual = null;
                return;
            }

            ElementData tag = new ElementData { Element = this, VisualElementName = "Legend" };

            Visual = new Border() { Tag = tag };
            Grid innerGrid = new Grid() { Tag = tag };

            (Visual as Border).Child = innerGrid;

            LegendContainer = new StackPanel() { Tag = tag };

            if (!String.IsNullOrEmpty(Title))
            {
                Title legendTitle = new Title();
                ApplyFontProperty(legendTitle);

                if (TitleBackground != null)
                    legendTitle.InternalBackground = TitleBackground;

                legendTitle.InternalHorizontalAlignment = TitleAlignmentX;
                legendTitle.InternalVerticalAlignment = VerticalAlignment.Top;
                legendTitle.TextAlignment = TitleTextAlignment;

                legendTitle.CreateVisualObject(tag);

                legendTitle.Measure(new Size(Double.MaxValue, Double.MaxValue));

                if (legendTitle.DesiredSize.Width > InternalMaxWidth)
                    legendTitle.Visual.Width = InternalMaxWidth;

                LegendContainer.Children.Add(legendTitle.Visual);
            }

            Grid legendContent = CreateLegendContent();
            legendContent.Tag = tag;

            LegendContainer.Children.Add(legendContent);

            LegendContainer.VerticalAlignment = VerticalAlignment.Center;
            LegendContainer.HorizontalAlignment = HorizontalAlignment.Stretch;

            ApplyVisualProperty();

            innerGrid.Children.Add(LegendContainer);

            Visual.Cursor = this.Cursor;
            Visual.Measure(new Size(Double.MaxValue, Double.MaxValue));

            if (!Double.IsPositiveInfinity(InternalMaxHeight) && InternalMaxHeight < Visual.DesiredSize.Height)
                Visual.Height = InternalMaxHeight;
            else 
                Visual.Height = Visual.DesiredSize.Height;

            if (!Double.IsPositiveInfinity(InternalMaxWidth) && InternalMaxWidth < Visual.DesiredSize.Width + InternalPadding.Left)
                Visual.Width = InternalMaxWidth;
            else if (Layout == Layouts.GridLayout)
                Visual.Width = Visual.DesiredSize.Width + InternalPadding.Left;
            else
                Visual.Width = Visual.DesiredSize.Width;

            PlotArea plotArea = (Chart as Chart).PlotArea;

            RectangleGeometry rectGeo = new RectangleGeometry();
            rectGeo.Rect = new Rect(InternalBorderThickness.Left, InternalBorderThickness.Top, Visual.Width - InternalBorderThickness.Left - InternalBorderThickness.Right, Visual.Height - InternalBorderThickness.Top - InternalBorderThickness.Bottom);
            rectGeo.RadiusX = CornerRadius.TopLeft;
            rectGeo.RadiusY = CornerRadius.TopRight;
            LegendContainer.Clip = rectGeo;

            ApplyShadow(innerGrid);

            if (VerticalAlignment == System.Windows.VerticalAlignment.Bottom && (HorizontalAlignment == System.Windows.HorizontalAlignment.Center
                || HorizontalAlignment == System.Windows.HorizontalAlignment.Left || HorizontalAlignment == System.Windows.HorizontalAlignment.Right
                || HorizontalAlignment == System.Windows.HorizontalAlignment.Stretch))
                Visual.Margin = new Thickness(0, DEFAULT_MARGIN, 0, 0);
            else if (VerticalAlignment == System.Windows.VerticalAlignment.Top && (HorizontalAlignment == System.Windows.HorizontalAlignment.Center
                || HorizontalAlignment == System.Windows.HorizontalAlignment.Left || HorizontalAlignment == System.Windows.HorizontalAlignment.Right
                || HorizontalAlignment == System.Windows.HorizontalAlignment.Stretch))
                Visual.Margin = new Thickness(0, 0, 0, DEFAULT_MARGIN);
            else if (HorizontalAlignment == System.Windows.HorizontalAlignment.Left && (VerticalAlignment == System.Windows.VerticalAlignment.Center
                || VerticalAlignment == System.Windows.VerticalAlignment.Stretch))
                Visual.Margin = new Thickness(0, 0, DEFAULT_MARGIN, 0);
            else if (HorizontalAlignment == System.Windows.HorizontalAlignment.Right && (VerticalAlignment == System.Windows.VerticalAlignment.Center
                || VerticalAlignment == System.Windows.VerticalAlignment.Stretch))
                Visual.Margin = new Thickness(DEFAULT_MARGIN, 0, 0, 0);
        }