healthLineChart.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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.wpId = this.$route.params.wpId;
  19. this.requestData();
  20. },
  21. methods:{
  22. requestData(){
  23. let that=this;
  24. that.API.requestData({
  25. method: "POST",
  26. subUrl: "healthsub/hsFjValueIndex",
  27. data:{
  28. wtId: that.wtId
  29. },
  30. success(res) {
  31. const color=["green","yellow","purple","blue","orange"];
  32. let chartData=[];
  33. let lineTitle=[];
  34. res.data.xData.forEach(ele=>{
  35. lineTitle.push(new Date(ele).formatDate("hh:mm"));
  36. });
  37. res.data.datasets.forEach((ele,index)=>{
  38. chartData.push({
  39. title:ele.name,
  40. data:ele.data,
  41. color:color[index],
  42. lineTitle
  43. });
  44. });
  45. that.chartData=chartData;
  46. },
  47. });
  48. }
  49. }
  50. };
  51. </script>
  52. <style lang="less" scoped>
  53. .pageBox {
  54. width: 100%;
  55. height:calc(100% - 1.481vh * 2);
  56. display: flex;
  57. flex-direction: column;
  58. justify-content: space-between;
  59. margin:1.481vh 0;
  60. .chart{
  61. width: 100%;
  62. height:25%;
  63. }
  64. }
  65. </style>