コード例 #1
0
ファイル: LegendTest.cs プロジェクト: tdhieu/openvss
        public void ToolTipTextNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;
            

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            legend.Title = "Legend";
            chart.Legends.Add(legend);

            CreateAndAddDefaultDataSeries(chart, legend);

            CreateAsyncTask(chart,
                () => legend.ToolTipText = "Legend ToolTip",
                () => Assert.AreEqual("Legend ToolTip", legend.ToolTipText));

            EnqueueTestComplete();
        }
コード例 #2
0
        private void SetLegendwithClickHandler()
        {
            foreach (var serie in m_chart.Series)
            {
                Legend legend = new Legend();

                legend.MouseLeftButtonDown += new EventHandler<LegendMouseButtonEventArgs>(legend_MouseLeftButtonDown);
                m_chart.Legends.Add(legend);
            }
        }
コード例 #3
0
ファイル: FunnelChartTests.cs プロジェクト: tdhieu/openvss
        public void TestLegendAlignmentInSection()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 350;
            chart.View3D = true;

            TestPanel.Children.Add(chart);

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            legend.Title = "Legend";
            chart.Legends.Add(legend);

            Common.CreateAndAddDefaultDataSeries(chart);
            chart.Series[0].RenderAs = RenderAs.SectionFunnel;
            chart.Series[0].ShowInLegend = true;

            EnqueueDelay(_sleepTime);

            EnqueueCallback(() =>
            {
                legend.HorizontalAlignment = HorizontalAlignment.Left;
                legend.VerticalAlignment = VerticalAlignment.Bottom;
            });

            EnqueueDelay(_sleepTime);

            EnqueueCallback(() =>
            {
                legend.HorizontalAlignment = HorizontalAlignment.Left;
                legend.VerticalAlignment = VerticalAlignment.Center;
            });

            EnqueueDelay(_sleepTime);

            EnqueueCallback(() =>
            {
                legend.HorizontalAlignment = HorizontalAlignment.Left;
                legend.VerticalAlignment = VerticalAlignment.Top;
            });

            EnqueueDelay(_sleepTime);

            EnqueueCallback(() =>
            {
                legend.HorizontalAlignment = HorizontalAlignment.Center;
                legend.VerticalAlignment = VerticalAlignment.Top;
            });

            EnqueueDelay(1000);

            EnqueueCallback(() =>
            {
                legend.HorizontalAlignment = HorizontalAlignment.Right;
                legend.VerticalAlignment = VerticalAlignment.Top;
            });

            EnqueueDelay(_sleepTime);

            EnqueueCallback(() =>
            {
                legend.HorizontalAlignment = HorizontalAlignment.Right;
                legend.VerticalAlignment = VerticalAlignment.Center;
            });

            EnqueueDelay(1000);

            EnqueueCallback(() =>
            {
                legend.HorizontalAlignment = HorizontalAlignment.Right;
                legend.VerticalAlignment = VerticalAlignment.Bottom;
            });

            EnqueueDelay(_sleepTime);

            EnqueueCallback(() =>
            {
                legend.HorizontalAlignment = HorizontalAlignment.Center;
                legend.VerticalAlignment = VerticalAlignment.Bottom;
            });

            EnqueueTestComplete();
        }
コード例 #4
0
ファイル: LegendTest.cs プロジェクト: zhangzy0193/visifire
        public void HrefNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;
            

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            chart.Legends.Add(legend);

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

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                legend.HrefTarget = HrefTargets._blank;
                legend.Href = "http://www.visifire.com";
                Assert.AreEqual("http://www.visifire.com", legend.Href);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
コード例 #5
0
ファイル: LegendTest.cs プロジェクト: zhangzy0193/visifire
        public void BorderThicknessNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;
            

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            legend.BorderColor = new SolidColorBrush(Colors.Red);
            chart.Legends.Add(legend);

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

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                legend.BorderThickness = new Thickness(2);
                Assert.AreEqual(new Thickness(2), legend.BorderThickness);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
コード例 #6
0
ファイル: LegendTest.cs プロジェクト: zhangzy0193/visifire
        public void TitleBackgroundNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;
            

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            legend.Title = "Legend";
            chart.Legends.Add(legend);

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

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                legend.TitleBackground = new SolidColorBrush(Colors.Gray);
                Common.AssertBrushesAreEqual(new SolidColorBrush(Colors.Gray), legend.TitleBackground);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
