Hello,
I am trying to implement TeeCharts for financial charting, i.e. Candle series. Whilst things are progressing OK, I need assistance with the following;
1. I would like the user to be able to scroll (left or right) using a standard VB scrollbar. How can I connect the scrollbar to the teechart so that any scrolling on the scrollbar will result in the chart scrolling in accordance.
2. Zooming, how can I implement a zoom in and out button, keeping in mind the scrollbar will need to adjust also.
3. When setting chart axis through code, am I best to do this in the OnBeforeDrawChart or OnAfterDraw call functions.
4. Can we set the candle width to two decimal places? This would allow the graphical elements (candles) to better grow and shrink as the user zooms in and out.
5. Can I prevent TeeCharts from panning past the data on both the left and right sides of the chart. Scrolling via the mouse is vertical only and I would like to stop TeeCharts from scrolling past the ends of the dataset when using the mouse for scrolling.
6. Can a horizontal line be located between two series. It would be good to be able to position the line using a percent setting just like we can define the heights of series using a percentage range, i.e. StartPosition, EndPosition.
I would really like some feedback on the above, we have implemented some functionality but I would like to know how others have implemented such functionality.
Any help is appreciated.
Cheers
A
Candle - Scrolling, RePaint queries
Hi paligap,
I've made an example with a possible a solution for questions 1,2 and 5.
I've made an example with a possible a solution for questions 1,2 and 5.
Code: Select all
Dim nValues As Integer 'number of values shown from the candle series
Private Sub Command1_Click() 'Zooming
nValues = nValues - 1
If nValues > 1 Then
Command2.Enabled = True
HScroll1_Change
With TChart1.Series(0)
TChart1.Axis.Left.SetMinMax .MinVisibleValue(3) - 5, .MaxVisibleValue(2) + 5
.asCandle.CandleWidth = .asCandle.CandleWidth + 2
End With
Else 'if nValues = 1
Command1.Enabled = False
With TChart1.Series(0).XValues
TChart1.Axis.Bottom.SetMinMax .Value(0) - 0.5, .Value(0) + 0.5
End With
End If
End Sub
Private Sub Command2_Click() 'UnZooming
If nValues < TChart1.Series(0).Count Then
Command1.Enabled = True
nValues = nValues + 1
If nValues = TChart1.Series(0).Count Then
Command2.Enabled = False
End If
If HScroll1.Value = HScroll1.Max Then 'if we unzoom when showing last value, we have to see another point from the left side
HScroll1.Value = HScroll1.Value - 1
Else
HScroll1_Change
End If
With TChart1.Series(0)
TChart1.Axis.Left.SetMinMax .MinVisibleValue(3) - 5, .MaxVisibleValue(2) + 5
If .asCandle.CandleWidth > 2 Then
.asCandle.CandleWidth = .asCandle.CandleWidth - 2
End If
End With
End If
End Sub
Private Sub Form_Load()
TChart1.Zoom.Enable = False
TChart1.Scroll.Enable = pmNone
With TChart1
.Aspect.View3D = False
.Legend.Visible = False
nValues = 20
.AddSeries scCandle
.Series(0).FillSampleValues 30
With .Axis.Bottom
.AutomaticMaximum = False
.AutomaticMinimum = False
.SetMinMax TChart1.Series(0).XValues.Value(0), TChart1.Series(0).XValues.Value(nValues - 1)
.MaximumOffset = 5
.MinimumOffset = 5
End With
End With
HScroll1.Max = TChart1.Series(0).Count - nValues - 1
HScroll1.Min = 0
End Sub
Private Sub HScroll1_Change()
With TChart1.Series(0).XValues
TChart1.Axis.Bottom.SetMinMax .Value(HScroll1.Value), .Value(HScroll1.Value + nValues - 1)
End With
HScroll1.Max = TChart1.Series(0).Count - nValues
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 |
Hi paligap,
Note that I've cleaned, explained and improved a little bit the code above right now (Monday 3rd December).
Regarding the other questions:
3. It depends on your axes requests. If you need updated series values to calculate axis settings, you'll need OnAfterDraw event.
4. Note that the property CandleWidth is an Integer, so if you try to set it to, for example, 0.5, the value will be rounded to 0.
6. I'm are not sure to understand what exactly you mean but probably you'll solve it using Color Line Tool or Color Band Tool and calculating your percentages manually.
Note that I've cleaned, explained and improved a little bit the code above right now (Monday 3rd December).
Regarding the other questions:
3. It depends on your axes requests. If you need updated series values to calculate axis settings, you'll need OnAfterDraw event.
4. Note that the property CandleWidth is an Integer, so if you try to set it to, for example, 0.5, the value will be rounded to 0.
6. I'm are not sure to understand what exactly you mean but probably you'll solve it using Color Line Tool or Color Band Tool and calculating your percentages manually.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |