How to show only last 6 values in the legend

TeeChart for ActiveX, COM and ASP
Post Reply
amueller
Newbie
Newbie
Posts: 30
Joined: Tue Jul 26, 2005 4:00 am

How to show only last 6 values in the legend

Post by amueller » Wed Oct 26, 2005 6:54 pm

Hello,

For some reason, my legend is only showing the last point in the legend. I really don't have anything that is making it only show 1 point, but it is. Here is the code... How can I have it show the last 6 points? Or better yet, how can I zoom a chart (by button push) such that only the last 6 points are being shown and they are all in the legend.

code

With TChart2

.Legend.Visible = True
.Legend.Gradient.StartColor = RGB(125, 125, 125)
.Legend.Gradient.EndColor = vbWhite

.Series(0).ShowInLegend = False
.Series(1).ShowInLegend = True
.Series(2).ShowInLegend = False

.Legend.Alignment = laRight
.Legend.Shadow.Transparency = 100

End With


Thanks!

Andrew

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

Post by Narcís » Thu Oct 27, 2005 8:07 am

Hi Andrew,

Yes, this can be achieved doing something like:

Code: Select all

Private Sub Command1_Click()
    TChart1.Series(1).ShowInLegend = False
    TChart1.Series(2).ShowInLegend = False
    
    TChart1.Legend.LegendStyle = lsValues
    
    With TChart1.Series(0)
        TChart1.Axis.Bottom.SetMinMax .XValues.Value(.Count - 6), _
                                        .XValues.Value(.Count - 1)
                                        
        TChart1.Legend.FirstValue = .Count - 6
    End With
End Sub

Private Sub Command2_Click()
    With TChart1.Axis
        .Left.Automatic = True
        .Bottom.Automatic = True
    End With
    
    TChart1.Series(1).ShowInLegend = True
    TChart1.Series(2).ShowInLegend = True
    
    TChart1.Legend.LegendStyle = lsAuto
End Sub

Private Sub Form_Load()
    For i = 0 To TChart1.SeriesCount - 1
        TChart1.Series(i).FillSampleValues 25
    Next
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

amueller
Newbie
Newbie
Posts: 30
Joined: Tue Jul 26, 2005 4:00 am

Post by amueller » Thu Oct 27, 2005 1:42 pm

That DID give me the last 6 on the chart, thanks... However, the legend didn't display. I got it to display myself, but it still only showed the last value and not the last 6.

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

Post by Narcís » Fri Oct 28, 2005 11:00 am

Hi Andrew,

Could you please send us an example we can run "as-is" to reproduce the problem here?

You can post your files at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup.
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

amueller
Newbie
Newbie
Posts: 30
Joined: Tue Jul 26, 2005 4:00 am

Post by amueller » Mon Oct 31, 2005 2:01 pm

I posted the VB6 project (simple test project) onto the newsgroup for you.

Thanks,

Andrew

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

Post by Narcís » Wed Nov 02, 2005 10:03 am

Hi Andrew,

Thanks for the example but I'm afraid that form files are missing. Could you please check it?

Thanks in advance.
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