Esempio n. 1
0
 /**
  * Builds CTAxDataSource object content from POI ChartDataSource.
  * @param ctAxDataSource OOXML data source to build
  * @param dataSource POI data source to use
  */
 public static void BuildAxDataSource <T>(CT_AxDataSource ctAxDataSource, IChartDataSource <T> dataSource)
 {
     if (dataSource.IsNumeric)
     {
         if (dataSource.IsReference)
         {
             BuildNumRef(ctAxDataSource.AddNewNumRef(), dataSource);
         }
         else
         {
             BuildNumLit(ctAxDataSource.AddNewNumLit(), dataSource);
         }
     }
     else
     {
         if (dataSource.IsReference)
         {
             BuildStrRef(ctAxDataSource.AddNewStrRef(), dataSource);
         }
         else
         {
             BuildStrLit(ctAxDataSource.AddNewStrLit(), dataSource);
         }
     }
 }
Esempio n. 2
0
            /// <summary>
            /// Returns last calculated number cache for X axis.
            /// </summary>
            //internal XSSFNumberCache LastCaculatedXCache
            //{
            //    get
            //    {
            //        return lastCaclulatedXCache;
            //    }
            //}
            /// <summary>
            /// Returns last calculated number cache for Y axis.
            /// </summary>
            //internal XSSFNumberCache LastCalculatedYCache
            //{
            //    get
            //    {
            //        return lastCalculatedYCache;
            //    }
            //}

            internal void AddToChart(CT_ScatterChart ctScatterChart)
            {
                CT_ScatterSer scatterSer = ctScatterChart.AddNewSer();

                scatterSer.AddNewIdx().val   = (uint)this.id;
                scatterSer.AddNewOrder().val = (uint)this.order;

                /* TODO: add some logic to automatically recognize cell
                 * types and choose appropriate data representation for
                 * X axis.
                 */
                /*CT_AxDataSource xVal = scatterSer.AddNewXVal();
                 * CT_NumRef xNumRef = xVal.AddNewNumRef();
                 * xNumRef.f = (xMarker.FormatAsString());
                 *
                 * CT_NumDataSource yVal = scatterSer.AddNewYVal();
                 * CT_NumRef yNumRef = yVal.AddNewNumRef();
                 * yNumRef.f = (yMarker.FormatAsString());
                 *
                 * if (useCache)
                 * {
                 *  // We can not store cache since markers are not immutable
                 *  XSSFNumberCache.BuildCache(xMarker, xNumRef);
                 *  lastCalculatedYCache = XSSFNumberCache.BuildCache(yMarker, yNumRef);
                 * }
                 */
                CT_AxDataSource xVal = scatterSer.AddNewXVal();

                XSSFChartUtil.BuildAxDataSource <Tx>(xVal, xs);
                CT_NumDataSource yVal = scatterSer.AddNewYVal();

                XSSFChartUtil.BuildNumDataSource <Ty>(yVal, ys);
            }
Esempio n. 3
0
            internal void AddToChart(CT_LineChart ctLineChart)
            {
                CT_LineSer  ctLineSer  = ctLineChart.AddNewSer();
                CT_Grouping ctGrouping = ctLineChart.AddNewGrouping();

                ctGrouping.val = ST_Grouping.standard;
                ctLineSer.AddNewIdx().val   = (uint)id;
                ctLineSer.AddNewOrder().val = (uint)order;

                // No marker symbol on the chart line.
                ctLineSer.AddNewMarker().AddNewSymbol().val = ST_MarkerStyle.none;

                CT_AxDataSource catDS = ctLineSer.AddNewCat();

                XSSFChartUtil.BuildAxDataSource(catDS, categories);
                CT_NumDataSource valueDS = ctLineSer.AddNewVal();

                XSSFChartUtil.BuildNumDataSource(valueDS, values);

                if (IsTitleSet)
                {
                    ctLineSer.tx = GetCTSerTx();
                }

                if (fillColor != null)
                {
                    ctLineSer.spPr = new OpenXmlFormats.Dml.Chart.CT_ShapeProperties();
                    CT_LineProperties           ctLineProperties           = ctLineSer.spPr.AddNewLn();
                    CT_SolidColorFillProperties ctSolidColorFillProperties = ctLineProperties.AddNewSolidFill();
                    CT_SRgbColor ctSRgbColor = ctSolidColorFillProperties.AddNewSrgbClr();
                    ctSRgbColor.val = fillColor;
                }
            }
