当前位置: 首页>>代码示例>>C#>>正文


C# DocumentBuilder.InsertChart方法代码示例

本文整理汇总了C#中DocumentBuilder.InsertChart方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentBuilder.InsertChart方法的具体用法?C# DocumentBuilder.InsertChart怎么用?C# DocumentBuilder.InsertChart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DocumentBuilder的用法示例。


在下文中一共展示了DocumentBuilder.InsertChart方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        // Simple bar graph 
        static void Main(string[] args)
        {
            // Check for license and apply if exists
            string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic";
            if (File.Exists(licenseFile))
            {
                // Apply Aspose.Words API License
				Aspose.Words.License license = new Aspose.Words.License();
				// Place license file in Bin/Debug/Folder
				license.SetLicense("Aspose.Words.lic");
            }

			//createing new document
			Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Write text on the document 
            builder.Write("Simple Bar graph using Aspose.Words \t");

            //select the chart type (here chartType is bar) 
            Shape shape1 = builder.InsertChart(ChartType.Bar, 432, 252);

            // save the document in the given path
            doc.Save("SimpleBarGraph.doc");
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:26,代码来源:Program.cs

示例2: Run

        public static void Run()
        {
            // ExStart:CreateChartUsingShape
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithCharts();
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            Shape shape = builder.InsertChart(ChartType.Line, 432, 252);
            Chart chart = shape.Chart;

            // Determines whether the title shall be shown for this chart. Default is true.
            chart.Title.Show = true;

            // Setting chart Title.
            chart.Title.Text = "Sample Line Chart Title";

            // Determines whether other chart elements shall be allowed to overlap title.
            chart.Title.Overlay = false;

            // Please note if null or empty value is specified as title text, auto generated title will be shown.

            // Determines how legend shall be shown for this chart.
            chart.Legend.Position = LegendPosition.Left;
            chart.Legend.Overlay = true;
            dataDir = dataDir + @"SimpleLineChart_out.docx";
            doc.Save(dataDir);
            // ExEnd:CreateChartUsingShape
            Console.WriteLine("\nSimple line chart created successfully.\nFile saved at " + dataDir);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:30,代码来源:CreateChartUsingShape.cs

示例3: InsertColumnChart

        /// <summary>
        ///  Shows how to insert a column chart into the document using DocumentBuilder.InsertChart method.
        /// </summary>             
        private static void InsertColumnChart(string dataDir)
        {
            // ExStart:InsertColumnChart
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Insert Column chart.
            Shape shape = builder.InsertChart(ChartType.Column, 432, 252);
            Chart chart = shape.Chart;

            // Use this overload to add series to any type of Bar, Column, Line and Surface charts.
            chart.Series.Add("AW Series 1", new string[] { "AW Category 1", "AW Category 2" }, new double[] { 1, 2 });

            dataDir = dataDir + @"TestInsertChartColumn_out.doc";
            doc.Save(dataDir);
            // ExEnd:InsertColumnChart
            Console.WriteLine("\nColumn chart created successfully.\nFile saved at " + dataDir);

        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:22,代码来源:CreateColumnChart.cs

示例4: Run

        public static void Run()
        {
            // ExStart:InsertBubbleChart
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithCharts();
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Insert Bubble chart.
            Shape shape = builder.InsertChart(ChartType.Bubble, 432, 252);
            Chart chart = shape.Chart;

            // Use this overload to add series to any type of Bubble charts.
            chart.Series.Add("AW Series 1", new double[] { 0.7, 1.8, 2.6 }, new double[] { 2.7, 3.2, 0.8 }, new double[] { 10, 4, 8 });
            dataDir = dataDir + @"TestInsertBubbleChart_out.docx";
            doc.Save(dataDir);
            // ExEnd:InsertBubbleChart
            Console.WriteLine("\nBubble chart created successfully.\nFile saved at " + dataDir);
        }        
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:19,代码来源:InsertBubbleChart.cs

示例5: Run

        public static void Run()
        {            
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithCharts();
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            Shape shape = builder.InsertChart(ChartType.Line, 432, 252);
            Chart chart = shape.Chart;
            // ExStart:WorkWithSingleChartSeries
            // Get first series.
            ChartSeries series0 = shape.Chart.Series[0];

            // Get second series.
            ChartSeries series1 = shape.Chart.Series[1];

            // Change first series name.
            series0.Name = "My Name1";

            // Change second series name.
            series1.Name = "My Name2";

            // You can also specify whether the line connecting the points on the chart shall be smoothed using Catmull-Rom splines.
            series0.Smooth = true;
            series1.Smooth = true;
            // ExEnd:WorkWithSingleChartSeries
            // ExStart:ChartDataPoint 
            // Specifies whether by default the parent element shall inverts its colors if the value is negative.
            series0.InvertIfNegative = true;

            // Set default marker symbol and size.
            series0.Marker.Symbol = MarkerSymbol.Circle;
            series0.Marker.Size = 15;

            series1.Marker.Symbol = MarkerSymbol.Star;
            series1.Marker.Size = 10;
            // ExEnd:ChartDataPoint 
            dataDir = dataDir + @"SingleChartSeries_out.docx";
            doc.Save(dataDir);
            
            Console.WriteLine("\nChart created successfully.\nFile saved at " + dataDir);
        }        
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:42,代码来源:WorkWithSingleChartSeries.cs

示例6: InsertSimpleColumnChart

        /// <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);
            
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:41,代码来源:CreateColumnChart.cs

示例7: Run

        public static void Run()
        {
            // ExStart:WorkWithChartDataLabel
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithCharts();
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            Shape shape = builder.InsertChart(ChartType.Bar, 432, 252);
            Chart chart = shape.Chart;

            // Get first series.
            ChartSeries series0 = shape.Chart.Series[0];
            ChartDataLabelCollection dataLabelCollection = series0.DataLabels;

            // Add data label to the first and second point of the first series.
            ChartDataLabel chartDataLabel00 = dataLabelCollection.Add(0);
            ChartDataLabel chartDataLabel01 = dataLabelCollection.Add(1);

            // Set properties.
            chartDataLabel00.ShowLegendKey = true;

            // By default, when you add data labels to the data points in a pie chart, leader lines are displayed for data labels that are
            // Positioned far outside the end of data points. Leader lines create a visual connection between a data label and its 
            // Corresponding data point.
            chartDataLabel00.ShowLeaderLines = true;

            chartDataLabel00.ShowCategoryName = false;
            chartDataLabel00.ShowPercentage = false;
            chartDataLabel00.ShowSeriesName = true;
            chartDataLabel00.ShowValue = true;
            chartDataLabel00.Separator = "/";
            chartDataLabel01.ShowValue = true;
            dataDir = dataDir + @"SimpleBarChart_out.docx";
            doc.Save(dataDir);
            // ExEnd:WorkWithChartDataLabel
            Console.WriteLine("\nSimple bar chart created successfully.\nFile saved at " + dataDir);
        }        
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:38,代码来源:WorkWithChartDataLabel.cs

示例8: Run

        public static void Run()
        {
            // ExStart:InsertAreaChart
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithCharts();
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Insert Area chart.
            Shape shape = builder.InsertChart(ChartType.Area, 432, 252);
            Chart chart = shape.Chart;

            // Use this overload to add series to any type of Area, Radar and Stock charts.
            chart.Series.Add("AW Series 1", new DateTime[] { 
    new DateTime(2002, 05, 01), 
    new DateTime(2002, 06, 01),
    new DateTime(2002, 07, 01),
    new DateTime(2002, 08, 01),
    new DateTime(2002, 09, 01)}, new double[] { 32, 32, 28, 12, 15 });
            dataDir = dataDir + @"TestInsertAreaChart_out.docx";
            doc.Save(dataDir);
            // ExEnd:InsertAreaChart
            Console.WriteLine("\nScatter chart created successfully.\nFile saved at " + dataDir);
        }        
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:24,代码来源:InsertAreaChart.cs

示例9: InsertChartRelativePositionEx

        public void InsertChartRelativePositionEx()
        {
            //ExStart
            //ExFor:DocumentBuilder.InsertChart(ChartType, RelativeHorizontalPosition, Double, RelativeVerticalPosition, Double, Double, Double, WrapType)
            //ExSummary:Shows how to insert a chart into a document and specify all positioning options in the arguments.
            Aspose.Words.Document doc = new Aspose.Words.Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.InsertChart(ChartType.Pie, RelativeHorizontalPosition.Margin, 100, RelativeVerticalPosition.Margin, 100,
                                    200, 100, WrapType.Square);

            doc.Save(MyDir + @"Document.InsertedChartRelativePosition.doc");
            //ExEnd
        }
开发者ID:animaal,项目名称:Aspose_Words_NET,代码行数:14,代码来源:ExDocumentBuilder.cs

示例10: InsertChartDoubleEx

        public void InsertChartDoubleEx()
        {
            //ExStart
            //ExFor:DocumentBuilder.InsertChart(ChartType, Double, Double)
            //ExSummary:Shows how to insert a chart into a document.
            Aspose.Words.Document doc = new Aspose.Words.Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.InsertChart(ChartType.Pie, Aspose.Words.ConvertUtil.PixelToPoint(300),
                                Aspose.Words.ConvertUtil.PixelToPoint(300));

            doc.Save(MyDir + @"Document.InsertedChartDouble.doc");
            //ExEnd
        }
开发者ID:animaal,项目名称:Aspose_Words_NET,代码行数:14,代码来源:ExDocumentBuilder.cs

示例11: EmptyValuesInChartData

        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 = new string[] { "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 });
            seriesColl.Add("AW Series 3", categories, new double[] { double.NaN, 4, 5, double.NaN, 7, 8 });
            seriesColl.Add("AW Series 4", categories, new double[] { double.NaN, double.NaN, double.NaN, double.NaN, double.NaN, 9 });

            doc.Save(MyDir + @"\Artifacts\EmptyValuesInChartData.docx");
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:23,代码来源:ExDocumentBuilder.cs

示例12: DataArraysWrongSize

        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 = new string[] { "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[] { double.NaN, 4, 5, double.NaN, double.NaN }), Throws.TypeOf<ArgumentException>());
            Assert.That(() => seriesColl.Add("AW Series 4", categories, new double[] { double.NaN, double.NaN, double.NaN, double.NaN, double.NaN }), Throws.TypeOf<ArgumentException>());
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:21,代码来源:ExDocumentBuilder.cs


注:本文中的DocumentBuilder.InsertChart方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。