Exemple #1
0
        SolidColorBrush twoSDBrush = new SolidColorBrush(Color.FromArgb(50,3, 3, 247)); //平均曲线颜色,红色

        #endregion Fields

        #region Constructors

        public PageAvgCurve()
        {
            InitializeComponent();

            chart1 = new Chart();
            chart2 = new Chart();
            chart2.ScrollingEnabled = chart1.ScrollingEnabled = false;
            chart1.BorderThickness = chart2.BorderThickness = new Thickness(0, 0, 0, 0);

            Axis yOACAxis = new Axis();
            Axis yEACAxis = new Axis();
            yOACAxis.Suffix = yEACAxis.Suffix = "(Nm)";
            chart1.AxesY.Add(yOACAxis);
            chart2.AxesY.Add(yEACAxis);

            Axis xAxisOAC = new Axis();
            Axis xAxisEAC = new Axis();
            xAxisEAC.AxisMinimum = xAxisOAC.AxisMinimum = 0;
            xAxisOAC.AxisMaximum = xAxisEAC.AxisMaximum = 100;
            xAxisEAC.Suffix = xAxisOAC.Suffix = "%";
            chart1.AxesX.Add(xAxisOAC);
            chart2.AxesX.Add(xAxisEAC);

            grid1.Children.Add(chart1);
            grid2.Children.Add(chart2);
        }
        public Chart CreateChart(ChartInformation ci)
        {
            Chart m_chart = new Chart();
            m_chart.BorderThickness = ci.m_BorderThickness;
            m_chart.Theme = ci.m_Theme;
            m_chart.View3D = ci.m_View3D;

            Axis m_axisX = new Axis();
            m_axisX.Title = ci.m_axisXTitle;
            m_chart.AxesX.Add(m_axisX);

            Axis m_asixY = new Axis();
            m_asixY.Title = ci.m_axisYTitle;
            m_asixY.Enabled = true;
            m_asixY.StartFromZero = true;
            m_asixY.AxisType = AxisTypes.Primary;
            m_asixY.AxisMaximum = ci.m_axisYMaximum;
            m_asixY.Interval = ci.m_axisYInterval;
            m_chart.AxesY.Add(m_asixY);
            for(int i = 0;i<ci.dsc.Count;i++)
            {
                DataSeries ds = new DataSeries();
                ds.LegendText = ci.dsc[i].LegendText;
                ds.RenderAs = ci.dsc[i].RenderAs;
                ds.AxisYType = ci.dsc[i].AxisYType;
                ds.DataPoints = new DataPointCollection(ci.dsc[i].DataPoints);
                m_chart.Series.Add(ds);
            }
            m_chart.Rendered+=new EventHandler(chart_Rendered);
            return m_chart;
        }
