Page 1 of 1
Does TeeChart 7 control need to be attached to a window?
Posted: Thu Sep 15, 2005 5:43 pm
by 9526208
Does TeeChart 7 control need to be attached to a host window and painted in order to run correctly some functions?
For example, user creates TChart object and adds a series to it, loads data etc. Generally, does the same sequence of calls which would produce a chart if the object would be hosted in the window as ActiveX control.
Then user makes a call to ISeries::Clicked or ITChart::Draw (may be some other methods). Those calls fail without chart being painted at least one time in a host window.
Posted: Mon Sep 19, 2005 11:06 am
by narcis
Hi Alex,
Could you please let us know what do you exactly want to do with Clicked method if the chart is not displayed in any window or form?
We have tried doing a call to Clicked method in a TChart created at run-time but not being drawn to any form and works fine:
Code: Select all
Option Explicit
Public Sub Command1_Click()
Dim chartObj As New TeeChart.TChart
Dim label1 As String, label2 As String, label3 As String, label4 As String, label5 As String
label1 = "The x xx x xxxx xxxxx xxx" & Chr(13) & "xxxx xxxxxx"
label2 = "xxx x xxxxxx xxx xx" & Chr(13) & "xxxxxxx xxxxxxxx xxx" & Chr(13) & "xxxxx xxx xxxxxxxx xx xxx" & Chr(13) & "xxxxxxxxxxxx"
label3 = "xxx x xxxxxxxx xxxxxxxxx" & Chr(13) & " xxxxxxxxxx xxx xxxxxxx" & Chr(13) & " xxx xxxxxx xxxxxx xx xxx"
label4 = "xxx xxxx x xxxxx xx" & Chr(13) & " xxxxxxxxxx xxx xxxxxxxxx" & Chr(13) & " xx xxx xxxx"
label5 = "xxx xxxx xx x xxxx xxxxx" & Chr(13) & " xx xxxxx xxxxxxxx"
chartObj.ClearChart
chartObj.AddSeries (scHorizBar)
chartObj.AddSeries scHorizBar
chartObj.Axis.Bottom.Visible = False
With chartObj.Series(0)
.Add 41, label1, RGB(255, 255, 204)
.Add 52, label2, RGB(255, 255, 204)
.Add 6, label3, RGB(255, 255, 204)
.Add 1, label4, RGB(255, 255, 204)
.Add 80, label5, RGB(255, 255, 204)
.Marks.Arrow.Visible = False
.Marks.Transparent = True
.Marks.ArrowLength = 0
.Marks.Style = smsValue
.ValueFormat = "0%"
.Marks.Font.Name = "Arial MT"
.Marks.Font.Size = 12
End With
With chartObj.Series(1)
.Add 36, label1, RGB(153, 0, 0)
.Add 55, label2, RGB(153, 0, 0)
.Add 8, label3, RGB(153, 0, 0)
.Add 1, label4, RGB(153, 0, 0)
.Add 50, label5, RGB(153, 0, 0)
.Marks.Arrow.Visible = False
.Marks.Transparent = True
.Marks.ArrowLength = 0
.Marks.Style = smsValue
.ValueFormat = "0%"
.Marks.Font.Name = "Arial MT"
.Marks.Font.Size = 12
End With
With chartObj.Axis.Left
.Labels.Align = alOpposite
.Ticks.Visible = False
.TicksInner.Visible = False
.MinorTicks.Visible = False
.Labels.Font.Name = "Arial MT"
.Labels.Font.Size = 12
.GridPen.Visible = False
.Labels.MultiLine = True
.Labels.Size = 0
End With
chartObj.Walls.Visible = False
chartObj.Panel.Border.Visible = False
chartObj.Panel.Color = vbWhite
chartObj.Height = 8.5 * 1440
chartObj.Width = 11 * 1440
chartObj.Aspect.View3D = False
chartObj.Legend.Visible = False
chartObj.Header.Visible = False
Dim a As Integer
a = chartObj.Series(0).Clicked(10, 10)
With chartObj.Export.asPDF
.Height = 612
.Width = 792
.SaveToFile "c:\test.pdf"
End With
With chartObj.Export.asJPEG
.Height = 600
.Width = 800
.SaveToFile "c:\test.jpg"
End With
End Sub
Does TeeChart 7 control need to be attached to a window?
Posted: Tue Oct 04, 2005 11:31 pm
by 9526208
narcis,
I posted the .net solution on steema.public.attachments subj: Does TeeChart 7 control need to be attached to a window?
It shows that unless we export chart somewhere (another solution to atach it to a window) canvas size is 1x1 and Clicked() returns -1; We also have similar problem with TChart::Draw function.
Posted: Thu Oct 06, 2005 10:22 am
by Chris
Hi Alex,
Try calling InternalRepaint having added your data into the Series, e.g.
Code: Select all
int v = pSeries.Add(41, null, 0);
v = pSeries.Add(52, null, 0);
pChart.Environment.InternalRepaint();
Posted: Fri Oct 07, 2005 10:44 pm
by 9526208
It works!
Thanks a lot!