Page 1 of 1
Chart Templating
Posted: Mon Jul 12, 2004 8:38 pm
by 6927067
I have implemented Tee chart as one of the features in a VB6 based interface. It's working great, but now I'd like to enhance it by adding an ability to template charts. That is, I'd like to be able to store all the properties of the chart including title, axis label formats, axis titles, etc. in some sort of file that can be called on to format the chart later. I don't want to store the actual data, or even any indication of the number of series. I just want to store the formatting.
I've tried to use the export/import of the .tee chart file, but this seems to only work if you have data series already in the chart and you only intend those series to be in the chart. In my case, the user is actually controlling how many series will be added to the chart and what their format will be. I want to store this format so that when they look at the chart later (which may now have different data in it), their chosen formatting is preserved.
Perhaps I am using the .tee file incorrectly, but I am under the impression that this is not possible. Is this true?
Steve
Posted: Tue Jul 13, 2004 7:20 am
by Chris
Hi,
Perhaps I am using the .tee file incorrectly, but I am under the impression that this is not possible. Is this true?
No, it is possible. Have you seen the VB6.0 example under:
C:\Program Files\Steema Software\TeeChart Pro v6 ActiveX Control\Examples\Visual Basic\Visual Basic 5 & 6\Database BLOBs ?
The INativeExport.SaveToStream method (see Help for details) takes a IncludeData boolean parameter which allows you to specify whether or not data is saved to the TEE file.
Posted: Tue Jul 13, 2004 8:48 pm
by 6927067
Thanks for your reply. I checked out the loadfromstream and loadfromfile methods, but I don't think this is what I want. What I want is the following:
1. In one VB form, have an Editor Panel (without any visible associated chart). In this panel, the user can enter non-series specific chart attributes like main titles, axis formats, etc.. Also, with perhaps a single dummy series, the user can enter the format of the series that will be added to the chart at a later time.
2. When the series are added to the chart, the formatting saved previously with the Editor panel is applied to them, along with the formatting for the non-series specific attributes.
I don't think this is what the VB example is doing. Is it?
Steve
Posted: Wed Jul 14, 2004 8:01 am
by Chris
Hi --
1. In one VB form, have an Editor Panel (without any visible associated chart). In this panel, the user can enter non-series specific chart attributes like main titles, axis formats, etc.. Also, with perhaps a single dummy series, the user can enter the format of the series that will be added to the chart at a later time.
2. When the series are added to the chart, the formatting saved previously with the Editor panel is applied to them, along with the formatting for the non-series specific attributes.
I don't think this is what the VB example is doing. Is it?
Not exactly. OK, so your users enter chart attributes into a form ... in this case, simply create a runtime instance of the TeeChart object, feed these parameters into it and save the chart as a TEE file as in the BLOBS example. Then you simply retrieve this TEE file, fill it with data and display it.
Posted: Thu Jul 15, 2004 5:14 pm
by 6927067
Ok, I think I am able to use the ideas mentioned previously. Thanks for the help.
One question. I have added an editor panel to my VB 6 form. I have set the editor panel's chart property to the dummy chart mentioned previously. This works in the sense that as I enter chart properties in the editor panel, those properties are reflected on the dummy chart. However, when I export the dummy chart, the changes I have made do not seem to export. In fact, I stopped the execution right before the export code and checked some of the properties of the dummy chart and the properties that I had set were not present in the chart's properties to be exported. An example is the chart title or header. Though the dummy chart on the form said the title I had entered with the editor panel, the property dummychart.header.text(0) was actually the old title that the chart had before I entered the title with the editor panel.
My thought is that the "Close" button that is normally resident on the editor form shown when Tchart.ShowEditor is invoked actually commits changes to the chart. If one adds an editor panel to one's own form that is attached to a chart (also on the form), then there is no "Close" button and so even though changes are reflected on the screen, they are not committed to the chart object and are thus not available for export.
Is there any way to commit the changes to the chart so that they will be exported under my current set up (ie. with editor panel control on form and no "Close" button)?
Steve
update
Posted: Thu Jul 15, 2004 5:44 pm
by 6927067
Actually, I also tried to make changes to the dummy chart using the showeditor method and those changes do not seem to take effect either when I export the .tee file.
Just to be clear, here is my process.
All in runtime,
1. Import to the dummy chart the .tee file that is used for formatting
2. Make changes to the dummy chart with the showeditor form
3. Export (using chart.export.asnative.savetofile) the dummy chart to a .tee file.
The changes made in step 2 do not seem to be saved in step 3.
Any suggestions?
Steve
Posted: Fri Jul 16, 2004 7:21 am
by Chris
Hi Steve,
All in runtime,
1. Import to the dummy chart the .tee file that is used for formatting
2. Make changes to the dummy chart with the showeditor form
3. Export (using chart.export.asnative.savetofile) the dummy chart to a .tee file.
The changes made in step 2 do not seem to be saved in step 3.
The following code works as expected here:
Code: Select all
Dim DummyChart As Object
Dim Stream
Private Sub Command1_Click()
Stream = DummyChart.Export.asNative.SaveToStream(True)
TChart1.Import.LoadFromStream Stream
End Sub
Private Sub Form_Load()
Set DummyChart = CreateObject("TeeChart.TChart")
DummyChart.Import.LoadFromURL "http://www.steema.com/demo.tee"
ChartEditorPanel1.ChartLink = DummyChart.ChartLink
End Sub
Does this work OK at your end? If you are still experiencing problems, could you please modify the above code snippet so I can reproduce them here?
Many thanks.