Exemple #3
0
        public void LineThicknessDefaultValue()
        {
            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 300;

            Common.CreateAndAddDefaultDataSeries(chart);
            ChartGrid grid = new ChartGrid();
            Axis axis = new Axis();
            axis.Grids.Add(grid);
            chart.AxesY.Add(axis);
            
            _isLoaded = false;
            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                Assert.AreEqual(0.25, grid.LineThickness);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
        public void Refresh(object sender)
        {
            Layout.Children.Clear();
            MultiChartControl.MultiChart MyChart = new MultiChartControl.MultiChart();
            DashBoardGraphViewModel vm = (DashBoardGraphViewModel)sender;
            MyChart.Series.Clear();

            for (int i = 0; i < vm.Datos.Count; i++)
            {
                MyChart.Series.Add(c.GetSerie(DashBoardGraph)[i]);
            }
            MyChart.Style = (Style)FindResource("ChartStyle");
            Axis a = new Axis();
            a.ValueFormatString = "0%";
            MyChart.AxesY.Add(a);
            Layout.Children.Add(MyChart);
            lblAnio.Content = AnioMesView.SelectedAnio.Anio;
            lblMes.Content = AnioMesView.SelectedMes.MesName;
            try
            {
                lblDireccion.Text = DashBoradTable.SelectedItem.Organigrama.JerarquiaName;
            }
            catch (Exception)
            {
                lblDireccion.Text = "OCAVM";
            }
        }
Exemple #5
0
        public void CheckDefaultLineThickness()
        {
            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 300;

            Common.CreateAndAddDefaultDataSeries(chart);
            Ticks tick = new Ticks();
            Axis axis = new Axis();
            axis.Ticks.Add(tick);
            chart.AxesX.Add(axis);
              
            _isLoaded = false;
            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                Assert.AreEqual(0.5, tick.LineThickness);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
Exemple #6
0
        private void CreateLcChartSpline(int index)
        {
            //添加横坐标
            if (lcChart.AxesX.Count == 0)
            {
                Axis xAxis = new Axis();
                xAxis.Title = "岩层编号";
                lcChart.AxesX.Add(xAxis);
            }

            //添加纵坐标
            if (lcChart.AxesY.Count == 0)
            {
                Axis yAxis = new Axis();
                yAxis.Title = LCDestOpt[index];
                yAxis.IntervalType = IntervalTypes.Number;
                yAxis.ValueFormatString = "f3";
                yAxis.Suffix = "m";
                lcChart.AxesY.Add(yAxis);
            }
            else
            {
                lcChart.AxesY[0].Title = LCDestOpt[index];
            }

            //设置数据点
            lcDataSeries.DataPoints.Clear();
            DataPoint dataPoint;
            int drawCount = keyLayers.Count;
            for (int i = 0; i < drawCount; i++)
            {
                //创建一个数据点的实例
                dataPoint = new DataPoint();
                //设置X轴点
                dataPoint.AxisXLabel = keyLayers[i].ycbh.ToString();
                dataPoint.XValue = i + 1;
                //设置Y轴点
                switch(index)
                {
                    case 0:
                        dataPoint.YValue = keyLayers[i].yczdxcz;
                        break;
                    case 1:
                        dataPoint.YValue = keyLayers[i].jsdjscjwy;
                        break;
                    case 2:
                        dataPoint.YValue = keyLayers[i].jsdjslcwy;
                        break;
                }

                dataPoint.MarkerSize = 8;
                dataPoint.MouseLeftButtonDown += new MouseButtonEventHandler(lcdataPoint_MouseLeftButtonDown);
                //添加数据点
                lcDataSeries.DataPoints.Add(dataPoint);
            }
        }
Exemple #7
0
        /// <summary>
        /// Initializes a new instance of the Visifire.Charts.PlotGroup class.
        /// </summary>
        /// <param name="renderAs">RenderAs</param>
        /// <param name="axisX">axisX</param>
        /// <param name="axisY">AxisY</param>
        public PlotGroup(RenderAs renderAs, Axis axisX, Axis axisY)
        {
            DataSeriesList = new List<DataSeries>();
            
            XWiseStackedDataList = new Dictionary<Double, XWiseStackedData>();

            RenderAs = renderAs;
            AxisX = axisX;
            AxisY = axisY;
        }
        public void DataPointDecimalXValueChecking()
        {
            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 300;

            Axis axisX = new Axis();
            axisX.Interval = 1;
            chart.AxesX.Add(axisX);
                   
            _isLoaded = false;
            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Random rand = new Random();

            DataSeries dataSeries1 = new DataSeries();

            List<Double> xList = new List<Double>();
            List<Double> yList = new List<Double>();
            Double y = 0;
            for (Double i = 0; i < 10; i++)
            {
                DataPoint dataPoint = new DataPoint();
                dataPoint.XValue = i + 1;
                xList.Add(i);
                dataPoint.YValue = (y = rand.Next(-100, 100));
                yList.Add(y);
                dataSeries1.DataPoints.Add(dataPoint);
            }

            chart.Series.Add(dataSeries1);

            DataSeries dataSeries2 = new DataSeries();
            dataSeries2.RenderAs = RenderAs.Column;

            Double j = 0.5;
            for (Int32 i = 0; i < 10; i++)
            {
                DataPoint dataPoint = new DataPoint();
                dataPoint.XValue = j;
                dataPoint.YValue = yList[i];
                dataSeries2.DataPoints.Add(dataPoint);
                j++;
            }
            chart.Series.Add(dataSeries2);
             
            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                window.Dispatcher.InvokeShutdown();
                window.Close();
            }
        }
Exemple #9
0
        public void ColumnChartPerformanceTest()
        {
            Double totalDuration = 0;
            DateTime start = DateTime.UtcNow;

            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 300;
            chart.View3D = false;

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

            Axis axisX = new Axis();
            axisX.Interval = 1;
            chart.AxesX.Add(axisX);

            Random rand = new Random();

            Int32 numberOfSeries = 0;
            DataSeries dataSeries = null;
            Int32 numberofDataPoint = 0;

            String msg = Common.AssertAverageDuration(100, 1, delegate
            {
                dataSeries = new DataSeries();
                dataSeries.RenderAs = RenderAs.Column;

                for (Int32 i = 0; i < 1000; i++)
                {
                    DataPoint dataPoint = new DataPoint();
                    dataPoint.AxisXLabel = "a" + i;
                    dataPoint.YValue = rand.Next(-100, 100);
                    dataSeries.DataPoints.Add(dataPoint);
                    numberofDataPoint++;
                }
                numberOfSeries++;
                chart.Series.Add(dataSeries);
            });

            window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                DateTime end = DateTime.UtcNow;
                totalDuration = (end - start).TotalSeconds;

                MessageBox.Show("Total Chart Loading Time: " + totalDuration + "s" + "\n"  + "Number of Render Count: " + chart.ChartArea._renderCount + "\n" + "Series Calculation: " + msg);
            }
            window.Dispatcher.InvokeShutdown();
        }
 /// <summary>
 /// Show form
 /// </summary>
 public WindowMain()
 {
     InitializeComponent();
     // Create Y axis
     Axis yAxis = new Axis();
     yAxis.AxisMaximum = 1;
     yAxis.Title = "Probability";
     chart.AxesY.Add(yAxis);
     // Create X axis
     Axis xAxis = new Axis();
     //xAxis.AxisMaximum = 100;
     xAxis.Title = "% (percent)";
     chart.AxesX.Add(xAxis);
 }
        public void TestAxisDecimalIntervalWithAxisXLabel()
        {
            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 300;

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

            Random rand = new Random();

            TestPanel.Children.Add(chart);

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

            DataSeries dataSeries = new DataSeries();
            dataSeries.RenderAs = RenderAs.Column;
            for (Int32 i = 0; i < 10; i++)
                dataSeries.DataPoints.Add(new DataPoint() { AxisXLabel = "Visifire", YValue = rand.Next(10, 100) });
            chart.Series.Add(dataSeries);

            EnqueueCallback(() =>
            {
                Axis axis = new Axis();
                axis.Interval = 0.1;
                chart.AxesX.Add(axis);
            });

            EnqueueDelay(_sleepTime);
            EnqueueTestComplete();
        }
        public void TextWrapNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;

            _axisX = new Axis();

            _axisX.AxisLabels = new AxisLabels();

            _axisX.AxisLabels.TextWrap = 0.5;
            _axisX.AxisLabels.Angle = 0;
            _axisX.Interval = 1;
            _axisX.AxisLabels.Rows = 1;
            chart.AxesX.Add(_axisX);

            DataSeries dataSeries = new DataSeries();

            dataSeries.RenderAs = RenderAs.Column;

            Random rand = new Random();

            for (Int32 i = 0; i < 5; i++)
            {
                DataPoint datapoint = new DataPoint();
                datapoint.AxisXLabel = "VisifireSilverlight" + i;
                datapoint.YValue = rand.Next(0, 100);
                datapoint.XValue = i + 1;
                dataSeries.DataPoints.Add(datapoint);
            }

            chart.Series.Add(dataSeries);

            CreateAsyncTest(chart,
                () => Assert.AreEqual(0.5, _axisX.AxisLabels.TextWrap, Common.HighPrecisionDelta));

            EnqueueTestComplete();
        }
        public void CheckAxisLabelsAutoPlacement2()
        {
            System.Windows.Browser.HtmlPage.Plugin.SetStyleAttribute("height", "400px");

            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 300;
            chart.ScrollingEnabled = false;

            chart.Loaded += new System.Windows.RoutedEventHandler(chart_Loaded);

            TestPanel.Children.Add(chart);

            Axis axisX = new Axis();
            axisX.AxisLabels = new AxisLabels();
            axisX.AxisLabels.FontColor = new SolidColorBrush(Colors.Red);
            chart.AxesX.Add(axisX);

            DataSeries dataSeries = new DataSeries();
            dataSeries.RenderAs = RenderAs.Line;
            
            Random rand = new Random();

            Int32 numberOfDataPoint = 0;
            Double totalDuration = 0;
            DateTime start = DateTime.UtcNow;
            String msg = Common.AssertAverageDuration(80, 1, delegate
            {
                for (Int32 i = 0; i < 500; i++)
                {
                    DataPoint datapoint = new DataPoint();
                    datapoint.AxisXLabel = "Visifire Label" + i;
                    datapoint.YValue = rand.Next(0, 100);
                    dataSeries.DataPoints.Add(datapoint);
                    numberOfDataPoint++;
                }

                chart.Series.Add(dataSeries);

            });

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

            EnqueueCallback(() =>
            {
                DateTime end = DateTime.UtcNow;

                totalDuration = (end - start).TotalSeconds;
            });

            EnqueueCallback(() =>
            {
                _htmlElement1 = Common.GetDisplayMessageButton(_htmlElement1);
                _htmlElement1.SetStyleAttribute("width", "900px");
                _htmlElement1.SetProperty("value", numberOfDataPoint + " AxisLabels 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.HtmlElement_OnClick));
            });
        }
        public void FontWeightNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;

            _axisX = new Axis();
            _axisY = new Axis();

            _axisX.AxisLabels = new AxisLabels();
            _axisY.AxisLabels = new AxisLabels();

            _axisX.AxisLabels.FontWeight = FontWeights.Bold;
            _axisY.AxisLabels.FontWeight = FontWeights.Bold;

            chart.AxesX.Add(_axisX);
            chart.AxesY.Add(_axisY);

            Common.CreateAndAddDefaultDataSeries(chart);
            EnqueueDelay(_sleepTime);

            CreateAsyncTask(chart,
                () => Assert.AreEqual(FontWeights.Bold, _axisX.AxisLabels.FontWeight),
                () => Assert.AreEqual(FontWeights.Bold, _axisY.AxisLabels.FontWeight));

            EnqueueTestComplete();
        }
        public void RowsNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;

            _axisX = new Axis();

            _axisX.AxisLabels = new AxisLabels();

            _axisX.AxisLabels.Rows = 2;
            chart.AxesX.Add(_axisX);

            Common.CreateAndAddDefaultDataSeries(chart);
            EnqueueDelay(_sleepTime);

            CreateAsyncTest(chart,
                () => Assert.AreEqual(2, _axisX.AxisLabels.Rows));

            EnqueueTestComplete();
        }
