Align Bar Chart, c # using Novacode

0

How can I align my bar chart in the center of my docx document?

My code:

    using Novacode; //adquirido na extensão DocX        
    namespace WF_TermograFacil
    {
    private void button1_Click(object sender, EventArgs e)
    {
        using (var docX = DocX.Load(@"C:\TermograFacil\Layout.docx"))
        {
                // Rotina para inserir um gráfico de barras dentro do docx
                BarChart c = new BarChart();
                c.BarDirection = BarDirection.Bar;
                c.BarGrouping = BarGrouping.Standard;
                c.GapWidth = 160;
                c.AddLegend(ChartLegendPosition.Right, false);

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

                // Create and add series
                Series s1 = new Series("Temp. Mín.");
                s1.Color = Color.FromArgb(0 , 176, 80);
                s1.Bind(company1, "Mounth", "Money");
                c.AddSeries(s1);
                Series s2 = new Series("Temp. Med.");
                s2.Color = Color.FromArgb(247, 150, 70);
                s2.Bind(company2, "Mounth", "Money");
                c.AddSeries(s2);
                Series s3 = new Series("Temp. Máx.");
                s3.Color = Color.FromArgb(255, 30, 30);
                s3.Bind(company3, "Mounth", "Money");
                c.AddSeries(s3);

                docX.InsertChart(c);
                docX.SaveAs(@"C:\TermograFacil\Final.docx");
                //Process.Start("WINWORD.EXE", @"C:\TermograFacil\Final.docx");

            }
            MessageBox.Show("O relatório foi gerado com sucesso!");

    }
    //Essa parte é para alimentar o Gráfico
    private class ChartData
    {
        public String Mounth { get; set; }
        public Double Money { get; set; }

        public static List<ChartData> CreateCompanyList1()
        {
            List<ChartData> company1 = new List<ChartData>();
            company1.Add(new ChartData() { Mounth = "Ar1", Money = 100 });
            return company1;
        }

        public static List<ChartData> CreateCompanyList2()
        {
            List<ChartData> company2 = new List<ChartData>();
            company2.Add(new ChartData() { Mounth = "Ar1", Money = 80 });
            return company2;
        }

        public static List<ChartData> CreateCompanyList3()
        {
            List<ChartData> company3 = new List<ChartData>();
            company3.Add(new ChartData() { Mounth = "Ar1", Money = 80 });
            return company3;
        }
    }

    }

To be easier to understand. I do the following to align the contents of a text inside the table:

    tabela.Rows[0].Cells[2].Paragraphs[0].Append("Texto Centralizado").Alignment = Novacode.Alignment.center;

If I could insert the Graph inside the table would be a way to align too, but the extension does not give me that possibility.

    
asked by anonymous 25.07.2017 / 02:40

0 answers