angular - 如何放大 angular 8 中的primeng p-chart?
问题描述
p-chart zoom 在我的项目中不起作用。角度版本是 8.3.21,primeNG 版本是 9.0.0,chartjs-plugin-zoom 版本是 0.7.7,我没有在我的项目中添加hammer.js。我的 HTML 代码是:
<div class="center">
<p-chart type="line" [data]="data" [options]="option"></p-chart> </div>
我的 ts 代码是:
option;
data= {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [{
label: 'My First Dataset',
data: [65, 59, 80, 81, 56, 55, 40],
fill: false,
borderColor: 'rgb(75, 192, 192)',
tension: 0.1
}]
}
ngOnInit(): void {
this.option = {
title: {
text: 'Chart.js Time Scale'
},
plugins: {
zoom: {
zoom: {
enabled: true,
drag: {
borderColor: 'rgba(225,225,225,0.3)',
borderWidth: 5,
backgroundColor: 'rgb(225,225,225)'
},
mode: 'xy',
rangeMin: {
x: null,
y: null
},
rangeMax: {
x: null,
y: null
},
speed: 0.1,
onZoom: function({ chart }) {
console.log(`I'm zooming!!!`);
},
onZoomComplete: function({ chart }) {
console.log(`I was zoomed!!!`);
}
}
}
}
};
}
我在 angular.json 中添加了这个脚本:
"scripts": [
"node_modules/quill/dist/quill.min.js",
"node_modules/chart.js/dist/Chart.min.css",
"node_modules/chartjs-plugin-zoom/dist/chartjs-plugin-zoom.min.js"
]
解决方案
推荐阅读
- javascript - Javascript正则表达式匹配字符串的一部分但不是整个字符串
- flask - Connexion & Flask:在请求处理程序中访问数据库
- package - Chocolatey:升级到新的主要版本时如何处理包的重大变化和卸载?
- sql-server - 在数据流任务中选择 oledb 目标表时出现 SSIS 2012 开发错误
- node.js - passport-github 有时无法读取 id 的属性
- apache-kafka - Kafka Connect HDFS Sink中的多个嵌套字段分区
- mysql - 如何根据行的结果值附加行或重新触发查询(在循环中?)?
- c# - 如何在 Mac 中使用 Selenium WebDriver 打开 Chrome 时保持打开状态
- javascript - AngularJS - 根据返回的 localStorage 隐藏标题、sidebarMeta、templateUrl
- raspberry-pi - 通过写入 micro SD 卡配置树莓派 wifi