Exemple #16
0
        public void DataPointRandomXValuesChecking()
        {
            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 300;

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

            Axis axisX = new Axis();
            axisX.Interval = 1;
            chart.AxesX.Add(axisX);

            Random rand = new Random();

            DataSeries dataSeries1 = new DataSeries();

            for (Int32 i = 0; i < 5; i++)
            {
                DataPoint dataPoint = new DataPoint();
                dataPoint.XValue = rand.Next(1, 10);
                dataPoint.YValue = rand.Next(-500, 500);
                dataSeries1.DataPoints.Add(dataPoint);
            }
            for (Int32 i = 0; i < 5; i++)
            {
                DataPoint dataPoint = new DataPoint();
                dataPoint.XValue = rand.Next(1, 10);
                dataPoint.YValue = rand.Next(-500, 500);
                dataSeries1.DataPoints.Add(dataPoint);
            }

            chart.Series.Add(dataSeries1);

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                window.Dispatcher.InvokeShutdown();
                window.Close();
            }
        }
        public void FontColorNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;

            _axisX = new Axis();
            _axisY = new Axis();

            _axisX.AxisLabels = new AxisLabels();
            _axisY.AxisLabels = new AxisLabels();

            _axisX.AxisLabels.FontColor = new SolidColorBrush(Colors.Red);
            _axisY.AxisLabels.FontColor = new SolidColorBrush(Colors.Red);

            chart.AxesX.Add(_axisX);
            chart.AxesY.Add(_axisY);

            Common.CreateAndAddDefaultDataSeries(chart);
            EnqueueDelay(_sleepTime);

            CreateAsyncTask(chart,
                () => Common.AssertBrushesAreEqual(new SolidColorBrush(Colors.Red), _axisX.AxisLabels.FontColor),
                () => Common.AssertBrushesAreEqual(new SolidColorBrush(Colors.Red), _axisY.AxisLabels.FontColor));

            EnqueueTestComplete();
        }
        public void TextAlignmentNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;

            _axisX = new Axis();
            _axisY = new Axis();

            _axisX.AxisLabels = new AxisLabels();
            _axisY.AxisLabels = new AxisLabels();

            _axisX.AxisLabels.TextAlignment = TextAlignment.Center;
            _axisY.AxisLabels.TextAlignment = TextAlignment.Center;

            chart.AxesX.Add(_axisX);
            chart.AxesY.Add(_axisY);

            Common.CreateAndAddDefaultDataSeries(chart);
            EnqueueDelay(_sleepTime);

            CreateAsyncTask(chart,
                () => Assert.AreEqual(TextAlignment.Center, _axisX.AxisLabels.TextAlignment),
                () => Assert.AreEqual(TextAlignment.Center, _axisY.AxisLabels.TextAlignment));

            EnqueueTestComplete();
        }
        public void IntervalNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;

            _axisX = new Axis();
            _axisY = new Axis();

            _axisX.AxisLabels = new AxisLabels();
            _axisY.AxisLabels = new AxisLabels();

            _axisX.AxisLabels.Interval = 2;
            _axisY.AxisLabels.Interval = 20;

            chart.AxesX.Add(_axisX);
            chart.AxesY.Add(_axisY);

            Common.CreateAndAddDefaultDataSeries(chart);
            EnqueueDelay(_sleepTime);

            CreateAsyncTask(chart,
                () => Assert.AreEqual(2, _axisX.AxisLabels.Interval),
                () => Assert.AreEqual(20, _axisY.AxisLabels.Interval));

            EnqueueTestComplete();
        }
        public void AreaDataSeriesStressTest()
        {
            System.Windows.Browser.HtmlPage.Plugin.SetStyleAttribute("height", "400px");

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

            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 300;
            chart.View3D = false;

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

            TestPanel.Children.Add(chart);

            Axis axisX = new Axis();
            axisX.Interval = 1;
            chart.AxesX.Add(axisX);

            Random rand = new Random();

            Int32 numberOfSeries = 0;
            DataSeries dataSeries = null;
            Int32 numberofDataPoint = 0;

            String msg = Common.AssertAverageDuration(200, 2, delegate
            {
                dataSeries = new DataSeries();
                dataSeries.RenderAs = RenderAs.Area;

                for (Int32 i = 0; i < 500; i++)
                {
                    DataPoint dataPoint = new DataPoint();
                    dataPoint.AxisXLabel = "a" + i;
                    dataPoint.YValue = rand.Next(-100, 100);
                    dataSeries.DataPoints.Add(dataPoint);
                    numberofDataPoint++;
                }
                numberOfSeries++;
                chart.Series.Add(dataSeries);
            });

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

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

            EnqueueCallback(() =>
            {
                _htmlElement1 = Common.GetDisplayMessageButton(_htmlElement1);
                _htmlElement1.SetStyleAttribute("width", "900px");
                _htmlElement1.SetProperty("value", dataSeries.RenderAs + " chart with " + numberOfSeries + " DataSeries having " + numberofDataPoint + " DataPoints. Total Chart Loading Time: " + totalDuration + "s. Number of Render Count: " + chart.ChartArea._renderCount);
                _htmlElement2 = Common.GetDisplayMessageButton(_htmlElement2);
                _htmlElement2.SetStyleAttribute("top", "540px");
                _htmlElement2.SetProperty("value", "Total Calculation: " + msg + " Click here to exit.");
                System.Windows.Browser.HtmlPage.Document.Body.AppendChild(_htmlElement1);
                System.Windows.Browser.HtmlPage.Document.Body.AppendChild(_htmlElement2);
            });

            EnqueueDelay(_sleepTime);
            EnqueueCallback(() =>
            {
                _htmlElement2.AttachEvent("onclick", new EventHandler<System.Windows.Browser.HtmlEventArgs>(this.HtmlElement_OnClick));
            });
        }
        // 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);
        }
        /// <summary>
        /// Calculate Min Max date from a List of dates for Polar chart
        /// </summary>
        /// <param name="dateTimeList">List of DateTimes</param>
        /// <param name="minDate">min Date</param>
        /// <param name="maxDate">out Max Date</param>
        /// <param name="minDateRange">Minimum date difference</param>
        /// <param name="maxDateRange">Maximum date difference</param>
        internal static void CalculateMinMaxDate4PolarChart(System.Collections.Generic.List<DateTime> dateTimeList, Axis axisX, out DateTime minDate, out DateTime maxDate, out TimeSpan minDateRange, out TimeSpan maxDateRange)
        {
            if(axisX.AxisMinimum == null)
                minDate = DateTime.Parse("12/30/1899", System.Globalization.CultureInfo.InvariantCulture);
            else
                minDate = Convert.ToDateTime(axisX.AxisMinimum);

            if (axisX.AxisMaximum != null)
                maxDate = Convert.ToDateTime(axisX.AxisMaximum);
            else
                maxDate = dateTimeList[dateTimeList.Count - 1];

            dateTimeList.Sort();

            minDateRange = new TimeSpan();
            maxDateRange = new TimeSpan();

            if (dateTimeList.Count > 0)
            {
                if (dateTimeList.Count >= 2)
                {
                    minDateRange = dateTimeList[1].Subtract(minDate);
                    maxDateRange = maxDate.Subtract(minDate);
                }
            }
            else
                maxDate = minDate;
        }
