コード例 #1
0
        private static ExcelOfPieChart AddOfPie(ExcelWorksheet ws, eOfPieChartType type, string name, int row, int col, ePresetChartStyle style, Action <ExcelOfPieChart> SetProperties)
        {
            var chart = ws.Drawings.AddOfPieChart(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");

            serie.DataPoints.Add(0);
            serie.DataPoints.Add(1);
            serie.DataPoints.Add(2);
            serie.DataPoints.Add(3);
            serie.DataPoints.Add(4);
            serie.DataPoints.Add(5);
            serie.DataPoints.Add(6);
            serie.DataPoints.Add(7);

            SetProperties(chart);

            chart.StyleManager.SetChartStyle(style);
            return(chart);
        }
コード例 #2
0
        private static void OfPieStyles(ExcelWorksheet ws, eOfPieChartType chartType)
        {
            //Style 1
            AddOfPie(ws, chartType, "OfPieChartStyle1", 0, 5, ePresetChartStyle.OfPieChartStyle1,
                     c =>
            {
                c.Legend.Position = eLegendPosition.Bottom;
            });

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

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

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

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

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

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

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

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

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

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

            //Style 12
            AddOfPie(ws, chartType, "OfPieChartStyle12", 66, 31, ePresetChartStyle.OfPieChartStyle12,
                     c =>
            {
            });
        }
コード例 #3
0
 /// <summary>
 /// Adds a new line chart to the worksheet.
 /// </summary>
 /// <param name="Name"></param>
 /// <param name="ChartType">Type of chart</param>
 /// <returns>The chart</returns>
 public ExcelOfPieChart AddOfPieChart(string Name, eOfPieChartType ChartType)
 {
     return((ExcelOfPieChart)AddChart(Name, (eChartType)ChartType, null));
 }
コード例 #4
0
 /// <summary>
 /// Add a new pie of pie or bar of pie 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 ExcelOfPieChart AddOfPieChart(string Name, eOfPieChartType ChartType, ExcelPivotTable PivotTableSource)
 {
     return((ExcelOfPieChart)AddChart(Name, (eChartType)ChartType, PivotTableSource));
 }
コード例 #5
0
 /// <summary>
 /// Adds a new column of pie- or bar of pie chart to the chart
 /// </summary>
 /// <param name="chartType">The type of the new chart</param>
 /// <returns>The chart</returns>
 public ExcelOfPieChart AddOfPieChart(eOfPieChartType chartType)
 {
     return((ExcelOfPieChart)Add((eChartType)chartType));
 }