Beispiel #1
0
        /// <summary>
        /// Adds a color to the specified serie. Not supported in <c>EPPlus</c> library.
        /// </summary>
        /// <param name="model">Serie from model.</param>
        /// <exception cref="System.ArgumentNullException">If <paramref name="model" /> is <c>null</c>.</exception>
        public static void AddSerieColor(ChartSerieModel model)
        {
            SentinelHelper.ArgumentNull(model);

            var xmlSerieList = ChartXmlHelper.GetElementsByTagName("c:v");
            var textNode     = xmlSerieList.FirstOrDefault(n => n.ParentNode.ParentNode.Name.Equals("ser") && n.InnerText.Equals(model.Name));

            if (textNode == null)
            {
                return;
            }

            var charType = model.ChartType;

            switch (charType)
            {
            case KnownChartType.Pie3D:
                break;

            default:
                var areaChartSeriesNode = textNode.ParentNode.ParentNode;
                areaChartSeriesNode.AddShapePropertiesNode(model);
                break;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Converts a <see cref="OfficeOpenXml.Drawing.Chart.ExcelChartAxis"/> objects to <see cref="System.Array"/> elements of type <see cref="System.Xml.XmlNode"/>.
        /// </summary>
        /// <param name="axes"><see cref="OfficeOpenXml.Drawing.Chart.ExcelChartAxis"/> objects.</param>
        /// <returns>
        /// List of nodes equivalent a <see cref="OfficeOpenXml.Drawing.Chart.ExcelChartAxis"/> objects.
        /// </returns>
        /// <exception cref="System.ComponentModel.InvalidEnumArgumentException">If <paramref name="axes" /> not belong to enumeration.</exception>
        public static IEnumerable <XmlNode> ToAxisXmlFrom(IEnumerable <ExcelChartAxis> axes)
        {
            SentinelHelper.ArgumentNull(axes);

            var xmlAxisNodeList = new List <XmlNode>
            {
                ChartXmlHelper.FromKnownChartElement(KnownChartElement.PrimaryCategoryAxis),
                ChartXmlHelper.FromKnownChartElement(KnownChartElement.PrimaryValueAxis),
            };

            var catAxisXmlNodes = ChartXmlHelper.GetElementsByTagName("c:catAx");

            if (catAxisXmlNodes.Count() <= 1)
            {
                return(xmlAxisNodeList);
            }

            xmlAxisNodeList.Add(ChartXmlHelper.FromKnownChartElement(KnownChartElement.SecondaryCategoryAxis));
            xmlAxisNodeList.Add(ChartXmlHelper.FromKnownChartElement(KnownChartElement.SecondaryValueAxis));

            return(xmlAxisNodeList);
        }