Page 1 of 1

Axis break

Posted: Wed May 19, 2004 2:56 pm
by 6922232
Hi,

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

P.

Posted: Wed May 19, 2004 10:59 pm
by Pep
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) ?

Posted: Mon May 24, 2004 8:43 am
by 6922232
Hi,

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

Image

Posted: Mon May 24, 2004 9:41 am
by Pep
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.

Posted: Tue May 25, 2004 7:56 am
by 6922232
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.

Posted: Tue May 25, 2004 8:01 am
by Pep
Hi,

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

Posted: Tue May 25, 2004 12:11 pm
by 6922232
We 've got both versions. But I tried this with the .NET

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

Posted: Tue May 25, 2004 3:10 pm
by 6922232
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.

Posted: Tue May 25, 2004 3:48 pm
by Pep
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)
%>
======================

Posted: Wed May 26, 2004 6:54 am
by 6922232
Thanx.

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