Page 1 of 1

Modification of Line Plot Title using C++

Posted: Fri Jul 07, 2006 2:08 pm
by 9346303
Currently I am using C++ to plot data to TDBChart.
I use the following code to modify the Title:

// clear the old names
DBChart1->Title->Text->Clear();
DBChart1->SubTitle->Text->Clear();
sprintf(Format, "%s vs %s", XUnit, YUnit);
DBChart1->Title->Text->Add(Format);
DBChart1->Title->DrawTitle();
sprintf(Format,"%s Vs %s", XName, YName);
DBChart1->SubTitle->Text->Add(Format);
DBChart1->SubTitle->DrawTitle();

but this does not work. Only the entries below the chart are being modified. Do you see what I have missed?

Thanks in advance.

Posted: Mon Jul 10, 2006 10:55 am
by Pep
Hi,

strange, it works fine here with the v7.07, I can see the title and subtitle texts. Could you please send me a simple app with which I can reproduce the problem " as is "here ? You can send me it directly to pep@steema.com

I found the problem

Posted: Mon Jul 10, 2006 1:43 pm
by 9346303
After reviewing the example code and the hints from your comments, I decided to try adding the following:

#include <stdio.h>
#include "EditChar.hpp"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "Base"
#pragma resource "*.dfm"

#pragma link "TeeSeriesTextEd"
#pragma link "TeeURL"
#pragma link "TeeXML"

After inspecting EditChar.hpp, I noticed that it includes seveal other *.hpp files.

Also, the function of the pragma smart_init looks like it might setup the pointer and storage areas.

I have not seen it before. The long and short answer is that it now works and I have the data changing. The title still does not work so I will send you my code for you to examine.

I had and still have a problem using the example code "as is" since I see a compiler error without modifing the code.

Thanks in advance for your help.

Posted: Mon Jul 10, 2006 1:46 pm
by narcis
Hi scottpj,

Which is the exact error message you get?

Thanks in advance.

Posted under a different thread 7.08 and 7.07 C++ example co

Posted: Mon Jul 10, 2006 1:50 pm
by 9346303
7.08 and 7.07 C++ example code compile failure

Posted: Mon Jul 10, 2006 1:55 pm
by narcis
Hi scottpj,

Ok, thanks for the information. We are looking into this and we will get back to you when we have further news.

Additional information about missing files

Posted: Mon Jul 10, 2006 2:06 pm
by 9346303
I noticed that you had a file called Base.cpp and Base.hpp.

In them I found your declaration of global variables, of which I am using Chart1, which are needed for EditChart().

Looking at the include files I see several files that I am not seen before.
From the labeling several appear to be yours, Te*.hpp. As for others I am not sure. Any clarification as to what files are needed for each include files/library feature that a programmer may be interested in and what global variables that will be required would be helpful.

Thank in advance for the help.

[Solved] Title work as advertised

Posted: Thu Jul 13, 2006 1:39 pm
by 9346303
It appears that the problem is due to an errant usage of a variable as a pointer.

The fix was to change my code from using separate statement for X and Y value to a single statement.

From
Series1->XValue[LoopCnt] = UIValues.V;
Series1->YValue[LoopCnt] = UIValues.V;

To
Series1->AddXY(XValue,YValue ,"",clTeeColor);

While I was in a for loop I checked for which variable need to be "saved" for plotting which implied a single statement. So I setup a XValue and YValue locally and use the above statement instead.

The affect of the single statements appears to be as an address instead of as a value.

Here is the code so far that is working for me:
// begin a line of data into the table
Series1->Clear();
DBChart1->Axes->Bottom->LabelsAngle = 90;
DBChart1->Axes->Bottom->AxisValuesFormat = "0.00e-0";
DBChart1->Axes->Bottom->Logarithmic = false; // True or False
DBChart1->Axes->Bottom->LogarithmicBase = 10; // 10 or e
DBChart1->Axes->Bottom->Title->Caption = XName + " (" + XUnit + ")";
DBChart1->Axes->Left->AxisValuesFormat = "0.00e-0";
DBChart1->Axes->Left->Logarithmic = false; // True or False
DBChart1->Axes->Left->LogarithmicBase = 10; // 10 or e
DBChart1->Axes->Left->Title->Caption = YName + " (" + YUnit + ")";
DBChart1->Title->Clear();
StrFormat = XName + " Vs " + YName;
DBChart1->Title->Text->Add(StrFormat);
Series1->Title = StrFormat;
StrFormat = XUnit + " Vs " + YUnit;
DBChart1->Title->Text->Add(StrFormat);

Thanks for the time and effort in helping me and for the hints as to what to try.