How Can I Create Dynamically Client-Side TeeChart Object?

TeeChart for ActiveX, COM and ASP
Post Reply
alpella
Newbie
Newbie
Posts: 8
Joined: Fri Nov 26, 2004 5:00 am

How Can I Create Dynamically Client-Side TeeChart Object?

Post by alpella » Fri Dec 29, 2006 11:56 am

I want to create TeeChart object dynamically with VbScript (Client-Side) I use that "Set Chart1 = CreateObject("AxTeeChart.AxTChart")" but I get an error message as "ActiveX Component Can't Create Object" I try that instancing(Dim mChart As New AxTeeChart.AxTChart) within Vb.Net and works. Where Can I find the right interface list? My base requirement is a code routin that creates lay-down multiple chart with data of selected categories on multiple checkboxes on the client-side of IE. There is no ASP, no server-side, nothing like that. My requirement is totally client-side. Is there anybody who can give any idea? Thanks...

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

Post by Pep » Fri Dec 29, 2006 4:58 pm

Hi,

how about using :

Code: Select all

<script LANGUAGE="VBScript">

Sub FillChart()
  set newTeeChart = document.createElement("<OBJECT ID='TChart1' WIDTH='450' HEIGHT='290'   

CLASSID='CLSID:FAB9B41C-87D6-474D-AB7E-F07D78F2422E'></OBJECT>")
  document.body.insertBefore newTeeChart
End Sub

Sub Window_Onload()
FillChart
End Sub

</script>

alpella
Newbie
Newbie
Posts: 8
Joined: Fri Nov 26, 2004 5:00 am

AddSeries and other methods

Post by alpella » Mon Jan 15, 2007 7:21 am

Thanks Pep... Your CLSID is correct, but I have a few problems about that. I create the chart object with this class-id, but I can't add any series to that. The code is like that;

Code: Select all

set newTeeChart = document.createElement("<OBJECT ID='Tchart2' WIDTH='450' HEIGHT='290' CLASSID='CLSID:FAB9B41C-87D6-474D-AB7E-F07D78F2422E'></OBJECT>") 
document.body.insertBefore newTeeChart 
newTeeChart.AddSeries 6


or I try that

Code: Select all

Tchart2.AddSeries 6
Both of them don't work! I receive an error message tells "Object doesn't support this property or method: newTeeChart.AddSeries" or "Tchart2.AddSeries"

So, "AddSeries" works with created object as drag&drop the teechart object to my htm page.

How can I add the series to my dynamic TeeChart object, so I need to use additional chart methods after that. Shortly, how can use the chart object after created with code.

Thanks for all...

Walt
Newbie
Newbie
Posts: 35
Joined: Wed Aug 17, 2005 4:00 am
Location: San Jose, CA
Contact:

Post by Walt » Tue Jan 16, 2007 8:34 pm

Try using setTimeout to call another function that will call AddSeries (or call AddSeries in a separate button click event) in order to delay that action a little bit. I think the issue is that IE is multithreaded and the chart is not ready for use immediately after creating it.

Maybe Steema can provide a better explaination of this problem (and it might actually be an issue with the chart control).

alpella
Newbie
Newbie
Posts: 8
Joined: Fri Nov 26, 2004 5:00 am

Post by alpella » Thu Jan 18, 2007 5:52 am

Hey, thanks a lot Walt. It looks like work. I'll try other methods ASAP...

alpella
Newbie
Newbie
Posts: 8
Joined: Fri Nov 26, 2004 5:00 am

Post by alpella » Fri Jan 19, 2007 2:22 pm

Yes, It works, thanks again for that Walt... However, I can't set the chart properties with code. I have found a newmethod of DOM, "cloneNode"... First I drag a TeeChart object to design view and I format in base of my requirements. Last, I clone that;

Code: Select all

Set myClonnedChart = TChart1.cloneNode(true)
I should specify that you cannot change the id property of the clonned object. Even if you code "myClonnedChart.id = 'newChart'" you cannot reach the clonned object through this way. You should use TChart1(index) - 0 is original, and 1,2,3...n is the clonned... After all, we have another serious problem, the printing. Yes, I need regular printing with clonned Charts and when I come to print preview screen I see the screen as "<OBJECT>blablaba". I think I will be canceled the "select and see the chart" feature of my product. :(

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

Post by Pep » Wed Jan 24, 2007 6:12 pm

Hi,

check with the following code (better that one I posted days ago) which allow you to create and fill the Series at the same time, and also allow you to print correctly.

Code: Select all

<!-- saved from url=(0022)http://internet.e-mail -->
<html>

<META HTTP-EQUIV="Expires" CONTENT="0">

<script LANGUAGE="VBScript">

Sub FillChart()
  set myObject = document.createElement("object")
  document.body.appendChild(myObject)
  myObject.width = "400"
  myObject.height = "300"
  myObject.id = "TChart1"
  myObject.classid= "clsid:FAB9B41C-87D6-474D-AB7E-F07D78F2422E"
  ' myObject.object.Header.Caption = "dynocreate TeeChart"
  ' or....
  TChart1.object.Header.Caption = "dynocreate TeeChart"
  TChart1.object.AddSeries 1
  TChart1.object.Series(0).FillSampleValues 20
  TChart1.Environment.IEPrintWithPage
End Sub

Sub Window_Onload()
  FillChart
End Sub

</script>

<BODY>
</BODY>
</html>

Post Reply