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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Adding Plot to an existing GraphPage
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Doltergost

Germany
14 Posts

Posted - 04/03/2024 :  09:27:16 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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.

YimingChen

1623 Posts

Posted - 04/03/2024 :  10:19:45 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Doltergost

Germany
14 Posts

Posted - 04/04/2024 :  02:59:14 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Yeah, thank you.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000