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
 Origin Forum
 Pie Charts: Customizing Labels, decimal places
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Emundts

Germany
Posts

Posted - 04/01/2007 :  07:16:00 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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.


Mike Buess

USA
3037 Posts

Posted - 04/02/2007 :  1:41:33 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
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