Page 1 of 1

Including GridBand Tool

Posted: Mon Sep 27, 2010 3:33 pm
by 6924015
I'm trying to add the GridBand Tool to a VBScript, but the docs show examples for visual basic. Here's the code I have:

HTML (object within a table cell):

Code: Select all

<object id="TChart1" CODEBASE="/chart/teechart7.cab#Version=7,0,0,0" TYPE="application/x-oleobject" width="100%" height="100%" classid="CLSID:FAB9B41C-87D6-474D-AB7E-F07D78F2422E" ></object>
within VBScript tag

Code: Select all

Sub Window_onload()
With TChart1
    .AddSeries scBar
    .Series(0).FillSampleValues 6
    
    .Tools.Add tcGridBand
    With .Tools.Items(0).asGridBand
        .Axis = TChart1.Axis.Left
        .Band1.Color = 16250354
        .Band2.Color = 16116201
    End With
End With
End Sub
When I run this code, I get an access violation by IE 8.0.7600 and crashes the browser with message "Access violation at address 504F6CB8 in module 'teechart7.ocx'. Read of address 0000015A". Which seems to come from the ".Axis = TChart1.Axis.Left" line. Omitting that gives "Unexpected call to method or property access.".

I suspect that I haven't added the GridBand properly to the chart. Does anyone know how to add a the GridBand tool to a chart within VBScript? or any tool for that matter?

Thanks in advance!

Re: Including GridBand Tool

Posted: Wed Sep 29, 2010 9:31 am
by narcis
Hi uptime,

Problem could be that you are using TChart1.Axis.Left within a With TChart1 clause, try using this:

Code: Select all

        .Axis = .Axis.Left

Re: Including GridBand Tool

Posted: Wed Sep 29, 2010 12:53 pm
by 6924015
Thanks for your suggestion NarcĂ­s.

After making that change I'm getting this: Object required: 'Axis'

Also I noticed that it added the Cursor tool (maybe it was added by default because GridBand Tool in vbScript it's not called 'tcGridBand'?)

Can anyone post an example HTML page with a chart with GridBand Tool using vbScript?

Re: Including GridBand Tool

Posted: Thu Sep 30, 2010 12:02 pm
by narcis
Hi uptime,

Find attached a VBScript working example with your code.

Re: Including GridBand Tool

Posted: Thu Sep 30, 2010 1:32 pm
by 6924015
Hello Narcis thank you for your response.

Unfortunately I need this to be all in HTML and vbScript (no ASP).

I was able to come up with a trimmed down html page as a better example:

Code: Select all

<html><head><title>GridBand chart</title></head>
<body>
<script language="VBScript">
Sub Window_onload()
With TChart0
    .AddSeries scBar
    .Series(0).FillSampleValues 6
    
    .Tools.Add tcGridBand
    With .Tools.Items(0).asGridBand
        .Axis = .Axis.Left
        .Band1.Color = 16250354
        .Band2.Color = 16116201
    End With
End With
End Sub
</script>

<object id="TChart0" CODEBASE="teechart7.cab#Version=7,0,0,0" TYPE="application/x-oleobject" width="100%" height="100%" classid="CLSID:FAB9B41C-87D6-474D-AB7E-F07D78F2422E" ></object>
</html>
If you take this code, you will see an error from Line 11 "Object required: 'Axis'" and also there is a Cursor tool added. I also attached a screenshot to show the Cursor on the chart.

Re: Including GridBand Tool

Posted: Wed Oct 06, 2010 11:27 am
by narcis
Hello uptime,

You need to do as in the code snippet below as some constants might not be defined.

Code: Select all

    <html><head><title>GridBand chart</title></head>
    <body>
    <script language="VBScript">
    Sub Window_onload()
    With TChart0
        .AddSeries scBar
        .Series(0).FillSampleValues 6
       
        .Tools.Add 16 'tcGridBand
        With .Tools.Items(0).asGridBand
            .Axis = 0 'aLeft
            .Band1.Color = 16250354
            .Band2.Color = 16116201
        End With
    End With
    End Sub
    </script>

    <object id="TChart0" CODEBASE="teechart7.cab" TYPE="application/x-oleobject" width="100%" height="100%" classid="CLSID:FAB9B41C-87D6-474D-AB7E-F07D78F2422E" ></object>
    </html>

Re: Including GridBand Tool

Posted: Thu Oct 07, 2010 4:18 pm
by 6924015
Yes that worked!

Thank you very much Narcis for all your feedback. It's very much appreciated :)