Page 1 of 1

Unable to display label on inner text and multi line text on

Posted: Tue Mar 17, 2015 3:30 pm
by 16670494
Title - Unable to display label on inner text and multi line text on legend.

We are currently migrating from another 3rd party control to TeeChart Pro ActiveX 14. The code we are writing is C++ using Visual Studio 2013 and will be running on Windows Server 2008R2 and above and Win 7 and above.

We are unable to create a label on inner tick because we are unable to find the coordinate to display label on inner tick. How can we determine coordinates to display label on inner tick? How can we draw text on inner tick inside Chart? How can we display multiline text on legend?

Re: Unable to display label on inner text and multi line text on

Posted: Wed Mar 18, 2015 10:59 am
by yeray
Hello,
WinArch wrote:We are unable to create a label on inner tick because we are unable to find the coordinate to display label on inner tick. How can we determine coordinates to display label on inner tick?
You can use the bottom axis CalcXPosValue function to convert axis values to screen pixel coordinates.
WinArch wrote:How can we draw text on inner tick inside Chart?
You can use Canvas.TextOut function to draw text manually at the OnAfterDraw event.
Here you have a simple example in Visual Basic:

Code: Select all

Private Sub Form_Load()
  TChart1.Aspect.View3D = False
  
  Dim i As Integer
  For i = 0 To 3
    TChart1.AddSeries scLine
    TChart1.Series(i).FillSampleValues
  Next i

  TChart1.Axis.Left.MinimumOffset = 50
End Sub

Private Sub TChart1_OnAfterDraw()
  Dim XPos, YPos, txtWidth, txtHeight As Integer
  Dim txt As String
  
  XPos = TChart1.Axis.Bottom.CalcXPosValue(2.5)
  YPos = TChart1.Axis.Bottom.Position
  txt = "my date"
  txtWidth = TChart1.Canvas.TextWidth(txt)
  txtHeight = TChart1.Canvas.TextHeight(txt)
  TChart1.Canvas.TextOut XPos - (txtWidth / 2), YPos - txtHeight - 2, txt
End Sub
WinArch wrote:How can we display multiline text on legend?
I'm afraid this is not supported in the current legend but you can always draw your custom legend manually as in the example here:
http://stackoverflow.com/questions/2390 ... n-teechart