pollution.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <view class="container">
  3. <qiun-title-bar title="近一周排放统计" />
  4. <view class="charts-box">
  5. <view class="charts-box">
  6. <qiun-data-charts
  7. canvasId="chart31"
  8. :canvas2d="isCanvas2d"
  9. type="area"
  10. :opts="{
  11. dataLabel: false,
  12. xAxis: {
  13. boundaryGap: 'justify',
  14. },
  15. extra: { area: { type: 'curve', addLine: true, gradient: true } },
  16. }"
  17. :chartData="data1"
  18. />
  19. </view>
  20. </view>
  21. <qiun-title-bar title="区域排放统计" />
  22. <view class="charts-box"><qiun-data-charts type="column" canvasId="chart32" :canvas2d="isCanvas2d" :opts="{ dataLabel: false, xAxis: { boundaryGap: 'center' }, extra: { column: { type: 'group', width: 15, activeBgColor: '#000000', activeBgOpacity: 0.08, linearType: 'custom', seriesGap: 5, linearOpacity: 0.5, barBorderCircle: true } } }" :chartData="data2" /></view>
  23. </view>
  24. </template>
  25. <script>
  26. import api from "@/common/api.js";
  27. import { log } from "@/utils/base.js";
  28. export default {
  29. name: "pollution",
  30. data() {
  31. return {
  32. data1: { categories: [], series: [] },
  33. data2: { categories: [], series: [] },
  34. //#ifndef MP-WEIXIN
  35. isCanvas2d: false,
  36. //#endif
  37. //#ifdef MP-WEIXIN
  38. isCanvas2d: true,
  39. //#endif
  40. };
  41. },
  42. mounted() {
  43. this.getInfo();
  44. },
  45. methods: {
  46. getInfo() {
  47. api.getSmokeTendency(0).then(({ data }) => {
  48. //this.data1 = { categories: [], series: [] };
  49. data = data.chartData[0];
  50. this.data1.categories = data.categories.slice(-7).map(v => {
  51. return v.substr(5);
  52. });
  53. this.data1.series = data.series.map(v => {
  54. return {
  55. name: v.name.replace("排放总量", ""),
  56. data: v.data.slice(-7),
  57. };
  58. });
  59. //console.log("=========>>>>", this.data1);
  60. });
  61. api.getSmokeTendency(1).then(({ data }) => {
  62. //this.data1 = { categories: [], series: [] };
  63. data = data.chartData[0];
  64. this.data2.categories = data.categories;
  65. this.data2.series = data.series.map(v => {
  66. return {
  67. name: v.name.replace("排放总量", ""),
  68. data: v.data,
  69. };
  70. });
  71. //console.log("=========>>>>", this.data2);
  72. });
  73. },
  74. },
  75. };
  76. </script>
  77. <style>
  78. .container {
  79. padding: 10px 0;
  80. font-size: 14px;
  81. line-height: 24px;
  82. }
  83. .charts-box {
  84. width: 100%;
  85. height: 300px;
  86. }
  87. </style>