i using zedgraph display pie charts in c# winforms application. want display legend , labels next each pie slice in following format:
legend: each item should display name of pie slice, e.g. "customers"
slice label: each label should display value , percent, e.g. "4 (25%)"
by default able have legend displaying name desired. on label requirement...
i have looked labeltype property, allows me select few options label format (here list). unfortunately, there no value_percent option. cannot use ones include name because long , ruins display of labels.
i though perhaps set text label myself able calculate both value , percent anyway, tried this:
pieitem.label.text = mycustomstring; this desired labels, sets legend key format same - lose requirement of name.
is possible change slice label text independent of legend text? or, possible achieve requirements way?
i have managed achieve requirements modifying source code. still interested in knowing if there way without making source changes, in mean time here did...
the source code can downloaded here, , used version 5.1.5 line number references may wrong in other versions.
there 2 segments of code need added, in 2 separate files:
zedgraph/types.cs
there enum called pielabeltype located @ line 729. here need add new value called value_percent.
zedgraph/pieitem.cs
there function called buildlabelstring located @ line 942. within function switch statement need add new condition our new pielabeltype:
case pielabeltype.value_percent: curve._labelstr = curve._pievalue.tostring("f", labelformat) + " (" + (curve._sweepangle / 360).tostring("p", labelformat) + ")"; break; i have chosen format "# (#.##%)", can required.
that's it. build project , include new modified dll in application , new pielabeltype ready use.
Comments
Post a Comment