2D Data Visualization Class

Sample Image

General.

CGraphView is a class that provides multiplot 2D data visualization. It is capable of simultaneous drawing for up to 32 2D plots.
CGraphView class is derived from CView MFC class and could be used as base class for different kinds of 2D data plot views. Features supported:
-Autoscale
-Zooming
-Fit width, height and page
-Mouse coordinates tracing
-Interactive add, remove and edit points
-Ability to add and display interactively up to 15000 points per second (depends on the speed of the computer)

Class interface.

Class interface provides several groups of functions:

    Graphs manipulation routines:

int AddGraph(COLORREF newColor = 0, char* title = "", BOOL bInvalidate = TRUE);
Function adds new graph to the view. Returns graph index if successful or -1 if not. If bInvalidate flag is set then view will be updated.

int RemoveGraph(int index, BOOL bInvalidate = TRUE);
Function removes graph from collection.

int UpdateGraph(int index, BOOL bInvalidate = TRUE);
Function updates graph information and view, if bInvalidate flag is set. Useful after collective operations with hidden graph.

CGraphProp* GetGraph(int index);
Function returns properties for the given graph or NULL in case of error.

CGraphProp* GetFirstGraph(int* index);
CGraphProp* GetNextGraph(int* index);
These functions are used to enumerate through all existing graphs in the view.

void SetGraphFlags(DWORD new_flags, BOOL bRedraw);
DWORD GetGraphFlags();
These functions are used to get or set graph view flags. Flag value is an OR'ed combination of:

#define GRAPH_AUTOSCALE 0x00000001    // use autoscale when adding new points
#define GRAPH_SQUAREPOINTS 0x00000002 // Draw rectangles around points
#define GRAPH_SHOW_TOOLTIP 0x00000004 // Show coordinates as a ToolTip when moving mouse #define GRAPH_DRAW_AXIS 0x00000008 //Draw axis


    Points manipulation routines:

int AddPoint(int graphnum, double x, double y, BOOL bRedraw, BOOL bUpdatePView, int index = -1);
Adds (if index == -1) or inserts new point to the graph. If bRedraw set - graph will be invalidated. If bUpdatePView set - then Point View List will be updated.

int EditPoint(int graphnum, int index, double x, double y, BOOL bRedraw);
Sets new point coordinates. If bRedraw set - invalidates graph.

int RemovePoint(int graphnum, int index, BOOL bRedraw);
Removes point from graph.

void ClearGraph(int graphnum, BOOL bRedraw, BOOL bUpdatePView);
removes all points from specified graph or from all graphs if graphnum == -1.


    Axis manipulation routines.

void SetAxisProps(char* _title, char* _UOM, int _precision, BOOL bXAxis, BOOL bRedraw);
Sets properties for axis. Properties include: Axis' title (_title), unit of measurement (_UOM) and precision - number of digits after comma (_precision). bXAxis parameter specify axis to apply attributes to and could be one of the following: GRAPH_X_AXIS or GRAPH_Y_AXIS.

void FormatAxisOutput(double value, BOOL bXAxis, int format_level, CString& res_str);
Returns formatted value parameter, regarding current axis' properties and format level. Currently three levels of format information are defined:
0 - minimum information.
1 - value and unit of measurement
2 - axis' title, value and unit of measurement


Point view list routines.

void ShowPointView(BOOL bShow);
Functions shows or hides point list.

BOOL GetPointViewState();
Returns current state of point view list.

void UpdatePointView();
Updates information in the point view list.

Class creation.

There are several steps that you should do in order to use this class in your application:
1. Include all graph files (except grres.rc) into your project.
2. Open grres.rc and copy following resources into your project resources:
    IDD_CHANGE_TITLE dialog
    IDD_GRAPH_AXISPROPS dialog
    IDD_GRAPH_GENPAGE dialog
    IDD_GRAPHS dialog
    IDD_GRAPHS_PROPPAGE dialog
    IDD_POINT_EDIT dialog
    IDR_GRAPH_PROPS menu
    IDR_PVIEW_RBMENU menu
    IDR_PVIEW_RBMENU_EMPTY menu
4. Derive your view class from CGraphView - and off we go!

Downloads

Download demo project - 107 Kb

Download source - 70 Kb

Latest updates and information could be found here.



Comments

  • Which Is The Best Herbal Product for Weak Structure and Lovemaking Dysfunction?

    Posted by agueffifielm on 06/21/2013 12:22am

    Do You Know many Dangers related with Counterfeit Oral Drug for Erectile Dysfunction Treatment? Rarely, males do practical experience muscle aches, especially in the back, right after they take the capsule [url=http://rxhealth.pw ] mail viagra [/url] find far more How to Stop Erectile Dysfunction

    Reply
  • Where can i get the newest version?

    Posted by Legacy on 06/06/2003 12:00am

    Originally posted by: Microsand

    Where can i get the newest version?
    

    Reply
  • Improve pan and zoom

    Posted by Legacy on 04/03/2003 12:00am

    Originally posted by:

    Add the following lines and the control is improved noticably - the mouse input is captured outside of the window.
    
    

    void CGraphPanel::OnLButtonDown(UINT nFlags, CPoint point)
    {
    //IWH: allow mouse to leave window and still have input
    SetCapture();
    ...


    void CGraphPanel::OnLButtonUp(UINT nFlags, CPoint point)
    {
    //IWH for mouse control outside of window
    if (GetCapture() == this)
    {
    ::ReleaseCapture();
    }
    ...

    Reply
  • Did you have following changes with the new version?

    Posted by Legacy on 07/11/2002 12:00am

    Originally posted by: chen

    Dear all,

    I used the new version of 2d Data visualisation class because it has better interface than the old ones.
    But i like the right button menu at the pointview part of the old version. I don't know why the right button menu, such as edit, delete, insert before, insert after, reflsh, copy as...be deleted at the new version? Also i need save the modified datas in the pointview as a txt file.

    Did you have any changes about these and help me realize this?

    Thanks in advance!

    Reply
  • How to get a point's coordinates by using a cursor ?

    Posted by Legacy on 09/14/2000 12:00am

    Originally posted by: BerLin

         Sorry!
    
    How to get a point's absolute coordinate by using a cursor (looks like a line)?
    How to get two points' releative coordinates by using two cursors ?
    How to show the absolute and releative coordinates in a moveable lable ?
    __________________________
    | | * ______________ |
    | . * ||Gpaph-1 ||
    | . | . || x=30.0, y=2.0||
    |. | ||dx=20.0,dy=0.5||
    | | ||______________||
    |` | | ` ` .|
    | ` | ` | ` ` |
    |__`_|____|________________|

    Thanks!

    Reply
  • Changes for large data sets

    Posted by Legacy on 02/17/2000 12:00am

    Originally posted by: Robert Bielik

    I noticed a problem when dealing with large data sets. The initialization of the List control takes
    
    a HUGE amount of time. Therefore I've changed the List control into being owner drawn. Then only the
    data currently visible in the list is retrieved, dynamically. Steps for this is given below:

    1. Open the IDD_GRAPHS dialog in the resource editor. Under the "More styles" properties for the
    list control, check the "Owner data" check box.

    2. Add the following line in pview.h:

    class CPointList : public CListCtrlEx
    {
    // Construction
    public:
    CPointList();

    [code snipped...]

    // Generated message map functions
    protected:
    //{{AFX_MSG(CPointList)
    afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
    //}}AFX_MSG
    >>>> afx_msg void OnGetDispInfo(NMHDR* pNMHDR, LRESULT* pResult); // Added 000211 Robert B.
    DECLARE_MESSAGE_MAP()
    };

    3. Add following in pview.cpp:

    BEGIN_MESSAGE_MAP(CPointList, CListCtrlEx)
    //{{AFX_MSG_MAP(CPointList)
    ON_WM_RBUTTONDOWN()
    ON_WM_LBUTTONDOWN()
    //}}AFX_MSG_MAP
    >> ON_NOTIFY_REFLECT(LVN_GETDISPINFO, OnGetDispInfo) // Added 000211 Robert B
    END_MESSAGE_MAP()

    /////////////////////////////////////////////////////////////////////////////
    // CPointList message handlers

    // OnGetDispInfo, added 000211 Robert B
    void CPointList::OnGetDispInfo(NMHDR* pNMHDR, LRESULT* pResult)
    {
    LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;

    CGraphView* grView = parentPtr->GetMainGraphView();
    CGraphProp* grprop = grView->GetGraph(parentPtr->m_CurrentGraph);
    if (grprop != NULL)
    {
    if (pDispInfo->item.mask & LVIF_TEXT)
    {
    SSinglePoint ssp;
    CString str;
    // Get data
    grprop->GetPoint(pDispInfo->item.iItem, &ssp);
    switch(pDispInfo->item.iSubItem)
    {
    case 0:
    grView->FormatAxisOutput(ssp.x, TRUE, 1, str);
    lstrcpy(pDispInfo->item.pszText, str);
    break;
    case 1:
    grView->FormatAxisOutput(ssp.y, FALSE, 1, str);
    lstrcpy(pDispInfo->item.pszText, str);
    break;
    default:
    break;
    }
    }
    }
    *pResult = 0;
    }

    4. Change CPointsView::InitListView() in pview.cpp:

    void CPointsView::InitListView()
    {
    INIT_WINDOW_MACRO;
    HIDE_WINDOW_MACRO;
    m_PointList.SetItemCount(0);
    if (m_CurrentGraph != -1 && parentView != NULL)
    {
    CGraphProp* grprop = parentView->GetGraph(m_CurrentGraph);
    if (grprop != NULL)
    {
    m_PointList.SetItemCount(grprop->GetSize());
    };
    };
    SHOW_WINDOW_MACRO;
    RedrawWindow();
    }

    5. Remove the code in the CPointsView::ChangePoint(...) and CPointsView::DeletePoint(...)

    void CPointsView::ChangePoint(SGraphChange* sgc)
    {
    /* This is not needed since data is owner drawn... 000211 Robert B
    just invalidate...
    */
    m_PointList.Invalidate();
    }

    void CPointsView::DeletePoint(SGraphChange* sgc)
    {
    /* This is not needed since data is owner drawn... 000211 Robert B
    */
    // Just remove one from count
    m_PointList.SetItemCountEx(m_PointList.GetItemCount() - 1);
    }

    That's it. Now, I'm not sure that all affected parts have been changed but this worked for me... ;-)

    /Robert Bielik


    Reply
  • How to draw dynamic graph? Help!!!

    Posted by Legacy on 02/06/2000 12:00am

    Originally posted by: Yigal Muttath

    Can any one tell me how can i draw dynamic graph using this
    classes i.e. shift the drawing to the left after
    it got to a specific scale,when any new point is added

    this is a call to an urgent help,please!!

    regards.

    Reply
  • how to draw my own graph?

    Posted by Legacy on 01/14/2000 12:00am

    Originally posted by: green bird

    Hi,
    
    

    what to do if i want to display my own graph using some data (instead of the graphs displayed by user)? where to set the data for points? and how to set them?

    Pls help! and pls drop me a message at:

    aibinbin@hotmail.com

    Thank u!

    Reply
  • How can I print?

    Posted by Legacy on 01/09/2000 12:00am

    Originally posted by: G�nther Abdinghoff

    It�s a very nice tool. But how can I print the graph.
    Has anyone a sample or informations how I can do it?
    Please send me a message.

    Thanks.

    Reply
  • 2D class in a dialog based application???

    Posted by Legacy on 12/11/1999 12:00am

    Originally posted by: Bobby Kennedy

    Hey there,
    
    

    I'm working on an application and want to
    incorporate the 2D Data Visualization class into it.
    Graphing is not the sole purpose of the application, just a
    feature - so I would like to be able popup up a dialog or a
    framewnd with the graph in it (based on data that I will,
    at graph creation time, pull from a database). My
    application is dialog based b/c the doc-view architecture is
    not necessary for it -- see the problem? I don't have a
    view class to derive from CGraphView.

    So I'm looking at manually creating a doc, a
    view, and a CFrameWnd (these would serve as the dialog with
    the graph in it), and then popping that up.

    Have you ever used the graph in a dialog based
    application? Is it possible? If so, how? Also, have you
    ever manually created a doc, view, and frame wnd by hand?
    If so, how do I go about it?


    Thanks a lot,

    Bobby Kennedy

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • On-demand Event Event Date: September 10, 2014 Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild." This loop of continuous delivery and continuous feedback is how the best mobile …

  • As mobile devices have pushed their way into the enterprise, they have brought cloud apps along with them. This app explosion means account passwords are multiplying, which exposes corporate data and leads to help desk calls from frustrated users. This paper will discover how IT can improve user productivity, gain visibility and control over SaaS and mobile apps, and stop password sprawl. Download this white paper to learn: How you can leverage your existing AD to manage app access. Key capabilities to …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds