Add a Chart Object to your view

Now that you have Added the CPlot files and resources to your project, you will want to add a chart object to your document or view class. Where that might go is up to you. If you will be wanting to save and restore the chart object, then it is best that it goes in the document class. If you just are using the chart object for display, put it in your view class. For the purposes of this example, we'll put the chart object in the view class.

Edit the header file of your view class, and add the following line before the class declaration:

#include "Chart.h"
This needs to be included in the header file since in the variable declaration, you'll add a reference to a chart object. In fact, do that now, and what you'll end up with is something that may look a little something like this:

#include "Chart.h"

class CTestProjectView : public CView
{
protected: // create from serialization only
	CTestProjectView();
	DECLARE_DYNCREATE(CTestProjectView)

// Attributes
public:
	CTestProjectDoc* GetDocument();

	CXYChart		m_Chart;
	// ... more declarations and stuff below
Here I've chosen to include an XY chart, but it could just as easily have been an Image Chart.
Tutorial:


CPlot Reference