View code
Protected Void Page_load ( Object Sender, eventargs e ){ If (! Ispostback) {createtempchart ();}} Public Void Createtempchart () {sqlconnection con = New Sqlconnection ( " Data Source =.; initial catalog = demo; Integrated Security = true " ); String Strsql = " Select productprice, worker from chartdb " ; Sqlcommand cmd = New Sqlcommand (strsql, con); con. open (); sqldatareader Dr = Cmd. executereader (); This . Chart1.width =600 ; This . Chart1.height = 400 ; This . Chart1.chartareas [ 0 ]. Axisx. Title = " Sales Staff " ; This . Chart1.chartareas [ 0 ]. Axisy. Title = " Sales revenue " ; This . Chart1.series [ 0 ]. Charttype = System. Web. UI. datavisualization. charting. seriescharttype. line; This . Chart1.series [ 0 ]. Isvalueshownaslabel = True ; This . Chart1.series [ 0 ]. Markerstyle = System. Web. UI. datavisualization. charting. markerstyle. triangle; This . Chart1.titles. Add ( " Sales Status " ); For ( Int I = 0 ; I < This . Chart1.legends. Count; I ++ ){ This . Chart1.legends [I]. legendstyle = System. Web. UI. datavisualization. charting. legendstyle. row; This . Chart1.legends [I]. Docking = System. Web. UI. datavisualization. charting. Docking. bottom; This . Chart1.legends [I]. Alignment = System. Drawing. stringalignment. Center ;} This . Chart1.series [ 0 ]. Legendtext = " Sales " ; This . Chart1.series [ 0 ]. Tooltip = " Sales: \ t # valx \ n revenue: \ t # Valy " ; This . Chart1.series [ 0 ]. Points. databindxy (DR, " Worker " , Dr, " Productprice " ); Dr. Close (); con. Close (); This . Chart1.databind ();}
databindxy method used