Selaa lähdekoodia

图表超过十条线 不显示问题

hbchen 9 kuukautta sitten
vanhempi
commit
71cad14d01
1 muutettua tiedostoa jossa 30 lisäystä ja 26 poistoa
  1. 30 26
      src/hooks/chart/render.js

+ 30 - 26
src/hooks/chart/render.js

@@ -561,17 +561,17 @@ function setStatisticFrequency(e){
         max: index===0? Number(LeftMaxValue):Number(RightMaxValue),
         tickWidth: 1,
       }
-
+      const noExceed = chartTheme && chartTheme.lineOptionList.length > index //线条数没超过图表可配置的线条数
       let series_item = {
         data: item.Value.map(_ =>[_.X,_.Y]),
-        dashStyle: (chartTheme&&chartTheme.lineOptionList[index].dashStyle)||'Solid',
-        type: (chartTheme&&chartTheme.lineOptionList[index].lineType) || 'spline',
+        dashStyle: (noExceed&&chartTheme.lineOptionList[index].dashStyle)||'Solid',
+        type: (noExceed&&chartTheme.lineOptionList[index].lineType) || 'spline',
         yAxis: index,
         name: item.Name,
         nameZh: item.Name,
         nameEn: item.NameEn||item.Name,
         color: item.Color,
-        lineWidth: (chartTheme&&chartTheme.lineOptionList[index].lineWidth)||3,
+        lineWidth: (noExceed&&chartTheme.lineOptionList[index].lineWidth)||3,
         chartType: 'linear',
         zIndex:1
       }
