Results 1 to 1 of 1
  1. #1
    Join Date
    Apr 2004

    Unanswered: OWC Chart X-Axis Sorting Problem

    Greetings People,

    I don't normally post to message boards, but this time I am so stuck I don't know what else to do.

    The problem I am having is with the sorting of the x-axis (year value) of a stacked column chart.

    Would anyone have any idea as to why the data gets sorted by the product code in the ledgend, and not the date on the x-axis?

    The data source is a query producing the results - - sorted by the year as you can see.

    The result of the following code is - sorted by the product code...

    <!--#include file="" -->
    Function ExportChartToGIF(objCSpace)
       'Get a random filename
       Dim strFileName
       strFileName = Timer & Rnd & ".gif"
       'Save the image as a GIF
       objCSpace.ExportPicture server.MapPath(".") & "\" & strFileName, "gif", 600, 350
       'Return the path to the GIF image of the graph
       ExportChartToGIF =  strFileName
    End Function
    Sub CleanUpGIF()
       Dim objFS
       Dim objFolder
       Dim gif
       set objFS = Server.CreateObject("Scripting.FileSystemObject")
       set objFolder = objFS.GetFolder(server.MapPath("."))
       'Loop through each file in the GIFpath folder
       for each gif in objFolder.Files
           'Delete GIF files older than 10 minutes
           if instr(gif.Name, ".gif") > 0 and _
             DateDiff("n", gif.DateLastModified, now) > 0 then
               objFS.DeleteFile objFolder & "/" & gif.Name, True
           end if
       set objFolder = nothing
       set objFS = nothing
    End Sub
    set objChartSpace = Server.CreateObject("OWC.Chart")
    set objChart = objChartSpace.Charts.Add()
    set c = objChartSpace.Constants
    objChart.Type = c.chChartTypeColumnStacked
    objChart.HasLegend = True
    'Give title to graph.
    objChart.HasTitle = true
    objChart.Title.Caption= "Yearly Product Sales ($)"
    set objFont = objChart.Title.Font
    objFont.Name = "Tahoma"
    objFont.Size = 10
    objFont.Bold = True
    Set objRS = Server.CreateObject("ADODB.Recordset")
    objRS.ActiveConnection = "scanoptics"
    objRS.Source = "select * from YearlyProductSalesCost"
    objRS.CursorType = adOpenStatic
    objRS.CursorLocation = adUseClient
    set objChartSpace.DataSource = objRS
    objChart.SetData c.chDimSeriesNames, 0, "ProductCode"
    for each objSeries in objChart.SeriesCollection
       objSeries.SetData c.chDimCategories, 0, "YearPart"
       objSeries.SetData c.chDimValues, 0, "SumOfProductCost"
    for each axis in objChart.Axes
       axis.HasTitle = True
       if axis.Type = c.chCategoryAxis then
          axis.Title.Caption = "Year"
          axis.Title.Caption = "Total Sales ($)"
       end if
    strChartFile = ExportChartToGIF(objChartSpace)
    Response.Write "<IMG SRC=""" & strChartFile & """>"
    Any help is greatly appreciated...

    I apologise if I posted this message to the wrong section of the site.

    Last edited by flipster; 04-09-04 at 01:14.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts