p-production-statistics-section-3.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view>
  3. <canvas canvas-id="canvasColumnStack" id="canvasColumnStack" @touchstart="touchColumn" style="width: 700rpx; height: 800rpx;"></canvas>
  4. </view>
  5. </template>
  6. <script>
  7. import uCharts from '@/components/u-charts/u-charts.js';
  8. var _self;
  9. var canvaColumn = null;
  10. export default {
  11. data() {
  12. return {
  13. cWidth: '',
  14. cHeight: '',
  15. pixelRatio: 1,
  16. serverData: '',
  17. };
  18. },
  19. mounted() {
  20. _self = this;
  21. this.cWidth = uni.upx2px(700);
  22. this.cHeight = uni.upx2px(780);
  23. this.getServerData();
  24. },
  25. methods: {
  26. getServerData() {
  27. let ColumnStack = {
  28. "categories": ["19日", "20日", "21日", "22日", "23日", "24日","25日"],
  29. "series": [{
  30. "name": "早班",
  31. "data": [96258.6, 102354.2, 87569.5, 87512.2, 79854.2, 89896.7,80666.3]
  32. }, {
  33. "name": "中班",
  34. "data": [15089.5, 34256.1, 30659.7, 28665.1, 27458.6, 26597.4,12658.7]
  35. }, {
  36. "name": "晚班",
  37. "data": [105203.2, 116542.2, 102654.2, 106598.2, 113568.2, 99685.2,0]
  38. }]
  39. };
  40. _self.showColumnStack("canvasColumnStack", ColumnStack);
  41. },
  42. showColumnStack(canvasId, chartData) {
  43. canvaColumn = new uCharts({
  44. $this: _self,
  45. canvasId: canvasId,
  46. type: 'column',
  47. legend: {
  48. show: true,
  49. position: 'top',
  50. itemGap: 30,
  51. },
  52. fontSize: 11,
  53. background: '#FFFFFF',
  54. pixelRatio: _self.pixelRatio,
  55. animation: true,
  56. categories: chartData.categories,
  57. series: chartData.series,
  58. xAxis: {
  59. disableGrid: true,
  60. },
  61. yAxis: {
  62. //disabled:true
  63. },
  64. dataLabel: false,
  65. width: _self.cWidth * _self.pixelRatio,
  66. height: _self.cHeight * _self.pixelRatio,
  67. extra: {
  68. column: {
  69. type: 'stack',
  70. width: _self.cWidth * _self.pixelRatio * 0.5 / chartData.categories.length
  71. }
  72. }
  73. });
  74. },
  75. touchColumn(e) {
  76. canvaColumn.showToolTip(e, {
  77. format: function(item, category) {
  78. // return category + ' ' + item.name + ':' + item.data
  79. return item.name + ':' + item.data
  80. }
  81. });
  82. },
  83. }
  84. }
  85. </script>
  86. <style lang="scss">
  87. </style>