Ejemplo n.º 1
0
        private void SetWaterfallLegendItems(ChartLegend legend, int index)
        {
            LegendItems[index].Clear();
            LegendItem legendItem;

            var positiveSegment = VisibleSeries[0].Segments.FirstOrDefault
                                      (seg => (seg as WaterfallSegment).SegmentType == WaterfallSegmentType.Positive);

            if (positiveSegment != null)
            {
                legendItem = GetWaterfallLegendItem(positiveSegment, SfChartResourceWrapper.Increase, 0, legend);

                LegendItems[index].Add(legendItem);
            }

            var negativeSegment = VisibleSeries[0].Segments.FirstOrDefault
                                      (seg => (seg as WaterfallSegment).SegmentType == WaterfallSegmentType.Negative);

            if (negativeSegment != null)
            {
                legendItem = GetWaterfallLegendItem(negativeSegment, SfChartResourceWrapper.Decrease, 1, legend);

                LegendItems[index].Add(legendItem);
            }

            var sumSegment = VisibleSeries[0].Segments.FirstOrDefault(seg => (seg as WaterfallSegment).SegmentType == WaterfallSegmentType.Sum);

            if (sumSegment != null)
            {
                legendItem = GetWaterfallLegendItem(sumSegment, SfChartResourceWrapper.Total, 2, legend);

                LegendItems[index].Add(legendItem);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Clone the entire chart control
        /// </summary>
        /// <returns></returns>
        public DependencyObject Clone()
        {
            ChartLegend legend = new ChartLegend()
            {
                CheckBoxVisibility     = this.CheckBoxVisibility,
                CornerRadius           = this.CornerRadius,
                DockPosition           = this.DockPosition,
                LegendPosition         = this.LegendPosition,
                Header                 = this.Header,
                HeaderTemplate         = this.HeaderTemplate,
                IconHeight             = this.IconHeight,
                IconVisibility         = this.IconVisibility,
                IconWidth              = this.IconWidth,
                ItemMargin             = this.ItemMargin,
                OffsetX                = this.OffsetX,
                OffsetY                = this.OffsetY,
                Orientation            = this.Orientation,
                ItemTemplate           = this.ItemTemplate,
                ItemsPanel             = this.ItemsPanel,
                ToggleSeriesVisibility = this.ToggleSeriesVisibility
            };

            ChartCloning.CloneControl(this, legend);
            return(legend);
        }
Ejemplo n.º 3
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 10 "..\..\..\..\BaoCaoComponents\BieuDoBanh\usTiLeDongGop.xaml"
                ((Milestone2.BaoCaoComponents.usTiLeDongGop)(target)).Loaded += new System.Windows.RoutedEventHandler(this.UserControl_Loaded);

            #line default
            #line hidden
                return;

            case 2:
                this.TrainsitionigContentSlide = ((MaterialDesignThemes.Wpf.Transitions.TransitioningContent)(target));
                return;

            case 3:
                this.chart = ((System.Windows.Controls.Grid)(target));
                return;

            case 4:
                this.TuNgayDatePicker = ((System.Windows.Controls.DatePicker)(target));

            #line 63 "..\..\..\..\BaoCaoComponents\BieuDoBanh\usTiLeDongGop.xaml"
                this.TuNgayDatePicker.SelectedDateChanged += new System.EventHandler <System.Windows.Controls.SelectionChangedEventArgs>(this.TuNgayDatePicker_SelectedDateChanged);

            #line default
            #line hidden
                return;

            case 5:
                this.DenNgayDatePicker = ((System.Windows.Controls.DatePicker)(target));

            #line 64 "..\..\..\..\BaoCaoComponents\BieuDoBanh\usTiLeDongGop.xaml"
                this.DenNgayDatePicker.SelectedDateChanged += new System.EventHandler <System.Windows.Controls.SelectionChangedEventArgs>(this.DenNgayDatePicker_SelectedDateChanged);

            #line default
            #line hidden
                return;

            case 6:
                this.pieChart = ((Syncfusion.UI.Xaml.Charts.SfChart)(target));
                return;

            case 7:
                this.ChartLegend1 = ((Syncfusion.UI.Xaml.Charts.ChartLegend)(target));
                return;

            case 8:
                this.pieSeries = ((Syncfusion.UI.Xaml.Charts.PieSeries)(target));
                return;

            case 9:
                this.ThongBaoSnackbar = ((MaterialDesignThemes.Wpf.Snackbar)(target));
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 4
0
        private static void OnSeriesPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ChartLegend legend = d as ChartLegend;

            if (legend != null && legend.ChartArea != null)
            {
                legend.ChartArea.IsUpdateLegend = true;
                legend.ChartArea.UpdateLegend(legend, true);
            }
        }
Ejemplo n.º 5
0
        private static void UpdateLegendInside(ChartLegend legend, Rect rect)
        {
            double x = 0d, y = 0d, width = 0d, height = 0d;

            switch (legend.DockPosition)
            {
            case ChartDock.Bottom:
                y      = rect.Y + rect.Height - legend.DesiredSize.Height;
                x      = GetHorizontalLegendAlignment(legend.HorizontalAlignment, rect, legend.DesiredSize);
                width  = rect.Width;
                height = legend.DesiredSize.Height;
                break;

            case ChartDock.Top:
                y      = rect.Y;
                x      = GetHorizontalLegendAlignment(legend.HorizontalAlignment, rect, legend.DesiredSize);
                width  = rect.Width;
                height = legend.DesiredSize.Height;
                break;

            case ChartDock.Right:
                y      = GetVerticalLegendAlignment(legend.VerticalAlignment, rect, legend.DesiredSize);
                x      = rect.X + rect.Width - legend.DesiredSize.Width;
                width  = legend.DesiredSize.Width;
                height = rect.Height;
                break;

            case ChartDock.Left:
                y      = GetVerticalLegendAlignment(legend.VerticalAlignment, rect, legend.DesiredSize);
                x      = rect.X;
                width  = legend.DesiredSize.Width;
                height = rect.Height;
                break;

            case ChartDock.Floating:
                x      = rect.Left;
                y      = rect.Top;
                width  = legend.DesiredSize.Width;
                height = legend.DesiredSize.Height;
                break;
            }
            legend.ArrangeRect = new Rect(x, y, width, height);
        }
Ejemplo n.º 6
0
        internal void Dispose()
        {
            if (PropertyChanged != null)
            {
                var invocationList = PropertyChanged.GetInvocationList();

                foreach (var handler in invocationList)
                {
                    PropertyChanged -= handler as PropertyChangedEventHandler;
                }

                PropertyChanged = null;
            }

            segment          = null;
            item             = null;
            series           = null;
            trendline        = null;
            legend           = null;
            XFormsLabelStyle = null;
            XFormsLegendItem = null;
        }
Ejemplo n.º 7
0
        private static void OnOrientationChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ChartLegend sender = d as ChartLegend;

            sender.ChangeOrientation();
        }
