zhao
2021-07-19 8347f2fbddbd25369359dcb2da1233ac48a19fdc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using System;
using System.Xml.Linq;
 
namespace Novacode
{
    /// <summary>
    /// Axis base class
    /// </summary>
    public abstract class Axis
    {
        /// <summary>
        /// ID of this Axis 
        /// </summary>
        public String Id
        {
            get
            {
                return Xml.Element(XName.Get("axId", DocX.c.NamespaceName)).Attribute(XName.Get("val")).Value;
            }
        }
 
        /// <summary>
        /// Return true if this axis is visible
        /// </summary>
        public Boolean IsVisible
        {
            get
            {
                return Xml.Element(XName.Get("delete", DocX.c.NamespaceName)).Attribute(XName.Get("val")).Value == "0";
            }
            set
            {
                if (value)
                    Xml.Element(XName.Get("delete", DocX.c.NamespaceName)).Attribute(XName.Get("val")).Value = "0";
                else
                    Xml.Element(XName.Get("delete", DocX.c.NamespaceName)).Attribute(XName.Get("val")).Value = "1";
            }
        }
 
        /// <summary>
        /// Axis xml element
        /// </summary>
        internal XElement Xml { get; set; }
 
        internal Axis(XElement xml)
        {
            Xml = xml;
        }
 
        public Axis(String id)
        { }
    }
 
    /// <summary>
    /// Represents Category Axes
    /// </summary>
    public class CategoryAxis : Axis
    {
        internal CategoryAxis(XElement xml)
            : base(xml)
        { }
 
        public CategoryAxis(String id)
            : base(id)
        {
            Xml = XElement.Parse(String.Format(
              @"<c:catAx xmlns:c=""http://schemas.openxmlformats.org/drawingml/2006/chart""> 
                <c:axId val=""{0}""/>
                <c:scaling>
                  <c:orientation val=""minMax""/>
                </c:scaling>
                <c:delete val=""0""/>
                <c:axPos val=""b""/>
                <c:majorTickMark val=""out""/>
                <c:minorTickMark val=""none""/>
                <c:tickLblPos val=""nextTo""/>
                <c:crossAx val=""154227840""/>
                <c:crosses val=""autoZero""/>
                <c:auto val=""1""/>
                <c:lblAlgn val=""ctr""/>
                <c:lblOffset val=""100""/>
                <c:noMultiLvlLbl val=""0""/>
              </c:catAx>", id));
        }
    }
 
    /// <summary>
    /// Represents Values Axes
    /// </summary>
    public class ValueAxis : Axis
    {
        internal ValueAxis(XElement xml)
            : base(xml)
        { }
 
        public ValueAxis(String id)
            : base(id)
        {
            Xml = XElement.Parse(String.Format(
              @"<c:valAx xmlns:c=""http://schemas.openxmlformats.org/drawingml/2006/chart"">
                <c:axId val=""{0}""/>
                <c:scaling>
                  <c:orientation val=""minMax""/>
                </c:scaling>
                <c:delete val=""0""/>
                <c:axPos val=""l""/>
                <c:numFmt sourceLinked=""0"" formatCode=""General""/>
                <c:majorGridlines/>
                <c:majorTickMark val=""out""/>
                <c:minorTickMark val=""none""/>
                <c:tickLblPos val=""nextTo""/>
                <c:crossAx val=""148921728""/>
                <c:crosses val=""autoZero""/>
                <c:crossBetween val=""between""/>
              </c:valAx>", id));
        }
    }
}