Draw the chart

Drawing the chart is a very easy operation. The only thing that has to be considered is that CPlot expects everything to be in the LOMETRIC mapping mode. If you are not in the LOMETRIC mapping mode, you need to convert the plotting rectangle to LOMETRIC units before passing it to CPlot. Beyond that, you simply need to call the OnDraw member of the chart with the current device context, and the plotting rectangle (which need not be the entire view, but any portion of it you care to have the chart drawn in.) Your CView derived OnDraw function may look something like the following:
void CTestProjectView::OnDraw(CDC* pDC)
{
	CRect		clientRect;
	int			nOldMode;

	nOldMode = pDC->GetMapMode();

	GetClientRect( clientRect );

	nOldMode = pDC->SetMapMode( MM_LOMETRIC );

	pDC->DPtoLP( (LPPOINT) &clientRect, 2 );

	m_Chart.OnDraw( pDC, clientRect );

	pDC->SetMapMode( nOldMode );
}
If everything goes well, you should now be able to build and run your project (remember, if you haven't done a full rebuild since adding the resources, do so now.) When you run it, you should get a window that looks something like the following:

Note that the X and Y ranges were automatically set by CPlot. We didn't even need to do anything with them! And the markers are there, just as requested. And the titles. Cool. In many cases, that's all you'll ever have to do. But printing is also really easy with CPlot, as is obtaining contextual menu support.


Tutorial:


CPlot Reference