Click here to Skip to main content
15,893,401 members
Articles / Desktop Programming / MFC

High-speed Charting Control

Rate me:
Please Sign up or sign in to vote.
4.95/5 (327 votes)
13 Jul 2010CPOL35 min read 4.2M   100.6K   788  
A flexible charting control to display 2D data
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>ChartDemo: CChartBarSerie Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
      <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>CChartBarSerie Class Reference</h1><!-- doxytag: class="CChartBarSerie" --><!-- doxytag: inherits="CChartXYSerie" -->Specialization of a <a class="el" href="class_c_chart_serie.html" title="Abstract class that provides a common &quot;interface&quot; for all series in the...">CChartSerie</a> to display a bars series.  
<a href="#_details">More...</a>
<p>
<code>#include &lt;<a class="el" href="_chart_bar_serie_8h-source.html">ChartBarSerie.h</a>&gt;</code>
<p>
<div class="dynheader">
Inheritance diagram for CChartBarSerie:</div>
<div class="dynsection">

<p><center><img src="class_c_chart_bar_serie.png" usemap="#CChartBarSerie_map" border="0" alt=""></center>
<map name="CChartBarSerie_map">
<area href="class_c_chart_x_y_serie.html" alt="CChartXYSerie" shape="rect" coords="0,112,219,136">
<area href="class_c_chart_serie_base.html" alt="CChartSerieBase< SChartXYPoint >" shape="rect" coords="0,56,219,80">
<area href="class_c_chart_serie.html" alt="CChartSerie" shape="rect" coords="0,0,219,24">
</map>
</div>

<p>
<a href="class_c_chart_bar_serie-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="05cae99f4f8c3c413913f0ee55f1cddc"></a><!-- doxytag: member="CChartBarSerie::CChartBarSerie" ref="05cae99f4f8c3c413913f0ee55f1cddc" args="(CChartCtrl *pParent)" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_c_chart_bar_serie.html#05cae99f4f8c3c413913f0ee55f1cddc">CChartBarSerie</a> (<a class="el" href="class_c_chart_ctrl.html">CChartCtrl</a> *pParent)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Constructor. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="f17c82f287b9e3bdcb0bfb44740c085b"></a><!-- doxytag: member="CChartBarSerie::~CChartBarSerie" ref="f17c82f287b9e3bdcb0bfb44740c085b" args="()" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_c_chart_bar_serie.html#f17c82f287b9e3bdcb0bfb44740c085b">~CChartBarSerie</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Destructor. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="20ce485665c27c0b9a645e77721da93c"></a><!-- doxytag: member="CChartBarSerie::SetHorizontal" ref="20ce485665c27c0b9a645e77721da93c" args="(bool bHorizontal)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_c_chart_bar_serie.html#20ce485665c27c0b9a645e77721da93c">SetHorizontal</a> (bool bHorizontal)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Specifies if the bars are vertical or horizontal. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="870117e88804601968a15176b5b00625"></a><!-- doxytag: member="CChartBarSerie::GetHorizontal" ref="870117e88804601968a15176b5b00625" args="() const " -->
bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_c_chart_bar_serie.html#870117e88804601968a15176b5b00625">GetHorizontal</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns true if bars are horizontal, false otherwise. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="f936ce9f2e08c89e3e1fdee221fdd2e9"></a><!-- doxytag: member="CChartBarSerie::SetBorderColor" ref="f936ce9f2e08c89e3e1fdee221fdd2e9" args="(COLORREF BorderColor)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_c_chart_bar_serie.html#f936ce9f2e08c89e3e1fdee221fdd2e9">SetBorderColor</a> (COLORREF BorderColor)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Sets the bars border color. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="30b9d6b27438a8040cc40d68e7ff74ae"></a><!-- doxytag: member="CChartBarSerie::GetBorderColor" ref="30b9d6b27438a8040cc40d68e7ff74ae" args="() const " -->
COLORREF&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_c_chart_bar_serie.html#30b9d6b27438a8040cc40d68e7ff74ae">GetBorderColor</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns the bars border color. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="d106f77a1fca397d7cf091b9322bbf84"></a><!-- doxytag: member="CChartBarSerie::SetBorderWidth" ref="d106f77a1fca397d7cf091b9322bbf84" args="(int Width)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_c_chart_bar_serie.html#d106f77a1fca397d7cf091b9322bbf84">SetBorderWidth</a> (int Width)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Sets the bars border width. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="1b3e0cb1970bb22e045628780a6218ae"></a><!-- doxytag: member="CChartBarSerie::GetBorderWidth" ref="1b3e0cb1970bb22e045628780a6218ae" args="() const " -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_c_chart_bar_serie.html#1b3e0cb1970bb22e045628780a6218ae">GetBorderWidth</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns the bars border width. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="47ed2782d775df69aa5018a85f44ed41"></a><!-- doxytag: member="CChartBarSerie::SetBarWidth" ref="47ed2782d775df69aa5018a85f44ed41" args="(int Width)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_c_chart_bar_serie.html#47ed2782d775df69aa5018a85f44ed41">SetBarWidth</a> (int Width)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Sets the bars width (in pixels). <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="8e4ab7a0af3097d935922f12ba9c4f3d"></a><!-- doxytag: member="CChartBarSerie::GetBarWidth" ref="8e4ab7a0af3097d935922f12ba9c4f3d" args="() const " -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_c_chart_bar_serie.html#8e4ab7a0af3097d935922f12ba9c4f3d">GetBarWidth</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns the bars width (in pixels). <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_c_chart_bar_serie.html#6d3435c3aed16932f8e7eff77dccdd15">SetGroupId</a> (unsigned GroupId)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set the group Id of the series.  <a href="#6d3435c3aed16932f8e7eff77dccdd15"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="49f2d1b1359904abbdc526e2f0ef1f79"></a><!-- doxytag: member="CChartBarSerie::GetGroupId" ref="49f2d1b1359904abbdc526e2f0ef1f79" args="() const " -->
unsigned&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_c_chart_bar_serie.html#49f2d1b1359904abbdc526e2f0ef1f79">GetGroupId</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns the group Id of the series. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_c_chart_bar_serie.html#e71413d96c465b3817f1a3e38f172991">SetStacked</a> (bool bStacked)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Specifies if the series is stacked with other bar series.  <a href="#e71413d96c465b3817f1a3e38f172991"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="4471f2073992b01919342a128b9ffbbe"></a><!-- doxytag: member="CChartBarSerie::IsStacked" ref="4471f2073992b01919342a128b9ffbbe" args="()" -->
bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_c_chart_bar_serie.html#4471f2073992b01919342a128b9ffbbe">IsStacked</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns true if the series is stacked. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="97475ad09ac06af0d9b0a719eaa4cc9a"></a><!-- doxytag: member="CChartBarSerie::ShowGradient" ref="97475ad09ac06af0d9b0a719eaa4cc9a" args="(bool bShow)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_c_chart_bar_serie.html#97475ad09ac06af0d9b0a719eaa4cc9a">ShowGradient</a> (bool bShow)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Specifies if a gradient is applied to the bars. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_c_chart_bar_serie.html#64f4107f6c697c104a09ff53e3b1d424">SetGradient</a> (COLORREF GradientColor, EGradientType GradientType)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Sets the gradient style.  <a href="#64f4107f6c697c104a09ff53e3b1d424"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_c_chart_bar_serie.html#03c8e2170ffe73224bb2434613e484e5">SetBaseLine</a> (bool bAutomatic, double dBaseLine)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Specifies a base line for the bars.  <a href="#03c8e2170ffe73224bb2434613e484e5"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_c_chart_bar_serie.html#49c4128340700712f2be11449d59cfee">IsPointOnSerie</a> (const CPoint &amp;screenPoint, unsigned &amp;uIndex) const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Check whether a screen point is on the series.  <a href="#49c4128340700712f2be11449d59cfee"></a><br></td></tr>
<tr><td colspan="2"><br><h2>Static Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="9f45f9eb57c9e5ece67adac71b4fffe1"></a><!-- doxytag: member="CChartBarSerie::SetInterSpace" ref="9f45f9eb57c9e5ece67adac71b4fffe1" args="(int Space)" -->
static void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_c_chart_bar_serie.html#9f45f9eb57c9e5ece67adac71b4fffe1">SetInterSpace</a> (int Space)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Static function used to specify the space (in pixels) between series of the same group. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a127aeb7d339f6ea056573b37e9c6998"></a><!-- doxytag: member="CChartBarSerie::GetInterSpace" ref="a127aeb7d339f6ea056573b37e9c6998" args="()" -->
static int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_c_chart_bar_serie.html#a127aeb7d339f6ea056573b37e9c6998">GetInterSpace</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Static function returning the space between series of the same group. <br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Specialization of a <a class="el" href="class_c_chart_serie.html" title="Abstract class that provides a common &quot;interface&quot; for all series in the...">CChartSerie</a> to display a bars series. 
<p>
This class is a specialized series class used to display vertical (default) or horizontal bars. Each bar in the series is centered around its X value (for vertical bars) or Y value (for horizontal bars). Bars can be grouped together, so that they do not overlap but are stacked next to each other (or on top of each other). This is done by specifying a group Id: bar series with the same group Id will be grouped together (stacked). Series with different group Id will be independant (they will be drawn as if they were the only one, meaning that the different series will probably overlap). <hr><h2>Member Function Documentation</h2>
<a class="anchor" name="49c4128340700712f2be11449d59cfee"></a><!-- doxytag: member="CChartBarSerie::IsPointOnSerie" ref="49c4128340700712f2be11449d59cfee" args="(const CPoint &amp;screenPoint, unsigned &amp;uIndex) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool CChartBarSerie::IsPointOnSerie           </td>
          <td>(</td>
          <td class="paramtype">const CPoint &amp;&nbsp;</td>
          <td class="paramname"> <em>screenPoint</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned &amp;&nbsp;</td>
          <td class="paramname"> <em>uIndex</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td> const<code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Check whether a screen point is on the series. 
<p>
This function returns true if the screen point is on one of the bars of the series. In that case, the index of the point is stored in the uIndex parameter. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>screenPoint</em>&nbsp;</td><td>The screen point to test </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>uIndex</em>&nbsp;</td><td>If the point is close to a specific point of the series, its index is stored here. </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>true if the point is on the series </dd></dl>

<p>Implements <a class="el" href="class_c_chart_serie.html#941aec6162f5b449fc570bc5063fb076">CChartSerie</a>.</p>

</div>
</div><p>
<a class="anchor" name="03c8e2170ffe73224bb2434613e484e5"></a><!-- doxytag: member="CChartBarSerie::SetBaseLine" ref="03c8e2170ffe73224bb2434613e484e5" args="(bool bAutomatic, double dBaseLine)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void CChartBarSerie::SetBaseLine           </td>
          <td>(</td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>bAutomatic</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">double&nbsp;</td>
          <td class="paramname"> <em>dBaseLine</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Specifies a base line for the bars. 
<p>
If a baseline is specified, the bars will be drawn between that value and the point value, instead of being drawn between the axis ans the point value. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>bAutomatic</em>&nbsp;</td><td>If true, the bars are drawn between the axis and the point value. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>dBaseLine</em>&nbsp;</td><td>The value of the baseline. This parameter is ignored if bAutomatic is true. </td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="64f4107f6c697c104a09ff53e3b1d424"></a><!-- doxytag: member="CChartBarSerie::SetGradient" ref="64f4107f6c697c104a09ff53e3b1d424" args="(COLORREF GradientColor, EGradientType GradientType)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void CChartBarSerie::SetGradient           </td>
          <td>(</td>
          <td class="paramtype">COLORREF&nbsp;</td>
          <td class="paramname"> <em>GradientColor</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">EGradientType&nbsp;</td>
          <td class="paramname"> <em>GradientType</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Sets the gradient style. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>GradientColor</em>&nbsp;</td><td>The second color used for the gradient (the first one being the original series color). </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>GradientType</em>&nbsp;</td><td>The type of gradient used between the two colors (vertical, horizontal, ...) </td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="6d3435c3aed16932f8e7eff77dccdd15"></a><!-- doxytag: member="CChartBarSerie::SetGroupId" ref="6d3435c3aed16932f8e7eff77dccdd15" args="(unsigned GroupId)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void CChartBarSerie::SetGroupId           </td>
          <td>(</td>
          <td class="paramtype">unsigned&nbsp;</td>
          <td class="paramname"> <em>GroupId</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Set the group Id of the series. 
<p>
The group Id allows to stack series next to each other (or on top of each other). 
</div>
</div><p>
<a class="anchor" name="e71413d96c465b3817f1a3e38f172991"></a><!-- doxytag: member="CChartBarSerie::SetStacked" ref="e71413d96c465b3817f1a3e38f172991" args="(bool bStacked)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void CChartBarSerie::SetStacked           </td>
          <td>(</td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>bStacked</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Specifies if the series is stacked with other bar series. 
<p>
All bar series with the same group Id and with the stacked flag to true will be drawn on top of each other (for vertical bars). 
</div>
</div><p>
<hr>The documentation for this class was generated from the following files:<ul>
<li>E:/Sources Misc/ChartDemo/ChartCtrl/<a class="el" href="_chart_bar_serie_8h-source.html">ChartBarSerie.h</a><li>E:/Sources Misc/ChartDemo/ChartCtrl/ChartBarSerie.cpp</ul>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer
Belgium Belgium
I am a 29 years old guy and I live with my girlfriend in Hoegaarden, little city from Belgium well known for its white beer Smile | :) .
I studied as an industrial engineer in electronics but I oriented myself more towards software development when I started to work.
Currently I am working in a research centre in mechatronica. I mainly develop in C++ but I also do a bit of Java.
When I have so spare time, I like to read (mainly fantasy) and play electric guitar.

Comments and Discussions