Can I manipulate the text comming as legend.

TeeChart for ActiveX, COM and ASP
Post Reply
CS
Newbie
Newbie
Posts: 22
Joined: Sat Jun 08, 2002 4:00 am

Can I manipulate the text comming as legend.

Post by CS » Thu Jun 04, 2009 10:39 am

If I have a chart as below
20 |
15 | X
10 | Z
5 | Y
0 |________________
1.0 2.0 3.0

If X,Y,Z are 3 bubbles plotted in the chart. I want legend to come as

X NameX
Y NameY
Z NameZ

Is this possible?
As of now legend comes as the point of X-axis and Y-axis.

I saw the below pieace of code in forum.
Set li = TChart1.Legend.Item(i)
sItemText = li.Text
It looks like I am not having TeeChart.ILegendItem in my version..
I am using teeChart Pro 5.0 .

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Thu Jun 04, 2009 12:05 pm

Hi CS,

I'm not sure to understand what do you exactly want. Doesn't this look as you want?

Code: Select all

  TChart1.AddSeries scBubble
  
  TChart1.Series(0).asBubble.AddBubble 1, 5, 5, "bubble 1", clTeeColor
  TChart1.Series(0).asBubble.AddBubble 1, 3, 3, "bubble 2", clTeeColor
  TChart1.Series(0).asBubble.AddBubble 0, 1, 4, "bubble 3", clTeeColor
  
  TChart1.Legend.LegendStyle = lsValues
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

CS
Newbie
Newbie
Posts: 22
Joined: Sat Jun 08, 2002 4:00 am

Post by CS » Fri Jun 05, 2009 6:32 am

I tried this before. If I use as you said the graph comes as

4 | X
3 |-----------Z
2 |
1 |-------Y
0 |________________
-------b b b
-------u u u
-------b b b
-------1 2 3

What ever was there in y axis is gone now. I want to retain that grpah

"-" these dots are put to make the allignment correct.Nothing to do with the requirement.

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Fri Jun 05, 2009 8:22 am

Hi CS,

I'm not sure to understand what are you exactly trying to achieve. Please, could you send us an image showing what you would like to do?
You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

CS
Newbie
Newbie
Posts: 22
Joined: Sat Jun 08, 2002 4:00 am

Re: Can I manipulate the text comming as legend.

Post by CS » Fri Jun 19, 2009 6:22 am

Sorry for the late reply. Was busy with some other thing.
I have uploaded the "SampleBubbleGraph.JPG" using your upload page. If you see that image you an see legend comming as "-6.102 VWAP" . what I am looking for is legend coming as "3.64 VWAP".
3.64 is value of x-axis. -6.102 is value of y-axis.

What I have tried is
.Series(0).asBubble.AddBubble 3.64,-6.102, 2, "VWAP", RGB(100,4555,111)

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Can I manipulate the text comming as legend.

Post by Yeray » Fri Jun 19, 2009 7:53 am

Hi CS,

These are the legent properties used for most common configurations:

Code: Select all

  TChart1.Legend.LegendStyle = lsAuto
  TChart1.Legend.TextStyle = ltsXValue
In your case you could include the X values int the labels string and set the legend to display only the labels but then the marks will also show the X values:

Code: Select all

  For i = 0 To 25
    X = Rnd * 100
    Y = Rnd * 1000
    TChart1.Series(0).AddXY X, Y, Str(X) + " VWAP", clTeeColor
  Next i
  TChart1.Legend.TextStyle = ltsPlain
So probably the best way to do what you want would be using OnGetLegentText event. Then, you could add your points as you were doing and format the legend text in the event:

Code: Select all

Private Sub Form_Load()
  For i = 0 To 25
    X = Rnd * 100
    Y = Rnd * 1000
    TChart1.Series(0).AddXY X, Y, "VWAP", clTeeColor
  Next i
  
  TChart1.Legend.TextStyle = ltsPlain
End Sub

Private Sub TChart1_OnGetLegendText(ByVal LegendStyle As Long, ByVal ValueIndex As Long, LegendText As String)
  LegendText = Str$(TChart1.Series(0).XValues.Value(ValueIndex)) + " " + LegendText
End Sub
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply