選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

BarChart.cs 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. #endregion
  70. #region Overrides
  71. protected override XElement CreateChartXml()
  72. {
  73. return XElement.Parse(
  74. @"<c:barChart xmlns:c=""http://schemas.openxmlformats.org/drawingml/2006/chart"">
  75. <c:barDir val=""col""/>
  76. <c:grouping val=""clustered""/>
  77. <c:gapWidth val=""150""/>
  78. </c:barChart>" );
  79. }
  80. #endregion
  81. }
  82. /// <summary>
  83. /// Specifies the possible directions for a bar chart.
  84. /// 21.2.3.3 ST_BarDir (Bar Direction)
  85. /// </summary>
  86. public enum BarDirection
  87. {
  88. [XmlName( "col" )]
  89. Column,
  90. [XmlName( "bar" )]
  91. Bar
  92. }
  93. /// <summary>
  94. /// Specifies the possible groupings for a bar chart.
  95. /// 21.2.3.4 ST_BarGrouping (Bar Grouping)
  96. /// </summary>
  97. public enum BarGrouping
  98. {
  99. [XmlName( "clustered" )]
  100. Clustered,
  101. [XmlName( "percentStacked" )]
  102. PercentStacked,
  103. [XmlName( "stacked" )]
  104. Stacked,
  105. [XmlName( "standard" )]
  106. Standard
  107. }
  108. }