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
 LabTalk Forum
 Sparkline Color
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Drbobshepherd

USA
Posts

Posted - 03/26/2012 :  09:58:44 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): Origin Pro 8.6 SR2
Operating System: Windows XP and Vista

How do you program it so the sparklines for different columns are different colors? The Sparkines X-function doesn't have a color variable, but it does have one for template, so I am thinking of creating a graph template for each color I want. Is there a better way?

DrBobShepherd

cpyang

USA
1406 Posts

Posted - 03/26/2012 :  5:20:03 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I cannot find a quick LabTalk solution, but I put down this OC code in case it is useful to you

// example to show how to create/update sparklines on all 
// columns on the current worksheet with alternating blue/red colors
void sparkline_colors()
{
	DWORD dwCntrl = EMBEDGRAPH_IN_LABELS | EMBEDGRAPH_HIDE_AXES | EMBEDGRAPH_HIDE_LEGENDS | EMBEDGRAPH_HIDE_SPECTRUMS | EMBEDGRAPH_HIDE_TEXT_OBJS | EMBEDGRAPH_SPARKLINE;
	Worksheet wks = Project.ActiveLayer();
	if(!wks)
		return;
	
	//add this will require theme_utils.c to be added to workspace
	//int nRowHeight = 20
	//wks_set_col_label_heights(wks, RCLT_SPARKLINE, nRowHeight, false);
	
	waitCursor hrGlass;
	for(int nC = 0; nC < wks.GetNumCols(); nC++)
	{
		if(wks.Columns(nC).GetType() != OKDATAOBJ_DESIGNATION_Y || is_col_all_text(wks, nC) > 0)
			continue;
		
		GraphPage gp;
		DataPlot dp = plot_col(wks, nC, gp, IDM_PLOT_LINE, true, "sparkline_label", true, 0);
		int ncolor = nC%2? SYSCOLOR_BLUE:SYSCOLOR_RED;
		dp.SetColor(ncolor);
		wks.EmbedGraph(RCLT_SPARKLINE, nC, gp, dwCntrl);
	}
}


CP
Go to Top of Page

Drbobshepherd

USA
Posts

Posted - 03/27/2012 :  6:20:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for your suggestion, but I think I will stick with my original idea and just create a graph template for each color, then apply the templates with sparkline X-function calls.
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