winform 应用程序内嵌webbrowser的一些参考
(留作备用)
[TOC]
主要是C#向页面js传递数据
大致的使用方式:
还有一些json对象的处理
- winform端 C#代码说明
使用了newtonsoft公司的json.net动态库
构造简单的对象:
//构造规则 为了使用这些类型需要加上引用
using Newtonsoft.Json.Linq;
//JObject => {}
//JProperty => "":""
//JArray => []
//实例
JObject link = new JObject(
new JProperty("source", source),
new JProperty("target",target),
new JProperty("value",value),
new JProperty("weight",value)
);
JObject json = new JObject(
new JProperty("links", new JArray(new JObject[] { })),
new JProperty("legend",newLegend(new string[] { })
);
//转换序列对象
json.tostring();
//{links:[{source:source},{target:target},{value:value},{weight:weight}],legend:[{},{},{}]}
- 网页端 js代码说明
使用了简单的处理方式调用函数直接生成页面
//获得chart实例
var myChart = echarts.init(document.getElementById('main'));
//转换参数
var cc=eval('('+arg+')');
//将序列转换为对象转换的对象可以枚举
var i=0;
for(;i<cc.links.length;i++){Ilinks.push(cc.links[i]);}
//处理完数据
myChart.setOption(option,true);