We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
F2 Version:3.2.2
Platform:Redmi 5A, MiUi 9.6, Android 7.1.2
Mini Showcase(like screenshots):
CodePen Link:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> <meta name="chart-name" content="曲线图的横向平移缩放"> <title>F2 图表组件库 - AntV</title> <link rel="stylesheet" href="https://gw.alipayobjects.com/os/rmsportal/YmDAMEQVbLJpVbKiRQVX.css" /> </head> <body> <script>/*Fixing iframe window.innerHeight 0 issue in Safari*/document.body.clientHeight;</script> <script src="https://gw.alipayobjects.com/os/antv/assets/f2/3.2.1/f2-all.min.js"></script> <script src="https://gw.alipayobjects.com/os/antv/assets/lib/jquery-3.2.1.min.js"></script> <script src="https://gw.alipayobjects.com/os/rmsportal/NjNldKHIVQRozfbAOJUW.js"></script> <div class="chart-wrapper"> <canvas id="mountNode"></canvas> </div> <p style="text-align: center;">请使用手机扫码观看</p> <script> // Generate sample data var data = []; var step = Math.PI / 4; for (var x = -25; x < 25; x += step) { data.push({ x: x, y: Math.sin(x) }); } var chart = new F2.Chart({ id: 'mountNode', pixelRatio: window.devicePixelRatio }); chart.scale('x', { type: 'cat' }); chart.source(data); chart.axis('x', { grid: function grid(text) { if (text == 0) { return { lineDash: null }; } } }); chart.axis('y', { grid: function grid(text) { if (text == 0) { return { lineDash: null }; } } }); chart.tooltip(false); chart.interaction('pan', { limitRange: { x: { min: -100, max: 100 } } }); chart.interaction('pinch', { maxScale: 5, minScale: 1 }); chart.line().position('x*y').shape('smooth'); chart.render(); </script> </body> </html>
x轴为cat类型时缩放困难,如果为linear则正常,麻烦看下是本应如此吗?
The text was updated successfully, but these errors were encountered:
这里面有一个绘图的 BUG,我修复了。但是除去这个 BUG,你的写法也有问题:
chart.scale('x', { type: 'cat ' })
另外, 对于分类类型,pan 平移的交互不需要设置 limitRange,我们会自动将其限定在 x 轴的数值范围内
pan
limitRange
我们在创建 line 的时候,还需要声明 sortable 为 false,以组织内部的排序导致线图错乱(默认情况下我会对线图、区域图的数据按照横轴进行排序的)
sortable
false
var data = []; var step = Math.PI / 4; for (var x = -25; x < 25; x += step) { data.push({ x: x + '', // 转成字符串 y: Math.sin(x) }); } var chart = new F2.Chart({ id: 'mountNode', animate: false, pixelRatio: window.devicePixelRatio }); // chart.scale('x', { // type: 'cat', // }); chart.source(data); chart.axis('x', { grid: function grid(text) { if (text == 0) { return { lineDash: null }; } } }); chart.axis('y', { grid: function grid(text) { if (text == 0) { return { lineDash: null }; } } }); chart.tooltip(false); chart.interaction('pan'); chart.interaction('pinch', { maxScale: 5, minScale: 1 }); chart.line({ sortable: false }).position('x*y').shape('smooth'); chart.render();
Sorry, something went wrong.
82d5c2c
Merge pull request #322 from antvis/fix-issue-316
0b952bd
fix: when the points is empty, return. Closed #316.
@antv/f2@3.2.3-beta.1 版本修复了这个问题!
好的 了解了 这个只是把官网的例子抓了抓改 很多地方都会注意的 谢谢~
simaQ
No branches or pull requests
F2 Version:3.2.2
Platform:Redmi 5A, MiUi 9.6, Android 7.1.2
Mini Showcase(like screenshots):
CodePen Link:
x轴为cat类型时缩放困难,如果为linear则正常,麻烦看下是本应如此吗?
The text was updated successfully, but these errors were encountered: