Problem in creating Line Graph

Discussion in 'C#' started by ashisharora_83, Aug 17, 2007.

  1. #1
    Hi
    I am facing some problem in creating Line Graph. I display percentage on Y axis and date on X Axis. but in my graph scale of percentage column goes above 100 which ideally should be till 100. I am using the below code to create the graph: -

    dim Percentage(100)
    dim date(100)


    sql = "select percentage as percentage,date as date from indymac_clienthealth_percentage_server_data"
    if clienthealth_r.state>0 then
    clienthealth_r.close
    end if
    clienthealth_r.Open sql,conn,3,3

    if clienthealth_r.RecordCount>0 then
    clienthealth_r.MoveFirst
    x=0
    y=0
    'z=0
    for a=0 to clienthealth_r.RecordCount-1
    percentage(a) = clienthealth_r("percentage")
    date(a) = clienthealth_r("date")
    clienthealth_r.MoveNext
    if clienthealth_r.EOF then
    exit for
    end if
    next
    end if

    set ObjChart = Server.CreateObject("OWC11.ChartSpace")

    set ChaCon = ObjChart.Constants

    set ObjCharts = ObjChart.Charts.Add

    'Title

    ObjChart.HasChartSpaceTitle=True
    ObjChart.ChartSpaceTitle.Font = "Tahoma"
    ObjChart.ChartSpaceTitle.Font.Size = 12
    ObjChart.ChartSpaceTitle.Font.Bold = True
    ObjChart.ChartSpaceTitle.Caption = "HISTORICAL SMS CLIENT HEALTH PERCENTAGE"

    'Legend

    ObjChart.HasChartSpaceLegend = True
    ObjChart.ChartSpaceLegend.Position = ChaCon.chLegendPositionRight

    'Axis Titles

    Set axCategoryAxis = ObjCharts.Axes(0)
    Set axValueAxis = ObjCharts.Axes(1)
    axCategoryAxis.HasTitle = True
    axCategoryAxis.Title.Caption = "DATE"
    axValueAxis.HasTitle = True
    axValueAxis.Title.Caption = "COUNT"

    'Adding bars

    set SerCol1 = ObjCharts.SeriesCollection.Add


    'Chart Type

    ObjCharts.Type = ChaCon.chChartTypeLineMarkers

    'DataLabels( Bar Values)

    SerCol1.DataLabelsCollection.Add
    SerCol1.DataLabelsCollection(0).Font.Bold=True
    SerCol1.DataLabelsCollection(0).Font.Size=10
    SerCol1.DataLabelsCollection(0).Font.Color="Black"


    'Data for Bars per Series (Both the SMS Clients)

    SerCol1.Caption = "Percentage"
    SerCol1.SetData ChaCon.chDimSeriesNames, ChaCon.chDataLiteral, "Percentage"
    SerCol1.SetData ChaCon.chDimCategories, ChaCon.chDataLiteral, Date
    SerCol1.SetData ChaCon.chDimValues, ChaCon.chDataLiteral, percentage

    'Graph Image Generation
    graphname = "temp/" & hour(now()) & minute(now()) & second(now()) & "cltdailygraph1.gif"
    ImagePath=server.mappath(graphname)
    ObjChart.ExportPicture ImagePath,"gif", 1000, 500

    set ChaCon = nothing
    set ObjCharts = nothing
    set ObjChart = nothing

    response.write "<img src=" & graphname & " width=""1000"" height=""500"" name=""graphimg3"">"

    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    set ObjFolder = objFSO.GetFolder(Server.Mappath("/smsreporting/temp/"))

    for each gif in objFolder.Files
    if instr(gif.Name,"cltdailygraph1.gif")>0 and DateDiff("n",gif.DateLastModified,now)>0 then
    objFSO.DeleteFile Server.Mappath("/smsreporting/temp/") & "\" & gif.Name, True
    end if
    next


    Thanks in advance...
     
    ashisharora_83, Aug 17, 2007 IP