Creating a Chart Line that Uses ActiveX

Environment: VC6 SP4, 2000 SP2

Introduction

Chart Line is an ActiveX component that enables you to visualize a chart similar to the Windows NT/2000/XP Task Manager Performance chart. The component enables you to manage four lines at a time. By modifying any properties of the control, it is possible to visualize different types of charts.

Quick Start

The Chart Line control makes it extremely easy to add Chart capability to your applications. It takes only two statements to display a chart.

Example

The following is a demonstration of a simple application, called Chartl32. In just a few short steps, you can produce a graphic application with complete functionality.

Before you start the following tutorial, you need to Start Visual Basic and load the Chart Line custom control. For information about loading the custom control, see the Visual Basic documentation. We will use Visual Basic 6.0.

  1. Design the Form
  2. Start by adding two controls to a blank form:

    1. Place the Chart line control
    2. Place a Timer Control (set the Interval property to 400)

    Now you can change the properties of the Chart line Control: You can change the Background color (ChartBackClor), the line Colors (Line1Color....Line4Color), or grid color (ChartForeColor). Also, you can define the range line limits of the chart (LowerRangeLine1,UpperRangeLine1...LowerRangeLine4,UpperRangeLine4).

  3. Add code to the Timer control
  4. This is easy. Most of the code goes into the Timer event:

    Private Sub Timer1_Timer()
    
    Random1 = Int((20 - 15 + 1) * Rnd + 15)
    Random2 = Int((50 - 45 + 1) * Rnd + 45)
    Random3 = Int((70 - 65 + 1) * Rnd + 65)
    Random4 = Int((95 - 85 + 1) * Rnd + 85)
    
    'Line 1
    Call Chartl321.PlotLine(1, Random1)
    
    'Line 2
    Call Chartl321.PlotLine(2, Random2)
    
    'Line 3
    Call Chartl321.PlotLine(3, Random3)
    
    'Line 4
    Call Chartl321.PlotLine(4, Random4)
    
    'Draw
    Chartl321.Draw
    
    End Sub
    

Methods

We have used the following two methods in this example:

PlotLine

Call this method to insert the new value of the line to plot on the chart into memory.

Parameters

  • NumLine: Specifies the number of lines to visualize
  • Value: Specifies the new value to plot on the chart

Draw

Call this method to visualize the new points on the chart.

Parameters

None.

Downloads

Download demo project - 89 Kb
Download source - 6 Kb


Comments

  • How to clear the graph

    Posted by sopeze on 05/01/2005 02:59pm

    What do I need to modify in order to clear the graph?

    Reply
  • How to use this control???

    Posted by sopeze on 04/30/2005 08:52pm

    What steps do I need to carry out in order to use this control in my VB project??? Please Help..

    • How to use this control

      Posted by frankqq on 12/02/2008 07:36am

      Thank you!

      Reply
    Reply
  • Thank You Very Much Indeed ..... !!

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

    Originally posted by: Tomcat

    Nice Work...!! I suggest you to add some extra features and fuctions to use it as a DSO interface.

    Reply
  • The real GURU is Kap

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

    Originally posted by: Ant

    He's the great programmer i ever know!

    Reply
  • The Real GURU on CODEGURU

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

    Originally posted by: Kap

    Listen to the GURU and enjoy his solid code!

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

Top White Papers and Webcasts

  • A majority of organizations are operating under the assumption that their network has already been compromised, or will be, according to a survey conducted by the SANS Institute. With many high profile breaches in 2013 occurring on endpoints, interest in improving endpoint security is top-of-mind for many information security professionals. The full results of the inaugural SANS Endpoint Security Survey are summarized in this white paper to help information security professionals track trends in endpoint …

  • Specialization and efficiency are always in need. Whether it's replacing an aging roof, getting a haircut, or tuning up a car, most seek the assistance of trusted experts. The same is true in the business world, where an increasing number of companies are seeking the help of others to administer their IT systems and services. This special edition of Unleashing IT highlights a new breed of IT caretaker -- Cisco Powered service providers -- and the business advantages and operational efficiencies they …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds