If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > OWC Chart X-Axis Sorting Problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-08-04, 23:34
flipster flipster is offline
Registered User
 
Join Date: Apr 2004
Posts: 1
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 - http://www.rsit.com.au/table.gif - sorted by the year as you can see.

The result of the following code is http://www.rsit.com.au/chart.gif - sorted by the product code...

Code:
<!--#include file="adovbs.inc" -->
<%

Function ExportChartToGIF(objCSpace)
   'Get a random filename
   Dim strFileName
   Randomize 
   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
   next
   set objFolder = nothing
   set objFS = nothing
End Sub



set objChartSpace = Server.CreateObject("OWC.Chart")
set objChart = objChartSpace.Charts.Add()
set c = objChartSpace.Constants

'chChartTypeLine
'chChartTypeColumnClustered
'chChartTypePie
'chChartTypeColumnStacked


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
objRS.Open()


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"
next


for each axis in objChart.Axes
   axis.HasTitle = True
   if axis.Type = c.chCategoryAxis then
      axis.Title.Caption = "Year"
   else
      axis.Title.Caption = "Total Sales ($)"
   end if
next

strChartFile = ExportChartToGIF(objChartSpace)
Response.Write "<IMG SRC=""" & strChartFile & """>"
CleanUpGIF
%>
Any help is greatly appreciated...

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

Flipster.

Last edited by flipster; 04-09-04 at 00:14.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On