CChartCtrl Class Reference

The main chart control class. More...

#include <ChartCtrl.h>

List of all members.

Public Types

enum  EAxisPos { LeftAxis = 0, BottomAxis, RightAxis, TopAxis }
 An enumeration of the different axis positions.

Public Member Functions

CDC * GetDC ()
 Retrieves de device context.
CRect GetPlottingRect () const
 Retrieves the plotting rectangle.
CChartLegendGetLegend () const
 Returns a pointer to the legend object.
CChartTitleGetTitle () const
 Returns a pointer to the title object.
CChartStandardAxisCreateStandardAxis (EAxisPos axisPos)
 Create and attach a standard axis to the control.
CChartLogarithmicAxisCreateLogarithmicAxis (EAxisPos axisPos)
 Create and attach a logarithmic axis to the control.
CChartDateTimeAxisCreateDateTimeAxis (EAxisPos axisPos)
 Create and attach a date/time axis to the control.
void AttachCustomAxis (CChartAxis *pAxis, EAxisPos axisPos)
 Attach a custom axis to the control.
CChartPointsSerieCreatePointsSerie (bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)
 Create and attach a point series to the control.
CChartLineSerieCreateLineSerie (bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)
 Create and attach a line series to the control.
CChartSurfaceSerieCreateSurfaceSerie (bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)
 Create and attach a surface series to the control.
CChartBarSerieCreateBarSerie (bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)
 Create and attach a bar series to the control.
CChartCandlestickSerieCreateCandlestickSerie (bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)
 Create and attach a candlestick series to the control.
CChartGanttSerieCreateGanttSerie (bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)
 Create and attach a gantt series to the control.
void AttachCustomSerie (CChartSerie *pNewSeries, bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)
 Attaches a custom series to the chart.
CChartSerieGetSerie (unsigned uSerieId) const
 Retrieves a specific series from the chart.
void RemoveSerie (unsigned uSerieId)
 Removes a specific series from the chart.
void RemoveAllSeries ()
 Removes all the series from the chart.
size_t GetSeriesCount () const
 Returns the number of series in the chart.
CChartCrossHairCursorCreateCrossHairCursor (bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)
 Create and attach a cross-hair cursor to the control.
CChartDragLineCursorCreateDragLineCursor (EAxisPos relatedAxis)
 Create and attach a drag-line cursor to the control.
void AttachCustomCursor (CChartCursor *pCursor)
 Attach a custom cursor to the control.
void RemoveCursor (unsigned cursorId)
 Removes a cursor with a specific Id from the control.
void ShowMouseCursor (bool bShow)
 Shows/hides the mouse cursor when it is over the plotting area.
CChartAxisGetBottomAxis () const
CChartAxisGetLeftAxis () const
CChartAxisGetTopAxis () const
CChartAxisGetRightAxis () const
CChartAxisGetAxis (EAxisPos axisPos) const
 Returns a specific axis attached to the control.
UINT GetEdgeType () const
 Returns the type of the edge used as border.
void SetEdgeType (UINT NewEdge)
 Sets the edge type.
COLORREF GetBackColor () const
 Returns the background color.
void SetBackColor (COLORREF NewCol)
 Sets the background color.
COLORREF GetBorderColor () const
 Returns the color of the plotting area's border.
void SetBorderColor (COLORREF NewCol)
 Sets the color of the plotting area's border.
COLORREF GetZoomRectColor () const
 Returns the color of the zoom rectangle.
void SetZoomRectColor (COLORREF NewCol)
 Sets the color of the zoom rectangle.
void SetBackGradient (COLORREF Col1, COLORREF Col2, EGradientType GradientType)
 Sets a gradient background.
void SetPanEnabled (bool bEnabled)
 Enables/disables the pan feature.
bool GetPanEnabled () const
 Returns true if the pan feature is enabled.
void SetZoomEnabled (bool bEnabled)
 Enables/disables the zoom feature.
bool GetZoomEnabled () const
 Returns true if the zoom feature is enabled.
void UndoPanZoom ()
 Undo all pan and zoom operations that were done on the chart.
void RefreshCtrl ()
 Forces a refresh of the control.
void EnableRefresh (bool bEnable)
 Enables/disables the refresh of the control.
int Create (CWnd *pParentWnd, const RECT &rect, UINT nID, DWORD dwStyle=WS_VISIBLE)
 Creates the control dynamically.
