课程表

Ext.js课程

工具箱
速查手册

Ext.js 条形图

当前位置:免费教程 » JS/JS库/框架 » Ext.js

描述

此图表用于以条形图格式表示数据。 它是一个笛卡尔图表。

语法

这里是简单的语法。

  1. Ext.create('Ext.chart.CartesianChart',{
  2. series: [{
  3. type: 'bar',
  4. xField: 'name',
  5. yField: 'G1'
  6. }]
  7. render, legend and other properties
  8. });

下面是一个简单的例子显示用法。

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <link href="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/theme-classic/resources/theme-classic-all.css" rel="stylesheet" />
  5. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/ext-all.js"></script>
  6. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/packages/charts/classic/charts.js"></script>
  7. <link href="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/packages/charts/classic/classic/resources/charts-all.css" rel="stylesheet" />
  8. <script type="text/javascript">
  9. Ext.onReady(function() {
  10. Ext.create('Ext.chart.CartesianChart', {
  11. renderTo: document.body,
  12. width: 600,
  13. height: 200,
  14. flipXY: true,
  15. store: {
  16. fields: ['name', 'g1', 'g2'],
  17. data: [
  18. {"name": "Item-0", "g1": 57, "g2": 59},
  19. {"name": "Item-1", "g1": 45, "g2": 50},
  20. {"name": "Item-2", "g1": 67, "g2": 43},
  21. {"name": "Item-3", "g1": 45, "g2": 18},
  22. {"name": "Item-4", "g1": 30, "g2": 90}
  23. ]
  24. },
  25. //set legend configuration
  26. legend: {
  27. docked: 'right'
  28. },
  29. //define the x and y-axis configuration.
  30. axes: [{
  31. type: 'numeric',
  32. position: 'bottom',
  33. grid: true,
  34. minimum: 0
  35. }, {
  36. type: 'category',
  37. position: 'left'
  38. }],
  39. //define the actual bar series.
  40. series: [{
  41. type: 'bar',
  42. xField: 'name',
  43. yField: ['g1', 'g2'],
  44. axis: 'left'
  45. }]
  46. });
  47. });
  48. </script>
  49. </head>
  50. <body>
  51. </body>
  52. </html>

尝试一下

转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号