Page 1 of 1

Bar Graph wont stack

Posted: Thu Jan 20, 2005 10:17 pm
by 6924764
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.

Posted: Fri Jan 21, 2005 5:50 pm
by Pep
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 ?

Re: Graph wont stack bars

Posted: Thu Jan 27, 2005 7:08 am
by 6924764
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

Posted: Thu Jan 27, 2005 10:09 am
by Marjan
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).