コード例 #7
0
ファイル: LegendTest.cs プロジェクト: zhangzy0193/visifire
        public void OpacityNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;
            

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            legend.Title = "Legend";
            chart.Legends.Add(legend);

            CreateAndAddDefaultDataSeries(chart);

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

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                legend.Opacity = 0.5;
                Assert.AreEqual(0.5, legend.Opacity, Common.HighPrecisionDelta);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
コード例 #8
0
ファイル: LegendTest.cs プロジェクト: tdhieu/openvss
        public void BorderThicknessNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            chart.Legends.Add(legend);

            CreateAndAddDefaultDataSeries(chart, legend);

            CreateAsyncTask(chart,
                () => legend.BorderThickness = new Thickness(2),
                () => Assert.AreEqual(new Thickness(2), legend.BorderThickness));

            EnqueueTestComplete();
        }
コード例 #9
0
ファイル: LegendTest.cs プロジェクト: tdhieu/openvss
        public void DockInsidePlotAreaNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;
            

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            chart.Legends.Add(legend);

            CreateAndAddDefaultDataSeries(chart, legend);

            CreateAsyncTask(chart,
                () => legend.DockInsidePlotArea = true,
                () => Assert.IsTrue(legend.DockInsidePlotArea));

            EnqueueTestComplete();
        }
コード例 #10
0
ファイル: LegendTest.cs プロジェクト: tdhieu/openvss
        public void HrefNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            chart.Legends.Add(legend);

            CreateAndAddDefaultDataSeries(chart, legend);

            CreateAsyncTask(chart,
                () => legend.HrefTarget = HrefTargets._blank,
                () => legend.Href = "http://",
                () => Assert.AreEqual("http://", legend.Href));

            EnqueueTestComplete();
        }
コード例 #11
0
ファイル: LegendTest.cs プロジェクト: tdhieu/openvss
        public void HorizontalAlignmentNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            chart.Legends.Add(legend);

            CreateAndAddDefaultDataSeries(chart, legend);

            CreateAsyncTask(chart,
                () => legend.HorizontalAlignment = HorizontalAlignment.Left,
                () => Assert.AreEqual(HorizontalAlignment.Left, legend.HorizontalAlignment));

            EnqueueTestComplete();
        }
コード例 #12
0
ファイル: LegendTest.cs プロジェクト: tdhieu/openvss
        /// <summary>
        /// Create DataSeries with refering legend
        /// </summary>
        /// <param name="chart"></param>
        /// <param name="legend"></param>
        public void CreateAndAddDefaultDataSeries(Chart chart, Legend legend)
        {
            DataSeries dataSeries = new DataSeries();

            dataSeries.RenderAs = RenderAs.Column;
            dataSeries.Legend = legend.Name;
            dataSeries.ShowInLegend = true;
            
            Random rand = new Random();

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

            chart.Series.Add(dataSeries);
        }
コード例 #13
0
ファイル: LegendTest.cs プロジェクト: tdhieu/openvss
        public void TestMultipleLegends()
        {
            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);

            Legend legend1 = new Legend();
            legend1.Name = "Legend1";
            legend1.Background = new SolidColorBrush(Colors.Red);
            chart.Legends.Add(legend1);
            Legend legend2 = new Legend();
            legend2.Name = "Legend2";
            legend1.Background = new SolidColorBrush(Colors.Green);
            chart.Legends.Add(legend2);
         
            EnqueueCallback(() =>
            {
                DataSeries dataSeries = new DataSeries();
                dataSeries.Legend = "Legend1";
                for (Int32 i = 0; i < 6; i++)
                    dataSeries.DataPoints.Add(new DataPoint() { XValue = i + 1, YValue = rand.Next(10, 100) });
                chart.Series.Add(dataSeries);

                dataSeries = new DataSeries();
                dataSeries.Legend = "Legend2";
                for (Int32 i = 0; i < 6; i++)
                    dataSeries.DataPoints.Add(new DataPoint() { XValue = i + 1, YValue = rand.Next(10, 100) });
                chart.Series.Add(dataSeries);

            });

            EnqueueDelay(_sleepTime);
            EnqueueTestComplete();
        }
