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
 Adding Plot to an existing GraphPage

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
Doltergost Posted - 04/03/2024 : 09:27:16 AM
Hi, with the following function i try to add another Plot to an existing Graphpage:

void addplot(string graphname, int plottyp, int MYFORM, int SYSCOLOR, Worksheet *ptrwks, int x1, int y1, string curvelabel)
{
PageBase pb = Project.Pages(graphname);

// Überürüfung ob ein solches Fenster existiert.
if( !pb.IsValid() )
{
printf("%s is not a valid window\n", graphname);
return;
}

GraphPage gp = pb;
GraphLayer gl = gp.Layers(0);


// DataRange für plotten der Messdaten
DataRange grafikdata1;
grafikdata1.Add(*ptrwks,x1,"X");
grafikdata1.Add(*ptrwks,y1,"Y");

int iPlots = 0;

foreach(DataPlot dp in gl.DataPlots)
{
iPlots++;
}
//printf("%d\n",iPlots);

int nPlotIndex = gl.AddPlot(grafikdata1, plottyp);
nPlotIndex = 1;

Tree tr0,tr1;

tr1.Root.Symbol.Size.nVal = 3; // Size of symbol
tr1.Root.Symbol.Shape.nVal = MYFORM;

GraphObject go = gl.GraphObjects("Legend");
go.Text = go.Text + "\n\l(" + (iPlots+1) + ")\c"+ (SYSCOLOR+1) + "(" + curvelabel + ")";

DataPlot dp1 = gl.DataPlots(iPlots);
dp1.SetColor(SYSCOLOR,TRUE);

bool bRet;

if( 0 == dp1.UpdateThemeIDs(tr1.Root))
{
bRet = dp1.ApplyFormat(tr1, true, true);
//printf("Done\n");
}

if(nPlotIndex >= 0)
{
gl.Rescale();
}

}

It does adding a Plot in the right color and edits the legend correctly, but the dp1.ApplyFromat doesnt work. It just changes the symbol to an right arrow.
2   L A T E S T    R E P L I E S    (Newest First)
Doltergost Posted - 04/04/2024 : 02:59:14 AM
Yeah, thank you.
YimingChen Posted - 04/03/2024 : 10:19:45 AM
Can you change the line
DataPlot dp1 = gl.DataPlots(iPlots);

to
DataPlot dp1 = gl.DataPlots(nPlotIndex);


I assume you want to change the format of the added plot.

James

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