Making Multicolored Single Data Bar Charts with CHRTB.BAS (77739)



The information in this article applies to:

  • Microsoft Basic Professional Development System for MS-DOS 7.0
  • Microsoft Cinemania for Windows 1993 edition
  • Microsoft Visual Basic for MS-DOS

This article was previously published under Q77739

SUMMARY

If you create a bar chart with CHRTB.BAS in Microsoft Basic PDS or with CHART.BAS in Visual Basic for MS-DOS and you only have one class of data, all the bars on the graph will be white. However, if you are comparing several classes of data, the bars for each class will be a different color.

CHRTB.BAS and CHART.BAS are part of the Quick Libraries. You can use the LIB and LINK commands to create the Quick Library. For more information explaining how to do this, please see the following article in the Microsoft Knowledge Base:

31156 How to Add Routines to Quick Libraries (.QLB Files)

You can modify the source code of CHRTB.BAS or CHART.BAS to alternate bar chart bar colors when using a single set of data, as shown in the example below.

MORE INFORMATION

If you have just one class of data and you want all the bars of a bar chart created with the Presentation Graphics toolbox library to differ in color, you will need to make the following changes to CHRTB.BAS or CHART.BAS.

On or around line 72 of the SUB clDrawBarData in CHRTB.BAS or CHART.BAS, you will find a line that reads as follows:
   V = V1(i%, j%)
				
After this line, add the following lines of code:
   IF GP.NSeries = 1 THEN
           BarColor% = ( BarColor% MOD 15 ) + 1
   ELSE
           BarColor% = J%
   END IF
				
You also need to change the following three lines of code:

On or around line 94, you will find a line that reads:

      clRenderBar BarMin, BarLoc, V, BarLoc - BarWid, J%
					
The "J%" in the above line should be changed to "BarColor%".

You will find this same call to clRenderBar twice more in this sub, and the same change needs to be made. The other two occurrences are on or around lines 107 and 116.


Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB77739