SRGDataManager Class

class SRGDataManager

This class stores the data of a graph. The data is stored as a virtual 2-dimensional array of SRGrpahData object. The row of this array is called Group while the column is called Index. Each data object in this array can be accessed by group and index numbers. Even though you can get one row of data by using GetGroup() function, you can not get a whole column in one function call. You need to use each group to get the corresponding column. It is highly recommended that you always use the GetSafeData() function to access existing individual data objects. A standard SRGDataManager object is instantiated by the SRGraph constructor. If you need to customize the data manager, first create your custom SRGDataManager object and then pass this object to SRGraph object via its constructor or SetDataManager() function. You can setup the data for your chart using functions from either the SRGraph or SRGDataManager object. Note that a SRGDataManager object can be shared by several SRGraph objects.

Defined in: DataMgr.h

Class Members

CHART_API SRGDataManager()

Constructor

CHART_API virtual ~SRGDataManager()

Destructor that frees the internal memory

CHART_API void SetDefaultDataStyle(SRGraphStyle v)

Initialize the default data style

CHART_API SRGraphStyle * GetDefaultDataStyle()

Obtain the default data style

inline int GetDefaultGroup() const

Retrieves the number of the default group

inline void SetDefaultGroup(int nDefaultGroup)

Sets the number of the default group

CHART_API virtual SRGraphDataList* NewGroup()

Creates a new SRGraphDataList object on the application heap

CHART_API virtual void Serialize(CArchive &ar)

Serialize this object

CHART_API virtual void KillData()

Clear all the data inside this object

CHART_API virtual void SetValue(int index,int group,double number,BOOL bUseDefaultStyle = FALSE)

Add a numeric data item into the data array

CHART_API virtual void SetText(int index,int group,LPCTSTR text)

Add a text string for the indicating data item

CHART_API virtual void SetHeader(int group,LPCTSTR text,int nCode = 1)

Add a text string for the indicating group of data

CHART_API virtual SRGraphDataList * GetGroup(int group,BOOL GrowList = TRUE)

Obtain a pointer to a group with given group index

CHART_API virtual CScale GetAutoScaleRange(BOOL HiLo = FALSE)

Returns the maximum and minimum values stored in this graph

CHART_API virtual int GetMaxXDivisions()

Returns the count of the longest group

CHART_API virtual int GetGroupCount()

Returns the number of groups in this object

CHART_API CString GetGraphTitle(int code = 1)

Returns the title string of this class object

CHART_API CString GetText(int group,int index,int code = 1)

Returns the text string of the given data item

CHART_API CString GetHeader(int group,int code = 1)

Returns the text string of the given group

CHART_API double GetDataTotal(int group = -1)

Returns the sum of the data of the specified group

CHART_API virtual int GetDataCount(int nGroup, BOOL bGrowList = TRUE)

Returns the number of data items in the specified group

CHART_API virtual void SetGraphTitle(LPCTSTR title, int code = 1)

Set the title for this object

CHART_API virtual double GetGroupAverage(int group)

Returns the average value of the specified group

CHART_API virtual double GetIndexTotal(int index,int nMinGroup = 0,int nMaxGroup = 0)

Returns the sum of the data items with specified index and group range

CHART_API virtual double GetTotal()

Returns the sum of a the data item in this object

CHART_API virtual double GetGroupAverage(int MinIndex,int MaxIndex,int Group)

Returns the average value of the specified group and index range

CHART_API virtual double GetDataTotal(int mingroup, int minindex, int maxgroup, int maxindex)

Returns the sum of the data items in the specified group and index range

CHART_API virtual double GetValue(int index,int group)

Returns the numeric value of the specified data item

CHART_API virtual CPtrList * GetDataList()

Returns the whole data list

CHART_API virtual POSITION GetFirstDataPosition()

Returns the header position of the internal data list

CHART_API virtual void * GetNextData(POSITION& p)

Returns the next position in the internal data list

CHART_API virtual SRGraphAnnotationList * GetTitle()

Returns the whole title string list

CHART_API virtual void SetGlobalStyle(int nStartGroup,int nEndGroup,int nStartIndex,int nEndIndex,SRGraphStyle *ptrStyle,BOOL bSetHeaders = TRUE)

Set the style to all the specified data item

CHART_API virtual void RollGroup(int nGroup, double dValue = 0.0, BOOL bDirection = FALSE)

Rolls a group in the specified direction

CHART_API virtual SRGraphData * GetData(int index, int group)

Returns the data object in the specified position

CHART_API virtual SRGraphData* GetSafeData(int index, int group)

Returns the data object in the specified position

CHART_API virtual void InvalidateGroupPosition()

Reset the internal pointer position

CPtrList m_data

The data list -- contains a SRGraphDataList for each group

SRGraphAnnotationList m_strTitle

The graph title

SRGraphStyle m_DefaultDataStyle

The default data style object

POSITION m_LastPos

POSITION of last accessed data item -- used to enhance data access speed

int m_LastGroup

Group of last accessed data item -- used to enhance data access speed

SRGraphDummyData dummydata

Dummy chart data object that is returned in case none exists

int m_nDefaultGroup

Default group for all display types that use only one group -- pie charts, etc.