예제 #1
0
        public Chart()
        {
            Xml      = XDocument.Parse("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n                   <c:chartSpace xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\">  \r\n                       <c:roundedCorners val=\"0\"/>\r\n                       <c:chart>\r\n                           <c:autoTitleDeleted val=\"0\"/>\r\n                           <c:plotVisOnly val=\"1\"/>\r\n                           <c:dispBlanksAs val=\"gap\"/>\r\n                           <c:showDLblsOverMax val=\"0\"/>\r\n                       </c:chart>\r\n                   </c:chartSpace>");
            ChartXml = CreateChartXml();
            XElement xElement = new XElement(XName.Get("plotArea", DocX.c.NamespaceName), new XElement(XName.Get("layout", DocX.c.NamespaceName)), ChartXml);
            XElement content  = XElement.Parse("<c:dLbls xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\">\r\n                    <c:showLegendKey val=\"0\"/>\r\n                    <c:showVal val=\"0\"/>\r\n                    <c:showCatName val=\"0\"/>\r\n                    <c:showSerName val=\"0\"/>\r\n                    <c:showPercent val=\"0\"/>\r\n                    <c:showBubbleSize val=\"0\"/>\r\n                    <c:showLeaderLines val=\"1\"/>\r\n                </c:dLbls>");

            ChartXml.Add(content);
            if (IsAxisExist)
            {
                CategoryAxis = new CategoryAxis("148921728");
                ValueAxis    = new ValueAxis("154227840");
                XElement content2  = XElement.Parse($"<c:axId val=\"{CategoryAxis.Id}\" xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\"/>");
                XElement content3  = XElement.Parse($"<c:axId val=\"{ValueAxis.Id}\" xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\"/>");
                XElement xElement2 = ChartXml.Element(XName.Get("gapWidth", DocX.c.NamespaceName));
                if (xElement2 != null)
                {
                    xElement2.AddAfterSelf(content3);
                    xElement2.AddAfterSelf(content2);
                }
                else
                {
                    ChartXml.Add(content2);
                    ChartXml.Add(content3);
                }
                xElement.Add(CategoryAxis.Xml);
                xElement.Add(ValueAxis.Xml);
            }
            ChartRootXml = Xml.Root.Element(XName.Get("chart", DocX.c.NamespaceName));
            ChartRootXml.Element(XName.Get("autoTitleDeleted", DocX.c.NamespaceName)).AddAfterSelf(xElement);
        }
예제 #2
0
        /// <summary>
        /// Create an Chart for this document
        /// </summary>
        public Chart()
        {
            // Create global xml
            Xml = XDocument.Parse
                      (@"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>
                   <c:chartSpace xmlns:c=""http://schemas.openxmlformats.org/drawingml/2006/chart"" xmlns:a=""http://schemas.openxmlformats.org/drawingml/2006/main"" xmlns:r=""http://schemas.openxmlformats.org/officeDocument/2006/relationships"">  
                       <c:roundedCorners val=""0""/>
                       <c:chart>
                           <c:autoTitleDeleted val=""0""/>
                           <c:plotVisOnly val=""1""/>
                           <c:dispBlanksAs val=""gap""/>
                           <c:showDLblsOverMax val=""0""/>
                       </c:chart>
                   </c:chartSpace>");

            // Create a real chart xml in an inheritor
            ChartXml = CreateChartXml();

            // Create result plotarea element
            XElement plotAreaXml = new XElement(
                XName.Get("plotArea", DocX.c.NamespaceName),
                new XElement(XName.Get("layout", DocX.c.NamespaceName)),
                ChartXml);

            // Set labels
            XElement dLblsXml = XElement.Parse(
                @"<c:dLbls xmlns:c=""http://schemas.openxmlformats.org/drawingml/2006/chart"">
                    <c:showLegendKey val=""0""/>
                    <c:showVal val=""0""/>
                    <c:showCatName val=""0""/>
                    <c:showSerName val=""0""/>
                    <c:showPercent val=""0""/>
                    <c:showBubbleSize val=""0""/>
                    <c:showLeaderLines val=""1""/>
                </c:dLbls>");

            ChartXml.Add(dLblsXml);

            // if axes exists, create their
            if (IsAxisExist)
            {
                CategoryAxis = new CategoryAxis("148921728");
                ValueAxis    = new ValueAxis("154227840");

                XElement axIDcatXml = XElement.Parse(String.Format(
                                                         @"<c:axId val=""{0}"" xmlns:c=""http://schemas.openxmlformats.org/drawingml/2006/chart""/>", CategoryAxis.Id));
                XElement axIDvalXml = XElement.Parse(String.Format(
                                                         @"<c:axId val=""{0}"" xmlns:c=""http://schemas.openxmlformats.org/drawingml/2006/chart""/>", ValueAxis.Id));

                ChartXml.Add(axIDcatXml);
                ChartXml.Add(axIDvalXml);

                plotAreaXml.Add(CategoryAxis.Xml);
                plotAreaXml.Add(ValueAxis.Xml);
            }

            ChartRootXml = Xml.Root.Element(XName.Get("chart", DocX.c.NamespaceName));
            ChartRootXml.Add(plotAreaXml);
        }
예제 #3
0
 public void AddLegend(ChartLegendPosition position, bool overlay)
 {
     if (Legend != null)
     {
         RemoveLegend();
     }
     Legend = new ChartLegend(position, overlay);
     ChartRootXml.Element(XName.Get("plotArea", DocX.c.NamespaceName)).AddAfterSelf(Legend.Xml);
 }
예제 #4
0
 /// <summary>
 /// Add a legend with parameters to the chart.
 /// </summary>
 public void AddLegend(ChartLegendPosition position, Boolean overlay)
 {
     if (Legend != null)
     {
         RemoveLegend();
     }
     Legend = new ChartLegend(position, overlay);
     ChartRootXml.Add(Legend.Xml);
 }
예제 #5
0
파일: Chart.cs 프로젝트: ywscr/DocXNETCore
 /// <summary>
 /// Add a legend with parameters to the chart.
 /// </summary>
 public void AddLegend(ChartLegendPosition position, Boolean overlay)
 {
     if (Legend != null)
     {
         RemoveLegend();
     }
     Legend = new ChartLegend(position, overlay);
     //ChartRootXml.Add(Legend.Xml);
     // Sourceman: seems to be necessary to keep track of the order of elements as defined in the schema (Word 2013)
     ChartRootXml.Element(XName.Get("plotArea", DocX.c.NamespaceName)).AddAfterSelf(Legend.Xml);
 }