Page 1 of 1

Display text and symbol information on a chart

Posted: Thu Nov 25, 2010 10:15 am
by 9533057
Hi Teechart support Team,

2 questions:
1 - How can I change Mark text without using _OnGetSeriesMark method (I would like to change mark text for 1 serie not for all my series) ?

Code: Select all

With AxTChart.Series(AxTChart.SeriesCount - 1).Marks.Item(nbMarks)
End With
->but unfortunately the .Text property is readonly...

2 - My need is to display information on my chart (a symbol and a text -> gray circle and Island Reversal text in my example)) like in the chart bellow:
marks.png
marks.png (25.63 KiB) Viewed 13080 times
What is the best way to do this ?

Thanks for your help

Guilz

Re: Display text and symbol information on a chart

Posted: Thu Nov 25, 2010 11:36 am
by yeray
Hi Guliz,
Guilz wrote:1 - How can I change Mark text without using _OnGetSeriesMark method (I would like to change mark text for 1 serie not for all my series) ?
You can change the label for each point:

Code: Select all

TChart1.Series(i).PointLabel(0) = "my text"
Guilz wrote:2 - My need is to display information on my chart (a symbol and a text -> gray circle and Island Reversal text in my example)) like in the chart bellow:
Here you have a simple example showing how to achieve a chart similar that the picture you've attached:

Code: Select all

Private Sub Form_Load()  
  TChart1.Aspect.View3D = False
  TChart1.Legend.Visible = False
  
  TChart1.AddSeries scFastLine
  TChart1.Series(0).FillSampleValues 1000
  
  TChart1.AddSeries scPoint
  With TChart1.Series(1)
    .Color = RGB(10, 10, 10)
    With .Marks
      .Visible = True
      .Transparent = True
      .Font.Color = vbGrayText
      .Arrow.Visible = False
      .ArrowLength = -15
    End With
    With .asPoint.Pointer
      .Style = psCircle
      .Pen.Visible = False
      .HorizontalSize = 8
      .VerticalSize = 8
      .Transparency = 50
    End With
  End With
  
  Dim i, c As Integer
  For i = 0 To TChart1.Series(0).Count - 1
    If i Mod 75 = 0 Then
      c = Rnd * 255
      TChart1.Series(1).AddXY TChart1.Series(0).XValues.Value(i), TChart1.Series(0).YValues.Value(i), "point nÂș" + Str$(TChart1.Series(1).Count), RGB(c, c, c)
    End If
  Next i
  
  TChart1.Axis.Bottom.Labels.Style = talValue
End Sub

Re: Display text and symbol information on a chart

Posted: Thu Nov 25, 2010 12:01 pm
by 9533057
Hi Yeray,

It is working like a charm, as usual :wink:

Thanks a lot

Regards,

Guilz

Re: Display text and symbol information on a chart

Posted: Thu Nov 25, 2010 1:44 pm
by yeray
Hi Guliz,

Pleased to be helpful! :D

Re: Display text and symbol information on a chart

Posted: Thu Nov 25, 2010 2:52 pm
by 9533057
I have an another issue with marks:
We use marks on chart and create function to let space between marks (for readability problem)
marks00.png
marks00.png (61.5 KiB) Viewed 13046 times
But on Candle Chart we would like to have the same logic with only 1 mark (Open, Close, High, Low and corresponding date) and not one mark for Open one mark for close one mark for High like in the screen shot bellow...
marks00.png
marks00.png (61.5 KiB) Viewed 13046 times
How can we do that ?

Thanks for your help

Guilz

Re: Display text and symbol information on a chart

Posted: Thu Nov 25, 2010 4:38 pm
by 10050769
Hello Guilz,

You can use in OnGetSeriesMark event a code as the next:

Code: Select all

Private Sub Form_Load()
TChart1.Aspect.View3D = False
TeeCommander1.Chart = TChart1
TChart1.AddSeries scCandle
TChart1.Series(0).FillSampleValues (5)
TChart1.Series(0).Marks.Visible = True
End Sub

Private Sub TChart1_OnGetSeriesMark(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, MarkText As String)
    
MarkText = "Data:" & Str$(TChart1.Series(0).asCandle.DateValues.Value(ValueIndex)) & vbCr & "Open" & Str$(TChart1.Series(0).asCandle.OpenValues.Value(ValueIndex)) & vbCr & "Close" & Str$(TChart1.Series(0).asCandle.CloseValues.Value(ValueIndex)) & vbCr & "High" & Str$(TChart1.Series(0).asCandle.HighValues.Value(ValueIndex)) & vbCr & "Low" & Str$(TChart1.Series(0).asCandle.LowValues.Value(ValueIndex))

End Sub
Could you tell us, if code works as you want?

I hope will helps.

Thanks,

Re: Display text and symbol information on a chart

Posted: Thu Nov 25, 2010 5:19 pm
by 9533057
Hi Sandra,

It is not working fine for me -
For Candle chart type, I would like to have less Marks for readability problem.
In fact .Marks.DrawEvery property does not work fine with candle type (see my picture to understand the problem)

Regards,

Guilz

Re: Display text and symbol information on a chart

Posted: Fri Nov 26, 2010 8:56 am
by 10050769
Hello Guilz,

I couldn't reproduce your problem using TeeChartAcitvex2010 and next code:

Code: Select all

Private Sub Form_Load()
TChart1.Aspect.View3D = False
TeeCommander1.Chart = TChart1
TChart1.AddSeries scCandle
TChart1.Series(0).FillSampleValues (25)
TChart1.Series(0).Marks.Visible = True
TChart1.Series(0).Marks.DrawEvery = 2

End Sub

Private Sub TChart1_OnGetSeriesMark(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, MarkText As String)
    
MarkText = "Data:" & Str$(TChart1.Series(0).asCandle.DateValues.Value(ValueIndex)) & vbCr & "Open" & Str$(TChart1.Series(0).asCandle.OpenValues.Value(ValueIndex)) & vbCr & "Close" & Str$(TChart1.Series(0).asCandle.CloseValues.Value(ValueIndex)) & vbCr & "High" & Str$(TChart1.Series(0).asCandle.HighValues.Value(ValueIndex)) & vbCr & "Low" & Str$(TChart1.Series(0).asCandle.LowValues.Value(ValueIndex))

End Sub
Could you please, send us a simple project or modify previous code? So we can reproduce your problem here. Moreover, you can tell us which version of TeeChart ActiveX are you using now?

Thanks,

Re: Display text and symbol information on a chart

Posted: Wed Dec 15, 2010 2:46 pm
by 15054354
Thanks Sandra,

indeed it's working also well with Version 8.

Cheers
Petar