Exemple #23
0
        public void DataPointStressXValueChecking()
        {
            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 300;

            Axis axisX = new Axis();
            axisX.Interval = 1;
            chart.AxesX.Add(axisX);

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

            Random rand = new Random();

            DataSeries dataSeries1 = new DataSeries();

            Int32 numberOfDataPoints = 0;

            Common.AssertAverageDuration(200, 2, delegate
            {
                for (Int32 i = 0; i < 250; i++)
                {
                    DataPoint dataPoint = new DataPoint();
                    dataPoint.XValue = i + 1;
                    dataPoint.YValue = rand.Next(-500, 500);
                    dataSeries1.DataPoints.Add(dataPoint);
                    numberOfDataPoints++;
                }
            });

            chart.Series.Add(dataSeries1);

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                window.Dispatcher.InvokeShutdown();
                window.Close();
            }
        }
Exemple #24
0
        public void DataPointStressXValuesChecking2()
        {
            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 300;
            chart.View3D = true;

            Axis axisX = new Axis();
            axisX.Interval = 1;
            chart.AxesX.Add(axisX);

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

            Random rand = new Random();

            DataSeries dataSeries1 = new DataSeries();
            dataSeries1.RenderAs = RenderAs.Area;

            Int32 numberOfDataPoints = 0;

            String msg = Common.AssertAverageDuration(300, 2, delegate
            {
                for (Int32 i = 0; i < 2500; i++)
                {
                    DataPoint dataPoint = new DataPoint();
                    dataPoint.XValue = i + 1;
                    dataPoint.YValue = Math.Sin((Math.PI * 2) * i / 2500) * 10;
                    dataSeries1.DataPoints.Add(dataPoint);
                    numberOfDataPoints++;
                }
            });

            chart.Series.Add(dataSeries1);

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                window.Dispatcher.InvokeShutdown();
                window.Close();
            }
        }