Esempio n. 4
0
        public static CT_RadarSer Parse(XElement node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_RadarSer ctObj = new CT_RadarSer();

            ctObj.dPt    = new List <CT_DPt>();
            ctObj.extLst = new List <CT_Extension>();
            foreach (XElement childNode in node.ChildElements())
            {
                if (childNode.Name.LocalName == "idx")
                {
                    ctObj.idx = CT_UnsignedInt.Parse(childNode, namespaceManager);
                }
                else if (childNode.Name.LocalName == "order")
                {
                    ctObj.order = CT_UnsignedInt.Parse(childNode, namespaceManager);
                }
                else if (childNode.Name.LocalName == "tx")
                {
                    ctObj.tx = CT_SerTx.Parse(childNode, namespaceManager);
                }
                else if (childNode.Name.LocalName == "spPr")
                {
                    ctObj.spPr = CT_ShapeProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.Name.LocalName == "marker")
                {
                    ctObj.marker = CT_Marker.Parse(childNode, namespaceManager);
                }
                else if (childNode.Name.LocalName == "dLbls")
                {
                    ctObj.dLbls = CT_DLbls.Parse(childNode, namespaceManager);
                }
                else if (childNode.Name.LocalName == "cat")
                {
                    ctObj.cat = CT_AxDataSource.Parse(childNode, namespaceManager);
                }
                else if (childNode.Name.LocalName == "val")
                {
                    ctObj.val = CT_NumDataSource.Parse(childNode, namespaceManager);
                }
                else if (childNode.Name.LocalName == "dPt")
                {
                    ctObj.dPt.Add(CT_DPt.Parse(childNode, namespaceManager));
                }
                else if (childNode.Name.LocalName == "extLst")
                {
                    ctObj.extLst.Add(CT_Extension.Parse(childNode, namespaceManager));
                }
            }
            return(ctObj);
        }
Esempio n. 5
0
            internal void AddToChart(CT_ScatterChart ctScatterChart)
            {
                CT_ScatterSer scatterSer = ctScatterChart.AddNewSer();

                scatterSer.AddNewIdx().val   = (uint)this.id;
                scatterSer.AddNewOrder().val = (uint)this.order;

                CT_AxDataSource xVal = scatterSer.AddNewXVal();

                XSSFChartUtil.BuildAxDataSource <Tx>(xVal, xs);
                CT_NumDataSource yVal = scatterSer.AddNewYVal();

                XSSFChartUtil.BuildNumDataSource <Ty>(yVal, ys);

                if (IsTitleSet)
                {
                    scatterSer.tx = this.GetCTSerTx();
                }
            }
Esempio n. 6
0
        public static CT_SurfaceSer Parse(XmlNode node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_SurfaceSer ctObj = new CT_SurfaceSer();

            ctObj.extLst = new List <CT_Extension>();
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.LocalName == "idx")
                {
                    ctObj.idx = CT_UnsignedInt.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "order")
                {
                    ctObj.order = CT_UnsignedInt.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "tx")
                {
                    ctObj.tx = CT_SerTx.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "spPr")
                {
                    ctObj.spPr = CT_ShapeProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "cat")
                {
                    ctObj.cat = CT_AxDataSource.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "val")
                {
                    ctObj.val = CT_NumDataSource.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "extLst")
                {
                    ctObj.extLst.Add(CT_Extension.Parse(childNode, namespaceManager));
                }
            }
            return(ctObj);
        }
            internal void AddToChart(CT_LineChart ctLineChart)
            {
                CT_LineSer ctLineSer = ctLineChart.AddNewSer();

                ctLineSer.AddNewIdx().val   = (uint)id;
                ctLineSer.AddNewOrder().val = (uint)order;

                // No marker symbol on the chart line.
                ctLineSer.AddNewMarker().AddNewSymbol().val = ST_MarkerStyle.none;

                CT_AxDataSource catDS = ctLineSer.AddNewCat();

                XSSFChartUtil.BuildAxDataSource(catDS, categories);
                CT_NumDataSource valueDS = ctLineSer.AddNewVal();

                XSSFChartUtil.BuildNumDataSource(valueDS, values);

                if (IsTitleSet)
                {
                    ctLineSer.tx = GetCTSerTx();
                }
            }
