Example #1
0
        bool ChangeChartType(SpreadChartType fromChartType, SpreadChartType toChartType)
        {
            _chart.SuspendEvents();
            bool flag = false;

            try
            {
                int  dataDimension = Dt.Cells.Data.SpreadChartUtility.GetDataDimension(fromChartType);
                int  num2          = Dt.Cells.Data.SpreadChartUtility.GetDataDimension(toChartType);
                bool flag2         = fromChartType.ToString().ToLower().Contains("bar");
                bool flag3         = toChartType.ToString().ToLower().Contains("bar");
                if (dataDimension != num2)
                {
                    if (toChartType == SpreadChartType.StockHighLowOpenClose)
                    {
                        flag = ChangeToStockChart(fromChartType, toChartType);
                    }
                    else if (fromChartType == SpreadChartType.StockHighLowOpenClose)
                    {
                        flag = ChangeFromStockChart(fromChartType, toChartType);
                    }
                    else if (num2 != 1)
                    {
                        flag = ChangeChartTypeToMulti(fromChartType, toChartType);
                    }
                    else if (num2 == 1)
                    {
                        flag = ChangeChartTypeOne(fromChartType, toChartType);
                    }
                }
                else
                {
                    if (flag2 != flag3)
                    {
                        AxisType axisType = _chart.AxisY.AxisType;
                        _chart.AxisY.AxisType = _chart.AxisX.AxisType;
                        _chart.AxisX.AxisType = axisType;
                        string itemsFormula = _chart.AxisY.ItemsFormula;
                        _chart.AxisY.ItemsFormula = _chart.AxisX.ItemsFormula;
                        _chart.AxisX.ItemsFormula = itemsFormula;
                    }
                    _chart.ChartType = toChartType;
                }
                if (flag2 != flag3)
                {
                    if (flag3)
                    {
                        if (_chart.AxisX != null)
                        {
                            _chart.AxisX.ShowMajorGridlines = true;
                        }
                        if (_chart.AxisY != null)
                        {
                            _chart.AxisY.ShowMajorGridlines = false;
                        }
                    }
                    if (flag2)
                    {
                        if (_chart.AxisY != null)
                        {
                            _chart.AxisY.ShowMajorGridlines = true;
                        }
                        if (_chart.AxisX != null)
                        {
                            _chart.AxisX.ShowMajorGridlines = false;
                        }
                    }
                }
                if (!Dt.Cells.Data.SpreadChartUtility.IsChartWithMarker(toChartType))
                {
                    return(flag);
                }
                foreach (SpreadDataSeries series in _chart.DataSeries)
                {
                    if (series.MarkerType == MarkerType.None)
                    {
                        series.MarkerType = MarkerType.Automatic;
                    }
                    if ((series.MarkerType != MarkerType.None) && ((series.MarkerSize.IsEmpty || (series.MarkerSize.Width == 0.0)) || (series.MarkerSize.Height == 0.0)))
                    {
                        series.MarkerSize = new Size(7.0, 7.0);
                    }
                }
            }
            finally
            {
                _chart.ResumeEvents();
            }
            return(flag);
        }