Axis break

TeeChart for ActiveX, COM and ASP
Post Reply
pschalkwijk
Newbie
Newbie
Posts: 6
Joined: Fri Nov 15, 2002 12:00 am
Location: NL

Axis break

Post by pschalkwijk » Wed May 19, 2004 2:56 pm

Hi,

I want to draw an axis-break in my chart.
Can anyone tell me how?

P.

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed May 19, 2004 10:59 pm

Hi,

I'm not sure what you refer with "axis-break". Could you please post an image ? Maybe you can use two axis (one with custom axis) ?

pschalkwijk
Newbie
Newbie
Posts: 6
Joined: Fri Nov 15, 2002 12:00 am
Location: NL

Post by pschalkwijk » Mon May 24, 2004 8:43 am

Hi,

Sorry for my simple - not detailed - message.
This image should do the trick.

Image

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon May 24, 2004 9:41 am

Hi,

I think the best way to do this is using the Canvas techniques, you can do something like in the following example :

Code: Select all

Private Sub Form_Load()
With TChart1
    .Aspect.View3D = False
    .AddSeries scLine
    For i = 0 To 5
        .Series(0).AddXY i, Rnd * 100, "", clTeeColor
    Next i
    .Panel.Color = vbWhite
    .Legend.Visible = False
    .Axis.Bottom.GridPen.Visible = False
    .Axis.Left.GridPen.Visible = False
End With
End Sub

Private Sub TChart1_OnAfterDraw()
    With TChart1
    .Canvas.Pen.Color = vbWhite
    .Canvas.Pen.Width = 5
    .Canvas.MoveTo .Axis.Left.Position - 10, .Series(0).CalcYPosValue(50)
    .Canvas.LineTo .Axis.Left.Position + 10, .Series(0).CalcYPosValue(55)
    End With
End Sub
or using custom axis. You can see some examples of use in the Demo features project included in the TeeChart installation.

pschalkwijk
Newbie
Newbie
Posts: 6
Joined: Fri Nov 15, 2002 12:00 am
Location: NL

Post by pschalkwijk » Tue May 25, 2004 7:56 am

Thanx for the code but...

The chart is used in a web environment (.NET). There I cann't find Canvas or Gridpen. Maybe I'm not that smart but I think some features are removed in the WebChart component.

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue May 25, 2004 8:01 am

Hi,

which TeeChart version are you using (ActiveX or NET) ?

pschalkwijk
Newbie
Newbie
Posts: 6
Joined: Fri Nov 15, 2002 12:00 am
Location: NL

Post by pschalkwijk » Tue May 25, 2004 12:11 pm

We 've got both versions. But I tried this with the .NET

In de ActiveX it works fine :oops: . Thanx.

pschalkwijk
Newbie
Newbie
Posts: 6
Joined: Fri Nov 15, 2002 12:00 am
Location: NL

Post by pschalkwijk » Tue May 25, 2004 3:10 pm

I create the object with CreateObject 'cause the graph is created in a COM DLL.
There OnAfterDraw isn't fired (or isn't hooked) when I call the method TChart.Export.asJPEG.SaveToFile ("test.jpg")

Can you tell me how to hook the event OnAfterDraw to a custom procedure?
In .NET it's much easier. But this is with VB6.

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue May 25, 2004 3:48 pm

Hi,

code from an example AX DLL project could be as follows:

(here: "TCTest.ChartClass1")
======================

Code: Select all

Private WithEvents m_Chart As TeeChart.TChart

Public Function ReturnChart() As Variant
    Set m_Chart = CreateObject("TeeChart.TChart")
    m_Chart.AddSeries (0)
    Dim t As Integer
    m_Chart.Series(0).FillSampleValues(10)
    ReturnChart = m_Chart.Export.asPNG.SaveToStream
    Set m_Chart = Nothing
End Function

Private Sub m_Chart_OnAfterDraw()
    m_Chart.Canvas.TextOut 100, 100, "Hello world"
End Sub
======================

The ASP script to call that may look like the following:
======================

Code: Select all

<%
 Function RunChart()
   Set Chart1 = CreateObject("TCTest.ChartClass1")
   RunChart=Chart1.ReturnChart
   Set Chart1=Nothing
 End Function
 Response.BinaryWrite(RunChart)
%>
======================

pschalkwijk
Newbie
Newbie
Posts: 6
Joined: Fri Nov 15, 2002 12:00 am
Location: NL

Post by pschalkwijk » Wed May 26, 2004 6:54 am

Thanx.

I'm new in VB and I wasn't aware of the keyword WithEvents.
With this keyword it works.

Post Reply