public void DataArraysWrongSize()
        {
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Add chart with default data.
            Shape shape = builder.InsertChart(ChartType.Line, 432, 252);
            Chart chart = shape.Chart;

            ChartSeriesCollection seriesColl = chart.Series;

            seriesColl.Clear();

            // Create category names array, second category will be null.
            string[] categories = { "Cat1", null, "Cat3", "Cat4", "Cat5", null };

            // Adding new series with empty (double.NaN) values.
            seriesColl.Add("AW Series 1", categories, new double[] { 1, 2, double.NaN, 4, 5, 6 });
            seriesColl.Add("AW Series 2", categories, new double[] { 2, 3, double.NaN, 5, 6, 7 });

            Assert.That(
                () => seriesColl.Add("AW Series 3", categories, new[] { double.NaN, 4, 5, double.NaN, double.NaN }),
                Throws.TypeOf <ArgumentException>());
            Assert.That(
                () => seriesColl.Add("AW Series 4", categories,
                                     new[] { double.NaN, double.NaN, double.NaN, double.NaN, double.NaN }),
                Throws.TypeOf <ArgumentException>());
        }
        public void EmptyValuesInChartData()
        {
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Add chart with default data.
            Shape shape = builder.InsertChart(ChartType.Line, 432, 252);
            Chart chart = shape.Chart;

            ChartSeriesCollection seriesColl = chart.Series;

            seriesColl.Clear();

            // Create category names array, second category will be null.
            string[] categories = { "Cat1", null, "Cat3", "Cat4", "Cat5", null };

            // Adding new series with empty (double.NaN) values.
            seriesColl.Add("AW Series 1", categories, new[] { 1, 2, double.NaN, 4, 5, 6 });
            seriesColl.Add("AW Series 2", categories, new[] { 2, 3, double.NaN, 5, 6, 7 });
            seriesColl.Add("AW Series 3", categories, new[] { double.NaN, 4, 5, double.NaN, 7, 8 });
            seriesColl.Add("AW Series 4", categories,
                           new[] { double.NaN, double.NaN, double.NaN, double.NaN, double.NaN, 9 });

            doc.Save(ArtifactsDir + "Charts.EmptyValuesInChartData.docx");
        }
        public void InsertSimpleColumnChart()
        {
            //ExStart:InsertSimpleColumnChart
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // You can specify different chart types and sizes.
            Shape shape = builder.InsertChart(ChartType.Column, 432, 252);

            Chart chart = shape.Chart;
            //ExStart:ChartSeriesCollection
            ChartSeriesCollection seriesColl = chart.Series;

            Console.WriteLine(seriesColl.Count);
            //ExEnd:ChartSeriesCollection

            // Delete default generated series.
            seriesColl.Clear();

            // Create category names array, in this example we have two categories.
            string[] categories = new string[] { "Category 1", "Category 2" };

            // Please note, data arrays must not be empty and arrays must be the same size.
            seriesColl.Add("Aspose Series 1", categories, new double[] { 1, 2 });
            seriesColl.Add("Aspose Series 2", categories, new double[] { 3, 4 });
            seriesColl.Add("Aspose Series 3", categories, new double[] { 5, 6 });
            seriesColl.Add("Aspose Series 4", categories, new double[] { 7, 8 });
            seriesColl.Add("Aspose Series 5", categories, new double[] { 9, 10 });

            doc.Save(ArtifactsDir + "WorkingWithCharts.InsertSimpleColumnChart.docx");
            //ExEnd:InsertSimpleColumnChart
        }
        /// <summary>
        /// 插入图表
        /// </summary>
        static void InsertChart()
        {
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Add chart with default data. You can specify different chart types and sizes.
            Shape shape = builder.InsertChart(ChartType.Line, 432, 252);

            // Chart property of Shape contains all chart related options.
            Chart chart = shape.Chart;

            // Get chart series collection.
            ChartSeriesCollection seriesColl = chart.Series;

            // Delete default generated series.
            seriesColl.Clear();

            // Create category names array, in this example we have two categories.
            string[] categories = new string[] { "AW Category 1", "AW Category 1" };

            // Adding new series. Please note, data arrays must not be empty and arrays must be the same size.
            seriesColl.Add("AW Series 1", categories, new double[] { 1, 2 });
            seriesColl.Add("AW Series 2", categories, new double[] { 3, 4 });
            seriesColl.Add("AW Series 3", categories, new double[] { 5, 6 });
            seriesColl.Add("AW Series 4", categories, new double[] { 7, 8 });
            seriesColl.Add("AW Series 5", categories, new double[] { 9, 10 });

            doc.Save(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestInsertChartColumn.docx"));
        }
        public void ChartSeriesCollectionModify()
        {
            //ExStart
            //ExFor:Charts.ChartSeriesCollection
            //ExFor:Charts.ChartSeriesCollection.Clear
            //ExFor:Charts.ChartSeriesCollection.Count
            //ExFor:Charts.ChartSeriesCollection.GetEnumerator
            //ExFor:Charts.ChartSeriesCollection.Item(Int32)
            //ExFor:Charts.ChartSeriesCollection.RemoveAt(Int32)
            //ExSummary:Shows how to work with a chart's data collection.
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Use a document builder to insert a bar chart
            Shape chartShape = builder.InsertChart(ChartType.Column, 400, 300);
            Chart chart      = chartShape.Chart;

            // All charts come with demo data
            // This column chart currently has 3 series with 4 categories, which means 4 clusters, 3 columns in each
            ChartSeriesCollection chartData = chart.Series;

            Assert.AreEqual(3, chartData.Count);

            // Iterate through the series with an enumerator and print their names
            using (IEnumerator <ChartSeries> enumerator = chart.Series.GetEnumerator())
            {
                // And use it to go over all the data labels in one series and change their separator
                while (enumerator.MoveNext())
                {
                    Console.WriteLine(enumerator.Current.Name);
                }
            }

            // We can add new data by adding a new series to the collection, with categories and data
            // We will match the existing category/series names in the demo data and add a 4th column to each column cluster
            string[] categories = { "Category 1", "Category 2", "Category 3", "Category 4" };
            chart.Series.Add("Series 4", categories, new[] { 4.4, 7.0, 3.5, 2.1 });

            Assert.AreEqual(4, chartData.Count);
            Assert.AreEqual("Series 4", chartData[3].Name);

            // We can remove series by index
            chartData.RemoveAt(2);

            Assert.AreEqual(3, chartData.Count);
            Assert.AreEqual("Series 4", chartData[2].Name);

            // We can also remove out all the series
            // This leaves us with an empty graph and is a convenient way of wiping out demo data
            chartData.Clear();

            Assert.AreEqual(0, chartData.Count);
            //ExEnd
        }
        /// <summary>
        ///  Shows how to insert a simple column chart into the document using DocumentBuilder.InsertChart method.
        /// </summary>
        private static void InsertSimpleColumnChart(string dataDir)
        {
            // ExStart:InsertSimpleColumnChart
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Add chart with default data. You can specify different chart types and sizes.
            Shape shape = builder.InsertChart(ChartType.Column, 432, 252);

            // Chart property of Shape contains all chart related options.
            Chart chart = shape.Chart;

            // ExStart:ChartSeriesCollection
            // Get chart series collection.
            ChartSeriesCollection seriesColl = chart.Series;

            // Check series count.
            Console.WriteLine(seriesColl.Count);
            // ExEnd:ChartSeriesCollection

            // Delete default generated series.
            seriesColl.Clear();

            // Create category names array, in this example we have two categories.
            string[] categories = new string[] { "AW Category 1", "AW Category 2" };

            // Adding new series. Please note, data arrays must not be empty and arrays must be the same size.
            seriesColl.Add("AW Series 1", categories, new double[] { 1, 2 });
            seriesColl.Add("AW Series 2", categories, new double[] { 3, 4 });
            seriesColl.Add("AW Series 3", categories, new double[] { 5, 6 });
            seriesColl.Add("AW Series 4", categories, new double[] { 7, 8 });
            seriesColl.Add("AW Series 5", categories, new double[] { 9, 10 });

            dataDir = dataDir + @"TestInsertSimpleChartColumn_out.doc";
            doc.Save(dataDir);
            // ExEnd:InsertSimpleColumnChart
            Console.WriteLine("\nSimple column chart created successfully.\nFile saved at " + dataDir);
        }