Zooming by code on a date range
Zooming by code on a date range
Hi,
I'd like to zoom by code selecting a date range.
For example, my chart has date on bottom axis and 5 years of data (since 2004) and I'd like to zoom on the specific range (between 2007 and 2008) by code (not by clicking on the chart to draw a rectangle zone with mouse)
How can I do that ?
Thanks a lot for your help.
Regards
Guilz
I'd like to zoom by code selecting a date range.
For example, my chart has date on bottom axis and 5 years of data (since 2004) and I'd like to zoom on the specific range (between 2007 and 2008) by code (not by clicking on the chart to draw a rectangle zone with mouse)
How can I do that ?
Thanks a lot for your help.
Regards
Guilz
Re: Zooming by code on a date range
Hi Guilz,
A zoom simply consists on changing the axes minimum and maximum values. In your case you could do for example the following:
A zoom simply consists on changing the axes minimum and maximum values. In your case you could do for example the following:
Code: Select all
Private Sub Form_Load()
TChart1.Aspect.View3D = False
TChart1.AddSeries scFastLine
TChart1.Series(0).XValues.DateTime = True
Dim month, year As Integer
For year = 2004 To 2009
For month = 1 To 12
TChart1.Series(0).AddXY DateValue("1/" & Str$(month) & "/" & Str$(year)), Rnd * 100, "", clTeeColor
Next month
Next year
DoZoom
End Sub
Private Sub DoZoom()
TChart1.Axis.Bottom.SetMinMax DateValue("1/1/2007"), DateValue("1/1/2008")
End Sub
Private Sub UndoZoom() ' function to be called when you'll want to undo the zoom
TChart1.Axis.Bottom.Automatic = True
End Sub
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Zooming by code on a date range
Thanks Yeray
What is the best way to do the same when the bottom axis is not in datetime mode ?
I think it is necessary to find the label caption in the labels collection to get label index and to use the SetMinMax method. Is it right ?
Does it exist best method to do that ?
Regards,
Guilz
What is the best way to do the same when the bottom axis is not in datetime mode ?
I think it is necessary to find the label caption in the labels collection to get label index and to use the SetMinMax method. Is it right ?
Does it exist best method to do that ?
Regards,
Guilz
Re: Zooming by code on a date range
Hi Guilz,
If your bottom axis isn't datetime it is possible that the labels coincide with the values index but note that this is not necessary.
For more information about Zooming, please, take a look at the Tutorial 11 - Zoom and Scroll. You'll find demos and tutorials at TeeChart programs group.
If you still find problems with it, please, try to explain what are you exactly trying to do. A picture would probably help us to understand it better.
If your bottom axis isn't datetime it is possible that the labels coincide with the values index but note that this is not necessary.
For more information about Zooming, please, take a look at the Tutorial 11 - Zoom and Scroll. You'll find demos and tutorials at TeeChart programs group.
If you still find problems with it, please, try to explain what are you exactly trying to do. A picture would probably help us to understand it better.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Zooming by code on a date range
Thks Yeray, your help is very usefull
Looking the tutorial about zooming and scrolling, help speak about TChartScrollBar component but I don't able to find and use it (I use Tchart Pro v7).
How can I find it ?
Here components list available for me:
TeeChart
TeeListBox
TeeEditor
TeePreviewer
TeeCommander
TeePreviewPanel
ChartGridNavigator
ChartPageNavigator
ChartEditorPanel
ChartGrid
SeriesXMLSource
SeriesTextSource
CrossTabSource
Thank you Yeray
Guilz
Looking the tutorial about zooming and scrolling, help speak about TChartScrollBar component but I don't able to find and use it (I use Tchart Pro v7).
How can I find it ?
Here components list available for me:
TeeChart
TeeListBox
TeeEditor
TeePreviewer
TeeCommander
TeePreviewPanel
ChartGridNavigator
ChartPageNavigator
ChartEditorPanel
ChartGrid
SeriesXMLSource
SeriesTextSource
CrossTabSource
Thank you Yeray
Guilz
Re: Zooming by code on a date range
Hi Guilz,
It's strange, I think it should be included in v7. Could you please see if there is the unit TeeScroB.dcu present in the lib folder of your TeeChart installation path (Normally it should be something like C:\Program Files\Steema Software\TeeChart 8.06 for Delphi 2010\Delphi14\Lib).
Anyway, it is a component with some problems so we usually recommend not to use it and use a normal TScrollBar component and do the scroll through it.
It's strange, I think it should be included in v7. Could you please see if there is the unit TeeScroB.dcu present in the lib folder of your TeeChart installation path (Normally it should be something like C:\Program Files\Steema Software\TeeChart 8.06 for Delphi 2010\Delphi14\Lib).
Anyway, it is a component with some problems so we usually recommend not to use it and use a normal TScrollBar component and do the scroll through it.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Zooming by code on a date range
I use Teechart with VB6.
Screenshot of the directory attached.
You speak about TScrollBar: what is the difference with TChartScrollBar ?
I don't have TScrollBar too
Guilz
Screenshot of the directory attached.
You speak about TScrollBar: what is the difference with TChartScrollBar ?
I don't have TScrollBar too
Guilz
- Attachments
-
- Teechart.jpg (76.64 KiB) Viewed 13397 times
Re: Zooming by code on a date range
Hi Guilz,
Ouh, excuse me. When you talked about TChartScrollBar, I started to think in VCL terms; I forgot that we are in ActiveX.
It's strange, does your ActiveX tutorial talk about TChartScrollBar? Can you please tell me exactly where?
In VB6 there is the HScrollBar that is useful to do the scrolling. For example:
Ouh, excuse me. When you talked about TChartScrollBar, I started to think in VCL terms; I forgot that we are in ActiveX.
It's strange, does your ActiveX tutorial talk about TChartScrollBar? Can you please tell me exactly where?
In VB6 there is the HScrollBar that is useful to do the scrolling. For example:
Code: Select all
Dim PointsShown As Integer
Private Sub Form_Load()
TeeCommander1.Chart = TChart1
TChart1.Aspect.View3D = False
TChart1.AddSeries scLine
TChart1.Series(0).asLine.Pointer.Visible = True
TChart1.Series(0).FillSampleValues 25
PointsShown = 5
HScroll1.Min = 0
HScroll1.Max = TChart1.Series(0).Count - PointsShown - 1
HScroll1.Value = 0
HScroll1_Change
End Sub
Private Sub HScroll1_Change()
TChart1.Axis.Bottom.SetMinMax HScroll1.Value, HScroll1.Value + PointsShown
End Sub
Private Sub HScroll1_Scroll()
HScroll1_Change
End Sub
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Zooming by code on a date range
I think Tutorial 11 - Zoom and Scroll is not specific for ActiveX component
So in my case, TChartScrollBar is not available but if this component has some bug not a problem for me
Thks a lot for your sample.
Guilz
So in my case, TChartScrollBar is not available but if this component has some bug not a problem for me
Thks a lot for your sample.
Guilz
Re: Zooming by code on a date range
Hi
Another day, another question
How can I adapt automaticaly optimal axis range (left axis) when I use setminmax function to zoom on a specific range (bottom axis) ?
Have a look to my screenshot, easier to understand.
Thanks for your help
Guilz
Another day, another question
How can I adapt automaticaly optimal axis range (left axis) when I use setminmax function to zoom on a specific range (bottom axis) ?
Have a look to my screenshot, easier to understand.
Thanks for your help
Guilz
- Attachments
-
- t1.jpg (181.55 KiB) Viewed 13381 times
-
- t2.jpg (189.01 KiB) Viewed 13382 times
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Zooming by code on a date range
Hi Guilz,
This is what TeeChart axes do automatically by default you can set axes to scale automatically and use their offset, for example:
This is what TeeChart axes do automatically by default you can set axes to scale automatically and use their offset, for example:
Code: Select all
Private Sub Command1_Click()
TChart1.Axis.Left.Automatic = True
TChart1.Axis.Bottom.Automatic = True
TChart1.Axis.Left.MinimumOffset = 50
TChart1.Axis.Left.MaximumOffset = 50
TChart1.Axis.Bottom.MinimumOffset = 50
TChart1.Axis.Bottom.MaximumOffset = 50
End Sub
Private Sub Form_Load()
TChart1.Axis.Left.SetMinMax 500, 1000
TChart1.Axis.Bottom.SetMinMax 5, 10
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 |
Instructions - How to post in this forum |
Re: Zooming by code on a date range
Hi narcis,
my axis automatic property are set to true but it does not reflect minimum and maximum values for the range define by setminmax method on bottom axis only -> on Left axis, min max values reflecting entire content of the graph.
Hope it help you to understand my problem
Thks a lot
Guilz
my axis automatic property are set to true but it does not reflect minimum and maximum values for the range define by setminmax method on bottom axis only -> on Left axis, min max values reflecting entire content of the graph.
Hope it help you to understand my problem
Thks a lot
Guilz
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Zooming by code on a date range
Hi Guilz,
Ok, I think I understand what you are trying to achieve now. You could do something as the local minimum and maximum example suggested here. You could use series' FirstVisibleIndex and LastVisibleIndex as first and last arguments. This is a TeeChart .NET thread but same applies to TeeChart ActiveX.
Hope this helps.
Ok, I think I understand what you are trying to achieve now. You could do something as the local minimum and maximum example suggested here. You could use series' FirstVisibleIndex and LastVisibleIndex as first and last arguments. This is a TeeChart .NET thread but same applies to TeeChart ActiveX.
Hope this helps.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Zooming by code on a date range
Hi Narcis,
Thanks for your answer but could you confirm me the FirstVisibleIndex and LastVisibleIndex properties are available for Teechart Pro 7.0 ActiveX because I can't find them Hope it is not only for .Net...
Guilz
Thanks for your answer but could you confirm me the FirstVisibleIndex and LastVisibleIndex properties are available for Teechart Pro 7.0 ActiveX because I can't find them Hope it is not only for .Net...
Guilz
Re: Zooming by code on a date range
Hi Guilz,
Yes, FirstVisibleIndex and LastVisibleIndex aren't available in TeeChart AX v7 but you can use MinVisibleValue and MaxVisibleValue as follows:
Yes, FirstVisibleIndex and LastVisibleIndex aren't available in TeeChart AX v7 but you can use MinVisibleValue and MaxVisibleValue as follows:
Code: Select all
Private Sub Form_Load()
TChart1.Aspect.View3D = False
TChart1.AddSeries scFastLine
TChart1.Series(0).Add Rnd * 1000, "", clTeeColor
Dim i As Integer
For i = 0 To 10
TChart1.Series(0).Add TChart1.Series(0).YValues.Value(TChart1.Series(0).Count - 1) + Rnd * 10 - 5, "", clTeeColor
Next i
TChart1.Series(0).Add Rnd * 100, "", clTeeColor
For i = 0 To 20
TChart1.Series(0).Add TChart1.Series(0).YValues.Value(TChart1.Series(0).Count - 1) + Rnd * 10 - 5, "", clTeeColor
Next i
End Sub
Private Sub Command1_Click()
TChart1.Axis.Bottom.SetMinMax 15, TChart1.Series(0).Count - 1
AdjustLeftAxis
End Sub
Private Sub AdjustLeftAxis()
TChart1.Environment.InternalRepaint
TChart1.Axis.Left.SetMinMax TChart1.Series(0).MinVisibleValue(1), TChart1.Series(0).MaxVisibleValue(1)
End Sub
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |