You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Axis.cs 3.5KB

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