portant; overflow-wrap: break-word !important;">利用威纶触摸屏ta:image/svg+xml,%3csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M7.60772 8.29444C7.02144 8.73734 6.29139 9 5.5 9C3.567 9 2 7.433 2 5.5C2 3.567 3.567 2 5.5 2C7.433 2 9 3.567 9 5.5C9 6.28241 8.74327 7.00486 8.30946 7.5877C8.3183 7.59444 8.3268 7.60186 8.33488 7.60994L10.4331 9.70816L9.726 10.4153L7.62777 8.31704C7.62055 8.30983 7.61387 8.30228 7.60772 8.29444ZM8 5.5C8 6.88071 6.88071 8 5.5 8C4.11929 8 3 6.88071 3 5.5C3 4.11929 4.11929 3 5.5 3C6.88071 3 8 4.11929 8 5.5Z' fill='%23576B95'/%3e%3c/svg%3e");">的JS元件与MQTT功能实现远程更新屏幕图表。
JS元件
JS元件是指威纶触摸屏系统中使用的Javascript(JS)元件。
这些元件是为了方便在触摸屏界面上实现动态内容展示和增强用户体验等方面而设计的。
通过JS元件,触摸屏可以实现动态内容的更新和刷新,让用户能够实时获取最新的信息和数据。
在组态开发过程中,开发人员可以利用这些JS元件来构建用户界面,响应用户操作,并与后台系统进行数据交换。
这样就能够实现更加丰富、灵活和智能化的触摸屏应用程序,满足不同场景下的需求。
比如,我们先简单定义一个雷达图ta:image/svg+xml,%3csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M7.60772 8.29444C7.02144 8.73734 6.29139 9 5.5 9C3.567 9 2 7.433 2 5.5C2 3.567 3.567 2 5.5 2C7.433 2 9 3.567 9 5.5C9 6.28241 8.74327 7.00486 8.30946 7.5877C8.3183 7.59444 8.3268 7.60186 8.33488 7.60994L10.4331 9.70816L9.726 10.4153L7.62777 8.31704C7.62055 8.30983 7.61387 8.30228 7.60772 8.29444ZM8 5.5C8 6.88071 6.88071 8 5.5 8C4.11929 8 3 6.88071 3 5.5C3 4.11929 4.11929 3 5.5 3C6.88071 3 8 4.11929 8 5.5Z' fill='%23576B95'/%3e%3c/svg%3e");">,并为它赋予初始数据和标签,如下:
portant; overflow-wrap: break-word !important;">var radarChart = new Chart(ctx, configuration)
portant; overflow-wrap: break-word !important;">var configuration = {
portant; overflow-wrap: break-word !important;"> type: 'radar',
portant; overflow-wrap: break-word !important;"> data: {
portant; overflow-wrap: break-word !important;"> labels: [ '员工1', '员工2', '员工3', '员工4', '员工5', '员工6', ],
portant; overflow-wrap: break-word !important;"> datasets: [{
portant; overflow-wrap: break-word !important;"> label: '去年生产量',
portant; overflow-wrap: break-word !important;"> data: [0, 1, 2, 3, 4, 5],
portant; overflow-wrap: break-word !important;"> fill: true,
portant; overflow-wrap: break-word !important;"> backgroundColor: 'rgba(255, 99, 132, 0.2)',
portant; overflow-wrap: break-word !important;"> borderColor: 'rgb(255, 99, 132)',
portant; overflow-wrap: break-word !important;"> pointBackgroundColor: 'rgb(255, 99, 132)',
portant; overflow-wrap: break-word !important;"> pointBorderColor: '#fff',
portant; overflow-wrap: break-word !important;"> },
portant; overflow-wrap: break-word !important;"> {
portant; overflow-wrap: break-word !important;"> label: '今年生产量',
portant; overflow-wrap: break-word !important;"> data: [5, 4, 3, 2, 1, 0],
portant; overflow-wrap: break-word !important;"> fill: true,
portant; overflow-wrap: break-word !important;"> backgroundColor: 'rgba(54, 162, 235, 0.2)',
portant; overflow-wrap: break-word !important;"> borderColor: 'rgb(54, 162, 235)',
portant; overflow-wrap: break-word !important;"> pointBackgroundColor: 'rgb(54, 162, 235)',
portant; overflow-wrap: break-word !important;"> pointBorderColor: '#fff',
portant; overflow-wrap: break-word !important;"> }]
portant; overflow-wrap: break-word !important;"> },
portant; overflow-wrap: break-word !important;"> options: {
portant; overflow-wrap: break-word !important;"> elements: {
portant; overflow-wrap: break-word !important;"> line: {
portant; overflow-wrap: break-word !important;"> borderWidth: 3
portant; overflow-wrap: break-word !important;"> }
portant; overflow-wrap: break-word !important;"> },
portant; overflow-wrap: break-word !important;"> scales: {
portant; overflow-wrap: break-word !important;"> r: {
portant; overflow-wrap: break-word !important;"> beginAtZero: true
portant; overflow-wrap: break-word !important;"> }
portant; overflow-wrap: break-word !important;"> }
portant; overflow-wrap: break-word !important;"> },
portant; overflow-wrap: break-word !important;">};
这是一段基础的创建雷达图的代码,不加修改的话会有以下效果:
雷达图(也称为蜘蛛图或星图)是一种常用的数据可视化工具,它具有多维度展示、对比性、适用性广泛等优点,是一种功能强大、直观易懂的数据可视化工具。
但是,我们在通过JS元件创建雷达图之后,它的数据将只能通过修改地址内的数据来实现更改,这就限制了其使用的便捷性。
那么实现如何远程更改图表呢?这就用到了另一个工具——MQTT。