healthLineChart.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <div class="pageBox">
  3. <simple-line-chart :height="'100px'" v-for="(item, index) in chartData" :key="index" :title="item.title" :data="item.data" :color="item.color" :lineTitle="item.lineTitle" />
  4. </div>
  5. </template>
  6. <script>
  7. import SimpleLineChart from "../../components/chart/line/simple-line-chart.vue";
  8. export default {
  9. setup() {},
  10. components: { SimpleLineChart },
  11. data() {
  12. return {
  13. chartData:[]
  14. };
  15. },
  16. created() {
  17. this.wtId = this.$route.params.wtId;
  18. this.requestData();
  19. },
  20. methods:{
  21. requestData(){
  22. let that=this;
  23. that.API.requestData({
  24. method: "POST",
  25. subUrl: "healthsub/hsFjValueIndex",
  26. data:{
  27. wtId: that.wtId
  28. },
  29. success(res) {
  30. const color=["green","yellow","purple","blue","orange"];
  31. let chartData=[];
  32. let lineTitle=[];
  33. res.data.xData.forEach(ele=>{
  34. lineTitle.push(new Date(ele).formatDate("hh:mm"));
  35. });
  36. res.data.datasets.forEach((ele,index)=>{
  37. chartData.push({
  38. title:ele.name,
  39. data:ele.data,
  40. color:color[index],
  41. lineTitle
  42. });
  43. });
  44. that.chartData=chartData;
  45. },
  46. });}
  47. }
  48. };
  49. </script>
  50. <style lang="less" scoped>
  51. .pageBox {
  52. width: 100%;
  53. height:calc(100% - 1.481vh * 2);
  54. display: flex;
  55. flex-direction: column;
  56. justify-content: space-between;
  57. margin:1.481vh 0;
  58. .chart{
  59. width: 100%;
  60. height:25%;
  61. }
  62. }
  63. </style>