Skip to content
This repository has been archived by the owner on Mar 9, 2020. It is now read-only.

Implementing Error bars #528

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 43 additions & 2 deletions EPPlus/Drawing/Chart/ExcelBarChartSerie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
*
* Author Change Date
* ******************************************************************************
* Jan Källman Initial Release 2009-10-01
* Jan Källman License changed GPL-->LGPL 2011-12-16
* Jan Källman Initial Release 2009-10-01
* Jan Källman License changed GPL-->LGPL 2011-12-16
* Kris Wragg Added error bar functionality 2019-08-25
*******************************************************************************/
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -79,5 +80,45 @@ internal bool InvertIfNegative
SetXmlNodeBool(INVERTIFNEGATIVE_PATH, value);
}
}

/// <summary>
/// Returns the error bar or creates it if it does not exist
/// </summary>
public ExcelChartErrorBar ErrorBar
{
get
{
if (HasErrorBar == false)
{
_horizontalErrorBar = AddErrorBar();
}

return _horizontalErrorBar;
}
}

/// <summary>
/// Returns whether this series has an error bar associated with it
/// </summary>
public bool HasErrorBar
{
get
{
return _horizontalErrorBar != null;
}
}

/// <summary>
/// Deletes the associated error bar if it exists
/// </summary>
public void DeleteErrorBar()
{
if(HasErrorBar)
{
ExcelChartErrorBar errBar = _horizontalErrorBar;
errBar.TopNode.ParentNode.RemoveChild(errBar.TopNode);
_horizontalErrorBar = null;
}
}
}
}
58 changes: 56 additions & 2 deletions EPPlus/Drawing/Chart/ExcelChart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
*
* Author Change Date
*******************************************************************************
* Jan Källman Added 2009-10-01
* Jan Källman License changed GPL-->LGPL 2011-12-16
* Jan Källman Added 2009-10-01
* Jan Källman License changed GPL-->LGPL 2011-12-16
* Kris Wragg Added enums for error bars 2019-08-25
*******************************************************************************/
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -346,6 +347,59 @@ public enum eSizeRepresents
/// </summary>
Width
}

public enum eErrorBarType
{
/// <summary>
/// Specifies that error bars shall be shown in the positive and negative directions.
/// </summary>
Both,
/// <summary>
/// Specifies that error bars shall be shown in the negative direction only.
/// </summary>
Minus,
/// <summary>
/// Specifies that error bars shall be shown in the positive direction only.
/// </summary>
Plus
}

public enum eErrorBarDirection
{
/// <summary>
/// Specifies that error bars shall be shown in the x direction.
/// </summary>
X,
/// <summary>
/// Specifies that error bars shall be shown in the y direction.
/// </summary>
Y
}

public enum eErrorBarValueType
{
/// <summary>
/// Specifies that the length of the error bars shall be determined by the Plus and Minus elements.
/// </summary>
CustomErrorBars,
/// <summary>
/// Specifies that the length of the error bars shall be the fixed value determined by Error Bar Value.
/// </summary>
FixedValue,
/// <summary>
/// Specifies that the length of the error bars shall be Error Bar Value percent of the data.
/// </summary>
Percentage,
/// <summary>
/// Specifies that the length of the error bars shall be Error Bar Value standard deviations of the data.
/// </summary>
StandardDeviation,
/// <summary>
/// Specifies that the length of the error bars shall be Error Bar Value standard errors of the data.
/// </summary>
StandardError
}

#endregion
/// <summary>
/// Base class for Chart object.
Expand Down
Loading