Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbscript chart

Status
Not open for further replies.

babyJebus

Programmer
Jan 25, 2007
8
GB
Hi all

Looking for some help with generating a vbscript chart.

Am creating a line chart and i need to show a legend. When i create the legend it only says the following:

series1
series2.....and so on.

Does anyone know how to make the legend actually display the name of the variable rather than just the series number.

Would be a massive help.
 
Are you creating a chart from scratch i.e. drawing axes etc or are you using the chart package that comes with excel?
 
Sorry should have said.

I am generating an html vbscript chart using data from an access database. here is the code:

If objChartSpace.Charts.Count = 0 Then
Set objChart = objChartSpace.Charts.Add
objChart.SeriesCollection.Add
objChart.SeriesCollection.Add
objChart.SeriesCollection.Add
objChart.SeriesCollection.Add
objChart.SeriesCollection.Add
objChart.SeriesCollection.Add
objChart.Type = 8
End If

objChartSpace.Charts(0).HasTitle = True
Set objTitle = objChartSpace.Charts(0).Title
objTitle.Caption = "Average Days to Close"
objTitle.Font.Bold = True
objTitle.Font.Name = "Tahoma"

objChartSpace.Charts(0).HasLegend = True

Set objBorder = objChartSpace.Charts(0).Border
objBorder.Color = "white"

objChartSpace.Charts(0).PlotArea.Interior.SetSolid "Whitesmoke"

Set objConstants = objChartSpace.Constants

Set axCategory = objChartSpace.Charts(0).Axes(objConstants.chAxisPositionTimescale)
axCategory.GroupingType = objConstants.chAxisGroupingNone

objChartSpace.Charts(0).SeriesCollection(0).SetData _
objConstants.chDimCategories, objConstants.chDataLiteral, categoryArray

objChartSpace.Charts(0).SeriesCollection(1).SetData _
objConstants.chDimValues, objConstants.chDataLiteral, valueArray1

objChartSpace.Charts(0).SeriesCollection(2).SetData _
objConstants.chDimValues, objConstants.chDataLiteral, valueArray2

objChartSpace.Charts(0).SeriesCollection(3).SetData _
objConstants.chDimValues, objConstants.chDataLiteral, valueArray3

objChartSpace.Charts(0).SeriesCollection(4).SetData _
objConstants.chDimValues, objConstants.chDataLiteral, valueArray4

objChartSpace.Charts(0).SeriesCollection(5).SetData _
objConstants.chDimValues, objConstants.chDataLiteral, valueArray5
 
How is your objChartSpace created?

If it is what I think it is, then maybe something like
Code:
legentlist = objChartSpace.Charts(0).Legend.LegendEntries
legentlist(0).Text = "One Series"
Look for LegendEntry in the Visual Basic Help Text in Excel. I'm playing with Win3.11 at the moment and these things didn't exist on Excel 5.

You may need a set on the first line. I can never remember when you need one and when you don't.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top