p8.html 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title></title>
  6. <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
  7. <link rel="stylesheet" href="../css/weui.css"/>
  8. <link rel="stylesheet" href="../css/weuix.css"/>
  9. <script src="../js/f2.min.js"></script>
  10. </head>
  11. <body ontouchstart>
  12. <div class="page-hd">
  13. <h1 class="page-hd-title">
  14. f2 图表 阿里出品
  15. </h1>
  16. <p class="page-hd-desc">很强大的图表库,为移动而生,只有145kb,支持几十种图表</p>
  17. </div>
  18. <div class="page-bd-15">
  19. <canvas id="myChart" height="260"></canvas>
  20. <br>
  21. <a href="http://antv.alipay.com/zh-cn/f2/3.x/index.html">开发文档</a>
  22. <script>
  23. const data = [
  24. { genre: '中国', sold: 275 },
  25. { genre: '印度', sold: 115 },
  26. { genre: '俄罗斯', sold: 120 },
  27. { genre: '美国', sold: 350 },
  28. { genre: '日本', sold: 150 },
  29. ];
  30. // Step 1: 创建 Chart 对象
  31. const chart = new F2.Chart({
  32. id: 'myChart',
  33. pixelRatio: window.devicePixelRatio // 指定分辨率
  34. });
  35. // Step 2: 载入数据源
  36. chart.source(data);
  37. // Step 3:创建图形语法,绘制柱状图,由 genre 和 sold 两个属性决定图形位置,genre 映射至 x 轴,sold 映射至 y 轴
  38. chart.interval().position('genre*sold').color('genre');
  39. // Step 4: 渲染图表
  40. chart.render();
  41. </script>
  42. </div>
  43. <br>
  44. <br>
  45. <div class="weui-footer weui-footer_fixed-bottom">
  46. <p class="weui-footer__links">
  47. <a href="../index.html" class="weui-footer__link">WeUI首页</a>
  48. </p>
  49. <p class="weui-footer__text">Copyright &copy; Yoby</p>
  50. </div>
  51. </body>
  52. </html>