Mike Buess
USA
3037 Posts |
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 |
 |
|