Echarts+WPF
C#
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq; namespace WpfBrowserApp1
{
/// <summary>
/// Page1.xaml 的交互逻辑
/// </summary>
public partial class Page1 : Page
{
public dynamic scriptObject = null;
public Page1()
{
InitializeComponent();
if (!BrowserInteropHelper.IsBrowserHosted)
{
MessageBox.Show("不满足与JS调用条件");
return;
}
scriptObject = BrowserInteropHelper.HostScript;
if (scriptObject != null)
{
scriptObject.SetWpfObj(new OprateBasic());
}
webbrowser.Source = new Uri("html页面的路径");
webbrowser.ObjectForScripting = new OprateBasic();
// m_webFrame.Source =
// new Uri(
// "");
// m_webFrame.NavigationUIVisibility = System.Windows.Navigation.NavigationUIVisibility.Hidden;
// Web.Navigate();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
//O option = JsonConvert.DeserializeObject<O>(Readjson(""));
webbrowser.InvokeScript("msg",Readjson(""));
//Web.InvokeScript("msg", Tb1.Text);
}
/// <summary>
/// 读取JSON文件
/// </summary>
/// <param name="key">JSON文件中的key值</param>
/// <returns>JSON文件中的value值</returns>
public static string Readjson(string key)
{
string jsonfile = "";//JSON文件路径 using (System.IO.StreamReader file = System.IO.File.OpenText(jsonfile))
{
using (JsonTextReader reader = new JsonTextReader(file))
{
JObject o = (JObject)JToken.ReadFrom(reader);
var value = o.ToString();
return value;
}
}
}
}
[System.Runtime.InteropServices.ComVisible(true)] // 将该类设置为com可访问
public class OprateBasic
{
public void palymusic(string msg)
{
//string json = File.ReadAllText("json文件路径“);
//dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(json); // string output = JsonConvert.SerializeObject(msg, Newtonsoft.Json.Formatting.Indented);
File.WriteAllText("data.json", msg);
// MessageBox.Show("WPF弹出框:" + msg);
}
}
}
html
<!-- saved from url=()about:internet -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>ECharts</title> <!-- 引入 echarts.js -->
<script src="../Scripts/echarts.js"></script>
<script src="../Scripts/echarts-all.js"></script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<!-- 为ECharts准备一个具备大小(宽高)的Dom -->
<div id="main" style="width: 600px;height:400px;"></div>
<input type="text" id="txtInput" />
<button onclick="Test()" style="width:100px;height:20px">测试</button>
<script>
var con = window.external
var option = {};
function Test() {
option.xAxis[].name = $("#txtInput").val()
con.palymusic(JSON.stringify(option));
} function msg(obj) {
alert(obj)
var myChart = echarts.init(document.getElementById('main'));
option = JSON.parse(obj)
myChart.setOption(option)
} </script>
<script type="text/javascript">
// 基于准备好的dom,初始化echarts实例 // 指定图表的配置项和数据 //var str = ""
// $.getJSON("../Data/data.json",function(data){
// $.each(data,function(infoindex,info){
//str+=info["dd"]
// })
//})
// alert(str);
//; </script>
</body>
</html>
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC 清单选项
如果要更改 Windows 用户帐户控制级别,请用以下节点之一替换
requestedExecutionLevel 节点。 <requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" /> 指定 requestedExecutionLevel 节点将会禁用文件和注册表虚拟化。
如果要利用文件和注册表虚拟化实现向后
兼容性,则删除 requestedExecutionLevel 节点。
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<defaultAssemblyRequest permissionSetReference="Custom" />
<PermissionSet class="System.Security.PermissionSet" version="" Unrestricted="true" ID="Custom" SameSite="site" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- 此应用程序设计使用的所有 Windows 版本的列表。Windows 将会自动选择最兼容的环境。-->
<!-- 如果应用程序设计使用 Windows ,请取消注释以下 supportedOS 节点-->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>-->
</application>
</compatibility>
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
<!-- <dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>-->
</asmv1:assembly>
Echarts+WPF的更多相关文章
- WPF仿百度Echarts人口迁移图
GitHub地址:https://github.com/ptddqr/wpf-echarts-map/tree/master 关于大名鼎鼎的百度Echarts我就不多说了 不了解的朋友直接看官方的例子 ...
- 在WPF中嵌入WebBrowser可视化页面
无论是哪种C/S技术,涉及数据可视化就非常的累赘了,当然大神也一定有,只不过面向大多数人,还是通过网页来实现,有的时候不想把这两个功能分开,一般会是客户的原因,所以我们打算在WPF中嵌入WebBrow ...
- .NET 5 尝鲜 - 开源项目TerminalMACS WPF管理端支持.NET 5
.NET 5 尝鲜 - 开源项目TerminalMACS WPF管理端支持.NET 5 一个使用 Prism 作为模块化框架.基于多个开源控件库作为UI控件选择.集成开源 UI 界面设计的 .NET ...
- 一起来玩echarts系列(一)------箱线图的分析与绘制
一.箱线图 Box-plot 箱线图一般被用作显示数据分散情况.具体是计算一组数据的中位数.25%分位数.75%分位数.上边界.下边界,来将数据从大到小排列,直观展示数据整体的分布情况. 大部分正常数 ...
- 在WPF中使用依赖注入的方式创建视图
在WPF中使用依赖注入的方式创建视图 0x00 问题的产生 互联网时代桌面开发真是越来越少了,很多应用都转到了浏览器端和移动智能终端,相应的软件开发上的新技术应用到桌面开发的文章也很少.我之前主要做W ...
- MVVM框架从WPF移植到UWP遇到的问题和解决方法
MVVM框架从WPF移植到UWP遇到的问题和解决方法 0x00 起因 这几天开始学习UWP了,之前有WPF经验,所以总体感觉还可以,看了一些基础概念和主题,写了几个测试程序,突然想起来了前一段时间在W ...
- MVVM模式解析和在WPF中的实现(六) 用依赖注入的方式配置ViewModel并注册消息
MVVM模式解析和在WPF中的实现(六) 用依赖注入的方式配置ViewModel并注册消息 系列目录: MVVM模式解析和在WPF中的实现(一)MVVM模式简介 MVVM模式解析和在WPF中的实现(二 ...
- MVVM模式解析和在WPF中的实现(五)View和ViewModel的通信
MVVM模式解析和在WPF中的实现(五) View和ViewModel的通信 系列目录: MVVM模式解析和在WPF中的实现(一)MVVM模式简介 MVVM模式解析和在WPF中的实现(二)数据绑定 M ...
- MVVM设计模式和WPF中的实现(四)事件绑定
MVVM设计模式和在WPF中的实现(四) 事件绑定 系列目录: MVVM模式解析和在WPF中的实现(一)MVVM模式简介 MVVM模式解析和在WPF中的实现(二)数据绑定 MVVM模式解析和在WPF中 ...
随机推荐
- 加载Firefox 和 chrome 浏览器配置
Firefox: Chrome:
- HTML注册页面验证注册信息
在这里主要介绍两种验证方式,一种是点击注册按钮后会提示最上方的出错位置,弹出窗口提示格式不对.另一种是利用鼠标事件,在鼠标进行不同操作时会有不同的click事件. 这两种都是利用javascript, ...
- 微信小程序之巧妙的封装
巧妙的封装 暴露一个访问地址xapp.config.js module.exports = { api_host: `https://a.squmo.com/yizu` } 继续引入,加暴露api.c ...
- 【转】分布式存储和一致性hash
本文我将对一致性算法作介绍,同时谈谈自己对一致性hash和一般意义上的hash算法的区别 hash是什么 hash即hash算法,又称为散列算法,百度百科的定义是 哈希算法将任意长度的二进制值映射为较 ...
- 记录一下学习Android的小知识
目前要设计即时通讯的整体架构,包括服务端.Android.IOS.PC.平板等等系统,所以需要研究一下手机的实现方式,开始从Android入手,偶尔在这记录下小知识. ADT: 1.页面功能请求结构, ...
- C语言的第二天-比较大小的小程序
#include <stdio.h> int main() { int a,b,c,max; printf("请输入三个数:"); scanf("%d,%d, ...
- JQUEY 引用
$(document).ready(function(){ alert($("a:first").attr("id")); });
- SEO网站title应该怎么写
第一:具有独特性 在你的网站中,也许有成千上万的页面,首页-分类-无数的文章页面,这些都有固定的标题,他们的标题最好不要相同.有的时候也许不是`站长们故意的,但是在使用编辑软件的时候,经常 会出现很多 ...
- [原创]Mybatis特殊值Enum类型转换器-ValuedEnumTypeHandler
引言 typeHandlers 阅读官方文档 typeHandlers 一节{:target="_blank"} MyBatis 在预处理语句(PreparedStatement) ...
- 【知识碎片】CSS 篇
1.CSS达到截取效果 地方卡机了会计师的立法及 => 地方卡机了... max-width: 400px; overflow: hidden; white-space: nowrap; t ...