![]() |
About AspChart
AspChart allows you to create professional looking charts "on the fly". Features include:
- Creates JPG (read/write), PNG (write-only), GIF/RLE (write-only) and BMP (read/write) formats
- 3D features
- Pie, Bar, Area and many other styles
- Automatically creates legends
- Supports multiple series per chart
What's New In 2.x
- Better support for MTS. Transactions are not supported in the 2.0 release but you should be able to incorporate AspChart into MTS packages without any troubles.
AspChart Installation
To use this ASP component move the DLL into a subdirectory (like \winnt\system32 for NT or \windows\system for Win95). Please use the version of regsvr32 that is included with this component or the version that comes with Microsoft ASP (they are the same version).
To register the component on the system change to the directory where you installed the DLL and type:
regsvr32 aspchart.dll
Simple Chart Example
Using the component is as simple as
- Creating the object
- Setting charting properties
- Calling the SaveImage method
The following code demonstrates how to use AspChart to generate a simple bar chart:
ctBar = 1 cNone = 0 cGradient =6 rem ********************************************************************** rem * Instantiate the Chart component rem ********************************************************************** Set Chart = Server.CreateObject ("ASPChart.Chart") rem ********************************************************************** rem * Add a Bar series with 3 points rem ********************************************************************** Chart.AddSeries (ctBar) Chart.AddValue 200, "Regular", vbBlue Chart.AddValue 233, "Enhanced ", vbRed Chart.AddValue 260, "Free", vbGreen Chart.BarStyle = cGradient rem ********************************************************************** rem * Set the PanelColor, remove the OuterBevel rem ********************************************************************** Chart.PanelColor = vbWhite Chart.BevelOuter = cNone Chart.ChartBGColor = vbWhite rem ********************************************************************** rem * Set the Width and Height of the image rem ********************************************************************** Chart.Height = 300 Chart.Width = 500 rem ********************************************************************** rem * Set the filename, save the image and write the image tag rem ********************************************************************** Chart.FileName = "d:\inetpub\wwwroot\images\smpchrt1.jpg" Chart.SaveChart Response.Write "<img src=""/images/smpchrt1.jpg"">" rem ********************************************************************** rem * Destroy the object rem ********************************************************************** Set Chart = nothingMultiple Series per Chart
The following example demonstrates how to create multiple series per chart.
Set Chart = Server.CreateObject("AspChart.Chart") Randomize Chart.AddSeries 7 'Candle Series dblOpen = 1000 + Rnd(100) for intCount = 1 to 30 dblBase = Round(100*Rnd-50) Chart.AddCandle Now + intCount, dblOpen, dblOpen+20, dblOpen-20, dblOpen+dblBase dblOpen = dblOpen + dblBase next Randomize Chart.AddSeries 5 'Add a Line Series dblOpen = 1000 + Rnd(100) for intCount = 1 to 30 dt = Now + intCount dblBase = Round(100*Rnd-50) Chart.AddXY dt, dblOpen, CStr (Month (dt)) + "/" + CStr (Day (dt)) + "/" + CStr (Year (dt) Mod 100), vbRed dblOpen = dblOpen + dblBase nextAbout purchasing AspChart
- The registration license fee covers only one CPU per license.
- Evaluation copies will expire. See the Expires property for details on determining when your copy will expire.
About Upgrades
- Users can upgrade for free for minor version changes. For example, upgrades from version 1.00 to 1.99 are free. The upgrade from 1.99 to 2.0 may carry an additional license fee.
- The latest version of the components are always available at http://www.serverobjects.com/products.htm. If a fee is associated with obtaining the upgrade it will be noted on that page.
Upgrade Instructions
To upgrade the component from a previous version please follow these steps:
- Stop all IIS related services such as Gopher, FTP and W3SVC.
- Change to the directory where the component is located and type "regsvr32 /u aspchart.dll"
- Move the new copy of aspchart.dll to the current directory and type "regsvr32 aspchart.dll"
- Restart the necessary services.
Questions about AspChart
See http://www.serverobjects.com/TechComm.htm for general ASP support errors and issues.
Download our troubleshooting utility for help with configuration problems.
The browser is caching the image so my chart is not updated on each request. What can I do about that? Web browsers tend to cache images. This is a browser problem, not an AspChart problem. The only solutions we know of are the following:
- Set Response.Expires = "0"
- Use the Response.BinaryWrite as demo'd in the binwchrt.asp sample script included with AspChart. Write an HTML wrapper that calls the ASP file as an image source tag as
<img src="/myapp/mychart.asp">
This method works for most browsers (it fails with some IE / Netscape versions).
- Create random filenames and then erase the images created during the Session_OnEnd event. This method works for all browsers.
- Add a meta tag to your ASP file <meta http-equiv="pragma" content="no-cache">. This will not work in ASP files that use the BinaryWrite call.
- Use a query_string that generates random numbers so that the browser thinks the URL is new each time. Using JScript you could do something like<img src="DrawMainChart.asp?Arpa=<%=(Math.random())%>">
What color constants are defined by VBScript? The standard color constants are:
- vbBlack
- vbRed
- vbGreen
- vbYellow
- vbBlue
- vbMagenta
- vbCyan
- vbWhite
You can, of course, add your own constants to your scripting code. For example: vbGrayText = &h80000011Does AspChart support multiple y-axis? No, not at this time. There are no known workarounds for this. This is planned for a future version but we have not committed to a ship date or time frame for delivery. The legend doesn't include items for every series I've added. If the chart size is too small, some legend items are dropped. To see all the legend items increase the size of the chart. There are no workarounds outside of providing the chart with more screen real-estate so that the complete legend can be drawn. "The chart fills the entire chart area. How do I extend the vertical chart axis so that it extends slightly beyond my highest data vertical axis value?" The VertAxisMax property allows you to do this. For example if your data values are no higher than 5.5 and you want the left (vertical) axis to extend up to 6 you would set the VertAxisMax property to 6.0. How do I convert HTML colors to RGB colors? HTML colors are easily converted to RGB values using the VBScript RGB function. For example the HTML color #E2BBF3 can be converted to RGB as follows
Chart.GradientStartColor = vbWhite Chart.GradientEndColor = RGB(&hE2, &hBB, &hF3)I'm not getting a chart and I'm not getting any errors.
- Try looking at the HTML source that's returned to the browser. The colors used in the HTML page may prevent you from seeing the error message since white text on a white background isn't a color combination that most people can readily see.
- Try the BinaryWrite examples that come with the eval zip file. If these work then you've probably got a problem with security. The non-BinaryWrite examples write the chart to a file and the problem may be that the anon IIS user (or other authenticated user) doesn't have proper rights to write to the directory you've designated.
- You changed the path to save the file to, to a valid path... didn't you? Look for the FileName property in non-BinaryWrite examples.
I create a chart but after calling SaveChart nothing gets written out. There are a few possible reasons for this:
- The path you specified is invalid. Fix the path and retry.
- The user context the component is operating under (either the anonymous IIS user or another account that has been autheticated) does not have write privileges to the directory you specified. Go into file manager, right click on the directory, select properties, select the security tab and then permissions. Make sure that any users which will use the component have privileges.
- The file you are trying to write to is open in another process.
You can check the Error property for O/S result codes that identify problems after an attempted save.
How do I reduce the image size for JPEGs? The JPG compression algorithm does not compress some charts or images very well. As a general rule you can reduce the size of the image by setting the JPEGQuality property to a lower value such as 60. The lower the number the worse the image degradation will be. I'm adding a large number of items to the chart. How do I display all these items in the legend? You've only got so much screen real-estate to work with.
- If the legend won't fit you'll have to size the chart up so that the entire legend fits. or...
- Drop the legend from the chart and create a separate legend using HTML or some other method to generate a legend.
How do I upgrade to the latest version? Download the latest "eval" version and follow the upgrade directions provided earlier in this document. In the unlicensed version I get a footer attached to every email stating "AspMail 3.x...". Does the licensed version include this footer. No. Can I redistribute this control with my products? No, the license does not allow for redistribution. I'm sorry but we currently do not have OEM agreements for redistribution of AspChart. My component is licensed. Should the Expires property return a date? No. Licensed versions return N/A for an expiration date. The registration process (per the instructions you received) should be run on the server. What are the minimum security requirements for AspChart and IIS/ASP? Technically, the only requirement AspChart has is that it must have access to the directory you are saving images to . But IIS and ASP have certain requirements that must be met to run properly. Thanks to Carl Howell for providing this information.
ASP script directory Creator Owner: Full Control (All)(All)
System: ""
Admin: ""
IUSR: (None)(RX)\WinNT\ Creator Owner: Full Control (All)(All)
System: ""
Admin: ""
IUSR: (WX)(X)\WinNT\System32\ System: Full Control (All)(All)
Admin: ""
IUSR: (RX)(RX)Inetsrv System: Full Control (All)(All)
Admin: ""
Everyone: (RX)(RX)Technical Support
If you require technical support please see our tech support page at http://www.serverobjects.com/support.htm
AspChart Properties
Property Description Angle By default the Angle property is set to 0. If you wish to rotate the final chart image set Angle to the angle of rotation. AxisGridColor Sets the grid line color of the chart (if present). AxisGridLines AxisGridLines is true by default and determines if an axis grid is displayed. Example:
Chart.AxisGridLines = false
AxisHorizFont The AxisHorizFont property exposes the horizontal axis font object. Valid sub-properties are
- Name : string
- Size : integer
- Bold : boolean
- Italic : boolean
- Underline : boolean
- Strikethrough : boolean
- Weight : smallint
Example:
Chart.AxisHorizFont.Name = "Arial" Chart.AxisHorizFont.Size = 12 Chart.AxisHorizFont.Bold = trueAxisHorizFontColor AxisHorizFontColor determines what color the horizontal axis font is drawn with. Example:
Chart.AxisHorizFontColor = vbBlackAxisLabelFontBottom AxisLabelFontLeft
These properties expose the axis label font objects. See AxisHorizFont for details. Example
Chart.AxisLabelFontBottom.Bold = true
AxisLabelFontColor AxisLabelFontColor determines what color the axis label fonts are drawn with. AxisVertFont The AxisVertFont property exposes the vertical axis font object. See AxisHorizFont for details. AxisVertFontColor AxisVertFontColor determines what color the vertical axis font is drawn with. BarLayout If you have multiple bar series in a chart the BarLayout property specifies how the bar series will be drawn. Valid values are
- cNone = 0
- cSide = 1
- cStacked = 2
Example:
Chart.BarLayout = cNoneBarStyle BarStyle determines the style of the bars drawn for bar series. Valid values are:
- cRectangle = 0
- cPyramid = 1
- cInvPyramid = 2
- cCylinder = 3
- cEllipse = 4
- cArrow = 5
- cRectGradient = 6
Example:
Chart.BarStyle = cRectGradientBevelInner The BevelInner property determines whether the inner bevel for the chart is displayed. Example:
Chart.BevelInner = falseBevelOuter The BevelOuter property determines whether the outer bevel for the chart is displayed. Example:
Chart.BevelOuter = falseBevelWidth The BevelWidth property determines the width in pixels between the inner and the outer bevels of a panel. Example:
Chart.BevelWidth = 2BorderWidth The BorderWidth property determines the width in pixels of the border around a panel. Example:
Chart.BorderWidth = 1BottomAxisIncrement Determines the minimum axis increment for the bottom axis. Example:
Chart.BottomAxisIncrement = 100
BottomWallColor The BottomWallColor property specifies the color used to fill the bottom wall background. Example:
Chart.BottomWallColor = vbYellowChartBGColor The ChartBGColor property specifies the color used to fill the chart background. Example:
Chart.ChartBGColor = vbWhiteChartTitleFont The ChartTitleFont property specifies the font characteristics used to draw chart titles. See AxisHorizFont for sub-properties. ChartTitleFontColor The ChartTitleFontColor property specifies the font color used to draw chart titles. Example:
Chart.ChartTitleFontColor = vbBlueColorDepth Sets the color depth of the resulting image. This only affects BMP pictures. The default is 24bit. Valid values are:
Description Value 1bit 1 4bit 2 8bit 3 15bit 4 16bit 5 24bit 6 32bit 7
Example:Chart.ColorDepth = 7
ConvertPath Path to optional (user supplied) image conversion utility. This property is used during the call to the ConvertImage method. See ConvertImage details for more information. Example:
Chart.ConvertPath = "c:\imgconv\myconv.exe"
ConvertParams Parameters used during the call to the ConvertImage method. See ConvertImage details for more information. Example:
Chart.ConvertParams = "image1.bmp chrt32.xbm"
CurrentSeries The CurrentSeries indicates/sets which series is currently active. For single series charts this will always be 1 but for multi-series charts this value will change each time a new series is added. You can switch between series by modifying this value. Example:
Chart.CurrentSeries = 2Error The Error property is used to report any errors that may have occurred during various method calls. Example:
Response.Write "Error: " & Chart.Error
Expires If the component is an eval version the expires property will return the date that the component quits functioning. Example:
Response.Write "Component Expires: " & Chart.ExpiresFileName The FileName property specifies the physical path where a file will be saved using the SaveChart method. Example:
Chart.FileName = "d:\inetpub\wwwroot\images\abc.jpg"Frame Typically charts have a frame around them. You can hide the grid lines using the AxisGridLines property. If you wish to hide the frame also you can set Frame to false. Example:
Chart.Frame = false
GradientDirection The chart panel may have a background gradient. Gradient direction determines which direction the gradient should be drawn in. Valid values are:
- cTopBottom = 0
- cBottomTop = 1
- cLeftRight = 2
- cRightLeft = 3
Example:
Chart.GradientDirection = cTopBottomGradientEndColor Determines the end color for the gradient. Example:
Chart.GradientEndColor = vbWhiteGradientStartColor Determines the beginning color for the gradient. Example:
Chart.GradientEndColor = vbYellowGradientVisible Determines whether the chart panel gradient is visible or not. Example:
Chart.GradientVisible = trueHeight The Height property determines the height of the chart. Example:
Chart.Height = 500HintsBGColor Determines the background color of the chart hints. HintsFont The HintsFont property specifies the font characteristics used to draw chart hints. See AxisHorizFont for sub-properties. HintsFontColor The HintsFontColor property specifies the font color used to draw chart hints. Example:
Chart.HintsFontColor = vbBlueHintsTransparent Determines whether chart hints are transparent or not. Example:
Chart.HintsTransparent = trueHintsVisible Determines whether chart hints are visible or not. Example:
Chart.HintsVisible = trueHLabelStyle, VLabelStyle Sets the Horizontal and Vertical Axis label styles. Valid values are:
Value Description 0 Automatic 1 None 2 Axis scales 3 Series point marks 4 XLabels Example:
Chart.HLabelStyle = 3
HorizAxisMax The axis minimums and maximums are automatically set based upon the points you add to the chart but you can override these calculated values. HorizAxisMax determines the maximum value displayed on the horizontal axis. This value must be set after your first call to AddSeries. Example:
Chart.HorizAxisMax = 200HorizAxisMin The axis minimums and maximums are automatically set based upon the points you add to the chart but you can override these calculated values. HorizAxisMin determines the minimum value displayed on the horizontal axis. This value must be set after your first call to AddSeries. Example:
Chart.HorizAxisMin = 10Image Image is a read only property that contains the binary data for the current Chart. You can use this to write the binary data directly to the client rather than using the SaveChart method. Your application design should dictate the best method to use. From ASP you can use Response.BinaryWrite to write this image data to the client. Be sure and set ContentType to the proper content-type. Currently the Image property only supports JPEG or PNG data. See the included file BinWChrt.asp for an example of how to use this property. Set the ImageFormat property to JPG or PNG before using this property. ImageFormat ImageFormat determines what graphics format the image will be saved to. Valid values are
- JPG = 1
- BMP = 2
- PNG = 3
- GIF (RLE) = 5
Example:
Chart.ImageFormat = 3JPEGQuality If the ImageFormat is set to JPEG then the JPEGQuality property specifies the quality of the JPEG image to be saved. Valid values are 1-100. Example:
Chart.JPEGQuality = 95LeftAxisIncrement Determines the axis increment for the left axis. Example:
Chart.LeftAxisIncrement = 100
LeftWallColor The LeftWallColor property specifies the color used to fill the left wall background. Example:
Chart.LeftWallColor = vbYellowLegendFont The LegendFont property exposes the Legend font object. See AxisHorizFont for details. LegendFontColor The LegendFontColor property specifies the font color used to draw legend text. Example:
Chart.LegendFontColor = vbGreenLegendPosition Determines where the legend should be placed on the chart. Valid values are:
- cLeft = 0
- cRight = 1
- cTop = 2
- cBottom = 3
Example:
Chart.LegendPosition = cRightLegendStyle Determines the style of the legend. Valid values are:
- cAuto = 0
- cSeries = 1
- cValues = 2
- cLastValues = 3
Example:
Chart.LegendStyle = cSeriesLegendTextStyle Determines how Legend text items will be formatted. The following values are legal.
Name Description Value Simple Point label only 0 LeftValue Point value and point label 1 RightValue Point label and point value 2 LeftPercent Percent and point label 3 RightPercent Point label and percent 4 XValue Point's X value (only for series with X values) 5 Example:
Chart.LegendTextStyle = 3
LegendVisible Determines if the legend will be displayed or not. Example:
Chart.LegendVisible = falseLineWidth LineWidth is the width of the line that's drawn for the following series types: QuickLine, Line, and Point. Setting the LineWidth sets the line width for the CurrentSeries only. Example:
Chart.LineWidth = 3
PanelColor Determines the color used to fill the chart panel background. Example:
Chart.PanelColor = vbWhiteProgressiveJPEGEncoding ProgressiveJPEGEncoding determines whether an image can be progressively displayed when it is decompressed. ProgressiveJPEGEncoding is off by default. Example:
Chart.ProgressiveJPEGEncoding = trueRegisteredTo Returns the name of the customer or company who purchased the component or "Evaluation" if the component is an evaluation copy. Example:
Response.Write "Registered To: " & Chart.RegisteredToSeriesColor Determines the color of the current series. Example:
Chart.SeriesColor = vbRedSeriesInLegend SeriesInLegend determines if the CurrentSeries is include in the legend. The default is true. Example:
Chart.SeriesInLegend = falseSeriesTitle Determines the title of the current series. Example:
Chart.SeriesTitle = "'97 Widget Shipments"Stairs For Line and Area series you can create stair stepped lines if you set Stairs = true. Version Gets the internal component version number. Example:
Response.Write "Component Version: " & Chart.VersionVertAxisMax The axis minimums and maximums are automatically set based upon the points you add to the chart but you can override these calculated values. VertAxisMax determines the maximum value displayed on the vertical axis. This value must be set after your first call to AddSeries. Example:
Chart.VertAxisMax = 200VertAxisMin The axis minimums and maximums are automatically set based upon the points you add to the chart but you can override these calculated values. VertAxisMin determines the minimum value displayed on the vertical axis. This value must be set after your first call to AddSeries. Example:
Chart.VertAxisMin = 10View3D The View3D property determines if the chart will have a 3D look or not. The default is true. Example:
Chart.View3D = falseWidth The Width property determines the width of the chart. Example:
Chart.Width = 500AspChart Component Methods
Method Parameters Return Value Description AddAxisLabel intAxis, strValue (none) Sets the Axis label intAxis may be
- 1 = Left Axis
- 2 = Bottom Axis
AddCandle strDate, dblOpen, dblHigh, dblLow, dblClose (none) Adds a new candle point to a Candle series. See the demo code AspChrt5.asp for a demonstration of this routine. AddSeries intSeriesType (none) Adds a new series to the chart. Valid values for intSeriesType are:
- cBar = 1
- cHBar = 2
- cPie = 3
- cArea = 4
- cLine = 5
- cPoint = 6
- cCandle = 7
- cQuickLine = 8
After adding a new series you will call AddValue to add values to the current series except for Candle charts which call AddCandle.
AddValue dblValue, strLabel, intColor (none) Adds new points to the current series. AddXY dblXValue, dblYValue, strXLabel, intColor (none) Inserts a new point in the Series having values dblX, dbl. strXLabel may be empty (""). AddXYArray array of AddXY values (none) Allows adding a large number of XY points to a chart efficiently. See AspChrt9.asp for a demo of how to use AddXYArray. AddY dblYValue, strLabel, intColor (none) Inserts a new point in the Series having the value dblY. strLabel may be empty (""). ChartTitleAdd strTitle (none) Adds the strTitle text to the chart title. ChartTitleClear (none) (none) Clears any text assigned to the chart title. Clear (none) (none) Clears the chart, clears all series and values added. ConvertImage bolEraseSource Boolean (true/false) The ConvertImage method allows you to convert images into formats not inherently supported by AspChart. Here's how it works:
- Assign the path and filename of your image conversion utility to ConvertPath.
- Assign the command-line parameters that your image conversion program requires to the ConvertParams property. Be sure and use explicit pathnames if necessary.
- Assign the FileName property so the Chart component knows where to save the chart to.
- Call ConvertImage
Here's what happens:
- AspChart will save the image to FileName.
- AspChart will execute your image conversion utility with the ConvertPath and ConvertParams you specified.
- AspChart will optionally erase (bolEraseSource) the file specified in FileName.
When debugging your setup it is best to specifiy bolEraseSource as false. Be sure the anonymous IIS user or authenticated users who access this component are able to execute the ConvertPath utility.
LoadBackdrop strFileName Boolean (true/false) Loads a BMP or JPG to be used as the chart background. Example:
Chart.LoadBackdrop ("d:\pub\images\corplogo.jpg")
SaveChart (none) Boolean (true/false) Saves the chart to the FileName property file. ShowMinorTicks LeftAxis, BottomAxis N/A Sets whether or not the Left and Bottom axis will show minor ticks. Example:
Chart.ShowMinorTicks false, false
Copyright © 1996, 1997, 1998, 1999 by ServerObjects Inc. All Rights Reserved.