August 14, 2018
Hot Topics:

Make a Light Chart Control

  • November 19, 2002
  • By Sam Huggill
  • Send Email »
  • More Articles »

OK. Now the properties have been built, we need to write some methods to actually perform the drawing of the graph. But before we can do that, we need to declare some variables in our control.The first thing we need to do is to add an enumeration of the available chart types. Add the following code to the General Declarations procedure of the user control:

Enum ChartTypesBar = 0 Line = 1End Enum

We now need to add an internal reference to this enumeration by the means of a variable. Add this declaration just below the ChartTypes enum:

Dim m_ChartType As ChartTypes

We now need some events, but fortunately these are standard ones. Just load up the ActiveX Control Interface Wizard again (Project, Add User Control, VB ActiveX Control Interface Wizard) and add the following events:


Theres two more things we need to do. First, we need to change some of the default values for the properties we made earlier. The HighScale property needs changing to 100, the HorizontalTickFrequency to 1 and the VerticalTickInterval to 1. The complete set of default variables should now look like this:

'Default Property Values:Const m_def_DisplayLegend = 0Const m_def_HighScale = 100Const m_def_LowScale = 0Const m_def_PlotPoints = 0Const m_def_Title = "0"Const m_def_VerticalTickInterval = 1Const m_def_HorizontalTickFrequency = 1Const m_def_ChartType = 0

(Notice the addition of the ChartType default.)

Secondly, we have to add a few of our own internal variables to help our methods pass data to each other. I will explain what each variable does after you have coded them:

Dim PlotData() As VariantDim PlotColors(15) As LongDim Legends(15) As LongDim ChartWidth As LongDim ChartHeight As LongDim TitleOffset As Long

Right. The first is a variant array that gets set when a call to the RegisterData method. This array becomes a two dimensional array holding information about each piece of data. The PlotColors and Legends variables simply hold the number of items each can hold (this is 15 because we use colours from the QBColor function). ChartWidth and ChartHeight specify the width and height of the chart, and TitleOffset holds the distance that the title is from the chart. Simple.

Page 4 of 7

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.


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