Exemple #1
0
        public IPieChart InsertPieChart()
        {
            ChartSpace chartSpace = this.chartPart.ChartSpace;
            Chart      chart      = chartSpace.GetFirstChild <Chart>() ?? chartSpace.AppendChild(new Chart());
            PlotArea   plotArea   = chart.PlotArea ?? (chart.PlotArea = new PlotArea());

            return(new OpenXmlPieChart(
                       this,
                       plotArea.AppendChild(
                           new DoughnutChart()
                           .AppendChildFluent(new PieChartSeries()
            {
                Index = new Index()
                {
                    Val = 0
                }
            })
                           )
                       ));
        }
Exemple #2
0
        public IBarChart InsertBarChart(CartesianAxes axes)
        {
            ChartSpace chartSpace = this.chartPart.ChartSpace;
            Chart      chart      = chartSpace.GetFirstChild <Chart>() ?? chartSpace.AppendChild(new Chart());
            PlotArea   plotArea   = chart.PlotArea ?? (chart.PlotArea = new PlotArea());

            return(new OpenXmlBarChart(
                       this,
                       plotArea.AppendChild(
                           new BarChart()
                           .AppendChildFluent(new AxisId()
            {
                Val = axes.CategoryAxis.Id
            })
                           .AppendChildFluent(new AxisId()
            {
                Val = axes.ValueAxis.Id
            })
                           )
                       ));
        }
Exemple #3
0
        public ILineChart InsertLineChart(CartesianAxes axes)
        {
            ChartSpace chartSpace = this.chartPart.ChartSpace;
            Chart      chart      = chartSpace.GetFirstChild <Chart>() ?? chartSpace.AppendChild(new Chart());
            PlotArea   plotArea   = chart.PlotArea ?? (chart.PlotArea = new PlotArea());

            Marker marker = new Marker();

            marker.SetAttribute(new DocumentFormat.OpenXml.OpenXmlAttribute("Val", marker.NamespaceUri, "1"));

            return(new OpenXmlLineChart(
                       this,
                       plotArea.AppendChild(
                           new LineChart()
                           .AppendChildFluent(new Grouping()
            {
                Val = GroupingValues.Standard
            })
                           .AppendChildFluent(new VaryColors()
            {
                Val = true
            })
                           .AppendChildFluent(new Marker())
                           .AppendChildFluent(new Smooth()
            {
                Val = false
            })
                           .AppendChildFluent(new AxisId()
            {
                Val = axes.CategoryAxis.Id
            })
                           .AppendChildFluent(new AxisId()
            {
                Val = axes.ValueAxis.Id
            })
                           )
                       ));
        }
        void setChartData(ChartPart chartPart1, ChartDataHolder[] ChartDataSlide)
        {
            ChartSpace chartSpace = chartPart1.ChartSpace;

            DocumentFormat.OpenXml.Drawing.Charts.Chart chart1 = chartSpace.GetFirstChild <DocumentFormat.OpenXml.Drawing.Charts.Chart>();
            PlotArea plotArea1 = chart1.GetFirstChild <PlotArea>();
            BarChart barChart1 = plotArea1.GetFirstChild <BarChart>();

            //BarChartSeries barChartSeries1 = barChart1.Elements<BarChartSeries>().ElementAtOrDefault(2);
            for (int i = 0; i < barChart1.Elements <BarChartSeries>().Count(); i++)
            {
                BarChartSeries barChartSeries = barChart1.Elements <BarChartSeries>().ElementAtOrDefault(i);
                ChartDataSlide dataModel      = ChartDataSlide.ElementAtOrDefault(i).chartData;

                SeriesText seriesText = barChartSeries.Elements <SeriesText>().ElementAtOrDefault(0);
                if (seriesText != null)
                {
                    var stringReference = seriesText.Descendants <StringReference>().FirstOrDefault();
                    var stringCache     = stringReference.Descendants <StringCache>().FirstOrDefault();
                    var stringPoint     = stringCache.Descendants <StringPoint>().FirstOrDefault();
                    var barLabel        = stringPoint.GetFirstChild <NumericValue>();
                    barLabel.Text = ChartDataSlide.ElementAtOrDefault(i).seriesText;
                }

                if (barChartSeries != null)
                {
                    Values          values1          = barChartSeries.GetFirstChild <Values>();
                    NumberReference numberReference1 = values1.GetFirstChild <NumberReference>();
                    NumberingCache  numberingCache1  = numberReference1.GetFirstChild <NumberingCache>();

                    NumericPoint numericPoint1 = numberingCache1.GetFirstChild <NumericPoint>();
                    NumericPoint numericPoint2 = numberingCache1.Elements <NumericPoint>().ElementAt(1);
                    NumericPoint numericPoint3 = numberingCache1.Elements <NumericPoint>().ElementAt(2);

                    NumericValue numericValue1 = numericPoint1.GetFirstChild <NumericValue>();
                    //numericValue1.Text = ".50";
                    if (numericValue1 != null)
                    {
                        numericValue1.Text = dataModel.Interaction.ToString();
                    }


                    NumericValue numericValue2 = numericPoint2.GetFirstChild <NumericValue>();
                    //numericValue2.Text = ".10";
                    if (numericValue2 != null)
                    {
                        numericValue2.Text = dataModel.Knowlegde.ToString();
                    }


                    NumericValue numericValue3 = numericPoint3.GetFirstChild <NumericValue>();
                    //numericValue3.Text = ".40";
                    if (numericValue3 != null)
                    {
                        numericValue3.Text = dataModel.Image.ToString();
                    }
                }
            }

            chartSpace.Save();
        }
Exemple #5
0
        private ValueAxis AppendValueAxis()
        {
            ChartSpace chartSpace = this.chartPart.ChartSpace;
            Chart      chart      = chartSpace.GetFirstChild <Chart>() ?? chartSpace.AppendChild(new Chart());
            PlotArea   plotArea   = chart.GetFirstChild <PlotArea>() ?? chart.AppendChild(new PlotArea());

            uint id = plotArea.Elements <ValueAxis>().Select(axis => axis.AxisId.Val.Value).DefaultIfEmpty(417314071u).Max() + 1;

            ValueAxis valueAxis = plotArea.AppendChild(
                new ValueAxis()
            {
                AxisId = new AxisId()
                {
                    Val = id
                },
                Scaling = new Scaling()
                {
                    Orientation = new Orientation()
                    {
                        Val = OrientationValues.MinMax
                    }
                },
                Delete = new Delete()
                {
                    Val = false
                },
                AxisPosition = new AxisPosition()
                {
                    Val = AxisPositionValues.Left
                },
                MajorGridlines = new MajorGridlines()
                {
                    ChartShapeProperties = new ChartShapeProperties()
                    {
                        // TODO
                    }
                },
                NumberingFormat = new NumberingFormat()
                {
                    FormatCode = "General", SourceLinked = true
                },
                MajorTickMark = new MajorTickMark()
                {
                    Val = TickMarkValues.None
                },
                MinorTickMark = new MinorTickMark()
                {
                    Val = TickMarkValues.None
                },
                TickLabelPosition = new TickLabelPosition()
                {
                    Val = TickLabelPositionValues.NextTo
                },
                ChartShapeProperties = new ChartShapeProperties()
                                       .AppendChildFluent(new Drawing.NoFill())
                                       .AppendChildFluent(new Drawing.Outline().AppendChildFluent(new Drawing.NoFill()))
                                       .AppendChildFluent(new Drawing.EffectList()),
                TextProperties = new TextProperties()
                {
                    BodyProperties = new Drawing.BodyProperties(),
                    ListStyle      = new Drawing.ListStyle()
                }
                .AppendChildFluent(
                    new Drawing.Paragraph()
                {
                    ParagraphProperties = new Drawing.ParagraphProperties().AppendChildFluent(
                        new Drawing.DefaultRunProperties()
                    {
                        FontSize  = 1197,
                        Bold      = false,
                        Italic    = false,
                        Underline = Drawing.TextUnderlineValues.None,
                        Strike    = Drawing.TextStrikeValues.NoStrike,
                        Kerning   = 1200,
                        Baseline  = 0
                    }
                        .AppendChildFluent(
                            new Drawing.SolidFill()
                    {
                        SchemeColor = new Drawing.SchemeColor()
                        {
                            Val = Drawing.SchemeColorValues.Text1
                        }
                        .AppendChildFluent(new Drawing.LuminanceModulation()
                        {
                            Val = 65000
                        })
                        .AppendChildFluent(new Drawing.LuminanceOffset()
                        {
                            Val = 35000
                        })
                    }
                            )
                        .AppendChildFluent(new Drawing.LatinFont()
                    {
                        Typeface = "+mn-lt"
                    })
                        .AppendChildFluent(new Drawing.EastAsianFont()
                    {
                        Typeface = "+mn-ea"
                    })
                        .AppendChildFluent(new Drawing.ComplexScriptFont()
                    {
                        Typeface = "+mn-cs"
                    })
                        )
                }
                    )
            }
                .AppendChildFluent(new Crosses()
            {
                Val = CrossesValues.AutoZero
            })
                .AppendChildFluent(new CrossBetween()
            {
                Val = CrossBetweenValues.Between
            })
                );

            return(valueAxis);
        }