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 |
|
|