Scroll Chart Control


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

Click here for larger image

Environment: Win2K SP2, VC6 SP4

Simply, this is a chart with support for "history". For bugs and improvements mail me, Thz.

The class has the following features:

  • Any number of lines.
  • Different styles, colors and width for each line.
  • Unlimited number of points per line, or you can put limit if you want.
  • Configurable grid.
  • Hscroll.
  • Automatic adjustment to vertical values.
  • ...

How to use

1. Declare a CScrollChart object -- it's a template you must use to specify a type of data.

CScrollChart< float > m_wndChart;

2. Use Create (See help file for values).

m_wndChart.Create( WS_VISIBLE | GS_NOTIFY, 

3. Add lines.

m_wndChart.AddLine(ID_LINE1, RGB(255,0,0));
m_wndChart.AddLine(ID_LINE2, RGB(0,0,255), LS_POINT | LS_HORZAUTO);
You can add new lines at any moment.

4. Add data to line.

m_wndChart.AddData(ID_LINE1, 3, 9);
m_wndChart.AddData(ID_LINE1, 10, 2);
m_wndChart.AddData(ID_LINE2, 3);
m_wndChart.AddData(ID_LINE2, 5);
m_wndChart.AddData(ID_LINE2, 34);


Download demo project - 14 Kb
Download source - 2 Kb
Download help - 7 Kb


  • Problem with compilation

    Posted by Legacy on 02/26/2004 08:00am

    Originally posted by: Petr Hracek

    Hey all,

    It's very great work. It's excelent.
    I have one big problem. I tried compile this demo code
    and MSVC++.NET2003 sow me message that _GetBaseMessageMap is not a member of CScrollChart <T>.

    And other error:
    d:\Temp\test\cldemo.cpp(47): error C2440: 'static_cast' : cannot convert from 'void (__thiscall CDialogMain::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'

    Can you help me anybody?


  • I found the one

    Posted by Legacy on 02/24/2004 08:00am

    Originally posted by: mingligar

    Thanks. your projet is The one I want to find. I get it.

  • can it display infinite data?

    Posted by Legacy on 10/31/2003 08:00am

    Originally posted by: edward

    can this display data as much as I like, or huge quantities?

  • Here is the solution of drawing negative value.

    Posted by Legacy on 08/06/2003 07:00am

    Originally posted by: Taghi

    << In the class file >>
    Change the "LPtoDP(T X,T Y)" function as the folowing :

    template<class T>
    CPoint CScrollChart<T>::LPtoDP(T X,T Y)
    int nY;
    int nX;
    CRect rectClient;
    nY = ((rectClient.Height() * (Y-m_MinValue) * 0.95) /( m_MaxValue-m_MinValue));
    nX = ((rectClient.Width() * (X - m_pointIni)) / m_nHzRange);
    return CPoint(nX, rectClient.Height() - nY);

    << In your program >>
    And if you want to refresh the min vertical limit textbox
    as in the demo program only in "OnNewLimits" message
    mapped function uncomment the folloing statment:

    //else m_TextVerMax.SetWindowText(strTmp);

    So that the whole function can looked as follow:

    void CTest02Dlg::OnNewLimits(WPARAM wParam, LPARAM lParam)
    CString strTmp;
    if ( (GetCurrentMessage()->message) == WM_NEWHORZLIMITS) m_TextHozMin.SetWindowText(strTmp);
    else m_TextVerMin.SetWindowText(strTmp);
    if ( (GetCurrentMessage()->message) == WM_NEWHORZLIMITS) m_TextHozMax.SetWindowText(strTmp);
    else m_TextVerMax.SetWindowText(strTmp);

  • Problem with the .Create

    Posted by Legacy on 04/28/2003 07:00am

    Originally posted by: Maarten


    BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);

    Specifies the chart control's ID.

    What is the chart control's ID? Is is the scrollbar?
    This header looks wonderfull but I can't get it running...
    In the example it has value 101. Why? I can't find the reason...

    Thanks for help!!


  • Concern about memory size

    Posted by Legacy on 08/13/2002 07:00am

    Originally posted by: Amit

    for your help.That u have suggested is one away solution and i also find other solution
    Create pointer
    CScrollChart *myscrollchart;
    myscrollchart=new CScrollChart();
    this work fine

    Now I have concern about memory size.
    when I put four scrollchart controls having 3 to 4 lines each with 0 timer the memory uses increases drastically.And CPU usage is also 99% which affect other application's working.
    So can any one suggest how to clip the control.
    Window display as of size of control would be sufficient for me.


  • To Delete control(sonia's solution not working)

    Posted by Legacy on 08/02/2002 07:00am

    Originally posted by: Amit

    I want to delete the control on the fly. but code suggested by sonia seems to be not working in my case.
    It is giving error while creating pointer of the template class CScrollChart .If any one knows the solution please help me


  • Problem Adding Lines..

    Posted by Legacy on 06/25/2002 07:00am

    Originally posted by: Jeremy

    Hello, thanks for the control. It looks very useful. I am able to draw the chart, but when I do AddLine and AddData nothing happens - I can't draw any lines on the chart.
    Can you give me any info that may help with this issue?


  • Print

    Posted by Legacy on 06/19/2002 07:00am

    Originally posted by: Helena

    How can I print the graph?

  • how to clear graph

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

    Originally posted by: hnf

    how clear the graph and restart an other

  • Loading, Please Wait ...

  • You must have javascript enabled in order to post comments.

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

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date