virtual void Print (const TChartString &strTitle, CPrintDialog *pPrntDialog=NULL)
 Print the chart.
 CChartCtrl ()
 Default constructor.
virtual ~CChartCtrl ()
 Default destructor.
void RegisterMouseListener (CChartMouseListener *pMouseListener)
 Register a mouse listener with the control.
void GoToFirstSerie ()
 Tell the control to set the current series to the first series.
CChartSerieGetNextSerie ()
 Returns the next series in the control.
void RefreshScreenAutoAxes ()
 Refreshes all the axes which are automatic for the screen.

Static Public Member Functions

static double DateToValue (const COleDateTime &Date)
 Helper function to convert a date to a double value.
static COleDateTime ValueToDate (double Value)
 Helper function to convert a double value to a date.

Protected Member Functions

afx_msg void OnPaint ()
afx_msg BOOL OnEraseBkgnd (CDC *pDC)
afx_msg void OnSize (UINT nType, int cx, int cy)
afx_msg void OnMouseMove (UINT nFlags, CPoint point)
afx_msg void OnLButtonDown (UINT nFlags, CPoint point)
afx_msg void OnLButtonUp (UINT nFlags, CPoint point)
afx_msg void OnLButtonDblClk (UINT nFlags, CPoint point)
afx_msg void OnRButtonDown (UINT nFlags, CPoint point)
afx_msg void OnRButtonUp (UINT nFlags, CPoint point)
afx_msg void OnRButtonDblClk (UINT nFlags, CPoint point)
afx_msg void OnHScroll (UINT nSBCode, UINT nPos, CScrollBar *pScrollBar)
afx_msg void OnVScroll (UINT nSBCode, UINT nPos, CScrollBar *pScrollBar)
virtual void OnBeginPrinting (CDC *pDC, CPrintInfo *pInfo)
virtual void OnPrint (CDC *pDC, CPrintInfo *pInfo)
virtual void OnEndPrinting (CDC *pDC, CPrintInfo *pInfo)
virtual void DrawChart (CDC *pDC, CRect ChartRect)
virtual void DrawBackground (CDC *pDC, CRect ChartRect)


Detailed Description

The main chart control class.

Member Function Documentation

void CChartCtrl::AttachCustomAxis ( CChartAxis pAxis,
EAxisPos  axisPos 
)

Attach a custom axis to the control.

This function takes ownership of the axis pointer, so you must not destroy it. If the axis is alread attached to a chart control (even this one), the function will fail with an assertion. This function should be used only when you want to provide a custom axis to the control, otherwise you should use the AttachStandardAxis, AttachLogarithmicAxis and AttachDateTimeAxis instead.

Parameters:
pAxis The axis to attach to the control.
axisPos The position of the axis. This value can be:
  • LeftAxis
  • BottomAxis
  • RightAxis
  • TopAxis

void CChartCtrl::AttachCustomCursor ( CChartCursor pCursor  ) 

Attach a custom cursor to the control.

You should only use this function if you want to attach a custom cursor to the control. Otherwise, you should use the CreateXXXCursor helper functions.

Parameters:
pCursor The custom cursor to be attached to the control.

void CChartCtrl::AttachCustomSerie ( CChartSerie pNewSeries,
bool  bSecondaryHorizAxis = false,
bool  bSecondaryVertAxis = false 
)

Attaches a custom series to the chart.

You should only use this function if you want to attach a custom series to the control. Otherwise, you should use the CreateXXXSerie helper functions. The function will assert if the associated axes are not attached to the control.

Parameters:
pNewSeries The new series to be added. The control will take ownership of the pointer, so dont't delete it yourself.
bSecondaryHorizAxis Specifies if the associated horizontal axis is secondary or not. If this value is false, the associated horizontal axis is the bottom axis, otherwise it is the top axis.
bSecondaryVertAxis Specifies if the associated vertical axis is secondary or not. If this value is false, the associated vertical axis is the left axis, otherwise it is the right axis.

int CChartCtrl::Create ( CWnd *  pParentWnd,
const RECT &  rect,
UINT  nID,
DWORD  dwStyle = WS_VISIBLE 
)

Creates the control dynamically.

Parameters:
pParentWnd Parent window of the control
rect Position of the control
nID ID of the control
dwStyle Style of the control

CChartBarSerie * CChartCtrl::CreateBarSerie ( bool  bSecondaryHorizAxis = false,
bool  bSecondaryVertAxis = false 
)

