コード例 #1
0
        public void DefaultOptionsForDataLabels()
        {
            //ExStart:DefaultOptionsForDataLabels
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            Shape shape = builder.InsertChart(ChartType.Pie, 432, 252);

            Chart chart = shape.Chart;

            chart.Series.Clear();

            ChartSeries series = chart.Series.Add("Aspose Series 1",
                                                  new string[] { "Category 1", "Category 2", "Category 3" },
                                                  new double[] { 2.7, 3.2, 0.8 });

            ChartDataLabelCollection labels = series.DataLabels;

            labels.ShowPercentage  = true;
            labels.ShowValue       = true;
            labels.ShowLeaderLines = false;
            labels.Separator       = " - ";

            doc.Save(ArtifactsDir + "WorkingWithCharts.DefaultOptionsForDataLabels.docx");
            //ExEnd:DefaultOptionsForDataLabels
        }
コード例 #2
0
        public void DefineNumberFormatForDataLabels()
        {
            //ExStart
            //ExFor:ChartDataLabelCollection.NumberFormat
            //ExFor:ChartNumberFormat.FormatCode
            //ExSummary:Shows how to set number format for the data labels of the entire series.
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

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

            // Delete default generated series
            shape.Chart.Series.Clear();

            ChartSeries series =
                shape.Chart.Series.Add("Aspose Test Series", new[] { "Word", "PDF", "Excel" }, new[] { 2.5, 1.5, 3.5 });

            ChartDataLabelCollection dataLabels = series.DataLabels;

            // Display chart values in the data labels, by default it is false
            dataLabels.ShowValue = true;
            // Set currency format for the data labels of the entire series
            dataLabels.NumberFormat.FormatCode = "\"$\"#,##0.00";

            doc.Save(ArtifactsDir + "Charts.DefineNumberFormatForDataLabels.docx");
            //ExEnd
        }
コード例 #3
0
        public void ChartDataLabel()
        {
            //ExStart:WorkWithChartDataLabel
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

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

            Chart       chart   = shape.Chart;
            ChartSeries series0 = shape.Chart.Series[0];

            ChartDataLabelCollection labels = series0.DataLabels;

            labels.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.
            labels.ShowLeaderLines  = true;
            labels.ShowCategoryName = false;
            labels.ShowPercentage   = false;
            labels.ShowSeriesName   = true;
            labels.ShowValue        = true;
            labels.Separator        = "/";
            labels.ShowValue        = true;

            doc.Save(ArtifactsDir + "WorkingWithCharts.ChartDataLabel.docx");
            //ExEnd:WorkWithChartDataLabel
        }
コード例 #4
0
        public static void DefaultOptionsForDataLabels(string dataDir)
        {
            // ExStart:DefaultOptionsForDataLabels
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

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

            chart.Series.Clear();

            ChartSeries series = chart.Series.Add("Series 1",
                                                  new string[] { "Category1", "Category2", "Category3" },
                                                  new double[] { 2.7, 3.2, 0.8 });

            ChartDataLabelCollection labels = series.DataLabels;

            labels.ShowPercentage  = true;
            labels.ShowValue       = true;
            labels.ShowLeaderLines = false;
            labels.Separator       = " - ";

            doc.Save(dataDir + "Demo.docx");
            // ExEnd:DefaultOptionsForDataLabels
            Console.WriteLine("\nDefault options for data labels of chart series created successfully.\nFile saved at " + dataDir);
        }
コード例 #5
0
        public static void WorkWithChartDataLabel(string dataDir)
        {
            // ExStart:WorkWithChartDataLabel
            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 labels = series0.DataLabels;

            // Set properties.
            labels.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.
            labels.ShowLeaderLines = true;

            labels.ShowCategoryName = false;
            labels.ShowPercentage   = false;
            labels.ShowSeriesName   = true;
            labels.ShowValue        = true;
            labels.Separator        = "/";
            labels.ShowValue        = true;
            dataDir = dataDir + "SimpleBarChart_out.docx";
            doc.Save(dataDir);
            // ExEnd:WorkWithChartDataLabel
            Console.WriteLine("\nSimple bar chart created successfully.\nFile saved at " + dataDir);
        }
コード例 #6
0
        public void WorkWithChartDataLabelCollection()
        {
            //ExStart
            //ExFor:ChartDataLabelCollection.ShowBubbleSize
            //ExFor:ChartDataLabelCollection.ShowCategoryName
            //ExFor:ChartDataLabelCollection.ShowSeriesName
            //ExFor:ChartDataLabelCollection.Separator
            //ExFor:ChartDataLabelCollection.ShowLeaderLines
            //ExFor:ChartDataLabelCollection.ShowLegendKey
            //ExFor:ChartDataLabelCollection.ShowPercentage
            //ExFor:ChartDataLabelCollection.ShowValue
            //ExSummary:Shows how to set default values for the data labels.
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

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

            // Clear demo data
            shapeWithBubbleChart.Chart.Series.Clear();

            ChartSeries bubbleChartSeries = shapeWithBubbleChart.Chart.Series.Add("Aspose Test Series",
                                                                                  new[] { 2.9, 3.5, 1.1, 4, 4 },
                                                                                  new[] { 1.9, 8.5, 2.1, 6, 1.5 },
                                                                                  new[] { 9, 4.5, 2.5, 8, 5 });

            // Set default values for the bubble chart data labels
            ChartDataLabelCollection bubbleChartDataLabels = bubbleChartSeries.DataLabels;

            bubbleChartDataLabels.ShowBubbleSize   = true;
            bubbleChartDataLabels.ShowCategoryName = true;
            bubbleChartDataLabels.ShowSeriesName   = true;
            bubbleChartDataLabels.Separator        = " - ";

            builder.InsertBreak(BreakType.PageBreak);

            // Insert pie chart
            Shape shapeWithPieChart = builder.InsertChart(ChartType.Pie, 432, 252);

            // Clear demo data
            shapeWithPieChart.Chart.Series.Clear();

            ChartSeries pieChartSeries = shapeWithPieChart.Chart.Series.Add("Aspose Test Series",
                                                                            new string[] { "Word", "PDF", "Excel" },
                                                                            new double[] { 2.7, 3.2, 0.8 });

            // Set default values for the pie chart data labels
            ChartDataLabelCollection pieChartDataLabels = pieChartSeries.DataLabels;

            pieChartDataLabels.ShowLeaderLines = true;
            pieChartDataLabels.ShowLegendKey   = true;
            pieChartDataLabels.ShowPercentage  = true;
            pieChartDataLabels.ShowValue       = true;

            doc.Save(ArtifactsDir + "Charts.WorkWithChartDataLabelCollection.docx");
            //ExEnd
        }
コード例 #7
0
        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);
        }