Esempio n. 8
0
            internal void AddToChart(CT_BarChart ctBarChart)
            {
                CT_BarSer      ctBarSer   = ctBarChart.AddNewSer();
                CT_BarGrouping ctGrouping = ctBarChart.AddNewGrouping();

                ctGrouping.val = ST_BarGrouping.clustered;
                ctBarSer.AddNewIdx().val        = (uint)id;
                ctBarSer.AddNewOrder().val      = (uint)order;
                CT_Boolean ctNoInvertIfNegative = new CT_Boolean();

                ctNoInvertIfNegative.val  = 0;
                ctBarSer.invertIfNegative = ctNoInvertIfNegative;

                CT_BarDir ctBarDir = ctBarChart.AddNewBarDir();

                ctBarDir.val = ST_BarDir.col;

                CT_AxDataSource catDS = ctBarSer.AddNewCat();

                XSSFChartUtil.BuildAxDataSource(catDS, categories);
                CT_NumDataSource valueDS = ctBarSer.AddNewVal();

                XSSFChartUtil.BuildNumDataSource(valueDS, values);

                if (IsTitleSet)
                {
                    ctBarSer.tx = GetCTSerTx();
                }

                if (fillColor != null)
                {
                    ctBarSer.spPr = new OpenXmlFormats.Dml.Chart.CT_ShapeProperties();
                    CT_SolidColorFillProperties ctSolidColorFillProperties = ctBarSer.spPr.AddNewSolidFill();
                    CT_SRgbColor ctSRgbColor = ctSolidColorFillProperties.AddNewSrgbClr();
                    ctSRgbColor.val = fillColor;
                }
            }
Esempio n. 9
0
        public static CT_BubbleSer Parse(XElement node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_BubbleSer ctObj = new CT_BubbleSer();

            ctObj.dPt       = new List <CT_DPt>();
            ctObj.trendline = new List <CT_Trendline>();
            ctObj.errBars   = new List <CT_ErrBars>();
            ctObj.extLst    = new List <CT_Extension>();
            foreach (XElement childNode in node.ChildElements())
            {
                if (childNode.Name.LocalName == "idx")
                {
                    ctObj.idx = CT_UnsignedInt.Parse(childNode, namespaceManager);
                }
                else if (childNode.Name.LocalName == "order")
                {
                    ctObj.order = CT_UnsignedInt.Parse(childNode, namespaceManager);
                }
                else if (childNode.Name.LocalName == "tx")
                {
                    ctObj.tx = CT_SerTx.Parse(childNode, namespaceManager);
                }
                else if (childNode.Name.LocalName == "spPr")
                {
                    ctObj.spPr = CT_ShapeProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.Name.LocalName == "invertIfNegative")
                {
                    ctObj.invertIfNegative = CT_Boolean.Parse(childNode, namespaceManager);
                }
                else if (childNode.Name.LocalName == "dLbls")
                {
                    ctObj.dLbls = CT_DLbls.Parse(childNode, namespaceManager);
                }
                else if (childNode.Name.LocalName == "xVal")
                {
                    ctObj.xVal = CT_AxDataSource.Parse(childNode, namespaceManager);
                }
                else if (childNode.Name.LocalName == "yVal")
                {
                    ctObj.yVal = CT_NumDataSource.Parse(childNode, namespaceManager);
                }
                else if (childNode.Name.LocalName == "bubbleSize")
                {
                    ctObj.bubbleSize = CT_NumDataSource.Parse(childNode, namespaceManager);
                }
                else if (childNode.Name.LocalName == "bubble3D")
                {
                    ctObj.bubble3D = CT_Boolean.Parse(childNode, namespaceManager);
                }
                else if (childNode.Name.LocalName == "dPt")
                {
                    ctObj.dPt.Add(CT_DPt.Parse(childNode, namespaceManager));
                }
                else if (childNode.Name.LocalName == "trendline")
                {
                    ctObj.trendline.Add(CT_Trendline.Parse(childNode, namespaceManager));
                }
                else if (childNode.Name.LocalName == "errBars")
                {
                    ctObj.errBars.Add(CT_ErrBars.Parse(childNode, namespaceManager));
                }
                else if (childNode.Name.LocalName == "extLst")
                {
                    ctObj.extLst.Add(CT_Extension.Parse(childNode, namespaceManager));
                }
            }
            return(ctObj);
        }