Exemple #25
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
        }
        public void OpacityNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;

            _axisX = new Axis();
            _axisY = new Axis();

            _axisX.AxisLabels = new AxisLabels();
            _axisY.AxisLabels = new AxisLabels();

            _axisX.AxisLabels.InternalOpacity = 0.5;
            _axisY.AxisLabels.InternalOpacity = 0.5;

            chart.AxesX.Add(_axisX);
            chart.AxesY.Add(_axisY);

            Common.CreateAndAddDefaultDataSeries(chart);
            EnqueueDelay(_sleepTime);

            CreateAsyncTask(chart,
                () => Assert.AreEqual(0.5, _axisX.AxisLabels.InternalOpacity, Common.HighPrecisionDelta),
                () => Assert.AreEqual(0.5, _axisY.AxisLabels.InternalOpacity, Common.HighPrecisionDelta));

            EnqueueTestComplete();
        }
        public void MultiSeriesChartCheckingWithSecondaryAxis()
        {
            System.Windows.Browser.HtmlPage.Plugin.SetStyleAttribute("height", "400px");

            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 300;
            chart.View3D = true;

            chart.ScrollingEnabled = false;

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

            TestPanel.Children.Add(chart);

            Int32 numberOfDataPoints = 0;

            Random rand = new Random();

            Axis axis = new Axis();
            axis.Interval = 1;
            axis.Background = new SolidColorBrush(Colors.LightGray);
            chart.AxesX.Add(axis);

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

            EnqueueCallback(() =>
            {
                DataSeries dataSeries1 = new DataSeries();
                dataSeries1.RenderAs = RenderAs.Area;
                numberOfDataPoints = 0;
                for (Int32 i = 0; i < 20; i++)
                {
                    DataPoint dataPoint = new DataPoint();
                    dataPoint.XValue = i + 1;
                    dataPoint.YValue = rand.Next(-500, 500);
                    dataSeries1.DataPoints.Add(dataPoint);
                    numberOfDataPoints++;
                }
                chart.Series.Add(dataSeries1);
                Assert.AreEqual(1, chart.Series.Count);
                _htmlElement1.SetProperty("value", dataSeries1.RenderAs + " with " + numberOfDataPoints + " DataPoints. Number of Render Count: " + chart.ChartArea._renderCount);
            });

            EnqueueCallback(() =>
            {
                DataSeries dataSeries2 = new DataSeries();
                dataSeries2.RenderAs = RenderAs.Line;
                numberOfDataPoints = 0;
                for (Int32 i = 0; i < 20; i++)
                {
                    DataPoint dataPoint = new DataPoint();
                    dataPoint.XValue = i + 1;
                    dataPoint.YValue = rand.Next(-500, 500);
                    dataSeries2.DataPoints.Add(dataPoint);
                    numberOfDataPoints++;
                }
                chart.Series.Add(dataSeries2);
                Assert.AreEqual(2, chart.Series.Count);
                isDataSeriesAdded = true;
                _htmlElement1.SetProperty("value", dataSeries2.RenderAs + " with " + numberOfDataPoints + " DataPoints. Number of Render Count: " + chart.ChartArea._renderCount);
            });

            EnqueueConditional(() => { return isDataSeriesAdded; });
            EnqueueDelay(1000);
            isDataSeriesAdded = false;

            EnqueueCallback(() =>
            {
                DataSeries dataSeries3 = new DataSeries();
                dataSeries3.RenderAs = RenderAs.StackedArea;
                dataSeries3.AxisYType = AxisTypes.Secondary;
                numberOfDataPoints = 0;
                for (Int32 i = 0; i < 20; i++)
                {
                    DataPoint dataPoint = new DataPoint();
                    dataPoint.XValue = i + 1;
                    dataPoint.YValue = rand.Next(100, 500);
                    dataSeries3.DataPoints.Add(dataPoint);
                    numberOfDataPoints++;
                }
                chart.Series.Add(dataSeries3);
                Assert.AreEqual(3, chart.Series.Count);
                isDataSeriesAdded = true;
                _htmlElement1.SetProperty("value", dataSeries3.RenderAs + " with " + numberOfDataPoints + " DataPoints. Number of Render Count: " + chart.ChartArea._renderCount);
            });

            EnqueueConditional(() => { return isDataSeriesAdded; });
            EnqueueDelay(1000);
            isDataSeriesAdded = false;

            EnqueueCallback(() =>
            {
                DataSeries dataSeries4 = new DataSeries();
                dataSeries4.RenderAs = RenderAs.StackedArea;
                dataSeries4.AxisYType = AxisTypes.Secondary;
                numberOfDataPoints = 0;
                for (Int32 i = 0; i < 20; i++)
                {
                    DataPoint dataPoint = new DataPoint();
                    dataPoint.XValue = i + 1;
                    dataPoint.YValue = rand.Next(-100, 400);
                    dataSeries4.DataPoints.Add(dataPoint);
                    numberOfDataPoints++;
                }
                chart.Series.Add(dataSeries4);
                Assert.AreEqual(4, chart.Series.Count);
                isDataSeriesAdded = true;
                _htmlElement1.SetProperty("value", dataSeries4.RenderAs + " with " + numberOfDataPoints + " DataPoints. Number of Render Count: " + chart.ChartArea._renderCount);
            });

            EnqueueConditional(() => { return isDataSeriesAdded; });
            EnqueueDelay(1000);
            isDataSeriesAdded = false;

            EnqueueCallback(() =>
            {
                DataSeries dataSeries5 = new DataSeries();
                dataSeries5.RenderAs = RenderAs.StackedColumn;
                numberOfDataPoints = 0;
                for (Int32 i = 0; i < 20; i++)
                {
                    DataPoint dataPoint = new DataPoint();
                    dataPoint.XValue = i + 1;
                    dataPoint.YValue = rand.Next(-200, 400);
                    dataSeries5.DataPoints.Add(dataPoint);
                    numberOfDataPoints++;
                }
                chart.Series.Add(dataSeries5);
                Assert.AreEqual(5, chart.Series.Count);
                isDataSeriesAdded = true;
                _htmlElement1.SetProperty("value", dataSeries5.RenderAs + " with " + numberOfDataPoints + " DataPoints. Number of Render Count: " + chart.ChartArea._renderCount);
            });

            EnqueueConditional(() => { return isDataSeriesAdded; });
            EnqueueDelay(1000);
            isDataSeriesAdded = false;

            EnqueueCallback(() =>
            {
                DataSeries dataSeries6 = new DataSeries();
                dataSeries6.RenderAs = RenderAs.Area;
                dataSeries6.AxisYType = AxisTypes.Secondary;
                numberOfDataPoints = 0;
                for (Int32 i = 0; i < 20; i++)
                {
                    DataPoint dataPoint = new DataPoint();
                    dataPoint.XValue = i + 1;
                    dataPoint.YValue = rand.Next(-100, 500);
                    dataPoint.ZValue = rand.Next(100, 500);
                    dataSeries6.DataPoints.Add(dataPoint);
                    numberOfDataPoints++;
                }
                chart.Series.Add(dataSeries6);
                Assert.AreEqual(6, chart.Series.Count);
                isDataSeriesAdded = true;
                _htmlElement1.SetProperty("value", dataSeries6.RenderAs + " with " + numberOfDataPoints + " DataPoints. Number of Render Count: " + chart.ChartArea._renderCount);
            });

            EnqueueConditional(() => { return isDataSeriesAdded; });
            EnqueueDelay(1000);
            isDataSeriesAdded = false;

            EnqueueCallback(() =>
            {
                DataSeries dataSeries7 = new DataSeries();
                dataSeries7.RenderAs = RenderAs.Line;
                numberOfDataPoints = 0;
                for (Int32 i = 0; i < 20; i++)
                {
                    DataPoint dataPoint = new DataPoint();
                    dataPoint.XValue = i + 1;
                    dataPoint.YValue = rand.Next(-400, 500);
                    dataSeries7.DataPoints.Add(dataPoint);
                    numberOfDataPoints++;
                }
                chart.Series.Add(dataSeries7);
                Assert.AreEqual(7, chart.Series.Count);
                isDataSeriesAdded = true;
                _htmlElement1.SetProperty("value", dataSeries7.RenderAs + " with " + numberOfDataPoints + " DataPoints. Number of Render Count: " + chart.ChartArea._renderCount);
            });

            EnqueueConditional(() => { return isDataSeriesAdded; });
            EnqueueDelay(1000);
            isDataSeriesAdded = false;

            EnqueueCallback(() =>
            {
                DataSeries dataSeries8 = new DataSeries();
                dataSeries8.RenderAs = RenderAs.StackedColumn100;
                dataSeries8.AxisYType = AxisTypes.Secondary;
                numberOfDataPoints = 0;
                for (Int32 i = 0; i < 20; i++)
                {
                    DataPoint dataPoint = new DataPoint();
                    dataPoint.XValue = i + 1;
                    dataPoint.YValue = rand.Next(0, 500);
                    dataSeries8.DataPoints.Add(dataPoint);
                    numberOfDataPoints++;
                }
                chart.Series.Add(dataSeries8);
                Assert.AreEqual(8, chart.Series.Count);
                isDataSeriesAdded = true;
                _htmlElement1.SetProperty("value", dataSeries8.RenderAs + " with " + numberOfDataPoints + " DataPoints. Click here to exit. Number of Render Count: " + chart.ChartArea._renderCount);
            });

            EnqueueConditional(() => { return isDataSeriesAdded; });
            isDataSeriesAdded = false;

            EnqueueCallback(() =>
            {
                EnqueueTestComplete();
            });

            _htmlElement1 = Common.GetDisplayMessageButton(_htmlElement1);
            _htmlElement1.SetStyleAttribute("width", "900px");
            System.Windows.Browser.HtmlPage.Document.Body.AppendChild(_htmlElement1);
        }
