private static ExcelScatterChart AddScatter(ExcelWorksheet ws, eScatterChartType type, string name, int row, int col, ePresetChartStyle style, Action <ExcelScatterChart> SetProperties)
        {
            var chart = ws.Drawings.AddScatterChart(name, type);

            chart.SetPosition(row, 0, col, 0);
            chart.To.Column    = col + 12;
            chart.To.ColumnOff = 0;
            chart.To.Row       = row + 18;
            chart.To.RowOff    = 0;
            var serie = chart.Series.Add("D2:D8", "A2:A8");

            SetProperties(chart);

            chart.StyleManager.SetChartStyle(style);
            return(chart);
        }
示例#2
0
 /// <summary>
 /// Adds a new scatter chart to the worksheet.
 /// </summary>
 /// <param name="Name"></param>
 /// <param name="ChartType">Type of chart</param>
 /// <returns>The chart</returns>
 public ExcelScatterChart AddScatterChart(string Name, eScatterChartType ChartType)
 {
     return((ExcelScatterChart)AddChart(Name, (eChartType)ChartType, null));
 }
示例#3
0
 /// <summary>
 /// Adds a new scatter chart to the worksheet.
 /// </summary>
 /// <param name="Name"></param>
 /// <param name="ChartType">Type of chart</param>
 /// <param name="PivotTableSource">The pivottable source for a pivotchart</param>
 /// <returns>The chart</returns>
 public ExcelScatterChart AddScatterChart(string Name, eScatterChartType ChartType, ExcelPivotTable PivotTableSource)
 {
     return((ExcelScatterChart)AddChart(Name, (eChartType)ChartType, PivotTableSource));
 }
        private static void ScatterLineStyle(ExcelWorksheet ws, eScatterChartType chartType)
        {
            //Style 1
            AddScatter(ws, chartType, "ScatterChartStyle1", 0, 5, ePresetChartStyle.ScatterChartStyle1,
                       c =>
            {
                c.Legend.Position = eLegendPosition.Bottom;
            });

            //Style 2
            AddScatter(ws, chartType, "ScatterChartStyle2", 0, 18, ePresetChartStyle.ScatterChartStyle2,
                       c =>
            {
                c.Legend.Position = eLegendPosition.Top;
            });

            //Style 3
            AddScatter(ws, chartType, "ScatterChartStyle3", 0, 31, ePresetChartStyle.ScatterChartStyle3,
                       c =>
            {
                c.DataLabel.ShowPercent = true;
            });

            //Style 4
            AddScatter(ws, chartType, "ScatterChartStyle4", 22, 5, ePresetChartStyle.ScatterChartStyle4,
                       c =>
            {
                c.Legend.Position = eLegendPosition.Bottom;
            });

            //Style 5
            AddScatter(ws, chartType, "ScatterChartStyle5", 22, 18, ePresetChartStyle.ScatterChartStyle5,
                       c =>
            {
                c.Legend.Position = eLegendPosition.Bottom;
            });

            //Style 6
            AddScatter(ws, chartType, "ScatterChartStyle6", 22, 31, ePresetChartStyle.ScatterChartStyle6,
                       c =>
            {
            });

            //Style 7
            AddScatter(ws, chartType, "ScatterChartStyle7", 44, 5, ePresetChartStyle.ScatterChartStyle7,
                       c =>
            {
                c.Legend.Position = eLegendPosition.Bottom;
            });

            //Style 8
            AddScatter(ws, chartType, "ScatterChartStyle8", 44, 18, ePresetChartStyle.ScatterChartStyle8,
                       c =>
            {
                c.Legend.Position       = eLegendPosition.Top;
                c.DataLabel.ShowPercent = true;
            });

            //Style 9
            AddScatter(ws, chartType, "ScatterChartStyle9", 44, 31, ePresetChartStyle.ScatterChartStyle9,
                       c =>
            {
                c.Legend.Remove();
                c.DataLabel.ShowValue    = true;
                c.DataLabel.ShowPercent  = true;
                c.DataLabel.ShowCategory = true;
            });

            //Style 10
            AddScatter(ws, chartType, "ScatterChartStyle10", 66, 5, ePresetChartStyle.ScatterChartStyle10,
                       c =>
            {
                c.Legend.Position       = eLegendPosition.Bottom;
                c.DataLabel.ShowPercent = true;
            });

            //Style 11
            AddScatter(ws, chartType, "ScatterChartStyle11", 66, 18, ePresetChartStyle.ScatterChartStyle11,
                       c =>
            {
            });

            //Style 12
            AddScatter(ws, chartType, "ScatterChartStyle12", 66, 31, ePresetChartStyle.ScatterChartStyle12,
                       c =>
            {
            });
        }
示例#5
0
 /// <summary>
 /// Adds a new scatter chart to the chart
 /// </summary>
 /// <param name="chartType">The type of the new chart</param>
 /// <returns>The chart</returns>
 public ExcelScatterChart AddScatterChart(eScatterChartType chartType)
 {
     return((ExcelScatterChart)Add((eChartType)chartType));
 }