Create and attach a bar series to the control.

Parameters:
bSecondaryHorizAxis Specifies if the horizontal axis is the secondary axis or not.
bSecondaryVertAxis Specifies if the vertical axis is the secondary axis or not.
Returns:
The created chart bar series.
Remarks:
The function will assert if the associated axes are not attached to the control.
See also:
AttachCustomSerie for more info about the parameters of the function.

CChartCandlestickSerie * CChartCtrl::CreateCandlestickSerie ( bool  bSecondaryHorizAxis = false,
bool  bSecondaryVertAxis = false 
)

Create and attach a candlestick series to the control.

Parameters:
bSecondaryHorizAxis Specifies if the horizontal axis is the secondary axis or not.
bSecondaryVertAxis Specifies if the vertical axis is the secondary axis or not.
Returns:
The created chart candlestick series.
Remarks:
The function will assert if the associated axes are not attached to the control.
See also:
AttachCustomSerie for more info about the parameters of the function.

CChartCrossHairCursor * CChartCtrl::CreateCrossHairCursor ( bool  bSecondaryHorizAxis = false,
bool  bSecondaryVertAxis = false 
)

Create and attach a cross-hair cursor to the control.

A cross-hair cursor display a cross on the control and move accordingly to the mouse. It is attached to an horizontal and a vertical axis.

Parameters:
bSecondaryHorizAxis Specifies if the horizontal axis is the secondary axis or not.
bSecondaryVertAxis Specifies if the vertical axis is the secondary axis or not.
Returns:
The created cross-hair cursor.
Remarks:
The function will assert if the associated axes are not attached to the control.

CChartDateTimeAxis * CChartCtrl::CreateDateTimeAxis ( EAxisPos  axisPos  ) 

Create and attach a date/time axis to the control.

Parameters:
axisPos The position of the axis.
Returns:
The created date/time axis.

CChartDragLineCursor * CChartCtrl::CreateDragLineCursor ( EAxisPos  relatedAxis  ) 

Create and attach a drag-line cursor to the control.

A drag-line cursor is a simple line (horizontal or vertical) that can be dragged with the mouse by clicking on it. It is attached to a specific axis.

Parameters:
relatedAxis The axis position to which the cursor is attached to.
Returns:
The created drag-line cursor.
Remarks:
The function will assert if the associated axis is not attached to the control.

CChartGanttSerie * CChartCtrl::CreateGanttSerie ( bool  bSecondaryHorizAxis = false,
bool  bSecondaryVertAxis = false 
)

Create and attach a gantt series to the control.

Parameters:
bSecondaryHorizAxis Specifies if the horizontal axis is the secondary axis or not.
bSecondaryVertAxis Specifies if the vertical axis is the secondary axis or not.
Returns:
The created chart gantt series.
Remarks:
The function will assert if the associated axes are not attached to the control.
See also:
AttachCustomSerie for more info about the parameters of the function.

CChartLineSerie * CChartCtrl::CreateLineSerie ( bool  bSecondaryHorizAxis = false,
bool  bSecondaryVertAxis = false 
)

Create and attach a line series to the control.

The function will assert if the associated axes are not attached to the control.

Parameters:
bSecondaryHorizAxis Specifies if the horizontal axis is the secondary axis or not.
bSecondaryVertAxis Specifies if the vertical axis is the secondary axis or not.
Returns:
The created chart line series.
Remarks:
The function will assert if the associated axes are not attached to the control.
See also:
AttachCustomSerie for more info about the parameters of the function.

CChartLogarithmicAxis * CChartCtrl::CreateLogarithmicAxis ( EAxisPos  axisPos  ) 

Create and attach a logarithmic axis to the control.

Parameters:
axisPos The position of the axis.
Returns:
The created logarithmic axis.

CChartPointsSerie * CChartCtrl::CreatePointsSerie ( bool  bSecondaryHorizAxis = false,
bool  bSecondaryVertAxis = false 
)

Create and attach a point series to the control.

Parameters:
bSecondaryHorizAxis Specifies if the horizontal axis is the secondary axis or not.
bSecondaryVertAxis Specifies if the vertical axis is the secondary axis or not.
Returns:
The created chart point series.
Remarks:
The function will assert if the associated axes are not attached to the control.
See also:
AttachCustomSerie for more info about the parameters of the function.

CChartStandardAxis * CChartCtrl::CreateStandardAxis ( EAxisPos  axisPos  ) 