Exemple #28
0
        public void DataPointAxisXLabelChecking()
        {
            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 300;

            Axis axisX = new Axis();
            axisX.Interval = 1;
            chart.AxesX.Add(axisX);

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

            Random rand = new Random();

            DataSeries dataSeries1 = new DataSeries();

            DataPoint dataPoint = new DataPoint();
            dataPoint.AxisXLabel = "a1";
            dataPoint.XValue = 0.001;
            dataPoint.YValue = rand.Next(0, 100);
            dataSeries1.DataPoints.Add(dataPoint);
            dataPoint = new DataPoint();
            dataPoint.AxisXLabel = "a1";
            dataPoint.XValue = 1.265;
            dataPoint.YValue = rand.Next(0, 100);
            dataSeries1.DataPoints.Add(dataPoint);
            dataPoint = new DataPoint();
            dataPoint.AxisXLabel = "a1";
            dataPoint.XValue = 2;
            dataPoint.YValue = rand.Next(0, 100);
            dataSeries1.DataPoints.Add(dataPoint);
            dataPoint = new DataPoint();
            dataPoint.AxisXLabel = "a1";
            dataPoint.XValue = 4.454;
            dataPoint.YValue = rand.Next(0, 100);
            dataSeries1.DataPoints.Add(dataPoint);
            dataPoint = new DataPoint();
            dataPoint.AxisXLabel = "a1";
            dataPoint.XValue = 5.998;
            dataPoint.YValue = rand.Next(0, 100);
            dataSeries1.DataPoints.Add(dataPoint);
            dataPoint = new DataPoint();
            dataPoint.AxisXLabel = "a1";
            dataPoint.XValue = 3.2;
            dataPoint.YValue = rand.Next(0, 100);
            dataSeries1.DataPoints.Add(dataPoint);

            chart.Series.Add(dataSeries1);
            
            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                window.Dispatcher.InvokeShutdown();
                window.Close();
            }
        }
Exemple #29
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;
        }
Exemple #30
0
 internal static void SaveOldValueOfAxisRange(Axis axis)
 {
     if (axis != null)
     {
         axis._oldInternalAxisMaximum = axis.InternalAxisMaximum;
         axis._oldInternalAxisMinimum = axis.InternalAxisMinimum;
     }
 }