Page 1 of 1

magic rectangle when using .Tools.Add tcAnnotate

Posted: Thu Jun 23, 2005 6:03 pm
by 9527086
When i use this instruction
.Tools.Add tcAnnotate after drawing a curves on my chart, a small rectangle appears on the left top corner of the chart. I don't know where it comes from. help me

thanx

Posted: Mon Jun 27, 2005 8:07 am
by narcis
Hi Ghynna,

That's what Annotation tool is about. The statement you mention is the one which creates that rectangle. For more information on TeeChart tools you could have a look at TeeChart tutorials, features demo and help files all available at TeeChart's program group.

Posted: Mon Jun 27, 2005 2:45 pm
by 9527086
Thank you for your answer, but i know that the Annotation tool is about that. The problem is that there is another small rectangle in the left top corner, in addition to the rectangle where i write my text. So there are 2 rectangles.
thank you in advance

Posted: Mon Jun 27, 2005 2:56 pm
by narcis
Hi Ghynna,

Could you please send us an example we can run "as-is" to reproduce the problem here? You can post your files at news://www.steema.net/steema.public.attachments newsgroup.

Posted: Wed Jun 29, 2005 3:22 pm
by 9527086
i send you a the source code (which is a part a program) that causes problems.

Private Sub DrawKinetic() 'ByVal nbpoint As Integer
If (draw_alpha = True) Then
GraphFile.RemoveAllSeries
GraphFile.AddSeries scPoint '(scFastLine)
GraphFile.Series(0).Clear
GraphFile.Axis.Left.Title.Caption = "Temperature"
GraphFile.Series(0).FastLine.LinePen.Width = 2

Dim val
Dim tmp
For i = 0 To nb_points - 1
val = temp(i)
GraphFile.Series(0).AddXY time(i), val, "", vbBlue
Next i
Dim peak As Double
Dim index As Integer
index = Peak_TemperatureIndex()
peak = Calcul_Alpha_DAlpha.temp(index)
With GraphFile
.Tools.Add tcAnnotate
.Tools.Items(0).Active = True
With .Tools.Items(0).asAnnotation
.Shape.CustomPosition = True
.Shape.Left = 100
.Shape.Top = 200
.Shape.Gradient.Visible = True
.Shape.ShapeStyle = fosRoundRectangle
.Shape.Font.Name = "Verdana"
.Text = "Peak temperature =" + Format(CStr(peak), "#####0.0#") + "°K" + Chr(13) + "Reaction Enthalpy =" + Format(CStr(enthalpy), "#####0.0#") + "kJ"
End With
End With

End If
End Sub

Posted: Thu Jun 30, 2005 2:24 pm
by narcis
Hi Ghynna,

It's hard to guess without being able to run your code as, in your snipet, you only add one Annotation tool. Would you be so kind to send us an example we can run "as-is" to reproduce the problem here so that we can reproduce the problem here and help you finding a solution?

Thanks in advance.

Posted: Mon Jul 04, 2005 2:18 pm
by 9527086
hi narcis
I send an example you can run "as-is" to reproduce the problem.
Thanx

ghynna

Posted: Mon Jul 04, 2005 3:19 pm
by narcis
Hi ghynna,

I've been able to reproduce your problem here and I've found a solution for it. The problem was that every time you changed the series style you where adding a new Annotation tool to the chart. To reproduce this click ComboSeries and then go to the Tools tab at the chart editor. You'll notice one additional Annotation tool for every time you clicked the combobox. To prevent that I've added a IF statement checking if there already was an Annotation tool in the chart. See code below:

Code: Select all

Private Sub ComboSeries_Click()
  With TChart1
  'Look to see if there's already a Series in the Chart
  'Remove the existing Series
    .RemoveAllSeries
  'Add and randomly populate the new Series
  'eg. .AddSeries(scHorizBar) is the same as .AddSeries(2)
    .AddSeries (ComboSeries.ListIndex)
    .Series(0).FillSampleValues 15
  'Name the Series to visualise in the Chart Editor.
    .Series(0).Title = ComboSeries.List(ComboSeries.ListIndex) & "Series"
  'Modify the Chart Title
    .Header.Text(0) = .Series(0).Title

            If .Tools.Count <= 0 Then 'Added IF statement to prevent additional annotation tools.
                .Tools.Add tcAnnotate
                .Tools.Items(0).Active = True
                With .Tools.Items(0).asAnnotation
                    .Shape.CustomPosition = True
                    .Shape.Left = 100
                    .Shape.Top = 200
                    .Shape.Gradient.Visible = True
                    .Shape.ShapeStyle = fosRoundRectangle
                    .Shape.Font.Name = "Verdana"
                    .Text = "My text"
                End With
            End If
  End With
End Sub