Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

BarChart.cs 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. /// This element contains the 2-D bar or column series on this chart.
  15. /// 21.2.2.16 barChart (Bar Charts)
  16. /// </summary>
  17. public class BarChart : Chart
  18. {
  19. #region Public Properties
  20. /// <summary>
  21. /// Specifies the possible directions for a bar chart.
  22. /// </summary>
  23. public BarDirection BarDirection
  24. {
  25. get
  26. {
  27. return XElementHelpers.GetValueToEnum<BarDirection>(
  28. ChartXml.Element(XName.Get("barDir", DocX.c.NamespaceName)));
  29. }
  30. set
  31. {
  32. XElementHelpers.SetValueFromEnum<BarDirection>(
  33. ChartXml.Element(XName.Get("barDir", DocX.c.NamespaceName)), value);
  34. }
  35. }
  36. /// <summary>
  37. /// Specifies the possible groupings for a bar chart.
  38. /// </summary>
  39. public BarGrouping BarGrouping
  40. {
  41. get
  42. {
  43. return XElementHelpers.GetValueToEnum<BarGrouping>(
  44. ChartXml.Element(XName.Get("grouping", DocX.c.NamespaceName)));
  45. }
  46. set
  47. {
  48. XElementHelpers.SetValueFromEnum<BarGrouping>(
  49. ChartXml.Element(XName.Get("grouping", DocX.c.NamespaceName)), value);
  50. }
  51. }
  52. /// <summary>
  53. /// Specifies that its contents contain a percentage between 0% and 500%.
  54. /// </summary>
  55. public Int32 GapWidth
  56. {
  57. get
  58. {
  59. return Convert.ToInt32(
  60. ChartXml.Element(XName.Get("gapWidth", DocX.c.NamespaceName)).Attribute(XName.Get("val")).Value);
  61. }
  62. set
  63. {
  64. if ((value < 1) || (value > 500))
  65. throw new ArgumentException("GapWidth lay between 0% and 500%!");
  66. ChartXml.Element(XName.Get("gapWidth", DocX.c.NamespaceName)).Attribute(XName.Get("val")).Value = value.ToString();
  67. }
  68. }
  69. public string Title
  70. {
  71. set
  72. {
  73. var t = new XElement(CXName("t"), "CCCC");
  74. var rpr = new XElement(CXName("rPr"), CAttr("lang", "zh-CN"), CAttr("altLang", "en-US"));
  75. var p = CElement("p",CElement())
  76. }
  77. }
  78. #endregion
  79. #region Overrides
  80. protected override XElement CreateChartXml()
  81. {
  82. return XElement.Parse(
  83. @"<c:barChart xmlns:c=""http://schemas.openxmlformats.org/drawingml/2006/chart"">
  84. <c:barDir val=""col""/>
  85. <c:grouping val=""clustered""/>
  86. <c:gapWidth val=""150""/>
  87. </c:barChart>");
  88. }
  89. #endregion
  90. }
  91. /// <summary>
  92. /// Specifies the possible directions for a bar chart.
  93. /// 21.2.3.3 ST_BarDir (Bar Direction)
  94. /// </summary>
  95. public enum BarDirection
  96. {
  97. [XmlName("col")]
  98. Column,
  99. [XmlName("bar")]
  100. Bar
  101. }
  102. /// <summary>
  103. /// Specifies the possible groupings for a bar chart.
  104. /// 21.2.3.4 ST_BarGrouping (Bar Grouping)
  105. /// </summary>
  106. public enum BarGrouping
  107. {
  108. [XmlName("clustered")]
  109. Clustered,
  110. [XmlName("percentStacked")]
  111. PercentStacked,
  112. [XmlName("stacked")]
  113. Stacked,
  114. [XmlName("standard")]
  115. Standard
  116. }
  117. }