从“JS”到“SL”
如何把从“JS树图”中选定的条件,传给“Silverlight”页面,让它根据条件进行页面的显示???
截图如下,左侧是“JSTreeView”,右侧是“Silverlight页面”。
[解决办法]
调用silverlight的方法
Silverlight和js之间的相互操作
如果你的chart图 类似
- JScript code
<head runat="server"> <script type="text/javascript" src="Visifire.js"></script></head><script type="text/javascript"> var chartXaml1 = '<vc:Chart xmlns:vc="clr-namespace:Visifire.Charts;assembly=SLVisifire.Charts" Width="500" Height="300" Theme="Theme1">' + ' <vc:Chart.Titles>' + ' <vc:Title Text="Visifire Chart 1"/>' + ' </vc:Chart.Titles>' + ' <vc:Chart.Series>' + ' <vc:DataSeries RenderAs="Column">' + ' <vc:DataSeries.DataPoints>' + ' <vc:DataPoint AxisXLabel="Jan" YValue="35"/>' + ' <vc:DataPoint AxisXLabel="Feb" YValue="32"/>' + ' <vc:DataPoint AxisXLabel="Mar" YValue="27"/>' + ' <vc:DataPoint AxisXLabel="Apr" YValue="17"/>' + ' <vc:DataPoint AxisXLabel="May" YValue="16"/>' + ' </vc:DataSeries.DataPoints>' + ' </vc:DataSeries>' + ' </vc:Chart.Series>' + ' </vc:Chart>'; var chartXaml2 = '<vc:Chart xmlns:vc="clr-namespace:Visifire.Charts;assembly=SLVisifire.Charts" Width="500" Height="300" Theme="Theme1">' + ' <vc:Chart.Titles>' + ' <vc:Title Text="Visifire Chart 2"/>' + ' </vc:Chart.Titles>' + ' <vc:Chart.Series>' + ' <vc:DataSeries RenderAs="Column">' + ' <vc:DataSeries.DataPoints>' + ' <vc:DataPoint AxisXLabel="Jan" YValue="25"/>' + ' <vc:DataPoint AxisXLabel="Feb" YValue="42"/>' + ' <vc:DataPoint AxisXLabel="Mar" YValue="18"/>' + ' <vc:DataPoint AxisXLabel="Apr" YValue="37"/>' + ' <vc:DataPoint AxisXLabel="May" YValue="40"/>' + ' </vc:DataSeries.DataPoints>' + ' </vc:DataSeries>' + ' </vc:Chart.Series>' + ' </vc:Chart>'; var chartXaml3 = '<vc:Chart xmlns:vc="clr-namespace:Visifire.Charts;assembly=SLVisifire.Charts" Width="500" Height="300" Theme="Theme1">' + ' <vc:Chart.Titles>' + ' <vc:Title Text="Visifire Chart 3"/>' + ' </vc:Chart.Titles>' + ' <vc:Chart.Series>' + ' <vc:DataSeries RenderAs="Column">' + ' <vc:DataSeries.DataPoints>' + ' <vc:DataPoint AxisXLabel="Jan" YValue="33"/>' + ' <vc:DataPoint AxisXLabel="Feb" YValue="12"/>' + ' <vc:DataPoint AxisXLabel="Mar" YValue="28"/>' + ' <vc:DataPoint AxisXLabel="Apr" YValue="57"/>' + ' <vc:DataPoint AxisXLabel="May" YValue="30"/>' + ' </vc:DataSeries.DataPoints>' + ' </vc:DataSeries>' + ' </vc:Chart.Series>' + ' </vc:Chart>'; </script><div id="VisifireChart0"> <script type="text/javascript"> // Create Visifire object var vChart1 = new Visifire('SL.Visifire.Charts.xap', "MyChart1", 500, 300); // Set Chart XAML as string vChart1.setDataXml(chartXaml1); // Render chart vChart1.render("VisifireChart0"); </script> </div> <div id="VisifireChart1"> <script type="text/javascript"> // Create Visifire object var vChart2 = new Visifire('SL.Visifire.Charts.xap', "MyChart2", 500, 300); // Set Chart XAML as string vChart2.setDataXml(chartXaml2); // Render chart vChart2.render("VisifireChart1"); </script> </div> <div id="VisifireChart2"> <script type="text/javascript"> // Create Visifire object var vChart3 = new Visifire('SL.Visifire.Charts.xap', "MyChart3", 500, 300); // Set Chart XAML as string vChart3.setDataXml(chartXaml3); // Render chart vChart3.render("VisifireChart2"); </script> </div>
[解决办法]
看你发的截图 js和silverlight 互操作 更合适点
[解决办法]
不忙 写个比较完整的
- JScript code
<script type="text/javascript"> var sales;// sales = [{ "Address": "北京", "Age": 2, "IsMember": false, "Name": "赵二" },//{ "Address": "北京", "Age": 3, "IsMember": false, "Name": "张三" },//{ "Address": "北京", "Age": 4, "IsMember": false, "Name": "李四" },//{ "Address": "北京", "Age": 5, "IsMember": false, "Name": "王五"}]; sales = [{ year: 2006, month: "Jan", ProductX: 20000, ProductY: 25000, ProductZ: 15000 }, { year: 2006, month: "Feb", ProductX: 10000, ProductY: 23000, ProductZ: 25000 }, { year: 2006, month: "Mar", ProductX: 22000, ProductY: 38000, ProductZ: 83000 }, { year: 2006, month: "Apr", ProductX: 23456, ProductY: 32435, ProductZ: 24223 }, { year: 2006, month: "May", ProductX: 25142, ProductY: 32415, ProductZ: 10923 }, { year: 2006, month: "Jun", ProductX: 18254, ProductY: 15342, ProductZ: 10934 }, { year: 2006, month: "Jul", ProductX: 18562, ProductY: 19832, ProductZ: 10293 }, { year: 2006, month: "Aug", ProductX: 28376, ProductY: 53426, ProductZ: 22376 }, { year: 2006, month: "Sep", ProductX: 48282, ProductY: 25000, ProductZ: 15000 }, { year: 2006, month: "Oct", ProductX: 38276, ProductY: 92821, ProductZ: 93834 }, { year: 2006, month: "Nov", ProductX: 28911, ProductY: 43289, ProductZ: 40936 }, { year: 2006, month: "Dec", ProductX: 52435, ProductY: 37271, ProductZ: 49381 }, { year: 2007, month: "Jan", ProductX: 82711, ProductY: 10297, ProductZ: 10943 }, { year: 2007, month: "Feb", ProductX: 20000, ProductY: 25000, ProductZ: 19142 }, { year: 2007, month: "Mar", ProductX: 17624, ProductY: 22762, ProductZ: 54436 }, { year: 2007, month: "Apr", ProductX: 18263, ProductY: 38494, ProductZ: 43528 }, { year: 2007, month: "May", ProductX: 38400, ProductY: 19203, ProductZ: 46880 }, { year: 2007, month: "Jun", ProductX: 12000, ProductY: 37840, ProductZ: 35470 }, { year: 2007, month: "Jul", ProductX: 25363, ProductY: 63548, ProductZ: 27533 }, { year: 2007, month: "Aug", ProductX: 19253, ProductY: 37261, ProductZ: 37348 }, { year: 2007, month: "Sep", ProductX: 23344, ProductY: 25000, ProductZ: 27245 }, { year: 2007, month: "Oct", ProductX: 20000, ProductY: 24354, ProductZ: 37272 }, { year: 2007, month: "Nov", ProductX: 28927, ProductY: 27338, ProductZ: 27273 }, { year: 2007, month: "Dec", ProductX: 12435, ProductY: 10239, ProductZ: 37271 }, { year: 2008, month: "Jan", ProductX: 20000, ProductY: 25000, ProductZ: 13243 }, { year: 2008, month: "Feb", ProductX: 12354, ProductY: 23456, ProductZ: 42356 }, { year: 2008, month: "Mar", ProductX: 15263, ProductY: 42336, ProductZ: 12334 }, { year: 2008, month: "Apr", ProductX: 26271, ProductY: 22111, ProductZ: 28373 }, { year: 2008, month: "May", ProductX: 27181, ProductY: 10927, ProductZ: 15252 }, { year: 2008, month: "Jun", ProductX: 38271, ProductY: 43352, ProductZ: 47352 }, { year: 2008, month: "Jul", ProductX: 27276, ProductY: 18663, ProductZ: 23465 }, { year: 2008, month: "Aug", ProductX: 19000, ProductY: 23220, ProductZ: 13345 }, { year: 2008, month: "Sep", ProductX: 21300, ProductY: 45210, ProductZ: 17627 }, { year: 2008, month: "Oct", ProductX: 32516, ProductY: 56245, ProductZ: 64542 }, { year: 2008, month: "Nov", ProductX: 26533, ProductY: 42342, ProductZ: 55427 }, { year: 2008, month: "Dec", ProductX: 34256, ProductY: 62300, ProductZ: 49278 }]; function Obj2str(o) { if (o == undefined) { return ""; } var r = []; if (typeof o == "string") return "\"" + o.replace(/([\"\\])/g, "\\$1").replace(/(\n)/g, "\\n").replace(/(\r)/g, "\\r").replace(/(\t)/g, "\\t") + "\""; if (typeof o == "object") { if (!o.sort) { for (var i in o) r.push("\"" + i + "\":" + Obj2str(o[i])); if (!!document.all && !/^\n?function\s*toString\(\)\s*\{\n?\s*\[native code\]\n?\s*\}\n?\s*$/.test(o.toString)) { r.push("toString:" + o.toString.toString()); } r = "{" + r.join() + "}"; } else { for (var i = 0; i < o.length; i++) r.push(Obj2str(o[i])); r = "[" + r.join() + "]"; } return r; } return o.toString().replace(/\"\:/g, '":""'); } function js() { alert("dddd"); } function addSource() { var slHost = document.getElementById("objectsilverlight"); //此处的id是silverlight中object标签的id var page = slHost.Content.Page; //Page就是在sl中注册的名称 page.ChartDataSource(Obj2str(sales)); } </script>
[解决办法]
“JS+Json”类型的Demo。。。