• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 797
  • Last Modified:

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.Chart")
    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.chChartTypeColumnClustered
      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.chChartTypeLineMarkers
                '-------------------------------
                '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.LabelShowActualValue = true

                  'ObjCharts.SeriesCollection.DataLabelsCollection(0).add
                'change      from the default bar graph To a line
                SerCol1.Type = ChaCon.chChartTypeLineMarkers
                '----------------------------
                  
    'Title of graph
    ObjChart.HasChartSpaceTitle=True
      'Legend in the graph
    ObjChart.ChartSpaceTitle.Caption = "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.Caption = "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
0
Yannie
Asked:
Yannie
  • 3
1 Solution
 
babuno5Commented:
we can you explain in detail as i have not understood exactly what you want
0
 
babuno5Commented:
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.Chart")
    Set ChaCon = ObjChart.Constants
    Set ObjCharts = ObjChart.Charts.Add
    'adding my line
     Set SerCol = ObjCharts.SeriesCollection.Add
   
    'ObjCharts.Type = ChaCon.chChartTypeColumnClustered
     ObjCharts.Type = ChaCon.chChartTypeLine
              'this is in purple line
              ObjChart.Charts(0).SeriesCollection(0).Caption = "Fuel Oil Cons"
              ObjChart.Charts(0).SeriesCollection(0).SetData ChaCon.chDimCategories, ChaCon.chDataLiteral, Val
              ObjChart.Charts(0).SeriesCollection(0).SetData ChaCon.chDimValues, ChaCon.chDataLiteral, Line1Val
               SerCol.Type = ChaCon.chChartTypeLineMarkers
Set SerCol1 = ObjCharts.SeriesCollection.Add              
              '-------------------------------
              'this is my line in the graph
              ObjChart.Charts(0).SeriesCollection(1).Caption = "Lub Oil Cons"
              ObjChart.Charts(0).SeriesCollection(1).SetData ChaCon.chDimCategories, ChaCon.chDataLiteral, Val
              ObjChart.Charts(0).SeriesCollection(1).SetData ChaCon.chDimValues, ChaCon.chDataLiteral, Line1Val1
              'change     from the default bar graph To a line
                            
              ObjChart.Charts(0).SeriesCollection(1).Type = ChaCon.chChartTypeLineMarkers
              '----------------------------
         Set SeriesLabels = ObjChart.Charts(0).SeriesCollection(0).DataLabelsCollection.Add

        ' Set the number format of the data labels.
        SeriesLabels.NumberFormat = "00.00"              

Set SeriesLabels1 = ObjChart.Charts(0).SeriesCollection(1).DataLabelsCollection.Add

        ' Set the number format of the data labels.
        SeriesLabels1.NumberFormat = "00.00"        
    'Title of graph
    ObjChart.HasChartSpaceTitle=True
     'Legend in the graph
    ObjChart.ChartSpaceTitle.Caption = "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.Caption = "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.HasChartSpaceLegend = True
    ObjChart.ChartSpaceLegend.Position = ChaCon.chLegendPositionRight
     'Call CleanUpGIF("\\oceanflow\iat$\lubOilConsump\reports\")
    ImagePath=server.mappath("oilgraph.gif")
   
    ObjChart.ExportPicture ImagePath,"gif", 700, 400
    Set ChaCon = nothing
    Set ObjCharts = nothing
    Set ObjChart = nothing %>
     
    <Img src="oilgraph.gif" width="700" height="400">
0
 
babuno5Commented:
a little modification

 <%
     '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.Chart")
    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.chChartTypeColumnClustered
     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.chChartTypeLineMarkers
               
              '-------------------------------
              '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, Line1Val1
              'change     from the default bar graph To a line
                            
              SerCol1.Type = ChaCon.chChartTypeLineMarkers
              '----------------------------
         Set SeriesLabels = ObjChart.Charts(0).SeriesCollection(0).DataLabelsCollection.Add

        ' Set the number format of the data labels.
        SeriesLabels.NumberFormat = "00.00"              

Set SeriesLabels1 = ObjChart.Charts(0).SeriesCollection(1).DataLabelsCollection.Add

        ' Set the number format of the data labels.
        SeriesLabels1.NumberFormat = "00.00"        
    'Title of graph
    ObjChart.HasChartSpaceTitle=True
     'Legend in the graph
    ObjChart.ChartSpaceTitle.Caption = "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.Caption = "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.HasChartSpaceLegend = True
    ObjChart.ChartSpaceLegend.Position = ChaCon.chLegendPositionRight
     'Call CleanUpGIF("\\oceanflow\iat$\lubOilConsump\reports\")
    ImagePath=server.mappath("oilgraph.gif")
   
    ObjChart.ExportPicture ImagePath,"gif", 700, 400
    Set ChaCon = nothing
    Set ObjCharts = nothing
    Set ObjChart = nothing %>
     
    <Img src="oilgraph.gif" width="700" height="400">
0
 
YannieAuthor Commented:
yeah u got wat i wanted! Thank you very much!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now