BCGControlBar Pro for MFC

Detailed Description

The CBCGPChartObject class implements Chart Objects. A Chart Object is defined as an (currently rectangular) area on the Chart (CBCGPChartVisualObject). The area can be formatted as any other chart element with text (see BCGPChartFormatLabel).

Placement of a Chart Object on the Chart is defined by one or more coordinates (stored as a rectangle) and a coordinate mode. Currently you can use the following coordinate modes defined by CBCGPChartObject::CoordinateMode enumerator (the documentation uses left, top, right, bottom members of CBCGPRect object to describe Chart Object's coordinates):

  • CM_PERCENTS - coordinates are treated as offsets from left, right, top and bottom bounds of the Chart calculated in percents from the Chart size.
  • CM_PIXELS - coordinates are treated as offsets in pixels from the Chart bounds.
  • CM_PIXELS_FIXED_SIZE - left/top coordinates are treated as offset of object from the left/top diagram corner, object has fixed size in pixels; left - offset from left diagram bound in pixels, top - offset from top diagram bound in pixels, right - width in pixels, bottom - height in pixels.
  • CM_CHART_VALUES - coordinates are treated as values on related X (left, right) and Y (top, bottom) axes.
  • CM_CHART_VALUE_DIST_ANGLE - left - X value, top - Y value, right - distance, bottom - angle.
  • CM_AXIS_INSIDE_MARK - left - X value, top - Y value, right - distance in pixels from the point defined by X or Y axis values, bottom - distance in pixels from the related axis.
  • CM_AXIS_OUTSIDE_MARK - the same as CM_AXIS_INSIDE_MARK, but the distance is calculated in opposite direction.
  • Chart Objects in CM_CHART_VALUES and CM_CHART_VALUE_DIST_ANGLE coordinate modes are scrolled with chart diagram and are clipped by diagram area. Currently these coordinate modes do not work for Polar and Ternary chart types. These modes are not valid for Pie, Pyramid and Funnel charts.

See CBCGPChartAxisMarkObject for more information about CM_AXIS_INSIDE_MARK and CM_AXIS_OUTSIDE_MARK coordinate modes.

You can skip coordinates of left-top or right-bottom corners for text objects or objects with custom size (you intend to call SetObjectSize() method). You can skip left-right or top-bottom coordinates for horizontal or vertical lines, or colored ranges. In this case the missing coordinates are calculated automatically.

You can specify the missing coordinates using the following static members:

  • CBCGPChartObject::_EmptyCoordinate - empty value
  • CBCGPChartObject::_EmptyPoint - empty point
  • CBCGPChartObject::_EmptyRect - empty rectangle

The CBCGPChartVisualObject class provides the following helpers for the most commonly used object types:

See also
CBCGPChartTextObject, CBCGPChartRangeObject, CBCGPChartLineObject, CBCGPChartAxisMarkObject

The following code illustrates how to add a text object to the Chart. The text will be located at point (30, 120) in client coordinates (pixels).

CString strAnn = _T("Sample annotation string.");
CBCGPChartVisualObject* pChart = m_wndChart.GetChart();
CBCGPChartTextObject* pAnn = new CBCGPChartTextObject(pChart, strAnn, 30, 120, m_brText, m_brFill, m_brBorder);
// tell the object to use pixels
// format the object with the larger than the default text and enlarge content padding
pAnn->m_format.m_textFormat.Create(_T("Calibri"), 14);
// set rounded corners for bounding rectangle
// display shadow
// add object to the parent chart
+ Inheritance diagram for CBCGPChartObject:

Public Member Functions

 CBCGPChartObjectConstructs a CBCGPChartObject object.
 GetBoundingRectReturns a bounding rectangle of a Chart Object.
 GetCoordinateModeReturns current coordinate mode.
 GetCoordinatesReturns current coordinates of a Chart Object.
 GetDescriptionObtain a chart object's description.
 GetObjectSizeCall this method to retrieve custom Chart Object size.
 GetTooltipObtain a chart object's tooltip.
 HitTestHit tests an Chart Object.
 IsForegroundSpecifies whether a Chart Object is foreground, or background.
 IsObjectShownOnAxisTells whether an object is displayed on specified axis.
 IsVisibleTells whether a Chart Object is visible, or hidden.
 OnCalcScreenPointsCalled by the framework to calculate screen positions (in parent Chart client coordinates).
 OnDrawCalled by the framework when it needs to draw a Chart Object.
 SetAxisMarkCoordinateSets "axis mark" coordinate.
 SetCoordinateModeSets new coordinate mode.
 SetCoordinatesSets new coordinates.
 SetCoordinatesSets new coordinates.
 SetCoordinatesSets new coordinates.
 SetForegroundSets a Chart Object foreground or background.
 SetObjectSizeSets custom object size.
 SetParentChartSets the parent Chart.
 SetRelatedAxesSets related axes.
 SetTooltipSpecifies a chart object's tooltip.
 SetVisibleShows or hides a Chart Object.

Public Attributes

 m_formatSpecifies a Chart Object formatting options.
 m_nObjectIDSpecifies a Chart Object ID.
 m_strTextSpecifies Chart Object's text.

Protected Member Functions

 OnCalcObjectSizeCalled by the framework to calculate a Chart Object size.
 OnDrawShapeCalled to draw a Chart Object's shape.
 OnDrawTextCalled to draw a Chart Object's text.