Yannie
asked on
OWC
Hi all..can anyone tell me how I can add data label to my graph please? below is the graph I have so far..I want the value of the graph to be labelled beside the marker in the graph..Please help?
Dim ObjChart
Dim ChaCon
Dim ObjCharts
Dim SerCol
Dim objAxis
Dim objFont
Set ObjChart = Server.CreateObject("OWC.C hart")
Set ChaCon = ObjChart.Constants
Set ObjCharts = ObjChart.Charts.Add
'adding my line
Set SerCol = ObjCharts.SeriesCollection .Add
Set SerCol1 = ObjCharts.SeriesCollection .Add
'ObjCharts.Type = ChaCon.chChartTypeColumnCl ustered
ObjCharts.Type = ChaCon.chChartTypeLine
'this is in purple line
SerCol.Caption = "Fuel Oil Cons"
SerCol.SetData ChaCon.chDimCategories, ChaCon.chDataLiteral, Val
SerCol.SetData ChaCon.chDimValues, ChaCon.chDataLiteral, Line1Val
SerCol.Type = ChaCon.chChartTypeLineMark ers
'------------------------- ------
'this is my line in the graph
SerCol1.Caption = "Lub Oil Cons"
SerCol1.SetData ChaCon.chDimCategories, ChaCon.chDataLiteral, Val
SerCol1.SetData ChaCon.chDimValues, ChaCon.chDataLiteral, LineVal
ObjCharts.seriescollection .LabelShow ActualValu e = true
'ObjCharts.SeriesCollectio n.DataLabe lsCollecti on(0).add
'change from the default bar graph To a line
SerCol1.Type = ChaCon.chChartTypeLineMark ers
'------------------------- ---
'Title of graph
ObjChart.HasChartSpaceTitl e=True
'Legend in the graph
ObjChart.ChartSpaceTitle.C aption = "FO/LO CONSP / HR"
' Set a variable to the Value (X) axis.
Set axCategoryAxis = ObjChart.Charts(0).Axes(0)
' Set a variable to the Value (Y) axis.
Set axValueAxis = ObjChart.Charts(0).Axes(1)
' The following two lines of code enable, and then
' set the title for the category axis.
axCategoryAxis.HasTitle = True
axCategoryAxis.Title.Capti on = "LITRES / TONNES"
' The following three lines of code set the font
' for the values displayed on the category axis.
axCategoryAxis.Font = "Arial"
axCategoryAxis.Font.Size = 8
axCategoryAxis.Font.Bold = True
Dim ObjChart
Dim ChaCon
Dim ObjCharts
Dim SerCol
Dim objAxis
Dim objFont
Set ObjChart = Server.CreateObject("OWC.C
Set ChaCon = ObjChart.Constants
Set ObjCharts = ObjChart.Charts.Add
'adding my line
Set SerCol = ObjCharts.SeriesCollection
Set SerCol1 = ObjCharts.SeriesCollection
'ObjCharts.Type = ChaCon.chChartTypeColumnCl
ObjCharts.Type = ChaCon.chChartTypeLine
'this is in purple line
SerCol.Caption = "Fuel Oil Cons"
SerCol.SetData ChaCon.chDimCategories, ChaCon.chDataLiteral, Val
SerCol.SetData ChaCon.chDimValues, ChaCon.chDataLiteral, Line1Val
SerCol.Type = ChaCon.chChartTypeLineMark
'-------------------------
'this is my line in the graph
SerCol1.Caption = "Lub Oil Cons"
SerCol1.SetData ChaCon.chDimCategories, ChaCon.chDataLiteral, Val
SerCol1.SetData ChaCon.chDimValues, ChaCon.chDataLiteral, LineVal
ObjCharts.seriescollection
'ObjCharts.SeriesCollectio
'change from the default bar graph To a line
SerCol1.Type = ChaCon.chChartTypeLineMark
'-------------------------
'Title of graph
ObjChart.HasChartSpaceTitl
'Legend in the graph
ObjChart.ChartSpaceTitle.C
' Set a variable to the Value (X) axis.
Set axCategoryAxis = ObjChart.Charts(0).Axes(0)
' Set a variable to the Value (Y) axis.
Set axValueAxis = ObjChart.Charts(0).Axes(1)
' The following two lines of code enable, and then
' set the title for the category axis.
axCategoryAxis.HasTitle = True
axCategoryAxis.Title.Capti
' The following three lines of code set the font
' for the values displayed on the category axis.
axCategoryAxis.Font = "Arial"
axCategoryAxis.Font.Size = 8
axCategoryAxis.Font.Bold = True
we can you explain in detail as i have not understood exactly what you want
are u looking for something like this
try this out and let me know
<%
'label the months.
dim Val(4)
Val(1) = 10
Val(2) = 11
Val(3) = 12
Val(4) = 13
dim Line1Val(4)
Line1Val(1) = 10
Line1Val(2) = 20
Line1Val(3) = 30
Line1Val(4) = 40
dim Line1Val1(4)
Line1Val1(1) = 40
Line1Val1(2) = 30
Line1Val1(3) = 20
Line1Val1(4) = 10
'Val(5) = 4
' Val(6) = 6
'Val(7) = 7
'Val(8) = 8
'Val(9) = 9
'Val(10) = 10
'Val(11) = 11
'Val(12) = 12
Dim ObjChart
Dim ChaCon
Dim ObjCharts
Dim SerCol
Dim objAxis
Dim objFont
Set ObjChart = Server.CreateObject("OWC.C hart")
Set ChaCon = ObjChart.Constants
Set ObjCharts = ObjChart.Charts.Add
'adding my line
Set SerCol = ObjCharts.SeriesCollection .Add
'ObjCharts.Type = ChaCon.chChartTypeColumnCl ustered
ObjCharts.Type = ChaCon.chChartTypeLine
'this is in purple line
ObjChart.Charts(0).SeriesC ollection( 0).Caption = "Fuel Oil Cons"
ObjChart.Charts(0).SeriesC ollection( 0).SetData ChaCon.chDimCategories, ChaCon.chDataLiteral, Val
ObjChart.Charts(0).SeriesC ollection( 0).SetData ChaCon.chDimValues, ChaCon.chDataLiteral, Line1Val
SerCol.Type = ChaCon.chChartTypeLineMark ers
Set SerCol1 = ObjCharts.SeriesCollection .Add
'------------------------- ------
'this is my line in the graph
ObjChart.Charts(0).SeriesC ollection( 1).Caption = "Lub Oil Cons"
ObjChart.Charts(0).SeriesC ollection( 1).SetData ChaCon.chDimCategories, ChaCon.chDataLiteral, Val
ObjChart.Charts(0).SeriesC ollection( 1).SetData ChaCon.chDimValues, ChaCon.chDataLiteral, Line1Val1
'change from the default bar graph To a line
ObjChart.Charts(0).SeriesC ollection( 1).Type = ChaCon.chChartTypeLineMark ers
'------------------------- ---
Set SeriesLabels = ObjChart.Charts(0).SeriesC ollection( 0).DataLab elsCollect ion.Add
' Set the number format of the data labels.
SeriesLabels.NumberFormat = "00.00"
Set SeriesLabels1 = ObjChart.Charts(0).SeriesC ollection( 1).DataLab elsCollect ion.Add
' Set the number format of the data labels.
SeriesLabels1.NumberFormat = "00.00"
'Title of graph
ObjChart.HasChartSpaceTitl e=True
'Legend in the graph
ObjChart.ChartSpaceTitle.C aption = "FO/LO CONS / HR"
Set axCategoryAxis = ObjChart.Charts(0).Axes(0)
' Set a variable to the Value (Y) axis.
Set axValueAxis = ObjChart.Charts(0).Axes(1)
' The following two lines of code enable, and then
' set the title for the category axis.
axCategoryAxis.HasTitle = True
axCategoryAxis.Title.Capti on = "Months"
' The following three lines of code set the font
' for the values displayed on the category axis.
axCategoryAxis.Font = "Arial"
axCategoryAxis.Font.Size = 8
axCategoryAxis.Font.Bold = True
' The following two lines of code enable, and then
' set the title for the value axis.
axValueAxis.HasTitle = True
axValueAxis.Title.Caption = "Litres" 'Put your Cation for Y-Axis
ObjChart.HasChartSpaceLege nd = True
ObjChart.ChartSpaceLegend. Position = ChaCon.chLegendPositionRig ht
'Call CleanUpGIF("\\oceanflow\ia t$\lubOilC onsump\rep orts\")
ImagePath=server.mappath(" oilgraph.g if")
ObjChart.ExportPicture ImagePath,"gif", 700, 400
Set ChaCon = nothing
Set ObjCharts = nothing
Set ObjChart = nothing %>
<Img src="oilgraph.gif" width="700" height="400">
try this out and let me know
<%
'label the months.
dim Val(4)
Val(1) = 10
Val(2) = 11
Val(3) = 12
Val(4) = 13
dim Line1Val(4)
Line1Val(1) = 10
Line1Val(2) = 20
Line1Val(3) = 30
Line1Val(4) = 40
dim Line1Val1(4)
Line1Val1(1) = 40
Line1Val1(2) = 30
Line1Val1(3) = 20
Line1Val1(4) = 10
'Val(5) = 4
' Val(6) = 6
'Val(7) = 7
'Val(8) = 8
'Val(9) = 9
'Val(10) = 10
'Val(11) = 11
'Val(12) = 12
Dim ObjChart
Dim ChaCon
Dim ObjCharts
Dim SerCol
Dim objAxis
Dim objFont
Set ObjChart = Server.CreateObject("OWC.C
Set ChaCon = ObjChart.Constants
Set ObjCharts = ObjChart.Charts.Add
'adding my line
Set SerCol = ObjCharts.SeriesCollection
'ObjCharts.Type = ChaCon.chChartTypeColumnCl
ObjCharts.Type = ChaCon.chChartTypeLine
'this is in purple line
ObjChart.Charts(0).SeriesC
ObjChart.Charts(0).SeriesC
ObjChart.Charts(0).SeriesC
SerCol.Type = ChaCon.chChartTypeLineMark
Set SerCol1 = ObjCharts.SeriesCollection
'-------------------------
'this is my line in the graph
ObjChart.Charts(0).SeriesC
ObjChart.Charts(0).SeriesC
ObjChart.Charts(0).SeriesC
'change from the default bar graph To a line
ObjChart.Charts(0).SeriesC
'-------------------------
Set SeriesLabels = ObjChart.Charts(0).SeriesC
' Set the number format of the data labels.
SeriesLabels.NumberFormat = "00.00"
Set SeriesLabels1 = ObjChart.Charts(0).SeriesC
' Set the number format of the data labels.
SeriesLabels1.NumberFormat
'Title of graph
ObjChart.HasChartSpaceTitl
'Legend in the graph
ObjChart.ChartSpaceTitle.C
Set axCategoryAxis = ObjChart.Charts(0).Axes(0)
' Set a variable to the Value (Y) axis.
Set axValueAxis = ObjChart.Charts(0).Axes(1)
' The following two lines of code enable, and then
' set the title for the category axis.
axCategoryAxis.HasTitle = True
axCategoryAxis.Title.Capti
' The following three lines of code set the font
' for the values displayed on the category axis.
axCategoryAxis.Font = "Arial"
axCategoryAxis.Font.Size = 8
axCategoryAxis.Font.Bold = True
' The following two lines of code enable, and then
' set the title for the value axis.
axValueAxis.HasTitle = True
axValueAxis.Title.Caption = "Litres" 'Put your Cation for Y-Axis
ObjChart.HasChartSpaceLege
ObjChart.ChartSpaceLegend.
'Call CleanUpGIF("\\oceanflow\ia
ImagePath=server.mappath("
ObjChart.ExportPicture ImagePath,"gif", 700, 400
Set ChaCon = nothing
Set ObjCharts = nothing
Set ObjChart = nothing %>
<Img src="oilgraph.gif" width="700" height="400">
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yeah u got wat i wanted! Thank you very much!