Пример #1
0
        private void CreateChart(ExcelWorksheet ws, ExcelPivotTable pivotTable)
        {
            ExcelBarChart chart = ws.Drawings.AddChart("crtTiempos", eChartType.BarClustered, pivotTable) as ExcelBarChart;

            chart.SetPosition(1, 0, 4, 0);
            chart.SetSize(600, 400);

            chart.Title.Text      = "Tiempos?";
            chart.Title.Font.Size = 18;
            chart.Title.Font.Bold = true;

            chart.GapWidth = 25;

            chart.DataLabel.ShowValue = true;

            chart.Legend.Remove();

            chart.XAxis.MajorTickMark = eAxisTickMark.None;
            chart.XAxis.MinorTickMark = eAxisTickMark.None;

            chart.YAxis.DisplayUnit = 1000; // K
            chart.YAxis.Deleted     = true;

            ExcelBarChartSerie serie = chart.Series[0] as ExcelBarChartSerie;

            serie.Fill.Color = Color.FromArgb(91, 155, 213);

            chart.SetAxisGridlines(true, true, false);

            chart.SetCategoriesOrder(true);
        }
Пример #2
0
        private ExcelChart AddBarChart(ExcelWorksheet ws, string NameChart, eChartType type, List <DataSerie> ListSeries)
        {
            ExcelBarChart chart = ws.Drawings.AddChart(NameChart, eChartType.ColumnClustered) as ExcelBarChart;

            chart.Title.Font.Size = 18;
            chart.Title.Font.Bold = true;

            chart.Legend.Remove();

            chart.YAxis.Border.Fill.Style = eFillStyle.NoFill;

            chart.YAxis.Font.Size = 9;

            chart.XAxis.MajorTickMark = eAxisTickMark.None;
            chart.XAxis.MinorTickMark = eAxisTickMark.None;

            chart.YAxis.MajorTickMark = eAxisTickMark.None;
            chart.YAxis.MinorTickMark = eAxisTickMark.None;

            for (int i = 0; i < ListSeries.Count; i++)
            {
                DataSerie          dat = ListSeries[i];
                ExcelBarChartSerie ser = (ExcelBarChartSerie)(chart.Series.Add(dat.Series, dat.xSeries));
                ser.DataLabel.ShowValue = true;
                ser.DataLabel.Position  = eLabelPosition.OutEnd;
                ser.Header = dat.name;

                if (dat.name == "Move")
                {
                    ser.DataLabel.Border.Fill.Color = Color.Red;
                    ser.DataLabel.Border.LineStyle  = eLineStyle.Solid;
                }
            }

            chart.YAxis.Format = string.Format("{0};{1}", "#,##0", "(#,##0)");

            return(chart);
        }