@@ -648,24 +648,24 @@ function setSplineOpt(e){
         let temNameEN=setDyncmicSerieName(item,dynamic_arr,'en')  
         //预测指标配置
         let predict_params = item.EdbInfoCategoryType === 1 ? getPredictParams(item) : {};
-
+        const noExceed = chartTheme && chartTheme.lineOptionList.length > index //线条数没超过图表可配置的线条数
         let seriesItemObj={
             data:[],
             dataGrouping:{
                 enabled:false
             },
-            type: (chartTheme&&chartTheme.lineOptionList[index].lineType) || 'spline',
-            dashStyle: (chartTheme&&chartTheme.lineOptionList[index].dashStyle)||'Solid',
+            type: (noExceed&&chartTheme.lineOptionList[index].lineType) || 'spline',
+            dashStyle: (noExceed&&chartTheme.lineOptionList[index].dashStyle)||'Solid',
             yAxis:index,
             name:temName,
             nameZh:temName,
             nameEn:temNameEN,
             color: item.ChartColor,
-            lineWidth: Number(item.ChartWidth)||(chartTheme&&chartTheme.lineOptionList[index].lineWidth)||1,
+            lineWidth: Number(item.ChartWidth)||(noExceed&&chartTheme.lineOptionList[index].lineWidth)||1,
             visible:true,
             LatestDate:item.LatestDate,
             LatestValue:item.LatestValue,
-            marker:chartTheme && chartTheme.lineOptionList[index].dataMark && chartTheme.lineOptionList[index].dataMark!='none'?{
+            marker:noExceed && chartTheme.lineOptionList[index].dataMark && chartTheme.lineOptionList[index].dataMark!='none'?{
                 enabled:true,
                 symbol: chartTheme.lineOptionList[index].markType || 'circle',
                 fillColor:chartTheme.lineOptionList[index].markColor,
@@ -834,29 +834,30 @@ function setSeasonOpt(e){
     const colorsArr=chartTheme&&chartTheme.colorsOptions.reverse();
     let series=[],yAxis=[]
     //农历默认选中一年数据并隐藏按钮  公历显示全部数据
-    // let rangeSelector={}
     // 农历数据需要去除第一项  农历和公历处理逻辑一样
     const chartDataHandle=calendarType === '农历'?
                         data.DataList.filter((item, index) => index > 0):
                         data.DataList
+    // 跟颜色对应
+    chartTheme && (chartTheme.lineOptionList=chartTheme.lineOptionList.reverse().slice(-chartDataHandle.length))
     // if(calendarType==='公历'){
         chartDataHandle.forEach((item,index)=>{
              //预测指标配置
             let predict_params =  data.EdbInfoCategoryType === 1 ? getSeasonPredictParams(item.CuttingDataTimestamp) : {};
-
+            const noExceed = chartTheme && chartTheme.lineOptionList.length > index //线条数没超过图表可配置的线条数
             let seriesItem={
                 data:[],
                 dataGrouping:{
                     enabled:false
                 },
-                type: (chartTheme&&chartTheme.lineOptionList[index].lineType) || data.ChartStyle,
-                dashStyle: (chartTheme&&chartTheme.lineOptionList[index].dashStyle)||'Solid',
+                type: (noExceed&&chartTheme.lineOptionList[index].lineType) || data.ChartStyle,
+                dashStyle: (noExceed&&chartTheme.lineOptionList[index].dashStyle)||'Solid',
                 yAxis:0,
                 name:item.ChartLegend,
-                lineWidth: (chartTheme&&chartTheme.lineOptionList[index].lineWidth) || 1,
+                lineWidth: (noExceed&&chartTheme.lineOptionList[index].lineWidth) || 1,
                 color:colorsArr.slice(-chartDataHandle.length)[index],                
                 visible:true,
-                marker:chartTheme && chartTheme.lineOptionList[index].dataMark && chartTheme.lineOptionList[index].dataMark!='none'?{
+                marker:noExceed && chartTheme.lineOptionList[index].dataMark && chartTheme.lineOptionList[index].dataMark!='none'?{
                     enabled:true,
                     symbol: chartTheme.lineOptionList[index].markType || 'circle',
                     fillColor:chartTheme.lineOptionList[index].markColor,
@@ -1606,18 +1607,18 @@ const setCommodityChart = (leftMin,leftMax) => {
     data.forEach((item,index) => {
         //处理首或/尾全是无效数据的以null填充
         let filterData = filterInvalidData(item)
-
+        const noExceed = chartTheme && chartTheme.lineOptionList.length > index //线条数没超过图表可配置的线条数
         let serie_item = {
             data: filterData,
-            type: (chartTheme&&chartTheme.lineOptionList[index].lineType) || 'spline',
-            dashStyle: (chartTheme&&chartTheme.lineOptionList[index].dashStyle)||'Solid',
+            type: (noExceed&&chartTheme.lineOptionList[index].lineType) || 'spline',
+            dashStyle: (noExceed&&chartTheme.lineOptionList[index].dashStyle)||'Solid',
             yAxis: 0,
             name: item.Name,
             nameZh: item.Name,
             nameEn: item.NameEn,
             color: item.Color,
             chartType: 'linear',
-            lineWidth: (chartTheme&&chartTheme.lineOptionList[index].lineWidth) || 3,
+            lineWidth: (noExceed&&chartTheme.lineOptionList[index].lineWidth) || 3,
             visible: true,
             marker: {
                 enabled: false
@@ -1802,17 +1803,18 @@ function initRelevanceChart(data){
     //处理series
     let seriesData=[]
     data.YDataList.forEach((item,index)=>{
+        const noExceed = chartTheme && chartTheme.lineOptionList.length > index //线条数没超过图表可配置的线条数
         let serie_item = {
           data: item.Value,
-          type: (chartTheme&&chartTheme.lineOptionList[index].lineType) || 'spline',
-          dashStyle: (chartTheme&&chartTheme.lineOptionList[index].dashStyle)||'Solid',
+          type: (noExceed&&chartTheme.lineOptionList[index].lineType) || 'spline',
+          dashStyle: (noExceed&&chartTheme.lineOptionList[index].dashStyle)||'Solid',
           yAxis: 0,
           name: data.ChartInfo.ChartName,
           nameZh: data.ChartInfo.ChartName,
           nameEn: data.ChartInfo.ChartNameEn,
           color: item.Color,
           chartType: 'linear',
-          lineWidth: (chartTheme&&chartTheme.lineOptionList[index].lineWidth) || 3,
+          lineWidth: (noExceed&&chartTheme.lineOptionList[index].lineWidth) || 3,
           visible:true,
           marker: {
             enabled: false
@@ -1945,6 +1947,7 @@ function setSectionScatterChart({DataResp,ChartInfo}) {
     //数据列
     let series = [];
     DataList.forEach((item,index) => {
+        const noExceed = chartTheme && chartTheme.lineOptionList.length > index //线条数没超过图表可配置的线条数
         //数据列
         let series_item = {
             data: [],
@@ -1958,7 +1961,7 @@ function setSectionScatterChart({DataResp,ChartInfo}) {
             zIndex:1,
             visible: true,
             marker: {
-                radius: (chartTheme&&chartTheme.lineOptionList[index].radius)||5,
+                radius: (noExceed&&chartTheme.lineOptionList[index].radius)||5,
             },
         }
         item.EdbInfoList.forEach(_ => {
@@ -2286,17 +2289,18 @@ function setRadarChart({DataResp,EdbInfoList,ChartInfo}) {
     //系列
     let series = [];
     YDataList.forEach((item,index) => {
+    const noExceed = chartTheme && chartTheme.lineOptionList.length > index //线条数没超过图表可配置的线条数
       let serie_item = {
         name: item.Name || item.Date,
         nameZh: item.Name || item.Date,
         nameEn: item.Date,
         data: item.Value,
         pointPlacement: 'on',
-        type: (chartTheme&&chartTheme.lineOptionList[index].lineType) || 'line',
-        dashStyle: (chartTheme&&chartTheme.lineOptionList[index].dashStyle)||'Solid',
+        type: (noExceed&&chartTheme.lineOptionList[index].lineType) || 'line',
+        dashStyle: (noExceed&&chartTheme.lineOptionList[index].dashStyle)||'Solid',
         yAxis: 0,
         color: item.Color,
-        lineWidth: (chartTheme&&chartTheme.lineOptionList[index].lineWidth) || 1,
+        lineWidth: (noExceed&&chartTheme.lineOptionList[index].lineWidth) || 1,
         chartType: 'linear'
       };
       series.push(serie_item)