jinlin
2025-02-18 6250f74b2a02770a37f2f0144c762f7952a12bd6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<template>
  <div class="mod-taskReliability-taskPhase">
    <div id="myChart" :style="myChartStyle"></div>
  </div>
</template>
 
<script>
  import echart from "echarts";
 
  export default {
    name: 'SimulatCurve',
    data() {
      return {
        xDataList: [],
        yDataList: [],
        mttr: '',
        mtbf: '',
        msr: '',
        mttfMle: '',
        mttrMle: '',
        myChart: {},
        myChartStyle: {width: "100%", height: "750px"}, //图表样式
        option: {}
      }
    },
    components: {},
    methods: {
      async initEcharts(Param) {
        console.log(Param)
        let res = await this.$http.post(`/taskReliability/SimulatAssess/getResultXML`, Param)
        console.log(res.data)
        if (res.data) {
          this.yDataList = res.data.curveParam.ydata
          this.xDataList = res.data.curveParam.xdata
          this.mttr = res.data.mttr.toFixed(4)
          this.mtbf = res.data.mtbf.toFixed(4)
          this.msr = res.data.msr.toFixed(4)
          this.mttfMle = res.data.mttfMle.toFixed(4)
          this.mttrMle = res.data.mttrMle.toFixed(4)
        }
        this.option = {
          title: {
            text: "mttf:" + this.mtbf + "  mttr:" + this.mttr + "  msr:" + this.msr + "  节点寿命:" + this.mttfMle + "  平均维修时间:" + this.mttrMle,
            textStyle: { // 主标题文本样式{"fontSize": 18,"fontWeight": "bolder","color": "#333"}
              fontFamily: 'Arial',
              fontSize: 27,
              fontStyle: 'normal',
              fontWeight: 'normal',
            },
            textAlign: 'auto',//整体(包括 text 和 subtext)的水平对齐
            textVerticalAlign: 'auto',//整体(包括 text 和 subtext)的垂直对齐
            left: 'center',//'5' | '5%',title 组件离容器左侧的距离
            right: 'auto',//'title 组件离容器右侧的距离
            top: '20px'
          },
          grid:{
            top:'15%'
          },
          xAxis: {
            data: this.xDataList,
            name: '仿真总时长',
            type: 'category',
            axisLabel: {
              formatter: function (value) {
                // 将 X 轴刻度值格式化为保留两位小数的字符串
                return parseFloat(value).toFixed(2);
              }
            }
          },
          yAxis: {
            type: "value",
            name: '可靠度',
          },
          series: [
            {
              symbol: "none",
              data: this.yDataList,
              type: 'line',
              smooth: true
            }
          ]
        };
        this.myChart = echart.init(document.getElementById("myChart"));
        console.log(this.option, ' this.option ')
        this.myChart.setOption(this.option);
        //随着屏幕大小调节图表
        window.addEventListener("resize", () => {
          this.myChart.resize();
        });
      },
      async getProductEcharts(Param) {
        let res = await this.$http.post(`/taskReliability/SimulatAssess/getResultData`, Param)
        console.log(res.data)
        if (res.data) {
          this.yDataList = res.data.curveParam.ydata
          this.xDataList = res.data.curveParam.xdata
          this.mttr = res.data.mttr.toFixed(4)
          this.mtbf = res.data.mtbf.toFixed(4)
          this.msr = res.data.msr.toFixed(4)
          this.mttfMle = res.data.mttfMle.toFixed(4)
          this.mttrMle = res.data.mttrMle.toFixed(4)
        }
        this.option = {
          title: {
            text: "mttf:" + this.mtbf + "  mttr:" + this.mttr + "  msr:" + this.msr + "  节点寿命:" + this.mttfMle + "  平均维修时间:" + this.mttrMle,
            textStyle: { // 主标题文本样式{"fontSize": 18,"fontWeight": "bolder","color": "#333"}
              fontFamily: 'Arial',
              fontSize: 27,
              fontStyle: 'normal',
              fontWeight: 'normal',
            },
            textAlign: 'auto',//整体(包括 text 和 subtext)的水平对齐
            textVerticalAlign: 'auto',//整体(包括 text 和 subtext)的垂直对齐
            left: 'center',//'5' | '5%',title 组件离容器左侧的距离
            right: 'auto',//'title 组件离容器右侧的距离
            top: '20px'
          },
          grid:{
            top:'15%'
          },
          xAxis: {
            data: this.xDataList,
            name: '仿真总时长',
            splitNumber: 10
          },
          yAxis: {
            name: '可靠度',
          },
          series: [
            {
              data: this.yDataList,
              type: 'line',
              smooth: true
            }
          ]
        };
        this.myChart = echart.init(document.getElementById("myChart"));
        console.log(this.option, ' this.option ')
        this.myChart.setOption(this.option);
        //随着屏幕大小调节图表
        window.addEventListener("resize", () => {
          this.myChart.resize();
        });
      }
    }
  }
</script>
<style>
 
</style>