示例#1
0
        private static void BarChart()
        {
            // Create new document.
            using (DocX document = DocX.Create(@"docs\BarChart.docx"))
            {
                // Create chart.
                BarChart c = new BarChart();
                c.BarDirection = BarDirection.Column;
                c.BarGrouping = BarGrouping.Standard;
                c.GapWidth = 400;
                c.AddLegend(ChartLegendPosition.Bottom, false);

                // Create data.
                List<ChartData> company1 = ChartData.CreateCompanyList1();
                List<ChartData> company2 = ChartData.CreateCompanyList2();

                // Create and add series
                Series s1 = new Series("Microsoft");
                s1.Color = Color.GreenYellow;
                s1.Bind(company1, "Mounth", "Money");
                c.AddSeries(s1);
                Series s2 = new Series("Apple");
                s2.Bind(company2, "Mounth", "Money");
                c.AddSeries(s2);

                // Insert chart into document
                document.InsertParagraph("Diagram").FontSize(20);
                document.InsertChart(c);
                document.Save();
            }
        }
示例#2
0
        private static void Chart3D()
        {
            Console.WriteLine("\tChart3D()");
            // Create new document.
            using (DocX document = DocX.Create(@"docs\3DChart.docx"))
            {
                // Create chart.
                BarChart c = new BarChart();
                c.View3D = true;

                // Create data.
                List<ChartData> company1 = ChartData.CreateCompanyList1();

                // Create and add series
                Series s = new Series("Microsoft");
                s.Color = Color.GreenYellow;
                s.Bind(company1, "Mounth", "Money");
                c.AddSeries(s);

                // Insert chart into document
                document.InsertParagraph("3D Diagram").FontSize(20);
                document.InsertChart(c);
                document.Save();
            }
            Console.WriteLine("\tCreated: docs\\3DChart.docx\n");
        }