Example #1
0
        /// <summary>
        /// Draw ChartArea
        /// </summary>
        /// <param name="chart">Chart</param>
        public void Draw(Chart chart)
        {
            isScrollingActive = Chart.IsScrollingActivated;

            _renderCount = 0;

            Chart = chart;

            ClearAxesPanel();

            ResetTitleAndLegendPannelsSize();

            SetSeriesStyleFromTheme();

            SetTitleStyleFromTheme();

            PopulateInternalAxesXList();

            PopulateInternalAxesYList();

            PopulateInternalSeriesList(false);

            SetDataPointColorFromColorSet(chart.Series);

            CreateDefaultToolTipsForSeries(chart);

            PlotDetails = new PlotDetails(chart);

            // Calculate all the required PlotDetails
            PlotDetails.Calculate(true);

            ApplySampling();
            
            SetLegendStyleFromTheme();

            CalculatePlankParameters();

            ClearTitlePanels();

            ClearLegendPanels();

            Boolean isLeftOrRightAlignedTitlesExist;

            Size actualChartSize = GetActualChartSize();

            // Add all the legends to chart of type dock outside
            AddTitles(chart, false, actualChartSize.Height, actualChartSize.Width, out isLeftOrRightAlignedTitlesExist);

            // Calculate max size for legend
            Size remainingSizeAfterAddingTitles = CalculateLegendMaxSize(actualChartSize);

            // Add all the legends to chart of type dock outside
            AddLegends(chart, false, remainingSizeAfterAddingTitles.Height, remainingSizeAfterAddingTitles.Width);

            // Create PlotArea
            CreatePlotArea(chart);

            // Calculate PlotArea Size
            _plotAreaSize = CalculatePlotAreaSize(remainingSizeAfterAddingTitles);

            // Need to recalculate PlotArea size if any title exist with left or right aligned
            if (isLeftOrRightAlignedTitlesExist)
            {
                ClearTitlePanels();

                AddTitles(chart, false, _plotAreaSize.Height, actualChartSize.Width, out isLeftOrRightAlignedTitlesExist);

                ResetTitleAndLegendPannelsSize();

                remainingSizeAfterAddingTitles = CalculateLegendMaxSize(actualChartSize);

                _plotAreaSize = CalculatePlotAreaSize(remainingSizeAfterAddingTitles);
            }

            HideAllAxesScrollBars();

            // Check if drawing axis is necessary or not
            if (PlotDetails.ChartOrientation != ChartOrientationType.NoAxis)
            {   
                SetAxesProperties();

                Chart._elementCanvas.Children.Clear();
                CreateTrendLinesLabel();

                if (PlotDetails.ChartOrientation != ChartOrientationType.Circular)
                {
                    /* Zoom icons should be enabled if chart type is changed from Pie/Doughnut/Funnel/Radar/Polar to 
                       any other chart type which supports zooming */
                    if (chart.ZoomingEnabled && AxisX.ScrollBarElement != null
                        && (!Double.IsNaN(AxisX.ScrollBarElement.Scale) && AxisX.ScrollBarElement.Scale != 1))
                        EnableZoomIcons(chart);
                }
                else
                {
                    /* Zoom icons should be disabled if chart type is changed to Radar/Polar from 
                       any other chart type which supports zooming */
                    DisableZoomIcons(chart);
                }
            }
            else if (PlotDetails.ChartOrientation == ChartOrientationType.NoAxis)
            {
                /* Zoom icons should be disabled if chart type is changed to Pie/Doughnut/Funnel from 
                   any other chart type which supports zooming */
                DisableZoomIcons(chart);
            }

            Size remainingSize = DrawChart(_plotAreaSize);

            // Add all the titles to chart of type dock inside
            AddTitles(Chart, true, remainingSize.Height, remainingSize.Width, out isLeftOrRightAlignedTitlesExist);

            // Add all the legends to chart of type dock inside
            AddLegends(Chart, true, remainingSize.Height, remainingSize.Width);

            AttachEventToRetainOldScrollOffsetOfScrollViewer();

            AttachOrDetachIntaractivity(chart.InternalSeries);

            if (!_isFirstTimeRender || !chart.InternalAnimationEnabled)
            {
                AttachScrollBarOffsetChangedEventWithAxes();
                Visifire.Charts.Chart.SelectDataPoints(Chart);

                chart.Dispatcher.BeginInvoke(new Action(chart.UnlockRender));
            }

            chart._forcedRedraw = false;
            chart._clearAndResetZoomState = false;

            AddOrRemovePanels(chart);

            AttachEvents2ZoomOutIcons(chart);

            SettingsForVirtualRendering();

            // System.Diagnostics.Debug.WriteLine("xxxxxxx--- Render End");
        }