Esempio n. 10
0
        public static CT_ScatterSer Parse(XmlNode node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_ScatterSer ctObj = new CT_ScatterSer();

            ctObj.dPt       = new List <CT_DPt>();
            ctObj.trendline = new List <CT_Trendline>();
            ctObj.errBars   = new List <CT_ErrBars>();
            ctObj.extLst    = new List <CT_Extension>();
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.LocalName == "idx")
                {
                    ctObj.idx = CT_UnsignedInt.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "order")
                {
                    ctObj.order = CT_UnsignedInt.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "tx")
                {
                    ctObj.tx = CT_SerTx.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "spPr")
                {
                    ctObj.spPr = CT_ShapeProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "marker")
                {
                    ctObj.marker = CT_Marker.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "dLbls")
                {
                    ctObj.dLbls = CT_DLbls.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "xVal")
                {
                    ctObj.xVal = CT_AxDataSource.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "yVal")
                {
                    ctObj.yVal = CT_NumDataSource.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "smooth")
                {
                    ctObj.smooth = CT_Boolean.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "dPt")
                {
                    ctObj.dPt.Add(CT_DPt.Parse(childNode, namespaceManager));
                }
                else if (childNode.LocalName == "trendline")
                {
                    ctObj.trendline.Add(CT_Trendline.Parse(childNode, namespaceManager));
                }
                else if (childNode.LocalName == "errBars")
                {
                    ctObj.errBars.Add(CT_ErrBars.Parse(childNode, namespaceManager));
                }
                else if (childNode.LocalName == "extLst")
                {
                    ctObj.extLst.Add(CT_Extension.Parse(childNode, namespaceManager));
                }
            }
            return(ctObj);
        }
Esempio n. 11
0
 public CT_AxDataSource AddNewXVal()
 {
     this.xValField = new CT_AxDataSource();
     return(this.xValField);
 }
Esempio n. 12
0
 public CT_AxDataSource AddNewCat()
 {
     this.catField = new CT_AxDataSource();
     return(this.catField);
 }
Esempio n. 13
0
        public static CT_BarSer Parse(XmlNode node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_BarSer ctObj = new CT_BarSer();

            ctObj.dPt       = new List <CT_DPt>();
            ctObj.trendline = new List <CT_Trendline>();
            ctObj.extLst    = new List <CT_Extension>();
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.LocalName == "idx")
                {
                    ctObj.idx = CT_UnsignedInt.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "order")
                {
                    ctObj.order = CT_UnsignedInt.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "tx")
                {
                    ctObj.tx = CT_SerTx.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "spPr")
                {
                    ctObj.spPr = CT_ShapeProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "invertIfNegative")
                {
                    ctObj.invertIfNegative = CT_Boolean.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "pictureOptions")
                {
                    ctObj.pictureOptions = CT_PictureOptions.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "dLbls")
                {
                    ctObj.dLbls = CT_DLbls.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "errBars")
                {
                    ctObj.errBars = CT_ErrBars.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "cat")
                {
                    ctObj.cat = CT_AxDataSource.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "val")
                {
                    ctObj.val = CT_NumDataSource.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "shape")
                {
                    ctObj.shape = CT_Shape.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "dPt")
                {
                    ctObj.dPt.Add(CT_DPt.Parse(childNode, namespaceManager));
                }
                else if (childNode.LocalName == "trendline")
                {
                    ctObj.trendline.Add(CT_Trendline.Parse(childNode, namespaceManager));
                }
                else if (childNode.LocalName == "extLst")
                {
                    ctObj.extLst.Add(CT_Extension.Parse(childNode, namespaceManager));
                }
            }
            return(ctObj);
        }