I want to create a line chart. I used to install telerik's justcode. I saw a chart on WP in my house. Today I tried it and found it online.Code. Finally find this http://www.visifire.com/wp7_chart_view.php? Type = xml & file = product/wpline2.xml (now it seems to have been walled ).
This website provides the XAML Implementation of charts, and I want to use the C # code to control the chart values (that is, the values of X and Y axes ), I found visifire's C # implementation on sliverlight on the Internet, and it took me one morning to transfer it to Windows Phone,
First Add a reference to slwpvisifire. charts. dll (slwpvisifire. charts. dll can be downloaded to the http://www.visifire.com/windows_phone_charts.php here)
Xmal part
< Phone: phoneapplicationpage X: Class = "Phoneapp9.mainpage" Xmlns = "Http://schemas.microsoft.com/winfx/2006/xaml/presentation" Xmlns: x = "Http://schemas.microsoft.com/winfx/2006/xaml" Xmlns: Phone = "CLR-namespace: Microsoft. Phone. controls; Assembly = Microsoft. Phone" Xmlns: Shell = "CLR-namespace: Microsoft. Phone. Shell; Assembly = Microsoft. Phone" Xmlns: d = "Http://schemas.microsoft.com/expression/blend/2008" Xmlns: MC = "Http://schemas.openxmlformats.org/markup-compatibility/2006" MC: ignorable = "D" D: designwidth = "480" D: designheight = "768" Fontfamily =" {Staticresource phonefontfamilynormal} " Fontsize =" {Staticresource phonefontsizenormal} " Foreground =" {Staticresource phoneforegroundbrush} " Supportedorientations = "Portrait" Orientation = "Portrait" Shell: systemtray. isvisible = "True" Loaded = "Phoneapplicationpage_loaded" > < VC: Chart Xmlns: VC = "CLR-namespace: visifire. charts; Assembly = slwpvisifire. Charts" Theme = "Theme5" Name = "Chart" > < VC: Chart. Titles > < VC: Title Text = "PM2.5 value trend chart" /> </ VC: Chart. Titles > < VC: Chart. axesx > < VC: Axis Startfromzero = "True" Axismaximum = "6" > < VC: axis. Grids > < VC: chartgrid Linethickness = "0.5" /> </ VC: axis. Grids > </ VC: Axis > </ VC: Chart. axesx > < VC: Chart. axesy > < VC: Axis > < VC: axis. Grids > < VC: chartgrid Linethickness = "0.5" Linestyle = "Solid" /> </ VC: axis. Grids > </ VC: Axis > </ VC: Chart. axesy > < VC: Chart. plotarea > < VC: plotarea Borderthickness = "0, 0, 1, 0" Bordercolor = "Gray" /> </ VC: Chart. plotarea > <! -- Comment out the Xmal implementation of data. --> <! -- <VC: Chart. series> <VC: dataseries renderas = "line" legendtext = "Company A" color = "# 3399ff" lightingenabled = "false" markersize = "15" name = "ds"> <VC: dataseries. datapoints> <VC: datapoint xvalue = "0" axisxlabel = "2001" yvalue = "1"/> <VC: datapoint xvalue = "1" axisxlabel = "2002" yvalue = "0.8"/> <VC: datapoint xvalue = "2" axisxlabel = "2003" yvalue = "1.8"/> <VC: datapoint xvalue = "3" axisxlabel = "2004" yvalue = "2.5"/> <VC: datapoint xvalue = "4" axisxlabel = "2005" yvalue = "3.1"/> <VC: datapoint xvalue = "5" axisxlabel = "2006" yvalue = "4.5"/> <VC: datapoint xvalue = "6" axisxlabel = "2007" yvalue = "5.8"/> <VC: datapoint xvalue = "7" axisxlabel = "2008" yvalue = "7.1"/> <VC: datapoint xvalue = "8" axisxlabel = "2009" yvalue = "6.5"/> <VC: datapoint xvalue = "9" axisxlabel = "2010" yvalue = "6.8"/> </VC: dataseries. datapoints> </VC: dataseries> <VC: dataseries renderas = "line" legendtext = "Company B" color = "#66cc00" lightingenabled = "false" markersize = "15"> <VC: dataseries. datapoints> <VC: datapoint xvalue = "0" axisxlabel = "2001" yvalue = "-2"/> <VC: datapoint xvalue = "1" axisxlabel = "2002" yvalue = "-1"/> <VC: datapoint xvalue = "2" axisxlabel = "2003" yvalue = "3.2"/> <VC: datapoint xvalue = "3" axisxlabel = "2004" yvalue = "4"/> <VC: datapoint xvalue = "4" axisxlabel = "2005" yvalue = "4.2"/> <VC: datapoint xvalue = "5" axisxlabel = "2006" yvalue = "5.9"/> <VC: datapoint xvalue = "6" axisxlabel = "2007" yvalue = "6.1"/> <VC: datapoint xvalue = "7" axisxlabel = "2008" yvalue = "6.4"/> <VC: datapoint xvalue = "8" axisxlabel = "2009" yvalue = "5.2"/> <VC: datapoint xvalue = "9" axisxlabel = "2010" yvalue = "4.8"/> </VC: dataseries. datapoints> </VC: dataseries> </VC: Chart. series>--> </ VC: Chart > </ Phone: phoneapplicationpage >
C # Section
Using system; using system. collections. generic; using system. LINQ; using system. net; using system. windows; using system. windows. controls; using system. windows. documents; using system. windows. input; using system. windows. media; using system. windows. media. animation; using system. windows. shapes; using Microsoft. phone. controls; using visifire. charts; namespace phoneapp9 {public partial class mainpage: phoneapplicationpage {// constructor public mainpage () {initializecomponent ();} private void phoneapplicationpage_loaded (Object sender, routedeventargs E) {dataseries = new dataseries {renderas = renderas. line}; dataseries. datapoints. add (New datapoint {axisxlabel = "07:00", yvalue = 53, xvalue = 0}); dataseries. datapoints. add (New datapoint {axisxlabel = "08:00", yvalue = 60, xvalue = 1}); dataseries. datapoints. add (New datapoint {axisxlabel = "09:00", yvalue = 78, xvalue = 2}); dataseries. datapoints. add (New datapoint {axisxlabel = "10:00", yvalue = 82, xvalue = 3}); dataseries. datapoints. add (New datapoint {axisxlabel = "11:00", yvalue = 89, xvalue = 4}); dataseries. datapoints. add (New datapoint {axisxlabel = "12:00", yvalue = 81, xvalue = 5}); dataseries. datapoints. add (New datapoint {axisxlabel = "13:00", yvalue = 79, xvalue = 6}); chart. series. add (dataseries );}}}