Bar Graph wont stack

TeeChart for ActiveX, COM and ASP
Post Reply
TChartUser
Newbie
Newbie
Posts: 12
Joined: Fri Nov 15, 2002 12:00 am
Location: San Diego, CA

Bar Graph wont stack

Post by TChartUser » Thu Jan 20, 2005 10:17 pm

Hello,

I'm using v5, asp page, trying to create a stacked bar graph out of an MS Access db.
I can't seem to get the bars to stack. They are overlapping. Here is my code:

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "DSN=xx;UID=;PWD=xx"

Set objCmd = Server.CreateObject("ADODB.Command")
objCmd.ActiveConnection = objConn
objCmd.CommandText = "UniqueNamesByVolume"
objCmd.CommandType = adCmdStoredProc


'Create Chart
Set DisruptionChart = CreateObject("TeeChart.TChart")
DisruptionChart.Width = 650
DisruptionChart.Height = 400
DisruptionChart.Legend.Visible=False
DisruptionChart.Panel.BevelOuter = 0
DisruptionChart.Panel.BorderStyle = 0
DisruptionChart.Axis.Bottom.Labels.DateTimeFormat = "MM/dd/yy"
DisruptionChart.Aspect.View3D = False
DisruptionChart.Axis.Bottom.Labels.Angle= 90


Set objRs = objCmd.Execute()

Dim i, j
i = 0

While Not objRs.EOF
DisruptionChart.AddSeries(scBar)
DisruptionChart.Series(i).asBar.MultiBar = mbStacked
DisruptionChart.Series(i).asBar.StackGroup = 1
DisruptionChart.Series(i).Marks.Visible = False
DisruptionChart.Series(i).Title = objRs("UniqueName")
DisruptionChart.Series(i).XValues.DateTime = True
i = i + 1
objRs.MoveNext
Wend

Set objCmd = Server.CreateObject("ADODB.Command")
objCmd.ActiveConnection = objConn
objCmd.CommandText = "MyDisruptions"
objCmd.CommandType = adCmdStoredProc

Set objRs = objCmd.Execute()

While Not objRs.EOF
For j = 0 To i - 1
If DisruptionChart.Series(j).Title = objRs("UniqueName") Then
DisruptionChart.Series(j).AddXY objRs("OutageDate"), objRs("Outages"), "", clTeeColor

Else
DisruptionChart.Series(j).AddNullXY objRs("OutageDate"), 0, ""
End If
Next
objRs.MoveNext
Wend

I'm using two queries because I want the series in the legend sortedby volume and the graph sorted by date. Any Help Appreciated.

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Fri Jan 21, 2005 5:50 pm

Hi,

It seems to work fine here using your code and adding a random values (using the v5.06).
Could you please post an example inthe steema.public.attachments newsgroup with which I can reproduce the problem "as is" here ?

TChartUser
Newbie
Newbie
Posts: 12
Joined: Fri Nov 15, 2002 12:00 am
Location: San Diego, CA

Re: Graph wont stack bars

Post by TChartUser » Thu Jan 27, 2005 7:08 am

Pep,

I have attached some docs to the email and posted to steema.public.attachments. I am still not able to resolve this issue. I have tried multiple methods in both classic asp and C#.NET . I get the same results on both. The lines show side by side or they overlap but I cannot get them to stack.
Do I need to specify the origin for each stacked bar?

Thank You,

Manny

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Thu Jan 27, 2005 10:09 am

Hi.

Looking at posted image the bars x coordinates do not coincide and also, all series don't have the same number of points. The stacking algorithm will work *only* if all series have the same number of points and all idividual series xvalues coincide. If this is not the case, stacking will not work. In this case the only solution is to make sure the above conditions are met. This can be done by:
a) Making a list of all possible x values;
b) For each series checking if a point for specific x value exist. If yes, add it to series, if not, add a null point to series (null points will not be shown in chart).

The end result will be all series will have the same number of points (and will stack correctly).
Marjan Slatinek,
http://www.steema.com

Post Reply