In the sample code below the rs contains 12400 records.
I set the bottom axis so I am only displaying the last 260 points.
How can I get the chart to scale the left axis to the maximum and minimum values visibly displayed?
#SAMPLE
With tc
.Environment.MouseWheelScroll = False
.RemoveAllSeries
.AddSeries scLine
.Axis.Left.MaximumOffset = 10
.Axis.Left.MinimumOffset = 10
.Series(0).VerticalAxis = aLeftAxis
.Series(0).DataSource = rs
.Series(0).YValues.ValueSource = "prClose"
.Axis.Bottom.SetMinMax (rs.RecordCount - 260), rs.RecordCount
#THE NEXT LINE SCALES ACCORDING TO THE WHOLE SERIES
.Axis.Left.SetMinMax .Series(0).YValues.Minimum, .Series(0).YValues.Maximum
End With
Axis min/max for visible data only
Hi,
you can use the MinVisibleValue and MaxVisibleValue methods, i.e. : :
you can use the MinVisibleValue and MaxVisibleValue methods, i.e. : :
Code: Select all
Private Sub Form_Load()
TChart1.Series(0).FillSampleValues (10)
TChart1.Axis.Bottom.SetMinMax 5, 8
TChart1.Environment.InternalRepaint
End Sub
Private Sub TChart1_OnAfterDraw()
With TChart1
.Axis.Left.SetMinMax .Series(0).MinVisibleValue(1), .Series(0).MaxVisibleValue(1)
End With
End Sub
Pep Jorge
http://support.steema.com
http://support.steema.com
Sorry
That was actually a bit embarressing since even doing it manually wasn't exactly rocket-science!
I think I do have a real question now though.
Same basic chart as before, ie, 12000 points, looking at 260 at a time. I want to enable the scroll feature - horizontal only - with the left mouse button. Using the built in scroll ability of the control works really well but I want it to stop at the left extent, ie. not scroll past a minimum x axis value of 1. I do want them to be able to scroll into the future so that is fine.
I think I do have a real question now though.
Same basic chart as before, ie, 12000 points, looking at 260 at a time. I want to enable the scroll feature - horizontal only - with the left mouse button. Using the built in scroll ability of the control works really well but I want it to stop at the left extent, ie. not scroll past a minimum x axis value of 1. I do want them to be able to scroll into the future so that is fine.
Hi,
you can use the OnScroll event, like in the below example :
you can use the OnScroll event, like in the below example :
Code: Select all
Private Sub Form_Load()
With TChart1
.AddSeries scLine
.Series(0).FillSampleValues (10)
.Scroll.Enable = pmHorizontal
.Zoom.MouseButton = mbRight
.Scroll.MouseButton = mbLeft
.Environment.InternalRepaint
End With
End Sub
Private Sub TChart1_OnAfterDraw()
With TChart1
.Axis.Left.SetMinMax .Series(0).MinVisibleValue(1), .Series(0).MaxVisibleValue(1)
End With
End Sub
Private Sub TChart1_OnScroll()
If TChart1.Axis.Bottom.Minimum < 1 Then
TChart1.Axis.Bottom.SetMinMax 1, TChart1.Axis.Bottom.MaxVisibleSeriesValue(True, 0)
End If
End Sub
Private Sub Command2_Click()
TChart1.Axis.Bottom.SetMinMax 3, 8
End Sub
Private Sub Command1_Click()
TChart1.Series(0).Add Rnd * 100, "", clTeeColor
End Sub
Pep Jorge
http://support.steema.com
http://support.steema.com