Bar chart query.

TeeChart for ActiveX, COM and ASP
Post Reply
TonyVSUK
Advanced
Posts: 163
Joined: Wed Mar 01, 2006 12:00 am

Bar chart query.

Post by TonyVSUK » Tue Oct 05, 2010 7:34 pm

Can someone try the VB code below?

The first bar has a X value of "0", but appears on the plot at approximately -3. What is going on?


Code: Select all

Private Sub DrawBar()
Dim i As Long

TChart1.RemoveAllSeries
For i = 0 To 5
    TChart1.AddSeries scBar
    TChart1.Series(i).AddXY i, i * 2, "", TChart1.Series(i).Color
Next i
End Sub
Attachments
TChart_Bar_problem.jpg
TChart_Bar_problem.jpg (21.5 KiB) Viewed 12110 times

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Bar chart query.

Post by Narcís » Wed Oct 06, 2010 10:07 am

Hi Tony,

I'm afraid this is a bug I have added to the defect list (TV52015189) to be fixed.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

TonyVSUK
Advanced
Posts: 163
Joined: Wed Mar 01, 2006 12:00 am

Re: Bar chart query.

Post by TonyVSUK » Wed Oct 06, 2010 10:12 am

Any idea when? I have customers waiting.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Bar chart query.

Post by Narcís » Wed Oct 06, 2010 10:17 am

Hi Tony,

I can't give you an estimate date for now but this is a high-priority item in the list.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Bar chart query.

Post by Narcís » Wed Oct 06, 2010 11:20 am

Hi Tony,

Thinking a little bit further about this issue, the stacking algorithm will work correctly *only* if all series have the same number of points and point x values coincide. If this is not the case, you'll have to use AddNullXY method to add "missing points". I'd use the following approach:

1) Make a list of all available (pool) of x values.
2) For individual series, cycle through (1) and use AddXY if point (x,y) exists and AddNullXY if specific point (x,y) does not exist for this series.

An easier alternative is setting MultiBar to mbNone, for example:

Code: Select all

Private Sub Form_Load()
    Dim i As Long
    
    TChart1.RemoveAllSeries
    For i = 0 To 5
        TChart1.AddSeries scBar
        TChart1.Series(i).asBar.MultiBar = mbNone
        TChart1.Series(i).asBar.BarWidthPercent = 20
        TChart1.Series(i).AddXY i, i * 2, "", TChart1.Series(i).Color
    Next i
End Sub
So we have closed the issue in the bug list.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

TonyVSUK
Advanced
Posts: 163
Joined: Wed Mar 01, 2006 12:00 am

Re: Bar chart query.

Post by TonyVSUK » Wed Oct 06, 2010 11:38 am

So we have closed the issue in the bug list.
Are you serious? How can anyone possibly make use of a chart component where the axes are not labelled correctly?

There are two series types now that do not label the axes correctly (gantt and bar).

This is a really serious bug.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Bar chart query.

Post by Narcís » Wed Oct 06, 2010 1:01 pm

Hi Tony,

This is how stacked series are designed. For stacking to work you need to have same number of points in all series and all of them should have same X values. Setting Multibar to mbNone doesn't label series wrongly but it may be nicer in 2D. There are 2 options here:

1. Set MultiBar to none and the chart to 2D view:

Code: Select all

Private Sub Form_Load()
    Dim i As Long
       
    TChart1.RemoveAllSeries
    TChart1.Aspect.View3D = False
    For i = 0 To 5
        TChart1.AddSeries scBar
        TChart1.Series(i).asBar.MultiBar = mbNone
        TChart1.Series(i).asBar.BarWidthPercent = 20
        TChart1.Series(i).AddXY i, i * 2, "", TChart1.Series(i).Color
    Next i
End Sub
2. Add same X values for all series setting to null the points which should not be displayed in the chart.

Code: Select all

Private Sub Form_Load()
    Dim i As Long
       
    TChart1.RemoveAllSeries
    TChart1.Aspect.View3D = False
    For i = 0 To 5
        TChart1.AddSeries scBar
        
        For j = 0 To 5
            TChart1.Series(i).AddXY j, i * 2, "", TChart1.Series(i).Color
            
            If i <> j Then
                TChart1.Series(i).SetNull j
            End If
        Next
    Next i
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

TonyVSUK
Advanced
Posts: 163
Joined: Wed Mar 01, 2006 12:00 am

Re: Bar chart query.

Post by TonyVSUK » Wed Oct 06, 2010 1:13 pm

My original query is not related to stacking in any way. It's basic code to draw some bars, and the x axis labels are completely wrong.

I don't want stacked series in this case, I just want the axis labelled correctly.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Bar chart query.

Post by Narcís » Wed Oct 06, 2010 1:19 pm

Hi Tony,

Yes, I understand but by default Bar series are set to MultiBar = mbSide. That's why I'm saying that if you are using several bar series the way you are you should either set MultiBar to mbNone or add null values where necessary. Actually, the example you sent would be easier using one single bar series, you can already have a different color for each series:

Code: Select all

Private Sub Form_Load()
    Dim i As Long
   
    TChart1.RemoveAllSeries
    TChart1.AddSeries scBar
    TChart1.Series(0).asBar.BarWidthPercent = 20
    TChart1.Series(0).ColorEachPoint = True
    
    For i = 0 To 5
        TChart1.Series(0).AddXY i, i * 2, "", clTeeColor
    Next i
End Sub
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Bar chart query.

Post by Narcís » Wed Oct 06, 2010 1:46 pm

Hi Tony,

Another option is setting Multibar to mbSideAll:

Code: Select all

Private Sub Form_Load()
  Dim i As Integer
  
  For i = 0 To 5
    TChart1.AddSeries scBar
    TChart1.Series(i).AddXY i, i * 2, "", TChart1.Series(i).Color
    TChart1.Series(i).asBar.MultiBar = mbSideAll
  Next i
End Sub
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply