Page 1 of 1

How to show only last 6 values in the legend

Posted: Wed Oct 26, 2005 6:54 pm
by 9527833
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

Posted: Thu Oct 27, 2005 8:07 am
by narcis
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

Posted: Thu Oct 27, 2005 1:42 pm
by 9527833
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.

Posted: Fri Oct 28, 2005 11:00 am
by narcis
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.

Posted: Mon Oct 31, 2005 2:01 pm
by 9527833
I posted the VB6 project (simple test project) onto the newsgroup for you.

Thanks,

Andrew

Posted: Wed Nov 02, 2005 10:03 am
by narcis
Hi Andrew,

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

Thanks in advance.