コード例 #14
0
ファイル: LegendTest.cs プロジェクト: tdhieu/openvss
        public void LegendEventChecking()
        {
            System.Windows.Browser.HtmlPage.Plugin.SetStyleAttribute("height", "400px");

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

            TestPanel.Children.Add(chart);

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            legend.Title = "Legend";
            chart.Legends.Add(legend);

            CreateAndAddDefaultDataSeries(chart, legend);

            legend.MouseEnter += delegate(Object sender, MouseEventArgs e)
            {
                _htmlElement.SetProperty("value", "Legend MouseEnter event fired");
            };

            legend.MouseLeave += delegate(Object sender, MouseEventArgs e)
            {
                _htmlElement.SetProperty("value", "Legend MouseLeave event fired");
            };

            legend.MouseLeftButtonUp += delegate(Object sender, MouseButtonEventArgs e)
            {
                _htmlElement.SetProperty("value", "Legend MouseLeftButtonUp event fired");
            };

            legend.MouseLeftButtonDown += delegate(Object sender, MouseButtonEventArgs e)
            {
                _htmlElement.SetProperty("value", "Legend MouseLeftButtonDown event fired");
            };

            EnqueueCallback(() =>
            {
                _htmlElement.AttachEvent("onclick", new EventHandler<System.Windows.Browser.HtmlEventArgs>(this.LegendTest_OnClick));
            });

            _htmlElement = Common.GetDisplayMessageButton(_htmlElement);
            _htmlElement.SetStyleAttribute("width", "900px");
            _htmlElement.SetProperty("value", "Click here to exit.");
            System.Windows.Browser.HtmlPage.Document.Body.AppendChild(_htmlElement);

        }
コード例 #15
0
ファイル: LegendTest.cs プロジェクト: zhangzy0193/visifire
        public void DockInsidePlotAreaNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;
            

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            chart.Legends.Add(legend);

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

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                legend.DockInsidePlotArea = true;
                Assert.IsTrue(legend.DockInsidePlotArea);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
コード例 #16
0
ファイル: LegendTest.cs プロジェクト: tdhieu/openvss
        public void EnabledNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;
            

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            chart.Legends.Add(legend);

            CreateAndAddDefaultDataSeries(chart, legend);
            
            CreateAsyncTask(chart,
                () => legend.Enabled = false,
                () => Assert.AreEqual(false, legend.Enabled));

            EnqueueTestComplete();
        }
コード例 #17
0
ファイル: LegendTest.cs プロジェクト: zhangzy0193/visifire
        public void LightingEnabledNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;
            

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            legend.Background = new SolidColorBrush(Colors.Red);
            chart.Legends.Add(legend);

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

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                legend.LightingEnabled = true;
                Assert.IsTrue(legend.LightingEnabled);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
コード例 #18
0
ファイル: LegendTest.cs プロジェクト: tdhieu/openvss
        public void FontColorNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;
            

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            chart.Legends.Add(legend);

            CreateAndAddDefaultDataSeries(chart, legend);

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

            EnqueueTestComplete();
        }
コード例 #19
0
ファイル: LegendTest.cs プロジェクト: zhangzy0193/visifire
        public void TitleFontFamilyNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;
            

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            legend.Title = "Legend";
            chart.Legends.Add(legend);

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

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                legend.TitleFontFamily = new FontFamily("Times New Roman");
                Assert.AreEqual(new FontFamily("Times New Roman"), legend.TitleFontFamily);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
コード例 #20
0
ファイル: LegendTest.cs プロジェクト: tdhieu/openvss
        public void FontSizeNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;
            

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            chart.Legends.Add(legend);

            CreateAndAddDefaultDataSeries(chart, legend);

            CreateAsyncTask(chart,
                () => legend.FontSize = 14,
                () => Assert.AreEqual(14, legend.FontSize, Common.HighPrecisionDelta));

            EnqueueTestComplete();
        }
コード例 #21
0
ファイル: LegendTest.cs プロジェクト: zhangzy0193/visifire
        public void TestLegendSerialization()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;

            _isLoaded = false;

            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Legend legend = new Legend();
            legend.Background = new SolidColorBrush(Colors.Aqua);
            chart.Legends.Add(legend);

            DataSeries ds = new DataSeries();
            ds.ShowInLegend = true;
            DataPoint dp = new DataPoint();
            dp.YValue = 20;
            ds.DataPoints.Add(dp);
            chart.Series.Add(ds);

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                MessageBox.Show(XamlWriter.Save(legend));
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
コード例 #22
0
ファイル: LegendTest.cs プロジェクト: tdhieu/openvss
        public void FontFamilyNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;
            

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            chart.Legends.Add(legend);

            CreateAndAddDefaultDataSeries(chart, legend);

            CreateAsyncTask(chart,
                () => legend.FontFamily = new FontFamily("Times New Roman"),
                () => Assert.AreEqual(new FontFamily("Times New Roman"), legend.FontFamily));

            EnqueueTestComplete();
        }
