/// <summary> /// BorderThicknessProperty changed call back function /// </summary> /// <param name="d">DependencyObject</param> /// <param name="e">DependencyPropertyChangedEventArgs</param> private static void OnBorderThicknessPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { PlotArea plotArea = d as PlotArea; plotArea.InternalBorderThickness = (Thickness)e.NewValue; plotArea.FirePropertyChanged(VcProperties.BorderThickness); }
/// <summary> /// Creates the visual element for chart grid /// </summary> /// <param name="width">ChartVisualCanvas width</param> /// <param name="height">ChartVisualCanvas height</param> /// <param name="animationEnabled">Whether animation is enabled</param> /// <param name="animationDuration">Animation duration</param> internal void CreateVisualObject(Double width, Double height, bool animationEnabled, Double animationDuration) { animationEnabled = animationEnabled && AnimationEnabled; if (!(Boolean)Enabled || (Double.IsNaN(width) && Double.IsNaN(height))) { Visual = null; return; } if (Visual == null) { Visual = new Canvas(); } else { Visual.Children.Clear(); } Width = width; Height = height; if (animationEnabled) { if ((Chart as Chart).PlotDetails.ChartOrientation != ChartOrientationType.Circular) { Storyboard = new Storyboard(); ScaleTransform st = new ScaleTransform() { ScaleX = 1, ScaleY = 1 }; Visual.RenderTransformOrigin = new Point(0.5, 0.5); Visual.RenderTransform = st; if (Placement == PlacementTypes.Top || Placement == PlacementTypes.Bottom) { Storyboard.Children.Add(CreateDoubleAnimation(st, "(ScaleTransform.ScaleY)", 0, 1, 0, animationDuration)); } else { Storyboard.Children.Add(CreateDoubleAnimation(st, "(ScaleTransform.ScaleX)", 0, 1, 0, animationDuration)); } } } if ((Chart as Chart).PlotDetails.ChartOrientation == ChartOrientationType.Circular) { CreateAndPositionChartGrid4CircularAxesY(); } else { CreateAndPositionChartGrid(animationEnabled, animationDuration); PlotArea plotArea = (Chart as Chart).PlotArea; Size visualSize; #if WPF Visual.Measure(new Size(Double.MaxValue, Double.MaxValue)); visualSize = new Size(Visual.DesiredSize.Width, Visual.DesiredSize.Height); #else visualSize = new Size(Visual.ActualWidth, Visual.ActualHeight); #endif RectangleGeometry rectGeo = new RectangleGeometry(); rectGeo.Rect = new Rect(plotArea.BorderThickness.Left, plotArea.BorderThickness.Top, visualSize.Width - plotArea.BorderThickness.Left - plotArea.BorderThickness.Right, visualSize.Height - plotArea.BorderThickness.Top - plotArea.BorderThickness.Bottom); rectGeo.RadiusX = plotArea.CornerRadius.TopRight; rectGeo.RadiusY = plotArea.CornerRadius.TopRight; Visual.Clip = rectGeo; } Visual.Opacity = this.Opacity; }
/// <summary> /// OpacityProperty changed call back function /// </summary> /// <param name="d">DependencyObject</param> /// <param name="e">DependencyPropertyChangedEventArgs</param> private static void OnOpacityPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { PlotArea plotArea = d as PlotArea; plotArea.InternalOpacity = (Double)e.NewValue; plotArea.FirePropertyChanged(VcProperties.Opacity); }
/// <summary> /// BackgroundProperty changed call back function /// </summary> /// <param name="d">DependencyObject</param> /// <param name="e">DependencyPropertyChangedEventArgs</param> private static void OnBackgroundPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { PlotArea plotArea = d as PlotArea; plotArea.InternalBackground = (Brush)e.NewValue; plotArea.FirePropertyChanged(VcProperties.Background); }
/// <summary> /// Initializes the various properties of the class /// </summary> private void Init() { // Initialize colorSets //ColorSets = new ColorSets(); // Initialize tooltip ToolTips = new ToolTipCollection(); // Initialize title list Titles = new TitleCollection(); // Initialize legend list Legends = new LegendCollection(); // Initialize trendLine list TrendLines = new TrendLineCollection(); // Initialize AxesX list AxesX = new AxisCollection(); // Initialize AxesY list AxesY = new AxisCollection(); // Initialize Series list Series = new DataSeriesCollection(); // Initialize PlotArea PlotArea = new PlotArea() { Chart = this }; // Attach event handler on collection changed event with ToolTip collection ToolTips.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(ToolTips_CollectionChanged); // Attach event handler on collection changed event with Title collection Titles.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Titles_CollectionChanged); // Attach event handler on collection changed event with Legend collection Legends.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Legends_CollectionChanged); // Attach event handler on collection changed event with TrendLines collection TrendLines.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(TrendLines_CollectionChanged); // Attach event handler on collection changed event with DataSeries collection Series.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Series_CollectionChanged); // Attach event handler on collection changed event with axisX collection (AxesX as AxisCollection).CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(AxesX_CollectionChanged); // Attach event handler on collection changed event with AxisY collection (AxesY as AxisCollection).CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(AxesY_CollectionChanged); }
public void TestPlotAreaSerialization() { Chart chart = new Chart(); chart.Width = 400; chart.Height = 300; _isLoaded = false; chart.Loaded += new RoutedEventHandler(chart_Loaded); PlotArea plotArea = new PlotArea(); plotArea.Background = new SolidColorBrush(Colors.Aqua); chart.PlotArea = plotArea; DataSeries ds = new DataSeries(); 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(plotArea)); } window.Dispatcher.InvokeShutdown(); window.Close(); }
/// <summary> /// Dibuja el reporte seleccionado con los filtros asociados /// </summary> /// <param name="idReporte"></param> /// <param name="filtros"></param> public void draw(string idReporte, params string[] filtros) { IChart chart = FactoryChart.Instance.getReporte(idReporte); if (chart != null) { LayoutRoot.Children.Clear(); Axis axis = new Axis(); ChartGrid grid = new ChartGrid(); axis.Grids.Add(grid); //axis.AxisOffset = 1.5; //axis.ValueFormatString = "000.00"; Chart newChar = chart.Draw(filtros); // Llenando los AxisXLAbel para llenar los huecos en las series. #region llenado de huecos if (idReporte != "EjecucionDeCalidad") { // Llenando los AxisXLAbel para llenar los huecos en las series. List<String> ciclosOrdered = chart.ObtenerCiclos(); ciclosOrdered.Sort(); List<DataSeries> oldSeries = new List<DataSeries>(); foreach (DataSeries dtemp in newChar.Series) { oldSeries.Add(dtemp); } newChar.Series.Clear(); foreach (DataSeries dtemp in oldSeries) { DataSeries dataSeries = new DataSeries(); dataSeries.Name = dtemp.Name; // Set DataSeries properties dataSeries.RenderAs = dtemp.RenderAs; dataSeries.MarkerType = dtemp.MarkerType; dataSeries.SelectionEnabled = dtemp.SelectionEnabled; dataSeries.LineThickness = dtemp.LineThickness; dataSeries.AxisYType = dtemp.AxisYType; dataSeries.AxisXType = dtemp.AxisXType; dataSeries.Padding = dtemp.Padding; //Iterando el distinct de los ciclos ordenados foreach (String cicloTmp in ciclosOrdered) { DataPoint dpTmp = obtenerPuntoPorLabel(dtemp, cicloTmp); if (dpTmp == null) { DataPoint dataPoint = new DataPoint(); dataPoint.AxisXLabel = cicloTmp; dataSeries.DataPoints.Add(dataPoint); } else { dataSeries.DataPoints.Add(dpTmp); } } if (idReporte == "SobreIndexados") { dataSeries.MouseLeftButtonDown += new MouseButtonEventHandler(dataSeries_MouseLeftButtonDown); dataSeries.MouseRightButtonDown += new MouseButtonEventHandler(dataSeries_MouseLeftButtonDown); gFiltros = filtros; } newChar.Series.Add(dataSeries); } } #endregion newChar.Style = (Style)FindResource("ChartStyle"); newChar.View3D = true; //newChar.DataPointWidth = 4.5; CornerRadius cr = new CornerRadius(20); newChar.CornerRadius = cr; newChar.ShadowEnabled = true; newChar.AxesY.Add(axis); newChar.ZoomingEnabled = true; try { newChar.Titles[0].Style = (Style)FindResource("TitleStyle"); PlotArea p = new PlotArea(); p.Padding = new Thickness(30); newChar.PlotArea = p; p.Background = Brushes.LightGray; if (newChar.AxesY.Count > 0 && newChar.AxesY[0].Grids.Count > 0) { newChar.AxesY[0].Grids[0].InterlacedColor = Brushes.White; } //Asignando una serie dummy para que salga la leyenda cuando se tiene una sola serie. if (newChar.Series.Count == 1 && newChar.Series[0].DataPoints.Count>0) { DataSeries dataSeries = new DataSeries(); // Set DataSeries properties dataSeries.RenderAs = RenderAs.Line; dataSeries.ShowInLegend = false; dataSeries.Name = "HIDDENSERIE"; newChar.Series.Add(dataSeries); } } catch(Exception e) { string s = e.Message; } LayoutRoot.Children.Add(newChar); } }