View code
1 Public Partial Class Webform3: system. Web. UI. Page 2 { 3 Protected Void Page_load ( Object Sender, eventargs E) 4 { 5 Createchart (); 6 } 7 Public Void Createchart () 8 { 9 Chart1.width = 400 ; 10 Chart1.height = 300 ; 11 Chart1.backcolor = Color. Azure; 12 Chart1.chartareas [ 0 ]. Backcolor = Color. Gray; 13 Chart1.series [ 0 ]. Charttype = seriescharttype. Pie; // Pie Chart 14 Chart1.series [ 0 ]. Postbackvalue = " # Index " ; // Data point index 15 Chart1.series [ 0 ]. Legendpostbackvalue = " # Index " ; // Data point index 16 Chart1.series [ 0 ]. Legendtooltip = " # Percent " ; // Percentage of data point y 17 Chart1.series [ 0 ]. Tooltip = " # Valx: \ t # Valy " ; 18 Int [] Intarr = New Int [] { 100 , 200 , 400 ,80 }; 19 String [] Strarr = New String [] { " A " , " B " , " C " , " D " }; 20 Chart1.series [ 0 ]. Points. databindxy (strarr, intarr ); 21 Legend L = New Legend (); 22 Chart1.legends. Add (L ); 23 If (! Ispostback) 24 Chart1.series [0 ]. Points [ 0 ]. Customproperties = " Exploded = true " ; 25 } 26 27 Protected Void Chart1_click ( Object Sender, imagemapeventargs E) 28 { 29 Int Index = Convert. toint32 (E. postbackvalue ); 30 If (Index> = 0 & Index <chart1.series [ 0 ]. Points. Count) 31 { 32 Chart1.series [ 0 ]. Points [Index]. customproperties + = " Exploded = true " ; 33 } 34 } 35 36 }