コード例 #23
0
ファイル: LegendTest.cs プロジェクト: zhangzy0193/visifire
        public void HorizontalAlignmentNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;
            

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            chart.Legends.Add(legend);

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

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                legend.HorizontalAlignment = HorizontalAlignment.Left;
                Assert.AreEqual(HorizontalAlignment.Left, legend.HorizontalAlignment);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
コード例 #24
0
ファイル: LegendTest.cs プロジェクト: tdhieu/openvss
        public void FontStyleNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;
            

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            chart.Legends.Add(legend);

            CreateAndAddDefaultDataSeries(chart, legend);

            CreateAsyncTask(chart,
                () => legend.FontStyle = FontStyles.Italic,
                () => Assert.AreEqual(FontStyles.Italic, legend.FontStyle));

            EnqueueTestComplete();
        }
コード例 #25
0
ファイル: Detail-1.xaml.cs プロジェクト: dalinhuang/loosoft
        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;
            }
        }
コード例 #26
0
ファイル: SamplingTest.cs プロジェクト: zhangzy0193/visifire
        /// <summary>
        /// Create a chart for Numeric Axis
        /// </summary>
        /// <returns></returns>
        public Chart CreateAChartWithSingleSeries()
        {
            Chart chart = new Chart();
            chart.Width = 600;
            chart.Height = 300;
            chart.ScrollingEnabled = false;

            Axis axisx = new Axis();
            axisx.AxisLabels = new AxisLabels();
            axisx.AxisLabels.Angle = 45;
            chart.AxesX.Add(axisx);
            
            
            Legend legend = new Legend();
            legend.HorizontalAlignment = HorizontalAlignment.Left;
            legend.VerticalAlignment = VerticalAlignment.Center;
            chart.Legends.Add(legend);

            Common.CreateAndAddDefaultDataSeries4Sampling(chart);
           
            chart.ColorSets = new ColorSets();
            //COLOR SET 1:
            ColorSet ct = new ColorSet();
            ct.Id = "MyColorSet1";
            ct.Brushes.Add(new SolidColorBrush(Colors.Blue));
            ct.Brushes.Add(new SolidColorBrush(Colors.Brown));
            ct.Brushes.Add(new SolidColorBrush(Colors.Cyan));
            ct.Brushes.Add(new SolidColorBrush(Colors.DarkGray));
            ct.Brushes.Add(new SolidColorBrush(Colors.Gray));
            ct.Brushes.Add(new SolidColorBrush(Colors.Green));

            // Add ColorSet to ColorSets collection
            chart.ColorSets.Add(ct);

            //COLOR SET 2:
            ColorSet ct1 = new ColorSet();
            ct1.Id = "MyColorSet2";
            ct1.Brushes.Add(new SolidColorBrush(Colors.Red));
            ct1.Brushes.Add(new SolidColorBrush(Colors.Blue));
            ct1.Brushes.Add(new SolidColorBrush(Colors.Green));
            ct1.Brushes.Add(new SolidColorBrush(Colors.Orange));
            ct1.Brushes.Add(new SolidColorBrush(Colors.Purple));
            ct1.Brushes.Add(new SolidColorBrush(Colors.Black));
            // Create new instance of ColorSets class
            chart.ColorSets.Add(ct1);

            return chart;
        }
