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
 Origin Forum
 Pie Charts: Customizing Labels, decimal places

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
Emundts Posted - 04/01/2007 : 07:16:00 AM
Origin Version (Select Help-->About Origin): Origin Pro 7.5 SR 6
Operating System: Windows XP

I have created several pie charts with label "percentage". The percentage values are always shown with two decimal places, e.g. 89,52%.
How can I change that? I would like to show only one decimal place.


1   L A T E S T    R E P L I E S    (Newest First)
Mike Buess Posted - 04/02/2007 : 1:41:33 PM
I can't find default settings for this but the following Origin C function will help format all slice labels in a pie graph at once. Add the function to Codebuilder's workspace as described here and run it by attaching the command format_pie_labels to the Custom Routine Button.

void format_pie_labels()
{
GraphLayer gl = Project.ActiveLayer();
if( !gl ) return;
DataPlot dp = gl.DataPlots(0);
if( !dp ) return;
TreeNode tn1,tn2;
tn1 = dp.Curve;
tn2 = tn1.GetNode("Labels");
if( !tn2 ) return;
tn2.Auto.nVal = 1;
tn2.Values.nVal = 0; // format labels manually
tn2.Percentages.nVal = 1;
tn2.Categories.nVal = 0;
dp.Curve = tn1;
gl.GetPage().Refresh();
gl.LT_execute("sec -p 0.01");
tn2.Auto.nVal = 0;
dp.Curve = tn1;
gl.GetPage().Refresh();
gl.LT_execute("sec -p 0.01");
Dataset ds(dp.GetDatasetName());
BasicStats bs;
Data_sum(&ds, &bs);
double dVal,dTotal = bs.total;
int nSlices = bs.N;
string str;
for(int i=1;i<=nSlices;i++)
{
GraphObject go = gl.GraphObjects("PIE." + i);
if( go )
{
dVal = 100.0 * ds[i-1] / dTotal;
str.Format("%.1f%%",dVal);
go.Text = str;
}
}
}

Mike Buess
Origin WebRing Member

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