Silverlight calls the visfire open-source chart componentSource code:
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 Visifire. charts; Namespace SL { Public Partial Class Visifiretest: usercontrol { Public Visifiretest () {initializecomponent (); List <datetime> updatetime = New List <datetime> (){ New Datetime ), New Datetime (2010,3 ),New Datetime (2010,4 ), New Datetime (2010,5 ), New Datetime ), New Datetime ), New Datetime ), New Datetime (,)}; List < String > Value = New List < String > (){"20 "," 25 "," 40 "," 55 "," 67 "," 74 "," 88 "," 94 "}; List < String > Value 1 = New List < String > (){" 33 ","44 "," 48 "," 15 "," 70 "," 56 "," 77 "," 5 "}; List < String > Value 2 = New List < String > (){" 10 "," 81 ","66 "," 60 "," 67 "," 12 "," 12 "," 100 "}; List < Object > ValueList = New List < Object > { Value , Value 1, Value 2}; createchart (" Memory usage ", Updatetime, ValueList ," % ", 1, intervaltypes. Minutes );} Public Void Createchart ( String Tablename, list <datetime> updatetime, list < Object > ValueList, String Rihgtstr, Int Chartinterval, intervaltypes intervaltype) {chart = New Chart (); // Create a chart /* Set chart attributes */ Chart. width = 500; Chart. Height = 400; Chart. toolbarenabled = True ; Chart. scrollingenabled = False ; Chart. view3d = True ; Title = New Title () {text = tablename, padding = New Thickness (0, 10, 5, 0 )}; // Chart title Chart. Titles. Add (title ); // Add a title Axis xaxis = New Axis (); // Create the X axis Xaxis. intervaltype = intervaltype; // X-axis classification type, hour * minute * Second Xaxis. interval = chartinterval; // Distance between X axis coordinates Xaxis. valueformatstring =" Hh: mm: SS "; // X axis time display format Chart. axesx. Add (xaxis ); // Add the X axis for the chart Axis yaxis = New Axis (); // Create the Y axis Yaxis. suffix = rihgtstr; // Y-axis suffix % Yaxis. axisminimum = 0; // The minimum value of the Y axis is 0. Chart. axesy. Add (yaxis ); // Add the Y axis for the chart For ( Int I = 0; I <ValueList. Count; I ++) {dataseries = New Dataseries (); // Create a data line Dataseries. renderas = renderas. line; // The data line display type is linear Dataseries. xvaluetype = chartvaluetypes. datetime; // Set the X axis type to the date type List < String > Value = (List <String >) ValueList [I]; For ( Int J = 0; j <updatetime. Count; j ++) {datapoint = New Datapoint (); // Create a data point Datapoint. xvalue = updatetime [J]; // Set the x-axis value of the data point; Datapoint. yvalue = Double . Parse ( Value [J]); // Set the Y axis Value Datapoint. markersize = 8;// Set the data point size Datapoint. mouseleftbuttondown + = New Mousebuttoneventhandler (datapoint_mouseleftbuttondown ); // Click the data point event Dataseries. datapoints. Add (datapoint ); // Add a data point for the data line } Chart. Series. Add (dataseries ); // Add data lines for charts } Layoutroot. Children. Add (Chart );} Void Datapoint_mouseleftbuttondown ( Object Sender, mousebuttoneventargs e ){}}}
I hope it will be useful to you ~