Karsa пре 1 година
родитељ
комит
8376a1513f
1 измењених фајлова са 88 додато и 8 уклоњено
  1. 88 8
      src/views/hzyb/chart/Detail.vue

+ 88 - 8
src/views/hzyb/chart/Detail.vue

@@ -217,10 +217,10 @@ const getChartInfo=async (type)=>{
     // resData.value=null
     loading.value=true
 
-    //相关性图表
-    if([3,4,6].includes(chartSource)) return getRelevanceDetail();
+    //相关性图表 统计频率图
+    if([3,4,6,7,8,9].includes(chartSource)) return getRelevanceDetail();
     //商品价格曲线调另外的接口
-    if([2,5].includes(chartSource)) return getCommordityDetail();
+    else if([2,5].includes(chartSource)) return getCommordityDetail();
 
     let res=null
     // 如果是从我的图库中来的
@@ -344,10 +344,12 @@ const getRelevanceDetail=async ()=>{
         if([3,4].includes(res.data.ChartInfo.Source)) { //相关性
             relevanceChartData.value=res.data
             initRelevanceChart(res.data);
-        }else if(res.data.ChartInfo.Source === 6) { //拟合方程曲线
+        }else if([6,7,8].includes(res.data.ChartInfo.Source)) { //拟合方程曲线 标准差 百分比
             setSplineOpt([res.data.DataResp])
+        }else if(res.data.ChartInfo.Source===9) { //统计频率
+            statisticFrequencyData.value = res.data.DataResp;
+            setStatisticFrequency();
         }
-
         // 向小程序发送分享数据
         let postData = {
             params:{
@@ -858,6 +860,84 @@ const setSectionScatterChart = () => {
     }
 }
 
+/* 统计频率图 */
+const statisticFrequencyData = ref({})
+const setStatisticFrequency = () => {
+    const { DataList,LeftMaxValue,LeftMinValue,RightMaxValue,RightMinValue } = statisticFrequencyData.value;
+    
+    let xAxis = {
+    ...scatterXAxis,
+    tickWidth: 1,
+    title: {
+        text:  ``,
+        align: 'high',
+        rotation: 0,
+        x: 0,
+        offset: 20,
+    }
+    }
+
+    //y和系列
+    let yAxis = [],series = [];
+    DataList.forEach((item,index) => {
+    let y_item = {
+        ...basicYAxis,
+        title: {
+        text: item.Unit,
+        align: 'high',
+        rotation: 0,
+        y: -15,
+        offset: 0,
+        },
+        opposite: item.IsAxis===1?false:true,
+        min: index===0? Number(LeftMinValue):Number(RightMinValue),
+        max: index===0? Number(LeftMaxValue):Number(RightMaxValue),
+        tickWidth: 1,
+    }
+
+    let series_item = {
+        data: item.Value.map(_ =>[_.X,_.Y]),
+        type: 'spline',
+        yAxis: index,
+        name: item.Name,
+        color: item.Color,
+        lineWidth: 3,
+        chartType: 'linear',
+        visible: true,
+        zIndex:1
+    }
+
+    series.push(series_item);
+    yAxis.push(y_item)
+    })
+
+    let tooltip = {
+    formatter: function() {
+        let that = this;
+        let xList = DataList[0].Value.map(_ =>_.X);
+        let step = xList[1]-xList[0];
+        let data_interval = `[${Number(that.x).toFixed(2)},${Number(that.x+step).toFixed(2)}]`;
+
+        let str=`<b>${ data_interval }</b>`;
+        that.points.forEach(item => {
+        str += `<br><span style="color:${item.color}">\u25CF</span>${item.series.name}: ${item.y}%<br>`
+        })
+        return str
+    },
+    shared: true
+    }
+
+    chartData.value = {
+        title: {
+            text:''
+        },
+        tooltip,
+        series,
+        yAxis,
+        xAxis
+    }
+}
+
 
 
 // 路由改变 解决从搜索页返回数据不刷新问题
@@ -1968,7 +2048,7 @@ const setChartParams = () => {
 // 刷新图表
 const handleRefreshChart=async ()=>{
     let res=null 
-    if([1,6].includes(resData.value.ChartInfo.Source)){
+    if([1,6,7,8,9].includes(resData.value.ChartInfo.Source)){
         res=await apiChartRefresh({ChartInfoId:Number(ChartInfoId)})
     }else if([2,5].includes(resData.value.ChartInfo.Source)){
         res=await apiCommonChartRefresh({ChartInfoId:Number(ChartInfoId)})
@@ -2061,7 +2141,7 @@ const sourceColl = ref(false)
             >
                 <img class="icon" src="@/assets/hzyb/share-poster-chart-icon.png" alt="">
             </share-poster>
-            <img class="icon" src="../../../assets/hzyb/chart/save.png" alt="" @click="handleSaveChart" v-if="canSave&&![3,4,6].includes(chartSource)">
+            <img class="icon" src="../../../assets/hzyb/chart/save.png" alt="" @click="handleSaveChart" v-if="canSave&&![3,4,6,7,8,9].includes(chartSource)">
             <img class="icon" src="../../../assets/hzyb/chart/refresh.png" alt="" @click="handleRefreshChart">
         </div>
         
@@ -2085,7 +2165,7 @@ const sourceColl = ref(false)
                 <span :class="calendarType==='农历'&&'active'" @click="calendarTypeChange('农历')">农历</span>
                 <span :class="calendarType==='公历'&&'active'" @click="calendarTypeChange('公历')">公历</span>
             </div>
-            <span style="color:#E3B377;flex:1;text-align:right" @click="showLimit=true" v-if="![3,4,6].includes(resData.ChartInfo.Source)">上下限设置</span>
+            <span style="color:#E3B377;flex:1;text-align:right" @click="showLimit=true" v-if="![3,4,6,7,8,9].includes(resData.ChartInfo.Source)">上下限设置</span>
         </div>
         <div :class="['source-box',{'un-coll-sty':sourceColl,'coll-sty': !sourceColl}]">
             来源:{{resData&&resData.ChartInfo.ChartSource}}