The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 How can I change the description of legend?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
winflowers Posted - 09/30/2004 : 12:53:11 PM
Origin Version (Select Help-->About Origin): 7.5
Operating System: windows 98

I have two questions here.

1. I usually do some comparison from a couple of worksheets, i.e. I plot the data from different worksheets into one graph. For example, there are 5 worksheets in the folder, and I would like to compare three of them. Now the question is: Is it possible to get the names of these three worksheets if I highlight them? What I am doing is put these three worksheets to a temporary folder, and use foreach() to get all worksheet names in this folder. Maybe there are some easier methodes.

2. I can use LT_execute("legend") to create new legends. But can I change the description of legend, for example I would like to use the name the worksheet as the description. Is it possible?

Thank you in advance!
6   L A T E S T    R E P L I E S    (Newest First)
easwar Posted - 10/01/2004 : 09:20:03 AM
quote:

I imported the data and checked the option "Rename worksheet to data file name", all the usderscores were still there and even the first character is number.



Hi,

This is a known issue and it was fixed in the SR4 patch for 7.5 - I suggest you apply the SR4 patch.

Easwar
OriginLab



Edited by - easwar on 10/01/2004 09:20:48 AM
Mike Buess Posted - 10/01/2004 : 07:29:31 AM
quote:
I imported the data and checked the option "Rename worksheet to data file name", all the usderscores were still there and even the first character is number.
Sounds like a bug because Origin should not allow that to happen. Best to email support about this problem. (tech@originlab.com)

Mike Buess
Origin WebRing Member
winflowers Posted - 10/01/2004 : 05:47:34 AM
quote:
Here's an example using the Custom Routine button. Find Custom.ogs in the program folder and edit its [Main] section in Notepad or CodeBuilder to look like this...

[Main]
stat= @KC + 2 * @KS;
if(stat==1) %L="";
if(stat==2) %L=%L %H;
if(stat) return;
ty -a %L;
// type -b $General.Userbutton;



The code doesn't work here and I am trying to find the reason.

quote:
Bad idea to use _ in a worksheet or column name. That's certain to lead to glitches like this. Not only that... underscores are not allowed in wks or col names. How did you get the second _ in your dataset name?


Now I know it's a bad idea to use _ in a worksheet name.
I imported the data and checked the option "Rename worksheet to data file name", all the usderscores were still there and even the first character is number. Of course, when I tried to rename the worksheets with underscore or start with a number, I failed.

Thank you very much for your codes and explanation!
Mike Buess Posted - 09/30/2004 : 6:30:38 PM
quote:
The question is that whether the OC can recognise the worksheets which are highlighted?
No, it cannot. Although it would be easy to set up a 2-button toolbar to do the job. One button to append name of active wks to a string variable. Second button to plot all wks listed in the string variable and then null the variable for next use. Would be trivial in LabTalk so you don't even need OC. You could even do it with a single button using modifier keys (@KS or @KC).

Here's an example using the Custom Routine button. Find Custom.ogs in the program folder and edit its [Main] section in Notepad or CodeBuilder to look like this...

[Main]
stat= @KC + 2 * @KS;
if(stat==1) %L="";
if(stat==2) %L=%L %H;
if(stat) return;
ty -a %L;
// type -b $General.Userbutton;

Press Control while you click the Custom Routine button to clear the wks list. Press Shift and click Custom Routine to add the name of the active wks to the list. Just click Custom Routine to print the list to the script window. Instead of that you can pass the string variable %L to the OC function that does the plotting.
quote:
The only problem is that the name of my worksheets include two "_".
Bad idea to use _ in a worksheet or column name. That's certain to lead to glitches like this. Not only that... underscores are not allowed in wks or col names. How did you get the second _ in your dataset name?

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 09/30/2004 6:40:30 PM

Edited by - Mike Buess on 09/30/2004 7:17:26 PM
winflowers Posted - 09/30/2004 : 5:43:13 PM
Mike Buess, thank you very much for your codes! But I think there is misunderstanding about question 1:
There are 5 worksheets with same structure and format in the folder, but I would like to plot three of them into one graph one layer. The point is to get the names of these three worksheets, then I can use them in OC and plot the graph. The question is that whether the OC can recognise the worksheets which are highlighted? I searched the help and found that only active worksheet can be recorded or use foreach() to get the names of all worksheets in the folder. Is there any solution?

2. The code works perfectly. The only problem is that the name of my worksheets include two "_". So your code couldn't get the correct name. That's my problem.
Mike Buess Posted - 09/30/2004 : 2:14:14 PM
1. You can get the wks names from the graph itself. This may not be the most elegant method but should work...
string wks_names()
{
string sWks,sList;
StringArray sa(0);
GraphLayer gl = Project.ActiveLayer();
int nPlots = gl.DataPlots.Count();
if( !nPlots ) return "";
foreach (DataPlot dp in gl.DataPlots)
{
sWks = dp.GetDatasetName(); // dataset name
sWks = sWks.GetToken(0,'_'); // wks name
sa.Add(sWks); // add to string array
}
sList = sa[0]; // now strip duplicates (may not be necessary)
for(int i=1;i<sa.GetSize();i++)
if( sList.Find(sa[i])==-1 )
sList.Format("%s, %s",sList,sa[i]);

return sList;
}
2. The legend is a text label (GraphObject) named 'legend'. The following code (similar to first) creates a new legend string in which the wks name is beside the symbol (represented by \l(i))...
void my_legend()
{
string sWks,sLegend;
GraphLayer gl = Project.ActiveLayer();
int nPlots = gl.DataPlots.Count();
if( !nPlots ) return;
int i;
foreach (DataPlot dp in gl.DataPlots)
{
i++;
sWks = dp.GetDatasetName(); // dataset name
sWks = sWks.GetToken(0,'_'); // wks name
if( i==1 )
sLegend = "\l(1) " + sWks; // first line
else
sLegend.Format("%s\n\l(%d) %s",sLegend,i,sWks)
}
gl.LT_execute("legend"); // create legend
GraphObject goLegend = gl.GraphObjects("legend");
if( goLegend.IsValid() )
goLegend.Text = sLegend; // replace the text
}


Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 09/30/2004 2:18:01 PM

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000