Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2839_HiveProjectManagement/HeuristicLab.ExtLibs/HeuristicLab.EPPlus/4.0.3/EPPlus-4.0.3/Drawing/Chart/ExcelScatterChart.cs @ 15761

Last change on this file since 15761 was 12074, checked in by sraggl, 10 years ago

#2341: Added EPPlus-4.0.3 to ExtLibs

File size: 6.2 KB
Line 
1/*******************************************************************************
2 * You may amend and distribute as you like, but don't remove this header!
3 *
4 * EPPlus provides server-side generation of Excel 2007/2010 spreadsheets.
5 * See http://www.codeplex.com/EPPlus for details.
6 *
7 * Copyright (C) 2011  Jan Källman
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
17 * See the GNU Lesser General Public License for more details.
18 *
19 * The GNU Lesser General Public License can be viewed at http://www.opensource.org/licenses/lgpl-license.php
20 * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
21 *
22 * All code and executables are provided "as is" with no warranty either express or implied.
23 * The author accepts no liability for any damage or loss of business that this product may cause.
24 *
25 * Code change notes:
26 *
27 * Author             Change            Date
28 * ******************************************************************************
29 * Jan Källman    Initial Release           2009-10-01
30 * Jan Källman    License changed GPL-->LGPL 2011-12-16
31 *******************************************************************************/
32using System;
33using System.Collections.Generic;
34using System.Text;
35using System.Xml;
36using OfficeOpenXml.Table.PivotTable;
37
38namespace OfficeOpenXml.Drawing.Chart
39{
40    /// <summary>
41    /// Provides access to scatter chart specific properties
42    /// </summary>
43    public sealed class ExcelScatterChart : ExcelChart
44    {
45        internal ExcelScatterChart(ExcelDrawings drawings, XmlNode node, eChartType type, ExcelChart topChart, ExcelPivotTable PivotTableSource) :
46            base(drawings, node, type, topChart, PivotTableSource)
47        {
48            SetTypeProperties();
49        }
50
51        internal ExcelScatterChart(ExcelDrawings drawings, XmlNode node, Uri uriChart, Packaging.ZipPackagePart part, XmlDocument chartXml, XmlNode chartNode) :
52            base(drawings, node, uriChart, part, chartXml, chartNode)
53        {
54            SetTypeProperties();
55        }
56
57        internal ExcelScatterChart(ExcelChart topChart, XmlNode chartNode) :
58            base(topChart, chartNode)
59        {
60            SetTypeProperties();
61        }
62        private void SetTypeProperties()
63        {
64           /***** ScatterStyle *****/
65           if(ChartType == eChartType.XYScatter ||
66              ChartType == eChartType.XYScatterLines ||
67              ChartType == eChartType.XYScatterLinesNoMarkers)
68           {
69               ScatterStyle = eScatterStyle.LineMarker;
70          }
71           else if (
72              ChartType == eChartType.XYScatterSmooth ||
73              ChartType == eChartType.XYScatterSmoothNoMarkers)
74           {
75               ScatterStyle = eScatterStyle.SmoothMarker;
76           }
77        }
78        #region "Grouping Enum Translation"
79        string _scatterTypePath = "c:scatterStyle/@val";
80        private eScatterStyle GetScatterEnum(string text)
81        {
82            switch (text)
83            {
84                case "smoothMarker":
85                    return eScatterStyle.SmoothMarker;
86                default:
87                    return eScatterStyle.LineMarker;
88            }
89        }
90
91        private string GetScatterText(eScatterStyle shatterStyle)
92        {
93            switch (shatterStyle)
94            {
95                case eScatterStyle.SmoothMarker:
96                    return "smoothMarker";
97                default:
98                    return "lineMarker";
99            }
100        }
101        #endregion
102        /// <summary>
103        /// If the scatter has LineMarkers or SmoothMarkers
104        /// </summary>
105        public eScatterStyle ScatterStyle
106        {
107            get
108            {
109                return GetScatterEnum(_chartXmlHelper.GetXmlNodeString(_scatterTypePath));
110            }
111            internal set
112            {
113                _chartXmlHelper.CreateNode(_scatterTypePath, true);
114                _chartXmlHelper.SetXmlNodeString(_scatterTypePath, GetScatterText(value));
115            }
116        }
117        string MARKER_PATH = "c:marker/@val";
118        /// <summary>
119        /// If the series has markers
120        /// </summary>
121        public bool Marker
122        {
123            get
124            {
125                return GetXmlNodeBool(MARKER_PATH, false);
126            }
127            set
128            {
129                SetXmlNodeBool(MARKER_PATH, value, false);
130            }
131        }
132        internal override eChartType GetChartType(string name)
133        {
134            if (name == "scatterChart")
135            {
136                if (ScatterStyle==eScatterStyle.LineMarker)
137                {
138                    if (((ExcelScatterChartSerie)Series[0]).Marker == eMarkerStyle.None)
139                    {
140                        return eChartType.XYScatterLinesNoMarkers;
141                    }
142                    else
143                    {
144                        if(ExistNode("c:ser/c:spPr/a:ln/noFill"))
145                        {
146                            return eChartType.XYScatter;
147                        }
148                        else
149                        {
150                            return eChartType.XYScatterLines;
151                        }
152                    }
153                }
154                else if (ScatterStyle == eScatterStyle.SmoothMarker)
155                {
156                    if (((ExcelScatterChartSerie)Series[0]).Marker == eMarkerStyle.None)
157                    {
158                        return eChartType.XYScatterSmoothNoMarkers;
159                    }
160                    else
161                    {
162                        return eChartType.XYScatterSmooth;
163                    }
164                }
165            }
166            return base.GetChartType(name);
167        }
168
169    }
170}
Note: See TracBrowser for help on using the repository browser.