コード例 #1
0
        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;
        }
コード例 #2
0
        /// <summary>
        /// Creates an instance of SLChart, given cell references of opposite cells in a cell range.
        /// </summary>
        /// <param name="StartCellReference">The cell reference of the start cell of the cell range to be in the chart, such as "A1". This is typically the top-left cell.</param>
        /// <param name="EndCellReference">The cell reference of the end cell of the cell range to be in the chart, such as "A1". This is typically the bottom-right cell.</param>
        /// <param name="Options">Chart creation options.</param>
        /// <returns>An SLChart with the required information.</returns>
        public SLC.SLChart CreateChart(string StartCellReference, string EndCellReference, SLC.SLCreateChartOptions Options)
        {
            int iStartRowIndex = -1;
            int iStartColumnIndex = -1;
            int iEndRowIndex = -1;
            int iEndColumnIndex = -1;
            if (!SLTool.FormatCellReferenceToRowColumnIndex(StartCellReference, out iStartRowIndex, out iStartColumnIndex))
            {
                iStartRowIndex = -1;
                iStartColumnIndex = -1;
            }
            if (!SLTool.FormatCellReferenceToRowColumnIndex(EndCellReference, out iEndRowIndex, out iEndColumnIndex))
            {
                iEndRowIndex = -1;
                iEndColumnIndex = -1;
            }

            return this.CreateChartInternal(gsSelectedWorksheetName, iStartRowIndex, iStartColumnIndex, iEndRowIndex, iEndColumnIndex, Options);
        }
コード例 #3
0
 /// <summary>
 /// Creates an instance of SLChart, given row and column indices of opposite cells in a cell range.
 /// </summary>
 /// <param name="WorksheetName">The name of the source worksheet.</param>
 /// <param name="StartRowIndex">The row index of the start row. This is typically the top row.</param>
 /// <param name="StartColumnIndex">The column index of the start column. This is typically the left-most column.</param>
 /// <param name="EndRowIndex">The row index of the end row. This is typically the bottom row.</param>
 /// <param name="EndColumnIndex">The column index of the end column. This is typically the right-most column.</param>
 /// <param name="Options">Chart creation options.</param>
 /// <returns>An SLChart with the required information.</returns>
 public SLC.SLChart CreateChart(string WorksheetName, int StartRowIndex, int StartColumnIndex, int EndRowIndex, int EndColumnIndex, SLC.SLCreateChartOptions Options)
 {
     return this.CreateChartInternal(WorksheetName, StartRowIndex, StartColumnIndex, EndRowIndex, EndColumnIndex, Options);
 }