Create and attach a standard axis to the control.

Parameters:
axisPos The position of the axis.
Returns:
The created standard axis.

CChartSurfaceSerie * CChartCtrl::CreateSurfaceSerie ( bool  bSecondaryHorizAxis = false,
bool  bSecondaryVertAxis = false 
)

Create and attach a surface series to the control.

The function will assert if the associated axes are not attached to the control.

Parameters:
bSecondaryHorizAxis Specifies if the horizontal axis is the secondary axis or not.
bSecondaryVertAxis Specifies if the vertical axis is the secondary axis or not.
Returns:
The created chart surface series.
Remarks:
The function will assert if the associated axes are not attached to the control.
See also:
AttachCustomSerie for more info about the parameters of the function.

void CChartCtrl::EnableRefresh ( bool  bEnable  ) 

Enables/disables the refresh of the control.

This function is used when several settings have to be changed at the same time on the control. This way we can avoid refreshing the control when it is not needed.

Parameters:
bEnable false to disable the refresh and true to re-enable the refresh.

CChartAxis* CChartCtrl::GetAxis ( EAxisPos  axisPos  )  const [inline]

Returns a specific axis attached to the control.

If the specified axis does not exist, NULL is returned.

Parameters:
axisPos The axis position (left, bottom, right or top).

CDC * CChartCtrl::GetDC (  ) 

Retrieves de device context.

This function is used for internal purposes only.

CChartSerie * CChartCtrl::GetNextSerie (  ) 

Returns the next series in the control.

This function is used with the GoToFirstSerie to iterate over all series in the control. First call GoToFirstSerie and then call this function until it returns NULL to iterate over all series. Warning: calling this function without calling GoToFirstSerie before might lead to unpredicted results. The same if you add or remove series between the call to GetFirstSerie and the call to GetNextSerie.

Returns:
the next series or NULL if we already are at the last series.

CChartSerie* CChartCtrl::GetSerie ( unsigned  uSerieId  )  const

Retrieves a specific series from the chart.

Parameters:
uSerieId The Id of the series to retrieve
Returns:
The series or NULL if uSerieId is not attributed.

void CChartCtrl::GoToFirstSerie (  ) 

Tell the control to set the current series to the first series.

This function is used with the GetNextSerie to iterate over all series in the control.

void CChartCtrl::Print ( const TChartString &  strTitle,
CPrintDialog *  pPrntDialog = NULL 
) [virtual]

Print the chart.

Parameters:
strTitle The title of the print document.
pPrntDialog A pointer to a CPrintDialog. If NULL is passed, the default print dialog will be displayed.

void CChartCtrl::RefreshCtrl (  ) 

Forces a refresh of the control.

This function is used for internal purposes.

void CChartCtrl::RegisterMouseListener ( CChartMouseListener pMouseListener  )  [inline]

Register a mouse listener with the control.

This listener will be notified each time a mouse event occurs on the control.

Parameters:
pMouseListener The mouse listener to register with this control.

void CChartCtrl::RemoveCursor ( unsigned  cursorId  ) 

Removes a cursor with a specific Id from the control.

The cursor Id can be retrieved on through the CChartCursor::GetCursorId function.

Parameters:
cursorId The Id of the cursor to remove from the control.

void CChartCtrl::RemoveSerie ( unsigned  uSerieId  ) 

Removes a specific series from the chart.

Parameters:
uSerieId The Id of the series to be removed.

void CChartCtrl::SetBackGradient ( COLORREF  Col1,
COLORREF  Col2,
EGradientType  GradientType 
)

Sets a gradient background.

Parameters:
Col1 The first gradient color
Col2 The second gradient color
GradientType The type of gradient used from Col1 to Col2. It can take the following values:
  • gtHorizontal: a simple left-to-right gradient, from Col1 to Col2.
  • gtVertical: a simple top-to-bottom gradient, from Col1 to Col2.
  • gtHorizontalDouble: a left-to-middle-to-right gradient, with Col2 in the middle.
  • gtVerticalDouble: a top-to-middle-to-bottom gradient, with Col2 in the middle.

void CChartCtrl::SetEdgeType ( UINT  NewEdge  )  [inline]

Sets the edge type.

Parameters:
NewEdge The type of the edge. See the DrawEdge function in MSDN for a list of the different types.


The documentation for this class was generated from the following files:

Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  doxygen 1.5.8