Ejemplo n.º 8
0
        private static void OnOffsetValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ChartLegend legend = d as ChartLegend;

            legend.OnOffsetValueChanged(e);
        }
Ejemplo n.º 9
0
        private LegendItem GetWaterfallLegendItem(object source, string label, int index, ChartLegend legend)
        {
            var legenditem = new LegendItem
            {
                Index  = index,
                Series = VisibleSeries[0],
                Legend = legend
            };

            Binding binding = new Binding();

            binding.Source = source;
            binding.Path   = new PropertyPath("Interior");
            BindingOperations.SetBinding(legenditem, LegendItem.InteriorProperty, binding);
            legenditem.Label = label;

            return(legenditem);
        }
Ejemplo n.º 10
0
        private void SetLegendItems(ChartLegend legend, int index)
        {
            var  series         = HasDataPointBasedLegend() ? legend.Series : VisibleSeries[0];
            var  yvalues        = series.ActualSeriesYValues[0] as List <double>;//When EmptyPoint is set last legend is not rendered.-WPF-18794
            var  circularSeries = series as CircularSeriesBase;
            bool isGroupTo      = circularSeries != null && !double.IsNaN(circularSeries.GroupTo);

            if (isGroupTo)
            {
                var groupToYValues = circularSeries.GetGroupToYValues();
                yvalues = groupToYValues.Item1 as List <double>;
            }

            LegendItems[index].Clear();
            int j        = 0;
            var Segments = series.Segments.ToList();

            if (series is FunnelSeries)
            {
                Segments.Reverse();
            }
            for (int i = 0; i < yvalues.Count; i++)
            {
                var legendIndex = i;
                if (double.IsNaN(yvalues[i]))
                {
                    if (!(series is TriangularSeriesBase) && !(series is CircularSeriesBase3D))
                    {
                        j++;
                    }
                    continue;
                }
                LegendItem legenditem;

                //Created duplicate legends to measure if segments are not created WPF-26728
                if (Segments.Count == 0)
                {
                    legenditem = new LegendItem
                    {
                        Index  = legendIndex,
                        Series = series,
                        Legend = legend
                    };
                }
                else
                {
                    var item = Segments[j];
                    legenditem = new LegendItem
                    {
                        Index  = legendIndex, //WPF-14337 Legend value wrong while using empty point in accumulation series
                        Item   = item.Item,
                        Series = series,
                        Legend = legend
                    };

                    if (series.ToggledLegendIndex.Count > 0 && (legend.CheckBoxVisibility == Visibility.Visible || legend.ToggleSeriesVisibility))
                    {
                        if (!item.IsSegmentVisible)
                        {
                            legend.isSegmentsUpdated   = true;
                            legenditem.IsSeriesVisible = false;
                            legend.isSegmentsUpdated   = false;
                        }
                    }

                    Binding binding = new Binding();
                    binding.Source = item;
                    binding.Path   = new PropertyPath("Interior");
                    BindingOperations.SetBinding(legenditem, LegendItem.InteriorProperty, binding);
                }

                if (isGroupTo && circularSeries.GroupedData.Count > 0 && legenditem.Index == Segments.Count - 1)
                {
                    legenditem.Label = circularSeries.GroupingLabel;
                }
                else if (legenditem.Item != null)
                {
                    legenditem.Label = series.GetActualXValue(series.ActualData.IndexOf(legenditem.Item)).ToString();
                }
                else
                {
                    legenditem.Label = series.GetActualXValue(legenditem.Index).ToString();
                }
                LegendItems[index].Add(legenditem);

                j++;
            }
        }
