KwikPeg Manuals
Home
PegChart
Examples
Examples
Index
Index


Members
Styles
Signals
(none)
Overview Derived from class PegThing

The PegChart class, although itself a derived class, is the base class for all of the charts in the KwikPeg Library. The PegChart is a virtual base class. Hence, it is not possible to instantiate a PegChart object directly.

The purpose of the PegChart class is to provide a framework for its derived children. It provides extended styles which ease the construction of charts. It also provides the services needed to draw charts with optional tick marks, value labels and grid lines along the X axis and/or Y axis.

To use the PegChart class or its derivatives, your KwikPeg configuration must have the following option enabled:
  Drawing: Charts



 See Also

PegLineChart

PegMultiLineChart

PegStripChart



 Styles

The PegChart class supports the following extended style flags:

CS_AUTOSIZE  If this flag is set, the chart will always take up the entire mClient region of its parent. When the parent is resized or moved, the PegChart object also resizes itself appropriately.
CS_DRAWXGRID  Draw grid lines along the X axis in the chart region.
CS_DRAWYGRID  Draw grid lines along the Y axis in the chart region.
CS_DRAWXTICS  Draw tick marks along the X axis at the specified intervals.
CS_DRAWYTICS  Draw tick marks along the Y axis at the specified intervals.
CS_DRAWXLABELS  Draw incremental value labels along the X axis below the chart. The label values are based on the minimum and maximum possible values of X.
CS_DRAWYLABELS  Draw incremental value labels along the Y axis to the left of the chart. The label values are based on the minimum and maximum possible values of Y.
CS_DUALYLABELS  Draw Y axis value labels along both the left and right edges of the chart. This style flag is ignored if the CS_DRAWYLABELS style flag is not also set.
CS_DUALYTICS  Draw Y axis tick marks along both the left and right edges of the chart. This style flag is ignored if the CS_DRAWYTICS style flag is not also set.
CS_DRAWLINEFILL  Fill the area between the trace lines and the (x,y=0) axis with the currently specified fill color.
CS_XAXISONZEROY  Draw the X axis along the Y=0 axis instead of below the chart. This style flag is ignored if the CS_DRAWXTICS style flag is not also set.

Top of page


 Members

Constructors:

PegChart(const PegRect &Rect,
  LONG lMinX, LONG lMaxX,
  LONG lMinY, LONG lMaxY,
  WORD wMajorXScale = 0,
  WORD wMajorYScale = 0)

This constructor creates a derived chart in the rectangle specified by parameter Rect. If style flag CS_AUTOSIZE is to be used (see function SetExStyle()), you may want to draw the chart in the parent's mClient rectangle.

Parameters lMinX and lMaxX specify the minimum and maximum X (horizontal) values. Parameters lMinY and lMaxY specify the minimum and maximum Y (vertical) values. Data points which lie outside these ranges, although not rejected, will not be viewable in the chart rectangle.

Parameters wMajorXScale and wMajorYScale define the intervals along the X and Y axes respectively at which major tick marks will be drawn. Of course, tick marks are only drawn if the object's CS_DRAWXTICS or CS_DRAWYTICS extended style flag is set.

For example, if the minimum Y value is -100, the maximum Y value is 900, the Y scale is 100 and the CS_DRAWYTICS extended style flag is set, then tick marks will be drawn on the Y axis at intervals of 100 starting at -100 and ending at 900. Consequently, there will be 11 tick marks drawn on the Y axis. If the CS_DRAWYGRID extended style flag is also set, horizontal grid lines will also be drawn at the same tick mark intervals.

The interval at which axis label values are drawn is independent of the tick mark/grid line scaling interval. Hence, tick marks might appear at intervals of 100 with the axis values labeled at intervals of 200.

 

Public Functions:

virtual void Draw(void)

The PegChart class overrides the Draw() function to draw the background color of the chart area and the optional tick marks, value labels and grid lines.

PegRect GetChartRegion() const

This function returns the rectangle which indicates the location on the screen at which the chart is being drawn. If the CS_AUTOSIZE extended style flag is set, the rectangle will be based on the position and size of the chart's parent. The chart and its tick marks and labels, if needed, will be drawn within this rectangle.

WORD GetExStyle(void) const

This function returns the current extended style flags value from variable mwExStyle.

PegFont *GetFont(void) const

This function returns a pointer to the current font being used to draw X and Y axis labels.

