private SLC.SLChart CreateChartInternal(string WorksheetName, int StartRowIndex, int StartColumnIndex, int EndRowIndex, int EndColumnIndex, SLC.SLCreateChartOptions Options)
        {
            if (Options == null) Options = new SLC.SLCreateChartOptions();

            SLC.SLChart chart = new SLC.SLChart();

            int iStartRowIndex = 1, iEndRowIndex = 1, iStartColumnIndex = 1, iEndColumnIndex = 1;
            if (StartRowIndex < EndRowIndex)
            {
                iStartRowIndex = StartRowIndex;
                iEndRowIndex = EndRowIndex;
            }
            else
            {
                iStartRowIndex = EndRowIndex;
                iEndRowIndex = StartRowIndex;
            }

            if (StartColumnIndex < EndColumnIndex)
            {
                iStartColumnIndex = StartColumnIndex;
                iEndColumnIndex = EndColumnIndex;
            }
            else
            {
                iStartColumnIndex = EndColumnIndex;
                iEndColumnIndex = StartColumnIndex;
            }

            if (iStartRowIndex < 1) iStartRowIndex = 1;
            if (iStartColumnIndex < 1) iStartColumnIndex = 1;
            if (iEndRowIndex > SLConstants.RowLimit) iEndRowIndex = SLConstants.RowLimit;
            if (iEndColumnIndex > SLConstants.ColumnLimit) iEndColumnIndex = SLConstants.ColumnLimit;

            // this will keep the calculations within workable range
            if (iStartRowIndex >= SLConstants.RowLimit) iStartRowIndex = SLConstants.RowLimit - 1;
            if (iStartColumnIndex >= SLConstants.ColumnLimit) iStartColumnIndex = SLConstants.ColumnLimit - 1;

            chart.WorksheetName = WorksheetName;

            if (Options.RowsAsDataSeries == null)
            {
                if ((iEndColumnIndex - iStartColumnIndex) >= (iEndRowIndex - iStartRowIndex))
                {
                    chart.RowsAsDataSeries = true;
                }
                else
                {
                    chart.RowsAsDataSeries = false;
                }
            }
            else
            {
                chart.RowsAsDataSeries = Options.RowsAsDataSeries.Value;
            }

            chart.ShowHiddenData = Options.ShowHiddenData;
            chart.ShowDataLabelsOverMaximum = Options.IsStylish ? false : true;

            int i;
            chart.listThemeColors = new List<System.Drawing.Color>();
            for (i = 0; i < SimpleTheme.listThemeColors.Count; ++i)
            {
                chart.listThemeColors.Add(SimpleTheme.listThemeColors[i]);
            }

            chart.Date1904 = this.slwb.WorkbookProperties.Date1904;
            chart.IsStylish = Options.IsStylish;
            chart.RoundedCorners = false;

            // assume combination charts are possible first
            chart.IsCombinable = true;

            chart.PlotArea = new SLC.SLPlotArea(SimpleTheme.listThemeColors, slwb.WorkbookProperties.Date1904, Options.IsStylish);
            chart.PlotArea.DataSeries = this.FillChartDataSeries(WorksheetName, StartRowIndex, StartColumnIndex, EndRowIndex, EndColumnIndex, chart.RowsAsDataSeries, chart.ShowHiddenData);
            chart.SetPlotAreaAxes();

            chart.HasShownSecondaryTextAxis = false;

            chart.StartRowIndex = iStartRowIndex;
            chart.StartColumnIndex = iStartColumnIndex;
            chart.EndRowIndex = iEndRowIndex;
            chart.EndColumnIndex = iEndColumnIndex;

            chart.ShowEmptyCellsAs = Options.IsStylish ? C.DisplayBlanksAsValues.Zero : C.DisplayBlanksAsValues.Gap;
            chart.ChartStyle = SLC.SLChartStyle.Style2;

            chart.ChartName = string.Format("Chart {0}", slws.Charts.Count + 1);

            chart.HasTitle = false;
            chart.Title = new SLC.SLTitle(SimpleTheme.listThemeColors, Options.IsStylish);
            chart.Title.Overlay = false;

            chart.Is3D = false;
            chart.Floor = new SLC.SLFloor(SimpleTheme.listThemeColors, Options.IsStylish);
            chart.SideWall = new SLC.SLSideWall(SimpleTheme.listThemeColors, Options.IsStylish);
            chart.BackWall = new SLC.SLBackWall(SimpleTheme.listThemeColors, Options.IsStylish);

            chart.ShowLegend = true;
            chart.Legend = new SLC.SLLegend(SimpleTheme.listThemeColors, Options.IsStylish);
            chart.Legend.Overlay = false;
            if (Options.IsStylish)
            {
                chart.Legend.LegendPosition = A.Charts.LegendPositionValues.Bottom;
            }

            chart.ShapeProperties = new SLA.SLShapeProperties(SimpleTheme.listThemeColors);

            if (Options.IsStylish)
            {
                chart.ShapeProperties.Fill.SetSolidFill(A.SchemeColorValues.Background1, 0, 0);
                chart.ShapeProperties.Outline.Width = 0.75m;
                chart.ShapeProperties.Outline.CapType = A.LineCapValues.Flat;
                chart.ShapeProperties.Outline.CompoundLineType = A.CompoundLineValues.Single;
                chart.ShapeProperties.Outline.Alignment = A.PenAlignmentValues.Center;
                chart.ShapeProperties.Outline.SetSolidLine(A.SchemeColorValues.Text1, 0.85m, 0);
                chart.ShapeProperties.Outline.JoinType = SLA.SLLineJoinValues.Round;
            }

            chart.TopPosition = 1;
            chart.LeftPosition = 1;
            chart.BottomPosition = 16;
            chart.RightPosition = 8.5;

            return chart;
        }
