BCGSuite for MFC
CBCGPChartAxisMarkObject

Detailed Description

The CBCGPChartAxisMarkObject class represents a Chart Object that can be placed near a related axis and specify some concrete value (or text).

This picture demonstrates an axis mark placed at Y axis value 5 to highlight the current value of horizontal line (see Chart Objects view in BCGPChartExample).

The following code adds an axis mark to the diagram using an CBCGPChartVisualObject::AddChartAxisMarkObject helper implemented in CBCGPChartVisualObject:

Copy
CBCGPChartVisualObject* pChart = m_wndChart.GetChart();
m_pMarkLine = pChart->AddChartAxisMarkObject(5.0, _T("5.0"), TRUE, TRUE, CBCGPBrush(), m_brAxisMarkFill);

Here we added a text "5.0" at value 5. of the vertical axis (TRUE) and display the mark outside the axis (TRUE).

The helper does not provide the ability to shift the axis mark object by a couple of pixels relative to axis position, but you can modify the coordinates of the base object to do so.

The following example shifts the axis mark by 10 pixels from the Y axis:

Copy
// get the current coordinates and modify them
CBCGPRect rcCoordinates = pMarkLine->GetCoordinates();
rcCoordinates.bottom = 10;
// set the coordinates back to the object preserving coordinate mode
pMarkLine->SetCoordinates(rcCoordinates, pMarkLine->GetCoordinateMode());

You can create a base Chart Object (CBCGPChartObject) as an axis mark. In this case the CoordinateMode enumerated value should be set to CBCGPChartObject::CM_AXIS_INSIDE_MARK or CBCGPChartObject::CM_AXIS_OUTSIDE_MARK. "Generic" coordinates passed as a rectangle to constructor or method CBCGPChartObject::SetCoordinates are interpreted as following:

The following code illustrates how to use the base object to define an axis mark at Y coordinate 5.:

Copy
CBCGPChartVisualObject* pChart = m_wndChart.GetChart();
// create the basic chart object
// set outside axis mark coordinate mode
// set coordinates for an axis mark located at the vertical axis (5. - axis coordinate, 2. - distance from axis)
pMarkLine->SetCoordinates(CBCGPChartObject::_EmptyCoordinate, 5., CBCGPChartObject::_EmptyCoordinate, 2.);
// format the object with the background brush
pMarkLine->m_format.m_brFillColor = m_brAxisMarkFill;
// set the text
pMarkLine->m_strText = "5.0";
// add the object to diagram
pChart->AddChartObject(pMarkLine);

The axis marks can be formatted using CBCGPChartObject::m_format as any other text label, e.g you can set fill color, outline color, text color, font and other attributes. See CBCGPChartObject::SetAxisMarkCoordinate helper, which shows another way to turn a Chart Object into "axis mark".

See also
CBCGPChartObject, BCGPChartFormatLabel, CBCGPChartVisualObject
+ Inheritance diagram for CBCGPChartAxisMarkObject:

Public Member Functions

 CBCGPChartAxisMarkObjectThe constructor.
 
- Public Member Functions inherited from CBCGPChartObject
 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.
 

Additional Inherited Members

- Public Attributes inherited from CBCGPChartObject
 m_formatSpecifies a Chart Object formatting options.
 
 m_nObjectIDSpecifies a Chart Object ID.
 
 m_strTextSpecifies Chart Object's text.
 
- Protected Member Functions inherited from CBCGPChartObject
 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.