WORD GetMajorTicSize(void) const
WORD GetMinorTicSize(void) const

These functions return the number of pixels used for the length of a major and minor tick mark. Hence, this value represents the height of an X axis tick mark and the width of a Y axis tick mark.

WORD GetMajorXScale(void) const
WORD GetMajorYScale(void) const

These functions return the interval at which tick marks and grid lines are drawn along the X and Y axis.

LONG GetMaxX(void) const
LONG GetMaxY(void) const

These functions return the maximum allowable value for X and Y.

WORD GetMinorXScale(void) const
WORD GetMinorYScale(void) const

These functions return the interval at which minor tick marks are drawn along the X and Y axis.

LONG GetMinX(void) const
LONG GetMinY(void) const

These functions return the minimum allowable value for X and Y.

WORD GetXLabelHeight(void) const

This function returns the height of the labels drawn along the X axis.

WORD GetXLabelScale(void) const
WORD GetYLabelScale(void) const

These functions return the interval at which value labels are drawn along the X and Y axis.

WORD GetYLabelWidth(void) const

This function returns the width of the labels drawn along the Y axis.

virtual void MapDataToPoint(PegChartPoint *pPoint)

This function converts the data point held in the private PegChartPoint structure referenced by pPoint to screen coordinates. The conversion accounts for the size of the chart region and the ranges allowed for X and Y values. The screen coordinates are stored in the PegChartPoint structure. This function is used only by the KwikPeg derived chart classes.

virtual void MapPointToData(PegChartPoint *pPoint)

This function converts the screen coordinates held in the private PegChartPoint structure referenced by pPoint to a data point value. The conversion uses the size of the chart region and the ranges allowed for X and Y values. The data point value is stored in the PegChartPoint structure. This function is used only by the KwikPeg derived chart classes.

virtual SIGNED Message(const PegMessage &Mesg)

The PegChart class overrides the Message() function to recalculate the chart location or layout when its parent is moved or resized.

virtual void RecalcLayout(BOOL bRedraw = TRUE)

This function calculates the layout of the chart in preparation for rendering the chart on the screen. If parameter bRedraw is TRUE, the visible display is updated. This function is used only by the KwikPeg derived chart classes.

virtual void RecalcSize(
  const PegRect &NewRect,
  BOOL bRedraw = TRUE)

This function resets the chart's location and size as specified by the the rectangle NewRect. The function then calls the RecalcLayout() function passing it the bRedraw flag. This function is used only by the KwikPeg derived chart classes.

void SetExStyle(WORD wStyle)

This function sets the current extended style flags maintained in variable mwExStyle to the value specified by wStyle. The style flag value is generated by ORing the style flag masks to identify the features which the chart must support.

void SetFont(PegFont *pFont)

This function sets the font to be used for drawing axis labels to the font referenced by pFont.

void SetMajorTicSize(WORD wSize)
void SetMinorTicSize(WORD wSize)

These functions set the number of pixels used for the length of a major and minor tick mark. Parameter wSize represents the height of an X axis tick mark and the width of a Y axis tick mark. The default value for a major tick is 12 pixels. The default value for a minor tick is 8 pixels.

void SetMajorXScale(WORD wScale)
void SetMajorYScale(WORD wScale)

These functions set the interval at which tick marks and grid lines will be drawn along the X and Y axis.

void SetMaxX(LONG lData)
void SetMaxY(LONG lData)

These functions set the maximum value for X and Y.

void SetMinorXScale(WORD wScale)
void SetMinorYScale(WORD wScale)

These functions set the interval at which minor tick marks will be drawn along the X and Y axis.

void SetMinX(LONG lData)
void SetMinY(LONG lData)

These functions set the minimum value for X and Y.

void SetXLabelHeight(WORD wHeight)

This function sets the height of the labels drawn along the X axis.

void SetXLabelScale(WORD wScale)
void SetYLabelScale(WORD wScale)

These functions set the interval at which value labels will be drawn along the X and Y axis.

void SetYLabelWidth(WORD wWidth)

This function sets the width of the labels drawn along the Y axis.


Top of page


 Examples

Objects of the PegChart class are not directly instantiable. See the single line chart (PegLineChart), the multiline chart (PegMultiLineChart) and the strip chart (PegStripChart) for examples of classes derived from the PegChart class.




Top of page
KwikPeg Manuals
Home
Index
Index

 
Copyright © 2000-2003