コード例 #27
0
ファイル: ChartArea.cs プロジェクト: tdhieu/openvss
        /// <summary>
        /// Add entries to a legend
        /// </summary>
        /// <param name="legend">Legend</param>
        /// <param name="dataPoints">List of InternalDataPoints</param>
        private void AddEntriesToLegend(Legend legend, List<DataPoint> dataPoints)
        {
            foreach (DataPoint dataPoint in dataPoints)
            {
                if (!(Boolean)dataPoint.Enabled || !(Boolean)dataPoint.ShowInLegend)
                    continue;

                if ((dataPoint.Parent.RenderAs == RenderAs.SectionFunnel || dataPoint.Parent.RenderAs == RenderAs.StreamLineFunnel) && dataPoint.InternalYValue < 0)
                    continue;

                String legendText = (String.IsNullOrEmpty(dataPoint.LegendText) ? dataPoint.Name : ObservableObject.GetFormattedMultilineText(dataPoint.LegendText));

                Brush markerColor = dataPoint._internalColor;

                if (dataPoint.Parent.RenderAs == RenderAs.CandleStick)
                {
                    markerColor = (Brush)dataPoint.GetValue(DataPoint.ColorProperty);

                    if (markerColor == null)
                    {
                        if (dataPoint.YValues != null)
                        {
                            if (dataPoint.YValues.Length >= 2)
                            {
                                Double openY = dataPoint.YValues[0];
                                Double closeY = dataPoint.YValues[1];

                                markerColor = (closeY > openY) ? dataPoint.Parent.PriceUpColor : dataPoint.Parent.PriceDownColor;
                            }
                        }
                    }
                    else
                        markerColor = dataPoint.Color;

                }

                if ((Boolean)dataPoint.LightingEnabled)
                {
                    if (dataPoint.Parent.RenderAs == RenderAs.Line)
                        markerColor = Graphics.GetLightingEnabledBrush(markerColor, "Linear", new Double[] { 0.65, 0.55 });
                }

                Boolean markerBevel;
                if ((dataPoint.Parent as DataSeries).RenderAs == RenderAs.Point
                    || (dataPoint.Parent as DataSeries).RenderAs == RenderAs.Stock
                    || (dataPoint.Parent as DataSeries).RenderAs == RenderAs.CandleStick
                    || (dataPoint.Parent as DataSeries).RenderAs == RenderAs.Bubble
                    || (dataPoint.Parent as DataSeries).RenderAs == RenderAs.Pie || (dataPoint.Parent as DataSeries).RenderAs == RenderAs.Doughnut
                    || (dataPoint.Parent as DataSeries).RenderAs == RenderAs.Line)
                {
                    markerBevel = false;
                }
                else
                    markerBevel = Chart.View3D ? false : dataPoint.Parent.Bevel ? dataPoint.Parent.Bevel : false;

                Size markerSize;
                if (dataPoint.Parent.RenderAs == RenderAs.Line)
                    markerSize = new Size(8, 8);
                else
                    markerSize = new Size(8, 8);

                dataPoint.LegendMarker = new Marker(
                        ((dataPoint.Parent.RenderAs == RenderAs.Line) ? (MarkerTypes)dataPoint.MarkerType : RenderAsToMarkerType(dataPoint.Parent.RenderAs, dataPoint.Parent)),
                        1,
                        markerSize,
                        markerBevel,
                        markerColor,
                        ""
                        );

                if ((dataPoint.Parent.RenderAs == RenderAs.Line || dataPoint.Parent.RenderAs == RenderAs.Stock || dataPoint.Parent.RenderAs == RenderAs.CandleStick) && dataPoint.MarkerEnabled == false)
                {
                    dataPoint.LegendMarker.Opacity = 0;
                }


                dataPoint.LegendMarker.DataSeriesOfLegendMarker = dataPoint.Parent;
                dataPoint.LegendMarker.Tag = new ElementData() { Element = dataPoint };

                legend.Entries.Add(new KeyValuePair<String, Marker>(legendText, dataPoint.LegendMarker));
            }

            if (legend != null && legend.Reversed)
                legend.Entries.Reverse();
        }
コード例 #28
0
ファイル: DataSeriesTest.cs プロジェクト: tdhieu/openvss
        public void CheckLegendProperty()
        {
            Chart chart = new Chart();
            chart.Width = 600;
            chart.Height = 300;

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

            Random rand = new Random();

            DataSeries dataSeries = CreateDataSeries();
            chart.Series.Add(dataSeries);

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend1");
            chart.Legends.Add(legend);

            dataSeries.ShowInLegend = true;
            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                dataSeries.Legend = "Legend1";
                Assert.AreEqual("Legend1", dataSeries.Legend);
            }
            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
コード例 #29
0
        public void CheckLegendProperty()
        {
            Chart chart = new Chart();
            chart.Width = 600;
            chart.Height = 300;

            Random rand = new Random();

            DataSeries dataSeries = CreateDataSeries();

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            chart.Legends.Add(legend);

            dataSeries.ShowInLegend = true;
            chart.Series.Add(dataSeries);

            EnqueueDelay(_sleepTime);
            CreateAsyncTask(chart,
                () => dataSeries.Legend = "Legend0",
                () => Assert.AreEqual("Legend0", dataSeries.Legend));

            EnqueueTestComplete();
        }
コード例 #30
0
ファイル: LegendTest.cs プロジェクト: tdhieu/openvss
        public void LightingEnabledNewValue()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;
            

            Legend legend = new Legend();
            legend.SetValue(FrameworkElement.NameProperty, "Legend0");
            legend.Background = new SolidColorBrush(Colors.Red);
            chart.Legends.Add(legend);

            CreateAndAddDefaultDataSeries(chart, legend);

            CreateAsyncTask(chart,
                () => legend.LightingEnabled = true,
                () => Assert.IsTrue(legend.LightingEnabled));

            EnqueueTestComplete();
        }