javascript - 请教chart.js的曲线图如何加上类似echarts dataZoom的功能?
问题描述
’use strict’;var salesChartCanvas = $('#salesChart').get(0).getContext('2d');var salesChart = new Chart(salesChartCanvas);var salesChartData = { labels: ['1日', '2日', '3日', '4日', '5日', '6日', '7日', '8日', '9日', '10日', '11日', '12日', '13日', '14日', '15日', '16日', '17日', '18日', '19日', '20日', '21日', '22日', '23日', '24日', '25日', '26日', '27日', '28日', '29日', '30日', '31日'], datasets: [{ label: 'Electronics', fillColor: 'rgb(210, 214, 222)', strokeColor: 'rgb(210, 214, 222)', pointColor: 'rgb(210, 214, 222)', pointStrokeColor: '#c1c7d1', pointHighlightFill: '#fff', pointHighlightStroke: 'rgb(220,220,220)', data: beian //[59, 65, 80, 81, 56, 55, 40,65, 59, 80, 81, 56, 55, 40,65, 59, 80, 81, 56, 55, 40,65, 59, 80, 81, 56, 55, 40,28, 48, 40]},{ label: 'Digital Goods', fillColor: 'rgba(60,141,188,0.9)', strokeColor: 'rgba(60,141,188,0.8)', pointColor: '#3b8bba', pointStrokeColor: 'rgba(60,141,188,1)', pointHighlightFill: '#fff', pointHighlightStroke: 'rgba(60,141,188,1)', data: lengen //[28, 19, 27, 48, 40, 86, 90, 48, 40, 19, 27,28, 86, 90,28, 27,48, 40, 19, 86, 90,28, 48, 40, 19, 27, 86, 90,0,0,0]} ]};var salesChartOptions = { showScale: true, scaleShowGridLines: false, scaleGridLineColor: 'rgba(0,0,0,.05)', scaleGridLineWidth: 1, scaleShowHorizontalLines: true, scaleShowVerticalLines: true, bezierCurve: true, bezierCurveTension: 0.3, pointDot: false, pointDotRadius: 4, pointDotStrokeWidth: 1, pointHitDetectionRadius: 20, datasetStroke: true, datasetStrokeWidth: 2, datasetFill: true, legendTemplate: '<ul class='<%=name.toLowerCase()%>-legend'><% for (var i=0; i<datasets.length; i++){%><li><span style='background-color:<%=datasets[i].lineColor%>'></span><%=datasets[i].label%></li><%}%></ul>', maintainAspectRatio: true, responsive: true};//Create the line chartsalesChart.Line(salesChartData, salesChartOptions);
图片
问题解答
回答1:来自Github Chart.js Issue:https://github.com/chartjs/Ch...
里面提到了这个插件:ChartJS Zoom
相关文章:
1. Python处理Dict生成json2. (python)关于如何做到按win+R再输入文件文件名就可以运行?3. 想练支付宝对接和微信支付对接开发(Java),好像个人不可以,怎么弄个企业的4. mysql - Sql union 操作5. java - Mybatis 数据库多表关联分页的问题6. 急急急!!!求大神解答网站评论问题,有大神帮帮小弟吗7. javascript - 按钮链接到另一个网址 怎么通过百度统计计算按钮的点击数量8. python - 如何使用websocket在网页上动态示实时数据的折线图?9. python - 请问这两个地方是为什么呢?10. python2.7 - python 正则前瞻 后瞻 无法匹配到正确的内容