Esempio n. 2
0
        internal SLChart Clone()
        {
            SLChart chart = new SLChart();
            chart.listThemeColors = new List<System.Drawing.Color>();
            for (int i = 0; i < this.listThemeColors.Count; ++i)
            {
                chart.listThemeColors.Add(this.listThemeColors[i]);
            }

            chart.Date1904 = this.Date1904;
            chart.RoundedCorners = this.RoundedCorners;
            chart.IsCombinable = this.IsCombinable;

            chart.TopPosition = this.TopPosition;
            chart.LeftPosition = this.LeftPosition;
            chart.BottomPosition = this.BottomPosition;
            chart.RightPosition = this.RightPosition;
            chart.WorksheetName = this.WorksheetName;
            chart.RowsAsDataSeries = this.RowsAsDataSeries;

            chart.StartRowIndex = this.StartRowIndex;
            chart.StartColumnIndex = this.StartColumnIndex;
            chart.EndRowIndex = this.EndRowIndex;
            chart.EndColumnIndex = this.EndColumnIndex;

            chart.ChartStyle = this.ChartStyle;
            chart.ShowEmptyCellsAs = this.ShowEmptyCellsAs;
            chart.RotateX = this.RotateX;
            chart.HeightPercent = this.HeightPercent;
            chart.RotateY = this.RotateY;
            chart.DepthPercent = this.DepthPercent;
            chart.RightAngleAxes = this.RightAngleAxes;
            chart.Perspective = this.Perspective;
            chart.ChartName = this.ChartName;

            chart.HasTitle = this.HasTitle;
            chart.Title = this.Title.Clone();
            
            chart.Is3D = this.Is3D;

            chart.Floor = this.Floor.Clone();
            chart.SideWall = this.SideWall.Clone();
            chart.BackWall = this.BackWall.Clone();
            chart.PlotArea = this.PlotArea.Clone();
            chart.HasShownSecondaryTextAxis = this.HasShownSecondaryTextAxis;
            chart.ShowLegend = this.ShowLegend;
            chart.Legend = this.Legend.Clone();
            chart.ShowHiddenData = this.ShowHiddenData;
            chart.ShapeProperties = this.ShapeProperties.Clone();

            return chart;
        }
        private SLC.SLChart CreateChartInternal(string WorksheetName, int StartRowIndex, int StartColumnIndex, int EndRowIndex, int EndColumnIndex, bool? RowsAsDataSeries, bool ShowHiddenData)
        {
            SLC.SLChart chart = new SLC.SLChart();

            int iStartRowIndex = 1, iEndRowIndex = 1, iStartColumnIndex = 1, iEndColumnIndex = 1;
            if (StartRowIndex < EndRowIndex)
            {
                iStartRowIndex = StartRowIndex;
                iEndRowIndex = EndRowIndex;
            }
            else
            {
                iStartRowIndex = EndRowIndex;
                iEndRowIndex = StartRowIndex;
            }

            if (StartColumnIndex < EndColumnIndex)
            {
                iStartColumnIndex = StartColumnIndex;
                iEndColumnIndex = EndColumnIndex;
            }
            else
            {
                iStartColumnIndex = EndColumnIndex;
                iEndColumnIndex = StartColumnIndex;
            }

            if (iStartRowIndex < 1) iStartRowIndex = 1;
            if (iStartColumnIndex < 1) iStartColumnIndex = 1;
            if (iEndRowIndex > SLConstants.RowLimit) iEndRowIndex = SLConstants.RowLimit;
            if (iEndColumnIndex > SLConstants.ColumnLimit) iEndColumnIndex = SLConstants.ColumnLimit;

            // this will keep the calculations within workable range
            if (iStartRowIndex >= SLConstants.RowLimit) iStartRowIndex = SLConstants.RowLimit - 1;
            if (iStartColumnIndex >= SLConstants.ColumnLimit) iStartColumnIndex = SLConstants.ColumnLimit - 1;

            chart.WorksheetName = WorksheetName;

            if (RowsAsDataSeries == null)
            {
                if ((iEndColumnIndex - iStartColumnIndex) >= (iEndRowIndex - iStartRowIndex))
                {
                    chart.RowsAsDataSeries = true;
                }
                else
                {
                    chart.RowsAsDataSeries = false;
                }
            }
            else
            {
                chart.RowsAsDataSeries = RowsAsDataSeries.Value;
            }

            int i;
            chart.listThemeColors = new List<System.Drawing.Color>();
            for (i = 0; i < SimpleTheme.listThemeColors.Count; ++i)
            {
                chart.listThemeColors.Add(SimpleTheme.listThemeColors[i]);
            }

            chart.Date1904 = this.slwb.WorkbookProperties.Date1904;
            chart.RoundedCorners = false;

            // assume combination charts are possible first
            chart.IsCombinable = true;

            chart.PlotArea = new SLC.SLPlotArea(SimpleTheme.listThemeColors, slwb.WorkbookProperties.Date1904);
            chart.PlotArea.DataSeries = this.FillChartDataSeries(WorksheetName, StartRowIndex, StartColumnIndex, EndRowIndex, EndColumnIndex, chart.RowsAsDataSeries, ShowHiddenData);
            chart.SetPlotAreaAxes();

            chart.HasShownSecondaryTextAxis = false;

            chart.StartRowIndex = iStartRowIndex;
            chart.StartColumnIndex = iStartColumnIndex;
            chart.EndRowIndex = iEndRowIndex;
            chart.EndColumnIndex = iEndColumnIndex;

            chart.ShowEmptyCellsAs = DocumentFormat.OpenXml.Drawing.Charts.DisplayBlanksAsValues.Gap;
            chart.ChartStyle = SLC.SLChartStyle.Style2;

            chart.ChartName = string.Format("Chart {0}", slws.Charts.Count + 1);

            chart.HasTitle = false;
            chart.Title = new SLC.SLTitle(SimpleTheme.listThemeColors);
            chart.Title.Overlay = false;

            chart.Is3D = false;
            chart.Floor = new SLC.SLFloor(SimpleTheme.listThemeColors);
            chart.SideWall = new SLC.SLSideWall(SimpleTheme.listThemeColors);
            chart.BackWall = new SLC.SLBackWall(SimpleTheme.listThemeColors);

            chart.ShowLegend = true;
            chart.Legend = new SLC.SLLegend(SimpleTheme.listThemeColors);
            chart.Legend.Overlay = false;

            chart.ShowHiddenData = ShowHiddenData;

            chart.ShapeProperties = new SLA.SLShapeProperties(SimpleTheme.listThemeColors);

            chart.TopPosition = 0;
            chart.LeftPosition = 0;
            chart.BottomPosition = 5;
            chart.RightPosition = 5;

            return chart;
        }