delphi - Draw a pie chart with special properties (alter style and starting point) -
i want create pie chart has features:
- it's starting point changes 90 degree (like gauge component)
- it turns clockwise.
- a fixed marker shows value.
- donut style.
i check pie chart properties. don't found corresponding feature.
i have teechart shipped delphi. it's v2011.03.32815. , don't have donut chart. think it's need coded. it' can done placing circle on it's canvas color matches chart background.
i can use gauge component. not have anti alias feature (teechart has teegdiplus ).
i've drawn illustrator of mean:
q1: how draw/code chart so?
here have simple example showing how use teechart draw tdonutseries similar 1 in picture. here how looks like:
and here code used generate it. it's tdonutseries 2 values , wide pen. , 2 tannotationtools texts:
uses tecanvas, teedonut, teetools, series; procedure tform1.formcreate(sender: tobject); var donut1: tdonutseries; annot1, annot2: tannotationtool; tmpx, tmpy: integer; begin (chart1.canvas tgdipluscanvas).antialiastext:=gpfbest; chart1.view3d:=false; chart1.legend.visible:=false; chart1.foot begin text.text:='g1'; font.color:=clblack; font.style:=[]; font.size:=25; end; donut1:=chart1.addseries(tdonutseries) tdonutseries; annot1:=chart1.tools.add(tannotationtool) tannotationtool; annot2:=chart1.tools.add(tannotationtool) tannotationtool; donut1 begin add(33, '', clwhite); add(66, '', rgb(0, 178, 247)); pen.color:=rgb(0, 178, 247); pen.width:=8; rotationangle:=90; marks.visible:=false; customxradius:=120; customyradius:=120; end; annot1 begin text:='56%'; shape.transparent:=true; shape.font.size:=25; end; annot2 begin text:='33%'; shape.transparent:=true; shape.font.size:=15; end; chart1.draw; annot1 begin shape.left:=donut1.circlexcenter-(shape.width div 2); shape.top:=donut1.circleycenter-(shape.height div 2); end; annot2 begin donut1.angletopos(180, donut1.customxradius, donut1.customyradius, tmpx, tmpy); shape.left:=tmpx-(shape.width div 2)+30; shape.top:=tmpy-(shape.height div 2)+30; end; end;
if prefer use series marks instead of tannotationtools, try setting them follows:
donut1.marks.transparent:=true; donut1.marks.font.size:=20; donut1.marks.callout.arrowhead:=ahsolid;
Comments
Post a Comment