Ejemplo n.º 11
0
        internal void SetLegendItemsSource(ChartLegend legend, int index)
        {
            if (legend == null || ActualSeries == null)
            {
                return;
            }
            legend.ChartArea = this;
            //HasDataPointBasedLegend() will return true when need to generate data point based legend items.
            if ((VisibleSeries.Count == 1 && VisibleSeries[0].IsSingleAccumulationSeries) || HasDataPointBasedLegend())
            {
                SetLegendItems(legend, index);
            }
            else if (VisibleSeries.Count == 1 && VisibleSeries[0] is WaterfallSeries)
            {
                SetWaterfallLegendItems(legend, index);
                legend.XAxis = VisibleSeries[0].IsActualTransposed ? (VisibleSeries[0] as ISupportAxes).ActualYAxis : (VisibleSeries[0] as ISupportAxes).ActualXAxis;
                legend.YAxis = VisibleSeries[0].IsActualTransposed ? (VisibleSeries[0] as ISupportAxes).ActualXAxis : (VisibleSeries[0] as ISupportAxes).ActualYAxis;
            }
            else
            {
                var technicalIndicators = new List <ChartSeriesBase>();
                var sfChart             = this as SfChart;
                if (sfChart != null)
                {
                    foreach (ChartSeries indicator in sfChart.TechnicalIndicators)
                    {
                        technicalIndicators.Add(indicator as ChartSeriesBase);
                    }
                }

                List <ChartSeriesBase> actualLegendSeries = sfChart != null?ActualSeries.Union(technicalIndicators).ToList() : ActualSeries;

                if (AreaType == ChartAreaType.PolarAxes || AreaType == ChartAreaType.CartesianAxes && Legend is ChartLegendCollection)
                {
                    actualLegendSeries = (from actualSeries in actualLegendSeries
                                          where
                                          GetActualRow(legend) == GetActualRow(actualSeries.IsActualTransposed ? actualSeries.ActualXAxis : actualSeries.ActualYAxis) &&
                                          GetActualColumn(legend) == GetActualColumn(actualSeries.IsActualTransposed ? actualSeries.ActualYAxis : actualSeries.ActualXAxis)
                                          select actualSeries).ToList();
                }

                if (actualLegendSeries.Count > 0 && actualLegendSeries[0] is ISupportAxes)
                {
                    legend.XAxis = actualLegendSeries[0].IsActualTransposed ? (actualLegendSeries[0] as ISupportAxes).ActualYAxis : (actualLegendSeries[0] as ISupportAxes).ActualXAxis;
                    legend.YAxis = actualLegendSeries[0].IsActualTransposed ? (actualLegendSeries[0] as ISupportAxes).ActualXAxis : (actualLegendSeries[0] as ISupportAxes).ActualYAxis;
                }

                IEnumerable <ChartSeriesBase> legendSeries;
                switch (AreaType)
                {
                case ChartAreaType.CartesianAxes:

                    legendSeries = from series in actualLegendSeries
                                   where series is ISupportAxes2D || series is ISupportAxes3D
                                   select series;
                    break;

                case ChartAreaType.PolarAxes:
                    legendSeries = from series in actualLegendSeries
                                   where series is PolarRadarSeriesBase
                                   select series;
                    break;

                default:
                    legendSeries = from series in actualLegendSeries
                                   where series is AccumulationSeriesBase || series is CircularSeriesBase3D
                                   select series;
                    break;
                }
                var chartSeries = legendSeries as ChartSeries[] ?? legendSeries.ToArray();

                foreach (var series in chartSeries)
                {
                    if (series.IsSeriesVisible)
                    {
                        if (LegendItems[index].Count > 0 && index < LegendItems[index].Count)//Legend not cleared when bind Series in MVVM view model-WPF-18625
                        {
                            LegendItems[index].Clear();
                        }
                    }
                }
                foreach (var item in chartSeries.Where(series => series.VisibilityOnLegend == Visibility.Visible))
                {
                    var containlegenditem = LegendItems[index].Where(it => it.Series == item).ToList();
                    if (LegendItems.Count == 0 || containlegenditem.Count() == 0)
                    {
                        var legenditem = new LegendItem {
                            Legend = legend, Series = item
                        };
                        if (item.IsSingleAccumulationSeries)
                        {
                            legenditem.Legend.isSegmentsUpdated = true;
                            if (item.IsSeriesVisible)
                            {
                                legenditem.IsSeriesVisible = true;
                            }
                            else
                            {
                                legenditem.IsSeriesVisible = false;
                            }
                            legenditem.Legend.isSegmentsUpdated = false;
                        }
                        LegendItems[index].Add(legenditem);
                    }
                }
                foreach (var item in chartSeries)
                {
                    var cartesian = item as CartesianSeries;
                    if (cartesian != null)
                    {
                        foreach (var trend in cartesian.Trendlines.Where(
                                     trendline => trendline.VisibilityOnLegend == Visibility.Visible))
                        {
                            var containlegenditem = LegendItems[index].Where(it => it.Trendline == trend).ToList();
                            if (LegendItems.Count == 0 || containlegenditem.Count() == 0)
                            {
                                var trendline = new LegendItem {
                                    Legend = legend, Trendline = trend
                                };
                                LegendItems[index].Add(trendline);
                                trend.UpdateLegendIconTemplate(true);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Updates the legend arrange rect.
        /// </summary>
        /// <param name="legend">The legend.</param>
        internal void UpdateLegendArrangeRect(ChartLegend legend)
        {
            if (legend == null && RootPanelDesiredSize == null)
            {
                return;
            }
            var elemSize = legend.DesiredSize;

            if (Legend is IList && AreaType == ChartAreaType.CartesianAxes)
            {
                if (legend.XAxis == null || legend.YAxis == null)
                {
                    return;
                }

                if (legend.InternalDockPosition == ChartDock.Floating)
                {
                    var xAxis = legend.XAxis;
                    var yAxis = legend.YAxis;
                    var rect  = new Rect(xAxis.ArrangeRect.X, yAxis.ArrangeRect.Y, xAxis.ArrangeRect.Width, yAxis.ArrangeRect.Height);
                    UpdateLegendInside(legend, rect);
                }
            }
            else
            {
                if (AreaType == ChartAreaType.PolarAxes && legend.LegendPosition == LegendPosition.Outside)
                {
                    var actualRect = new Rect(0, 0, RootPanelDesiredSize.Value.Width, RootPanelDesiredSize.Value.Height);
                    switch (legend.InternalDockPosition)
                    {
                    case ChartDock.Top:
                        legend.ArrangeRect = new Rect(actualRect.Left, actualRect.Top, actualRect.Width, elemSize.Height);
                        break;

                    case ChartDock.Left:
                        legend.ArrangeRect = new Rect(actualRect.Left, actualRect.Top, elemSize.Width, actualRect.Height);
                        break;

                    case ChartDock.Right:
                        legend.ArrangeRect = new Rect(actualRect.Width + actualRect.Left, 0, elemSize.Width, actualRect.Height);
                        break;

                    case ChartDock.Bottom:
                        legend.ArrangeRect = new Rect(actualRect.Left, actualRect.Bottom, actualRect.Width, elemSize.Height);
                        break;

                    case ChartDock.Floating:
                    {
                        UpdateLegendInside(legend, actualRect);
                        break;
                    }
                    }
                }
                else
                {
                    var actualRect = AreaType == ChartAreaType.None ? new Rect(0, 0, RootPanelDesiredSize.Value.Width, RootPanelDesiredSize.Value.Height) : SeriesClipRect;
                    switch (legend.InternalDockPosition)
                    {
                    case ChartDock.Top:
                        legend.ArrangeRect = new Rect(actualRect.Left, actualRect.Top - AxisThickness.Top, actualRect.Width, elemSize.Height);
                        break;

                    case ChartDock.Left:
                        legend.ArrangeRect = new Rect(actualRect.Left - AxisThickness.Left, actualRect.Top, elemSize.Width, actualRect.Height);
                        break;

                    case ChartDock.Right:
                        legend.ArrangeRect = new Rect(actualRect.Width + actualRect.Left + AxisThickness.Right, 0, elemSize.Width, actualRect.Height);
                        break;

                    case ChartDock.Bottom:
                        legend.ArrangeRect = new Rect(actualRect.Left, actualRect.Bottom + AxisThickness.Bottom, actualRect.Width, elemSize.Height);
                        break;

                    case ChartDock.Floating:
                    {
                        UpdateLegendInside(legend, AreaType == ChartAreaType.CartesianAxes ? seriesClipRect : actualRect);
                        break;
                    }
                    }
                }
            }
        }