Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

Axis.cs 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*************************************************************************************
  2. DocX – DocX is the community edition of Xceed Words for .NET
  3. Copyright (C) 2009-2016 Xceed Software Inc.
  4. This program is provided to you under the terms of the Microsoft Public
  5. License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
  6. For more features and fast professional support,
  7. pick up Xceed Words for .NET at https://xceed.com/xceed-words-for-net/
  8. ***********************************************************************************/
  9. using System;
  10. using System.Xml.Linq;
  11. namespace Xceed.Words.NET
  12. {
  13. /// <summary>
  14. /// Axis base class
  15. /// </summary>
  16. public abstract class Axis
  17. {
  18. #region Public Properties
  19. /// <summary>
  20. /// ID of this Axis
  21. /// </summary>
  22. public String Id
  23. {
  24. get
  25. {
  26. return Xml.Element( XName.Get( "axId", DocX.c.NamespaceName ) ).Attribute( XName.Get( "val" ) ).Value;
  27. }
  28. }
  29. /// <summary>
  30. /// Return true if this axis is visible
  31. /// </summary>
  32. public Boolean IsVisible
  33. {
  34. get
  35. {
  36. return Xml.Element( XName.Get( "delete", DocX.c.NamespaceName ) ).Attribute( XName.Get( "val" ) ).Value == "0";
  37. }
  38. set
  39. {
  40. if( value )
  41. Xml.Element( XName.Get( "delete", DocX.c.NamespaceName ) ).Attribute( XName.Get( "val" ) ).Value = "0";
  42. else
  43. Xml.Element( XName.Get( "delete", DocX.c.NamespaceName ) ).Attribute( XName.Get( "val" ) ).Value = "1";
  44. }
  45. }
  46. #endregion
  47. #region Internal Properties
  48. /// <summary>
  49. /// Axis xml element
  50. /// </summary>
  51. internal XElement Xml
  52. {
  53. get; set;
  54. }
  55. #endregion
  56. #region Constructors
  57. internal Axis( XElement xml )
  58. {
  59. Xml = xml;
  60. }
  61. public Axis( String id )
  62. {
  63. }
  64. #endregion
  65. }
  66. /// <summary>
  67. /// Represents Category Axes
  68. /// </summary>
  69. public class CategoryAxis : Axis
  70. {
  71. internal CategoryAxis( XElement xml )
  72. : base( xml )
  73. {
  74. }
  75. public CategoryAxis( String id )
  76. : base( id )
  77. {
  78. Xml = XElement.Parse( String.Format(
  79. @"<c:catAx xmlns:c=""http://schemas.openxmlformats.org/drawingml/2006/chart"">
  80. <c:axId val=""{0}""/>
  81. <c:scaling>
  82. <c:orientation val=""minMax""/>
  83. </c:scaling>
  84. <c:delete val=""0""/>
  85. <c:axPos val=""b""/>
  86. <c:majorTickMark val=""out""/>
  87. <c:minorTickMark val=""none""/>
  88. <c:tickLblPos val=""nextTo""/>
  89. <c:crossAx val=""154227840""/>
  90. <c:crosses val=""autoZero""/>
  91. <c:auto val=""1""/>
  92. <c:lblAlgn val=""ctr""/>
  93. <c:lblOffset val=""100""/>
  94. <c:noMultiLvlLbl val=""0""/>
  95. </c:catAx>", id ) );
  96. }
  97. }
  98. /// <summary>
  99. /// Represents Values Axes
  100. /// </summary>
  101. public class ValueAxis : Axis
  102. {
  103. internal ValueAxis( XElement xml )
  104. : base( xml )
  105. {
  106. }
  107. public ValueAxis( String id )
  108. : base( id )
  109. {
  110. Xml = XElement.Parse( String.Format(
  111. @"<c:valAx xmlns:c=""http://schemas.openxmlformats.org/drawingml/2006/chart"">
  112. <c:axId val=""{0}""/>
  113. <c:scaling>
  114. <c:orientation val=""minMax""/>
  115. </c:scaling>
  116. <c:delete val=""0""/>
  117. <c:axPos val=""l""/>
  118. <c:numFmt sourceLinked=""0"" formatCode=""General""/>
  119. <c:majorGridlines/>
  120. <c:majorTickMark val=""out""/>
  121. <c:minorTickMark val=""none""/>
  122. <c:tickLblPos val=""nextTo""/>
  123. <c:crossAx val=""148921728""/>
  124. <c:crosses val=""autoZero""/>
  125. <c:crossBetween val=""between""/>
  126. </c:valAx>", id ) );
  127. }
  128. }
  129. }