render.js 95 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783
  1. // 图渲染逻辑模块
  2. import {onMounted,ref,nextTick,reactive} from 'vue'
  3. import {chartDefaultOpts,scatterXAxis,basicYAxis,basicXAxis,leadUnitEnMap,relevanceUnitEnMap,seasonOptions} from './config'
  4. import Highcharts from 'highcharts/highstock';
  5. import HighchartsFormat from 'highcharts';
  6. import HighchartsMore from 'highcharts/highcharts-more';
  7. import HightchartsExport from 'highcharts/modules/exporting';
  8. import Boost from 'highcharts/modules/boost'
  9. import HighchartszhCN from './highcahrts-zh_CN.js'
  10. import moment from 'moment'
  11. import _ from 'lodash';
  12. HighchartszhCN(Highcharts)
  13. HightchartsExport(Highcharts)
  14. HighchartsMore(Highcharts)
  15. Boost(Highcharts)
  16. /**
  17. * 渲染图方法
  18. * @param data 图详情数据
  19. * @param renderId 图表在dom中的id
  20. * @param lang 图表显示为中文/英文 默认 zh中文 en英文
  21. * @param changeLangIsCheck 切换中英文时 是否要校验
  22. * @param showChartTitle 是否显示图表标题 默认true
  23. */
  24. let ChartIns=null//图表实例
  25. let chartData=ref(null)//图的所有数据
  26. let LangType=ref('zh')//当前图表显示的语言版本
  27. let RenderDomId=ref('')//图表渲染的domid
  28. let options=ref(null)//渲染图的数据
  29. const axisLimitState = reactive({//极值数据
  30. leftIndex:-1,//左侧上下限对应下标
  31. rightIndex: -1, //右侧上下限对应下标
  32. rightTwoIndex: -1,//右2上下限对应下标
  33. hasLeftAxis:false,
  34. hasRightAxis:false,
  35. hasRightTwoAxis:false,
  36. hasXAxis:false,
  37. leftMin:0,
  38. leftMax:0,
  39. rightMin:0,
  40. rightMax:0,
  41. rightTwoMin:0,
  42. rightTwoMax:0,
  43. xMin:0,
  44. xMax:0,
  45. })
  46. //仅ETA图库内图表需要使用自定义上下限
  47. let useSelfLimit = false
  48. let isUseSelfLimit = ref(false)
  49. const screen = ref(document.body.clientWidth < 1200 ? 'phone' : 'pc');
  50. // webcomponent的EtaChart.ce.vue文件用到了这里的逻辑
  51. // 有修改了 chartRender,setLimitData 这俩方法的,需要重新编辑下webcomponent(npm run build.lib),然后替换掉report项目的对应文件eta_comp.js
  52. export function useChartRender(){
  53. return {
  54. options,
  55. axisLimitState,
  56. chartRender,
  57. setLimitData,
  58. isUseSelfLimit
  59. }
  60. }
  61. /**备注一下 越多越乱
  62. * @params
  63. * Source 1 ; chartType只在source:1用到 1曲线 2季节 3面积 4堆积柱 5散点 6组合 7柱形 10截面散点 11雷达图
  64. * 2 商品价格
  65. * 3 相关性
  66. * 4 滚动相关性
  67. * 5 商品利润
  68. * 6 拟合方程
  69. * 7 统计特征/标准差
  70. * 8 统计特征/百分位
  71. * 9 统计特征/频率
  72. * 10 跨品种分析
  73. */
  74. export function chartRender({data,renderId,lang='zh',changeLangIsCheck,showChartTitle=true,shouldUseSelfLimit=false}){
  75. // 初始化掉极值数据
  76. axisLimitState.leftIndex=-1
  77. axisLimitState.rightIndex=-1
  78. axisLimitState.rightTwoIndex=-1
  79. axisLimitState.hasLeftAxis=false
  80. axisLimitState.hasRightAxis=false
  81. axisLimitState.hasRightTwoAxis=false
  82. axisLimitState.hasXAxis=false
  83. //使用自定义上下限时,不需要初始化极值
  84. if(!isUseSelfLimit.value){
  85. axisLimitState.leftMin=0
  86. axisLimitState.leftMax=0
  87. axisLimitState.rightMin=0
  88. axisLimitState.rightMax=0
  89. axisLimitState.rightTwoMin=0
  90. axisLimitState.rightTwoMax=0
  91. axisLimitState.xMin=0
  92. axisLimitState.xMax=0
  93. }
  94. let chartOpt={}
  95. LangType.value=lang
  96. RenderDomId.value=renderId
  97. chartData.value=data
  98. /* useSelfLimit = ['/myETA/chartdetail','/chartETA/chartdetail'].includes(window.location.pathname) */
  99. useSelfLimit = shouldUseSelfLimit
  100. if([1,11].includes(data.ChartInfo.Source)){
  101. const chartSetMap = {
  102. 1: setSplineOpt,
  103. 2: setSeasonOpt,
  104. 3: setStackOrCombinChart,
  105. 4: setStackOrCombinChart,
  106. 5: setScatterOptions,
  107. 6: setStackOrCombinChart,
  108. 7: initBarData,
  109. 10: setSectionScatterChart,
  110. 11: setRadarChart,
  111. 14: setSectionalCombinationChart,
  112. };
  113. chartOpt=chartSetMap[data.ChartInfo.ChartType](data)
  114. }else if([2,5].includes(data.ChartInfo.Source)){//商品价格曲线
  115. chartOpt=initCommodityData(data);
  116. }else if([3].includes(data.ChartInfo.Source)){//相关性 滚动相关性
  117. chartOpt=initRelevanceChart(data);
  118. }else if([4,6,7,8].includes(data.ChartInfo.Source)){//滚动相关性 拟合方程 标准差 百分比
  119. chartOpt=setSplineOpt(data);
  120. }else if([9].includes(data.ChartInfo.Source)){//统计频率
  121. chartOpt=setStatisticFrequency(data);
  122. }else if(data.ChartInfo.Source===10) {
  123. /* 历史数据chartInfo里上下限全是空 兼容下历史数据不崩 */
  124. axisLimitState.hasLeftAxis=true
  125. axisLimitState.leftMin=data.ChartInfo.LeftMin?Number(data.ChartInfo.LeftMin):Number(data.DataResp.YMinValue)
  126. axisLimitState.leftMax=data.ChartInfo.LeftMax?Number(data.ChartInfo.LeftMax):Number(data.DataResp.YMaxValue)
  127. axisLimitState.hasXAxis=true
  128. axisLimitState.xMin= data.ChartInfo.XMin?Number(data.ChartInfo.XMin):Number(data.DataResp.XMinValue)
  129. axisLimitState.xMax=data.ChartInfo.XMax?Number(data.ChartInfo.XMax):Number(data.DataResp.XMaxValue),
  130. chartOpt = setCrossVarietyChart(data)
  131. }
  132. /*
  133. eta1.4.1增加了主题色
  134. 仍然以defaultOpts为最底层配置 外层配置在这里统一设置了如legend chart背景色
  135. x轴y轴系列等样式还是需要在具体的options中单独设置
  136. */
  137. let themeOptions = setThemeOptions();
  138. options.value={...chartDefaultOpts,...themeOptions, ...chartOpt}
  139. // 设置图标题
  140. setChartTitle(showChartTitle)
  141. // 设置语言
  142. setChartLang(changeLangIsCheck)
  143. Highcharts.setOptions({ global: { useUTC:data.ChartInfo.ChartType==2?true:false } });
  144. //stock不支持线形图只支持时间图 某些用chart
  145. let is_linear = chartOpt.series
  146. ? chartOpt.series.some(_ => _.chartType === 'linear')
  147. : false ;
  148. is_linear ?ChartIns=Highcharts.chart(RenderDomId.value,options.value) : ChartIns=Highcharts.stockChart(RenderDomId.value,options.value);
  149. return ChartIns
  150. }
  151. //主题色一些外层公用配置 目前只有绘图区和legend和colors
  152. function setThemeOptions() {
  153. if(!chartData.value.ChartInfo.ChartThemeStyle) return {}
  154. let chartTheme = JSON.parse(chartData.value.ChartInfo.ChartThemeStyle)
  155. return {
  156. legend: {
  157. ...chartDefaultOpts.legend,
  158. ...chartTheme.legendOptions
  159. },
  160. chart: {
  161. ...chartDefaultOpts.chart,
  162. ...chartTheme.drawOption
  163. },
  164. colors: chartTheme.colorsOptions
  165. }
  166. }
  167. /* 处理轴的标识线结构 在指定轴位置上拼接标识线
  168. 0:右轴 1:左轴 2:右2轴 x轴固定3
  169. axisType表示x轴类型 处理时间轴的值 datetime/null
  170. */
  171. function setAxisPlotLines(axis,axisType) {
  172. const { MarkersLines,ChartType } = chartData.value.ChartInfo;
  173. const { EdbInfoList } = chartData.value;
  174. if(!MarkersLines) return []
  175. let markerLines = JSON.parse(MarkersLines);
  176. let arr = markerLines.filter(_ => _.isShow&&_.axis===axis)
  177. let plotLines = arr.map(_ => {
  178. //是否是x时间轴
  179. let isXDateAxis = axis===3&&axisType==='datetime';
  180. let markerValue;
  181. if(isXDateAxis) {
  182. //季节图x轴额外拼个年份
  183. let nowYear = ChartType===2 ? new Date(EdbInfoList[0].DataList[1].DataList
  184. [0].DataTimestamp).getFullYear() : '';
  185. markerValue = ChartType===2
  186. ? new Date(`${nowYear}-${_.value}`).getTime()
  187. : new Date(_.value).getTime()
  188. }else {
  189. markerValue = Number(_.value)
  190. }
  191. return {
  192. value: markerValue,
  193. dashStyle: _.dashStyle,
  194. width: Number(_.lineWidth),
  195. color: _.color,
  196. label: {
  197. text: _.text||'',
  198. verticalAlign: _.textPosition,
  199. style: {
  200. color: _.textColor,
  201. fontSize: _.textFontSize
  202. }
  203. }
  204. }
  205. })
  206. return plotLines
  207. }
  208. /* 处理标识区拼接 axisType表示x轴类型处理时间轴的值 datetime/null */
  209. function setAxisPlotAreas(axis,axisType) {
  210. const { MarkersAreas,ChartType } = chartData.value.ChartInfo;
  211. const { EdbInfoList } = chartData.value;
  212. if(!MarkersAreas) return []
  213. let markerAreas = JSON.parse(MarkersAreas);
  214. let arr = markerAreas.filter(_ => _.isShow&&_.axis===axis)
  215. let plotBands = arr.map(_ => {
  216. //是否是x时间轴
  217. let isXDateAxis = axis===3&&axisType==='datetime';
  218. let fromMarkerValue,toMarkerValue;
  219. if(isXDateAxis) {
  220. //季节图x轴额外拼个年份
  221. let nowYear = ChartType===2 ? new Date(EdbInfoList[0].DataList[1].DataList
  222. [0].DataTimestamp).getFullYear() : '';
  223. fromMarkerValue = ChartType===2
  224. ? new Date(`${nowYear}-${_.fromValue}`).getTime()
  225. : new Date(_.fromValue).getTime()
  226. toMarkerValue = ChartType===2
  227. ? new Date(`${nowYear}-${_.toValue}`).getTime()
  228. : new Date(_.toValue).getTime()
  229. }else {
  230. fromMarkerValue = Number(_.fromValue);
  231. toMarkerValue = Number(_.toValue);
  232. }
  233. //默认label有些偏移 重新归正下
  234. let positionMapValue = {
  235. 'top': 12,
  236. 'middle': 0,
  237. 'bottom': -10
  238. }
  239. return {
  240. from: fromMarkerValue,
  241. to: toMarkerValue,
  242. color: _.color,
  243. label: {
  244. text: _.text||'',
  245. verticalAlign: _.textPosition,
  246. y: positionMapValue[_.textPosition],
  247. style: {
  248. color: _.textColor,
  249. fontSize: _.textFontSize
  250. }
  251. }
  252. }
  253. })
  254. return plotBands
  255. }
  256. /* 预测配置 分区 */
  257. function getPredictParams ({LatestDate,PredictChartColor}) {
  258. return {
  259. zoneAxis: 'x',
  260. zones: [{
  261. value: new Date(LatestDate).getTime()+1
  262. }, {
  263. dashStyle: 'ShortDot',
  264. color: PredictChartColor
  265. }]
  266. }
  267. }
  268. /* 季节图预测数据 年份=分割点年份做分割 年份>分割点年份全为预测 */
  269. function getSeasonPredictParams (timestamp){
  270. return timestamp
  271. ? {
  272. zoneAxis: 'x',
  273. zones: [{
  274. value: new Date(timestamp).getTime()+1
  275. }, {
  276. dashStyle: 'ShortDot',
  277. }]
  278. }
  279. : {}
  280. }
  281. // 查询范围为1年内 x轴显示为月/日 否则默认年/月
  282. function xTimeDiffer(minTime,maxTime,dateType){
  283. //年限差
  284. let year_differ=moment(maxTime).diff(moment(minTime),'years',true)
  285. // console.log('年限差',year_differ)
  286. if ([5, 6].includes(dateType) && year_differ <= 1) {
  287. return true
  288. } else {
  289. return false
  290. }
  291. }
  292. /* 拼接动态的指标名称小标签 */
  293. function concatDynamicTag(item,lang){
  294. const { IsAxis,IsOrder,EdbInfoType,LeadValue,LeadUnit } = item;
  295. // IsAxis左轴1 右轴0 2右2轴
  296. //IsOrder正序false 逆序true
  297. //IsOrder正序false 逆序true
  298. //IsOrder正序false 逆序true
  299. //EdbInfoType是否是领先指标
  300. const axisLabelMap =lang=='zh'? {
  301. 0: '右轴',
  302. 2: '右2轴'
  303. }:{
  304. 0: 'RHS',
  305. 2: '2-RHS'
  306. }
  307. const orderLabelMap =lang=='zh'? {
  308. 1: '逆序'
  309. }:{
  310. 1: 'REV'
  311. }
  312. const edbInfoMap =lang=='zh'? {
  313. 0: '领先'
  314. }:{
  315. 0: 'Lead'
  316. }
  317. //英文领先单位转换
  318. const leadUnit = lang==='zh' ? LeadUnit : leadUnitEnMap[LeadUnit];
  319. let axis_tag = axisLabelMap[IsAxis] || '';
  320. //逆序拼接
  321. let order_tag = orderLabelMap[Number(IsOrder)] ? `${axis_tag ? ',': ''}${orderLabelMap[Number(IsOrder)]}` : ''
  322. //领先拼接
  323. let edb_tag = edbInfoMap[EdbInfoType] ? `${(axis_tag||order_tag) ? ',' : '' }${edbInfoMap[EdbInfoType]}${LeadValue}${leadUnit}` : '';
  324. let dynamic_tag = (axis_tag || order_tag || edb_tag) ? `(${axis_tag}${order_tag}${edb_tag})` : '';
  325. return dynamic_tag
  326. }
  327. /* 拼接数据列动态name */
  328. function setDyncmicSerieName (item,dynamic_arr,lang='zh') {
  329. let temName =''
  330. /* if(lang=='zh'){
  331. temName= dynamic_arr.length > 1
  332. ? `${item.EdbName}(${item.SourceName})${concatDynamicTag(item,'zh')}`
  333. : `${item.EdbName}${concatDynamicTag(item,'zh')}`
  334. }else{
  335. temName=item.EdbNameEn?`${item.EdbNameEn}${concatDynamicTag(item,'en')}`:''
  336. } */
  337. const temNameEn = item.EdbNameEn?`${item.EdbNameEn}${concatDynamicTag(item,'en')}`:''
  338. const temNameZh = dynamic_arr.length > 1
  339. ? `${item.EdbAliasName||item.EdbName}(${item.SourceName})${concatDynamicTag(item,'zh')}`
  340. : `${item.EdbAliasName||item.EdbName}${concatDynamicTag(item,'zh')}`
  341. temName = lang=='zh'?temNameZh:temNameEn?temNameEn:temNameZh
  342. if(temName.length>20){
  343. let temArr=[]
  344. for(let i=0;i<temName.length/20;i++){
  345. temArr.push(temName.slice(i*20,i*20+20))
  346. }
  347. temName=temArr.join('<br>')
  348. }
  349. return temName
  350. }
  351. /* 指标顺序调整 IsAxis: 0右轴 1左轴 2右2*/
  352. function changeEdbOrder (data){
  353. // 左轴指标
  354. let left_edbs = data.filter(_ => _.IsAxis===1);
  355. //右轴指标
  356. let right_edbs = data.filter(_ => !_.IsAxis);
  357. // 右2轴指标
  358. let right_two_edbs = data.filter(_ => _.IsAxis === 2);
  359. // 按 左 右 右2顺序排列
  360. return [left_edbs,right_edbs,right_two_edbs].flat(Infinity);
  361. }
  362. //检查图表英文配置是否完整
  363. function checkChartEnData(){
  364. let result = true
  365. //图表名称:this.chartInfo.ChartNameEn
  366. if(!chartData.value.ChartInfo.ChartNameEn){
  367. result = false
  368. }
  369. //指标名称:this.dataList[].EdbNameEn
  370. //指标单位:this.dataList[].UnitEn
  371. chartData.value.EdbInfoList.forEach(item=>{
  372. if(!item.EdbNameEn){
  373. result = false
  374. }
  375. if(chartData.value.ChartInfo.ChartType!==10&&item.Unit&&!item.UnitEn){
  376. result = false
  377. }
  378. })
  379. return result
  380. }
  381. // 设置图表显示的语言
  382. function setChartLang(changeLangIsCheck){
  383. if(changeLangIsCheck&&!checkChartEnData()) return
  384. const {ChartType,Source} = chartData.value.ChartInfo
  385. if(Source==1){
  386. // 散点图
  387. if(ChartType == 5){
  388. options.value.yAxis.title.text = LangType.value == 'zh' ? options.value.yAxis.title.textZh : options.value.yAxis.title.textEn;
  389. // options.value.yAxis.title.style = LangType.value == 'zh' ? {} : options.value.yAxis.title.styleEn;
  390. options.value.xAxis.title.text = LangType.value == 'zh' ? options.value.xAxis.title.textZh : options.value.xAxis.title.textEn
  391. // options.value.xAxis.title.style = LangType.value == 'zh' ? {} : options.value.xAxis.title.styleEn;
  392. options.value.series.forEach(item => {
  393. item.name = LangType.value == 'zh' ? item.nameZh : item.nameEn;
  394. });
  395. options.value.tooltip.formatter = LangType.value == 'zh' ? options.value.tooltip.formatterZh : options.value.tooltip.formatterEn;
  396. }else{
  397. // 单位
  398. options.value.yAxis.forEach(item => {
  399. item.title.text = LangType.value == 'zh' ? item.title.textZh : item.title.textEn;
  400. // item.title.style = LangType.value == 'zh' ? {} : (item.title.styleEn || {})
  401. });
  402. // 图例 名称
  403. if(ChartType != 2){
  404. // 季节图 不更改图例名称
  405. options.value.series.forEach(item => {
  406. item.name = LangType.value == 'zh'
  407. ? item.nameZh
  408. : (item.nameEn!='无英文名称'?item.nameEn:`<span style="color:#999">${item.nameEn}</span>`)
  409. });
  410. }
  411. //截面散点 x轴标题
  412. if(ChartType === 10){
  413. options.value.xAxis.title.text = LangType.value == 'zh' ? options.value.xAxis.title.textZh : options.value.xAxis.title.textEn;
  414. // options.value.xAxis.title.style = LangType.value == 'zh' ? {} : options.value.xAxis.title.styleEn;
  415. options.value.tooltip.formatter = LangType.value == 'zh' ? options.value.tooltip.formatterCh : options.value.tooltip.formatterEn;
  416. options.value.series.forEach(item => {
  417. if(!item.linkedTo) {
  418. item.data.forEach(point => {
  419. point.dataLabels.format = LangType.value == 'zh' ? point.dataLabels.formatZh : (point.dataLabels.formatEn||'无英文标签');
  420. point.dataLabels.color = (LangType.value==='en' && !point.dataLabels.formatEn) ? '#999' : '#333'
  421. })
  422. }
  423. });
  424. }
  425. //柱形图额外设置x轴中英文
  426. if([7,11].includes(ChartType)){
  427. //x轴
  428. options.value.xAxis.categories = chartData.value.XEdbIdValue.map(_ => LangType.value == 'zh'
  429. ? chartData.value.EdbInfoList.find(edb => edb.EdbInfoId===_).EdbAliasName || chartData.value.EdbInfoList.find(edb => edb.EdbInfoId===_).EdbName
  430. : chartData.value.EdbInfoList.find(edb => edb.EdbInfoId===_).EdbNameEn)
  431. }
  432. }
  433. }
  434. if([2,3,4].includes(Source)){
  435. options.value.yAxis.forEach(item => {
  436. item.title.text = LangType.value == 'zh' ? item.title.textZh: item.title.textEn||item.title.textZh
  437. });
  438. //图例
  439. options.value.series.forEach(item => {
  440. item.name = LangType.value == 'en' ?(item.nameEn||item.nameZh) : item.nameZh
  441. });
  442. //tooltip
  443. options.value.tooltip.formatter = LangType.value == 'en'?options.value.tooltip.formatterEn:options.value.tooltip.formatterZh
  444. //x轴
  445. if(Source==2){
  446. options.value.xAxis.categories = commodityXData.value.map(_ => {
  447. LangType.value == 'en'?_.NameEn:_.Name
  448. });
  449. }
  450. if([3].includes(Source)){
  451. options.value.xAxis.title.text=LangType.value == 'en'?(options.value.xAxis.title.textEn||options.value.xAxis.title.textZh):options.value.xAxis.title.textZh
  452. }
  453. }
  454. }
  455. // 设置图标题
  456. function setChartTitle(showChartTitle){
  457. if(showChartTitle){
  458. const ChartInfo=chartData.value.ChartInfo
  459. options.value.title.textZh=ChartInfo.ChartName
  460. options.value.title.textEn=ChartInfo.ChartNameEn
  461. options.value.title.text=LangType.value == 'zh' ?options.value.title.textZh:options.value.title.textEn||options.value.title.textZh
  462. }else{
  463. options.value.title.text=''
  464. }
  465. }
  466. // 截面组合图
  467. function setSectionalCombinationChart(e){
  468. /* 主题样式*/
  469. const chartTheme = e.ChartInfo.ChartThemeStyle ? JSON.parse(e.ChartInfo.ChartThemeStyle) : null;
  470. const {XDataList,UnitList,SeriesList,IsHeap}=e.DataResp;
  471. axisLimitState.leftIndex=SeriesList.findIndex((item) => item.IsAxis===1);
  472. axisLimitState.rightIndex=SeriesList.findIndex((item) => !item.IsAxis);
  473. axisLimitState.rightTwoIndex=SeriesList.findIndex((item) => item.IsAxis ===2);
  474. if(axisLimitState.leftIndex!=-1) {
  475. axisLimitState.hasLeftAxis=true
  476. }
  477. if(axisLimitState.rightIndex!=-1){
  478. axisLimitState.hasRightAxis=true
  479. }
  480. if(axisLimitState.rightTwoIndex!=-1){
  481. axisLimitState.hasRightTwoAxis=true
  482. }
  483. //x轴
  484. const xAxis={
  485. categories:XDataList.map(_=>this.currentLang=='en'?_.NameEn:_.Name),
  486. tickWidth: 1,
  487. labels: {
  488. style:{
  489. ...chartTheme&&chartTheme.xAxisOptions.style
  490. },
  491. },
  492. plotBands: setAxisPlotAreas(3),
  493. plotLines: setAxisPlotLines(3)
  494. }
  495. let yAxis=[]
  496. let seriesData=[]
  497. //有右二轴时排个序 按照左 右 右2的顺序
  498. const chartData = SeriesList.some(_ =>_.IsAxis===2) ? changeEdbOrder(SeriesList) : _.cloneDeep(SeriesList);
  499. chartData.forEach((item,index)=>{
  500. //轴位置值相同的下标
  501. const sameSideIndex = chartData.findIndex(
  502. (i) => i.IsAxis === item.IsAxis
  503. );
  504. const yTitleMap={
  505. 1:['LeftName','LeftNameEn'],
  506. 0:['RightName','RightNameEn'],
  507. 2:['RightTwoName','RightTwoNameEn'],
  508. }
  509. let minLimit = 0,maxLimit = 0
  510. const limitMap = {
  511. 0:['rightMin','rightMax'],
  512. 1:['leftMin','leftMax'],
  513. 2:['rightTwoMin','rightTwoMax']
  514. }
  515. if(limitMap[item.IsAxis]){
  516. minLimit = axisLimitState[`${limitMap[item.IsAxis][0]}`]||0
  517. maxLimit = axisLimitState[`${limitMap[item.IsAxis][1]}`]||0
  518. }
  519. let yItem = {
  520. ...basicYAxis,
  521. title: {
  522. text: UnitList[yTitleMap[item.IsAxis][0]],
  523. textCh:UnitList[yTitleMap[item.IsAxis][0]], // 中文
  524. // 中文不存在,无论英文有无都显示空
  525. textEn:UnitList[yTitleMap[item.IsAxis][0]]?UnitList[yTitleMap[item.IsAxis][1]]:'', // 英文
  526. style:{
  527. ...chartTheme&&chartTheme.yAxisOptions.style
  528. },
  529. align: 'high',
  530. rotation: 0,
  531. y: -12,
  532. // x: (item.IsAxis===0 && this.rightTwoIndex>-1) ? -chartData[this.rightTwoIndex].Unit.length*12 : 0,
  533. textAlign: item.IsAxis===1 ? 'left' : 'right',
  534. reserveSpace: false
  535. },
  536. labels: {
  537. formatter: function (ctx) {
  538. return ctx.value;
  539. },
  540. align: 'center',
  541. x: [0,2].includes(item.IsAxis) ? 5 : -5,
  542. style: {
  543. ...chartTheme&&chartTheme.yAxisOptions.style,
  544. }
  545. },
  546. opposite: [0,2].includes(item.IsAxis),
  547. min: Number(minLimit),
  548. max: Number(maxLimit),
  549. tickWidth: 1,
  550. visible: sameSideIndex === index,
  551. plotBands: setAxisPlotAreas(item.IsAxis),
  552. plotLines: setAxisPlotLines(item.IsAxis)
  553. };
  554. //堆叠图的yAxis必须一致 数据列所对应的y轴
  555. let serie_yIndex = index;
  556. if(IsHeap==1) {
  557. // 类型为堆叠图时公用第一个指标y轴
  558. serie_yIndex = 0;
  559. }
  560. //数据列
  561. let dataArr=item.DataList||[]
  562. // 根据NoDataEdbIndex 将对应位置的值置为null
  563. dataArr.forEach((i,index)=>{
  564. if(item.NoDataEdbIndex.includes(index)){
  565. dataArr[index]=null
  566. }
  567. })
  568. //图表可配置的线条数就10条,第11条用第1条的配置,索引取下模
  569. const lineIndex = chartTheme ? index%chartTheme.lineOptionList.length : index
  570. let obj={
  571. data:dataArr,
  572. type: item.ChartStyle||'',
  573. dashStyle: (chartTheme&&chartTheme.lineOptionList[lineIndex].dashStyle)||'Solid',
  574. chartType:'linear',
  575. yAxis: serie_yIndex,
  576. name:item.SeriesName,
  577. nameZh:item.SeriesName,
  578. nameEn:item.SeriesNameEn,
  579. unitName:UnitList[yTitleMap[item.IsAxis][0]],
  580. unitNameCh:UnitList[yTitleMap[item.IsAxis][0]],
  581. unitNameEn:UnitList[yTitleMap[item.IsAxis][0]]?UnitList[yTitleMap[item.IsAxis][1]]:'',
  582. color: item.ChartColor,
  583. lineWidth: Number(item.ChartWidth)||(chartTheme&&chartTheme.lineOptionList[lineIndex].lineWidth),
  584. borderWidth: 1,
  585. borderColor: item.ChartColor,
  586. marker: {//展示数据点
  587. enabled:item.ChartStyle!='column'&&item.IsPoint?true:false,
  588. radius: (chartTheme&&chartTheme.lineOptionList[lineIndex].radius)||5,
  589. },
  590. dataLabels: {//展示数值
  591. enabled: item.IsNumber?true:false,
  592. align:item.ChartStyle=='column'?'center':undefined,
  593. y:item.ChartStyle=='column'?-20:0,
  594. inside: item.ChartStyle=='column'?false:undefined,
  595. crop: item.ChartStyle=='column'?false:true,
  596. },
  597. stacking:IsHeap==1?'normal':undefined,
  598. zIndex: ['line','spline'].includes(item.ChartStyle) ? 1 : 0, //防止组合图曲线被遮住
  599. }
  600. yAxis.push(yItem)
  601. seriesData.push(obj)
  602. })
  603. const tooltip={
  604. formatter:function () {
  605. let str=`<b>${this.points[0].x}</b>`
  606. this.points.forEach(item=>{
  607. const sObj=seriesData.find(_=>_.name===item.series.name)
  608. str=str+`<br><span style="color:${item.color}">\u25CF</span>${sObj.name}:${item.y} ${sObj.unitNameCh}`
  609. })
  610. return str
  611. },
  612. formatterCh:function () {
  613. let str=`<b>${this.points[0].x}</b>`
  614. this.points.forEach(item=>{
  615. const sObj=seriesData.find(_=>_.name===item.series.name)
  616. str=str+`<br><span style="color:${item.color}">\u25CF</span>${sObj.nameCh}:${item.y} ${sObj.unitNameCh}`
  617. })
  618. return str
  619. },
  620. formatterEn:function () {
  621. let str=`<b>${this.points[0].x}</b>`
  622. this.points.forEach(item=>{
  623. const sObj=seriesData.find(_=>_.name===item.series.name)
  624. str=str+`<br><span style="color:${item.color}">\u25CF</span>${sObj.nameEn}:${item.y} ${sObj.unitNameEn}`
  625. })
  626. return str
  627. },
  628. shared:true
  629. }
  630. return {
  631. title: {
  632. text:''
  633. },
  634. tooltip,
  635. series: seriesData,
  636. yAxis: yAxis,
  637. xAxis,
  638. }
  639. }
  640. //统计频率图
  641. function setStatisticFrequency(e){
  642. axisLimitState.leftIndex=-1
  643. axisLimitState.rightIndex=-1
  644. axisLimitState.rightTwoIndex=-1
  645. /* 主题样式*/
  646. const chartTheme = e.ChartInfo.ChartThemeStyle ? JSON.parse(e.ChartInfo.ChartThemeStyle) : null;
  647. const { DataList,LeftMaxValue,LeftMinValue,RightMaxValue,RightMinValue } = e.DataResp;
  648. const xAxis = {
  649. ...scatterXAxis,
  650. tickWidth: 1,
  651. labels: {
  652. style: {
  653. ...chartTheme&&chartTheme.xAxisOptions.style
  654. }
  655. }
  656. }
  657. //y和系列
  658. let yAxis = [],series = [];
  659. DataList.forEach((item,index) => {
  660. let y_item = {
  661. ...basicYAxis,
  662. title: {
  663. text: item.Unit,
  664. textCh:item.Unit,// 中文
  665. textEn:item.UnitEn||item.Unit,
  666. align: 'high',
  667. rotation: 0,
  668. y: -15,
  669. reserveSpace: false,
  670. style:{
  671. ...chartTheme&&chartTheme.yAxisOptions.style
  672. },
  673. },
  674. labels: {
  675. style:{
  676. ...chartTheme&&chartTheme.yAxisOptions.style
  677. },
  678. },
  679. opposite: item.IsAxis===1?false:true,
  680. min: index===0? Number(LeftMinValue):Number(RightMinValue),
  681. max: index===0? Number(LeftMaxValue):Number(RightMaxValue),
  682. tickWidth: 1,
  683. }
  684. //图表可配置的线条数就10条,第11条用第1条的配置,索引取下模
  685. const lineIndex = chartTheme ? index%chartTheme.lineOptionList.length : index
  686. let series_item = {
  687. data: item.Value.map(_ =>[_.X,_.Y]),
  688. dashStyle: (chartTheme&&chartTheme.lineOptionList[lineIndex].dashStyle)||'Solid',
  689. type: (chartTheme&&chartTheme.lineOptionList[lineIndex].lineType) || 'spline',
  690. yAxis: index,
  691. name: item.Name,
  692. nameZh: item.Name,
  693. nameEn: item.NameEn||item.Name,
  694. color: item.Color,
  695. lineWidth: (chartTheme&&chartTheme.lineOptionList[lineIndex].lineWidth)||3,
  696. chartType: 'linear',
  697. zIndex:1
  698. }
  699. series.push(series_item);
  700. yAxis.push(y_item)
  701. })
  702. let tooltip = {
  703. formatter: function() {
  704. let xList = DataList[0].Value.map(_ =>_.X);
  705. let step = xList[1]-xList[0];
  706. let data_interval = `[${this.x},${this.x+step}]`;
  707. let str=`<b>${ data_interval }</b>`;
  708. this.points.forEach(item => {
  709. str += `<br><span style="color:${item.color}">\u25CF</span>${item.series.name}: ${item.y}%<br>`
  710. })
  711. return str
  712. },
  713. shared: true
  714. }
  715. return {
  716. title: {
  717. text:''
  718. },
  719. tooltip,
  720. series,
  721. yAxis,
  722. xAxis
  723. }
  724. }
  725. //曲线图
  726. function setSplineOpt(e){
  727. //其他Source也会用到曲线图,这里需要兼容
  728. const isETASource = e.ChartInfo.Source===1
  729. const data=[4,6,7,8].includes(e.ChartInfo.Source)?[e.DataResp]:e.EdbInfoList
  730. let series=[]
  731. let yAxis=[]
  732. let xAxis = {}
  733. let temYLeftArr=[]
  734. let temYRightArr=[]
  735. let temYRightTwoArr = []
  736. let temYLeftIndex=data.findIndex((item) => item.IsAxis===1)
  737. let temYRightIndex=data.findIndex((item) => !item.IsAxis)
  738. let temYRightTwoIndex = data.findIndex((item) => item.IsAxis===2)
  739. axisLimitState.leftIndex=temYLeftIndex
  740. axisLimitState.rightIndex=temYRightIndex
  741. axisLimitState.rightTwoIndex=temYRightTwoIndex
  742. /* 主题样式*/
  743. const chartTheme = e.ChartInfo.ChartThemeStyle ? JSON.parse(e.ChartInfo.ChartThemeStyle) : null;
  744. let minAndMaxTimeTemArr=[]//存放所有指标的最大最小时间
  745. //有右二轴时排个序 按照左 右 右2的顺序
  746. let newData = data.some(_ =>_.IsAxis===2) ? changeEdbOrder(data) : data;
  747. newData.forEach((item,index)=>{
  748. //轴位置值相同的下标
  749. let sameSideIndex = newData.findIndex(i => i.IsAxis === item.IsAxis);
  750. let dynamic_title = item.EdbName;
  751. let dynamic_arr = newData.filter(
  752. (item) => dynamic_title === item.EdbName
  753. );
  754. //处理数据列name
  755. let temName= setDyncmicSerieName(item,dynamic_arr,'zh')
  756. let temNameEN=setDyncmicSerieName(item,dynamic_arr,'en')
  757. //预测指标配置
  758. let predict_params = item.EdbInfoCategoryType === 1 ? getPredictParams(item) : {};
  759. //图表可配置的线条数就10条,第11条用第1条的配置,索引取下模
  760. const lineIndex = chartTheme ? index%chartTheme.lineOptionList.length : index
  761. let seriesItemObj={
  762. data:[],
  763. dataGrouping:{
  764. enabled:false
  765. },
  766. type: (chartTheme&&chartTheme.lineOptionList[lineIndex].lineType) || 'spline',
  767. dashStyle: (chartTheme&&chartTheme.lineOptionList[lineIndex].dashStyle)||'Solid',
  768. yAxis:index,
  769. name:temName,
  770. nameZh:temName,
  771. nameEn:temNameEN,
  772. color: item.ChartColor,
  773. lineWidth: Number(item.ChartWidth)||(chartTheme&&chartTheme.lineOptionList[lineIndex].lineWidth)||1,
  774. visible:true,
  775. LatestDate:item.LatestDate,
  776. LatestValue:item.LatestValue,
  777. marker:chartTheme && chartTheme.lineOptionList[lineIndex].dataMark && chartTheme.lineOptionList[lineIndex].dataMark!='none'?{
  778. enabled:true,
  779. symbol: chartTheme.lineOptionList[lineIndex].markType || 'circle',
  780. fillColor:chartTheme.lineOptionList[lineIndex].markColor,
  781. radius: chartTheme.lineOptionList[lineIndex].markSize
  782. }:{},
  783. ...predict_params
  784. }
  785. item.DataList = item.DataList || [];
  786. for (let i of item.DataList) {
  787. seriesItemObj.data.push([i.DataTimestamp, i.Value]);
  788. }
  789. series.push(seriesItemObj)
  790. // 设置y轴
  791. if(item.IsAxis){
  792. temYLeftArr.push(item)
  793. }else{
  794. temYRightArr.push(item)
  795. }
  796. //获取上下限
  797. console.log('useSelfLimit',useSelfLimit)
  798. let minLimit = 0,maxLimit = 0
  799. if(!useSelfLimit||!isETASource){
  800. minLimit = item.MinData
  801. maxLimit = item.MaxData
  802. }
  803. if(useSelfLimit&&isETASource){
  804. const limitMap = {
  805. 0:['rightMin','rightMax'],
  806. 1:['leftMin','leftMax'],
  807. 2:['rightTwoMin','rightTwoMax']
  808. }
  809. if(limitMap[item.IsAxis]){
  810. minLimit = axisLimitState[`${limitMap[item.IsAxis][0]}`]||0
  811. maxLimit = axisLimitState[`${limitMap[item.IsAxis][1]}`]||0
  812. }
  813. }
  814. const textZh = item.ConvertUnit||item.Unit
  815. const textEn = item.ConvertEnUnit||item.UnitEn||item.ConvertUnit||item.Unit
  816. let yItem={
  817. ...basicYAxis,
  818. IsAxis:item.IsAxis,
  819. labels: {
  820. formatter: function (ctx) {
  821. return sameSideIndex !== index ? '' : ctx.value;
  822. },
  823. align: 'center',
  824. x: [0,2].includes(item.IsAxis) ? 5 : -5,
  825. style:{
  826. ...chartTheme&&chartTheme.yAxisOptions.style
  827. },
  828. },
  829. tickWidth: sameSideIndex !== index ? 0 : 1,
  830. title: {
  831. text: sameSideIndex !== index ? '' : `${textZh}`,
  832. textZh:textZh,//中文单位
  833. textEn:textZh?textEn:'',//英文单位,但如果无中文单位则不显示
  834. align: 'high',
  835. rotation: 0,
  836. y: -15,
  837. x: (item.IsAxis===0 && temYRightTwoIndex>-1) ? -newData[temYRightTwoIndex].Unit.length*12 : 0,
  838. textAlign: item.IsAxis===1 ? 'left' : 'right',
  839. reserveSpace: false,
  840. style:{
  841. ...chartTheme&&chartTheme.yAxisOptions.style
  842. }
  843. },
  844. opposite: [0,2].includes(item.IsAxis),
  845. reversed: item.IsOrder,
  846. min: Number(minLimit),
  847. max: Number(maxLimit),
  848. visible: sameSideIndex === index,
  849. chartEdbInfo:item,//指标数据用于在保存时读取指标数据
  850. plotBands: setAxisPlotAreas(item.IsAxis),
  851. plotLines: setAxisPlotLines(item.IsAxis)
  852. }
  853. yAxis.push(yItem)
  854. if(item.DataList.length>0){
  855. minAndMaxTimeTemArr.push(item.DataList[0].DataTimestamp)
  856. minAndMaxTimeTemArr.push(item.DataList[item.DataList.length-1].DataTimestamp)
  857. }
  858. })
  859. // 设置x轴
  860. // 找出所有指标的最大和最小时间 分成6段
  861. let minTime=Math.min.apply(null,minAndMaxTimeTemArr)
  862. let maxTime=Math.max.apply(null,minAndMaxTimeTemArr)
  863. const isLessThanOneYear = xTimeDiffer(minTime,maxTime,e.ChartInfo.DateType)
  864. xAxis={
  865. ...basicXAxis,
  866. labels: {
  867. formatter: function (ctx) {
  868. return isLessThanOneYear
  869. ? HighchartsFormat.dateFormat('%m/%d', ctx.value)
  870. : HighchartsFormat.dateFormat('%y/%m', ctx.value);
  871. },
  872. style: {
  873. ...chartTheme&&chartTheme.xAxisOptions.style
  874. }
  875. },
  876. tickInterval:screen.value === 'phone'?((maxTime-minTime)/6)/(24*3600*1000)>30?(maxTime-minTime)/6:24*3600*1000*30:undefined,
  877. plotBands: setAxisPlotAreas(3,'datetime'),
  878. plotLines: setAxisPlotLines(3,'datetime')
  879. }
  880. yAxis.forEach(item=>{
  881. if(item.IsAxis===1){//左轴
  882. axisLimitState.hasLeftAxis=true
  883. if(!useSelfLimit||!isETASource){
  884. axisLimitState.leftMin=data[temYLeftIndex].MinData
  885. axisLimitState.leftMax=data[temYLeftIndex].MaxData
  886. item.min=data[temYLeftIndex].MinData
  887. item.max=data[temYLeftIndex].MaxData
  888. }
  889. }else if (item.IsAxis===2){ // 右2轴
  890. axisLimitState.hasRightTwoAxis=true
  891. if(!useSelfLimit||!isETASource){
  892. axisLimitState.rightTwoMin=data[temYRightTwoIndex].MinData
  893. axisLimitState.rightTwoMax=data[temYRightTwoIndex].MaxData
  894. item.min=data[temYRightTwoIndex].MinData
  895. item.max=data[temYRightTwoIndex].MaxData
  896. }
  897. }else{
  898. axisLimitState.hasRightAxis=true
  899. if(!useSelfLimit||!isETASource){
  900. axisLimitState.rightMin=data[temYRightIndex].MinData
  901. axisLimitState.rightMax=data[temYRightIndex].MaxData
  902. item.min=data[temYRightIndex].MinData
  903. item.max=data[temYRightIndex].MaxData
  904. }
  905. }
  906. })
  907. return {
  908. series,
  909. xAxis:[xAxis],
  910. yAxis,
  911. rangeSelector:{ enabled: false}
  912. }
  913. }
  914. //季节图
  915. function setSeasonOpt(e){
  916. axisLimitState.leftIndex=0
  917. const {RightAxis:SeasonRightConfig={}} = e.DataResp||{}
  918. axisLimitState.rightIndex=SeasonRightConfig.IsShow?1:-1
  919. axisLimitState.rightTwoIndex=-1
  920. /* 主题样式*/
  921. const chartTheme = e.ChartInfo.ChartThemeStyle ? JSON.parse(e.ChartInfo.ChartThemeStyle) : null;
  922. let chartData={}
  923. const data=e.EdbInfoList[0]
  924. const calendarType=e.ChartInfo.Calendar||'公历'
  925. const colorsArr=chartTheme&&chartTheme.colorsOptions.reverse();
  926. let series=[],yAxis=[]
  927. //农历默认选中一年数据并隐藏按钮 公历显示全部数据
  928. // 农历数据需要去除第一项 农历和公历处理逻辑一样
  929. const chartDataHandle=calendarType === '农历'?
  930. data.DataList.filter((item, index) => index > 0):
  931. data.DataList
  932. // 跟颜色对应
  933. chartTheme && (chartTheme.lineOptionList=chartTheme.lineOptionList.reverse().slice(-chartDataHandle.length))
  934. // if(calendarType==='公历'){
  935. //常规左轴
  936. chartDataHandle.forEach((item,index)=>{
  937. //预测指标配置
  938. let predict_params = data.EdbInfoCategoryType === 1 ? getSeasonPredictParams(item.CuttingDataTimestamp) : {};
  939. //图表可配置的线条数就10条,第11条用第1条的配置,索引取下模
  940. const lineIndex = chartTheme ? index%chartTheme.lineOptionList.length : index
  941. let seriesItem={
  942. data:[],
  943. dataGrouping:{
  944. enabled:false
  945. },
  946. type: (chartTheme&&chartTheme.lineOptionList[lineIndex].lineType) || data.ChartStyle,
  947. dashStyle: (chartTheme&&chartTheme.lineOptionList[lineIndex].dashStyle)||'Solid',
  948. yAxis:0,
  949. name:item.ChartLegend,
  950. lineWidth: (chartTheme&&chartTheme.lineOptionList[lineIndex].lineWidth) || 1,
  951. // color:colorsArr.slice(-chartDataHandle.length)[lineIndex], //与PC端的配置不同步,导致两边 十条之后的线条颜色不对应
  952. visible:true,
  953. marker:chartTheme && chartTheme.lineOptionList[lineIndex].dataMark && chartTheme.lineOptionList[lineIndex].dataMark!='none'?{
  954. enabled:true,
  955. symbol: chartTheme.lineOptionList[lineIndex].markType || 'circle',
  956. fillColor:chartTheme.lineOptionList[lineIndex].markColor,
  957. radius: chartTheme.lineOptionList[lineIndex].markSize
  958. }:{},
  959. ...predict_params
  960. }
  961. item.DataList=item.DataList||[]
  962. for(let i of item.DataList){
  963. seriesItem.data.push([i.DataTimestamp, i.Value])
  964. }
  965. series.push(seriesItem)
  966. })
  967. chartData.colors = colorsArr.slice(-chartDataHandle.length)
  968. //同期上下限/均线/标准差
  969. const {MaxMinLimits={},SamePeriodAverage={},SamePeriodStandardDeviation={}} = e.DataResp||{}
  970. if(MaxMinLimits.IsShow&&MaxMinLimits.List&&MaxMinLimits.List.length){
  971. let serieItem = {
  972. type:'arearange',//上下限是一个范围
  973. data:[],
  974. name:MaxMinLimits.Legend||'同期上下限',
  975. color:MaxMinLimits.Color||'#075EEE' ,
  976. fillOpacity:parseRgbaColor(MaxMinLimits.Color||'')>0.75?0.75:parseRgbaColor(MaxMinLimits.Color||'') //透明度最高0.75
  977. }
  978. MaxMinLimits.List.forEach(item=>{
  979. serieItem.data.push([item.DataTimestamp,item.MinValue,item.MaxValue])
  980. })
  981. series.push(serieItem)
  982. }
  983. if(SamePeriodAverage.IsShow&&SamePeriodAverage.List){
  984. let serieItem = {
  985. type:'line',
  986. data:[],
  987. lineWidth:SamePeriodAverage.LineWidth,
  988. dashStyle:SamePeriodAverage.LineType,
  989. name:SamePeriodAverage.Legend||'同期均值',
  990. color:SamePeriodAverage.Color||'#075EEE'
  991. }
  992. SamePeriodAverage.List.forEach(item=>{
  993. serieItem.data.push([item.DataTimestamp,item.Value])
  994. })
  995. series.push(serieItem)
  996. }
  997. if(SamePeriodStandardDeviation.IsShow&&SamePeriodStandardDeviation.List){
  998. let serieItem = {
  999. type:'arearange',//标准差也是一个范围
  1000. data:[],
  1001. name:SamePeriodStandardDeviation.Legend||'同期标准差',
  1002. color:SamePeriodStandardDeviation.Color||'#075EEE',
  1003. fillOpacity:parseRgbaColor(SamePeriodStandardDeviation.Color||'')>0.75?0.75:parseRgbaColor(SamePeriodStandardDeviation.Color||'')
  1004. }
  1005. SamePeriodStandardDeviation.List.forEach(item=>{
  1006. serieItem.data.push([item.DataTimestamp,item.MinValue,item.MaxValue])
  1007. })
  1008. series.push(serieItem)
  1009. }
  1010. //右轴
  1011. if(SeasonRightConfig.IsShow){
  1012. //右轴的设置
  1013. let serieConfig = SeasonRightConfig.Style==='column'?{
  1014. //柱形
  1015. type:'column',
  1016. color:SeasonRightConfig.ChartColor
  1017. }:{
  1018. //标记点
  1019. type:'spline',
  1020. lineWidth:SeasonRightConfig.LineWidth,
  1021. dashStyle:SeasonRightConfig.LineStyle,
  1022. color:SeasonRightConfig.IsConnected?SeasonRightConfig.LineColor:'rgba(255, 255, 255, 0)',//没有连线颜色设置为透明
  1023. marker:{
  1024. enabled:true,
  1025. symbol:SeasonRightConfig.Shape,
  1026. fillColor:SeasonRightConfig.ChartColor,
  1027. radius:SeasonRightConfig.Size
  1028. },
  1029. }
  1030. let serieItem = {
  1031. ...serieConfig,
  1032. name:SeasonRightConfig.Legend||'',
  1033. data:[],
  1034. yAxis:1,
  1035. }
  1036. const DataList = (SeasonRightConfig.IndicatorType===1?SeasonRightConfig.EdbInfoList[0].DataList:e.EdbInfoList[1]?.DataList)||[]
  1037. DataList.forEach(item=>{
  1038. serieItem.data.push([item.DataTimestamp,item.Value])
  1039. })
  1040. series.push(serieItem)
  1041. }
  1042. //获取上下限
  1043. let minLimit = 0,maxLimit = 0,rightMin = 0,rightMax = 0
  1044. //非ETA图库不使用自定义上下限 非ETA图库的季节性图也不能设置右轴
  1045. if(!useSelfLimit){
  1046. minLimit = data.MinData
  1047. maxLimit = data.MaxData
  1048. }else{
  1049. minLimit = axisLimitState.leftMin||0
  1050. maxLimit = axisLimitState.leftMax||0
  1051. //右轴上下限设置
  1052. if(axisLimitState.rightIndex!==-1){
  1053. rightMin = axisLimitState.rightMin||0
  1054. rightMax = axisLimitState.rightMax||0
  1055. }
  1056. }
  1057. const textZh = data.ConvertUnit||data.Unit
  1058. const textEn = data.ConvertEnUnit||data.UnitEn||data.ConvertUnit||data.Unit
  1059. yAxis=[{
  1060. IsAxis:data.IsAxis,
  1061. labels: {
  1062. align: 'center',
  1063. y:5,
  1064. style: {
  1065. ...chartTheme&&chartTheme.yAxisOptions.style
  1066. }
  1067. },
  1068. title: {
  1069. text: `${textZh}`,
  1070. textZh:textZh, // 中文
  1071. // 中文不存在,无论英文有无都显示空
  1072. textEn:textZh?textEn||'英文单位':'', // 英文
  1073. align: 'high',
  1074. rotation: 0,
  1075. y: -5,
  1076. x: 0,
  1077. textAlign: 'left',
  1078. reserveSpace: false,
  1079. style:{
  1080. ...chartTheme&&chartTheme.yAxisOptions.style
  1081. },
  1082. },
  1083. max: Number(maxLimit),
  1084. min: Number(minLimit),
  1085. plotBands: setAxisPlotAreas(1),
  1086. plotLines: setAxisPlotLines(1),
  1087. lineWidth: 1,
  1088. lineColor: '#bfbfbf',
  1089. tickColor: '#bfbfbf',
  1090. offset: 0,
  1091. opposite: false,
  1092. reversed: false,
  1093. visible: true,
  1094. gridLineWidth: 0,
  1095. tickWidth: 1,
  1096. tickLength:5,
  1097. tickPosition: 'inside',
  1098. endOnTick: false,
  1099. startOnTick: false,
  1100. showLastLabel: true, //显示最后刻度值
  1101. tickPixelInterval: 50,
  1102. // chartEdbInfo:item//指标数据
  1103. }]
  1104. //如果有右轴,yAxis加上右轴
  1105. if(SeasonRightConfig.IsShow){
  1106. const rightEdb = (SeasonRightConfig.IndicatorType===1?SeasonRightConfig.EdbInfoList[0]:e.EdbInfoList[1])||{Unit:''}
  1107. //左轴同比:text为空或% 右轴指标:取指标单位
  1108. if(SeasonRightConfig.IndicatorType===1){
  1109. rightEdb.Unit = SeasonRightConfig.NumFormat===1?'%':''
  1110. }else{
  1111. rightEdb.Unit = e.EdbInfoList[1]&&(e.EdbInfoList[1].ConvertUnit||e.EdbInfoList[1].Unit)||''
  1112. }
  1113. yAxis.push({
  1114. ...seasonOptions.yAxis,
  1115. opposite: true,//右轴
  1116. labels: {
  1117. align: 'center',
  1118. y:5,
  1119. style: {
  1120. ...chartTheme&&chartTheme.yAxisOptions.style
  1121. }
  1122. },
  1123. title: {
  1124. text: rightEdb.Unit||'',
  1125. style:{
  1126. ...chartTheme&&chartTheme.yAxisOptions.style
  1127. },
  1128. align: 'high',
  1129. rotation: 0,
  1130. y: -5,
  1131. x: 0,
  1132. textAlign: 'right',
  1133. reserveSpace: false,
  1134. },
  1135. max: Number(rightMax),
  1136. min: Number(rightMin),
  1137. })
  1138. }
  1139. chartData.series=series
  1140. chartData.yAxis=yAxis
  1141. // chartData.rangeSelector=rangeSelector
  1142. // 设置坐标轴极值
  1143. axisLimitState.hasLeftAxis=true
  1144. if(!useSelfLimit){
  1145. axisLimitState.leftMin=Number(data.MinData)
  1146. axisLimitState.leftMax=Number(data.MaxData)
  1147. }
  1148. // 季节图x轴显示月/日
  1149. let xAxis={
  1150. tickPosition: 'inside',
  1151. lineColor: '#bfbfbf',
  1152. tickColor: '#bfbfbf',
  1153. tickLength:5,
  1154. type: 'datetime',
  1155. ordinal: false,
  1156. dateTimeLabelFormats: {
  1157. day: '%y/%m',
  1158. week: '%y/%m',
  1159. month: '%y/%m',
  1160. year: '%y/%m',
  1161. },
  1162. labels: {
  1163. formatter: (ctx)=> {
  1164. return HighchartsFormat.dateFormat('%m/%d', ctx.value)
  1165. },
  1166. style: {
  1167. ...chartTheme&&chartTheme.xAxisOptions.style
  1168. }
  1169. },
  1170. tickInterval:screen.value === 'phone'?24*3600*1000*60:undefined,//季节图
  1171. plotBands: setAxisPlotAreas(3,'datetime'),
  1172. plotLines: setAxisPlotLines(3,'datetime')
  1173. }
  1174. chartData.xAxis=[xAxis]
  1175. // 季节图提示框显示 月/日
  1176. chartData.tooltip={
  1177. split: false,
  1178. shared: true,
  1179. dateTimeLabelFormats: {
  1180. // 时间格式化字符
  1181. day: '%m/%d',
  1182. week: '%m/%d',
  1183. month: '%m/%d',
  1184. year: '%m/%d',
  1185. },
  1186. xDateFormat: '%m/%d',
  1187. }
  1188. return {
  1189. ...chartData,
  1190. // title: {
  1191. // enabled: true,
  1192. // text:e.ChartInfo.ChartName
  1193. // },
  1194. // legend:{
  1195. // enabled:true,
  1196. // verticalAlign: 'top',
  1197. // y:-10,
  1198. // x:(10 * data.Unit.length)/2
  1199. // }
  1200. }
  1201. }
  1202. //堆叠图/组合图设置
  1203. //本来和曲线图逻辑基本一致兼容下即可 为了以后便于维护和阅读还是拆开写吧
  1204. function setStackOrCombinChart(e){
  1205. const data=e.EdbInfoList
  1206. //图表类型
  1207. const chartTypeMap = {
  1208. 3: 'areaspline',
  1209. 4: 'column',
  1210. 6: ''
  1211. };
  1212. let chartStyle = chartTypeMap[e.ChartInfo.ChartType];
  1213. /* 主题样式*/
  1214. const chartTheme = e.ChartInfo.ChartThemeStyle ? JSON.parse(e.ChartInfo.ChartThemeStyle) : null;
  1215. let series=[]
  1216. let yAxis=[]
  1217. let xAxis = {}
  1218. let ExtraConfig={}
  1219. let temYLeftArr=[]
  1220. let temYRightArr=[]
  1221. let temYRightTwoArr = []
  1222. let temYLeftIndex,temYRightIndex,temYRightTwoIndex;
  1223. let minAndMaxTimeTemArr=[]//存放所有指标的最大最小时间
  1224. //有右二轴时排个序 按照左 右 右2的顺序
  1225. let newData = data.some(_ =>_.IsAxis===2) ? changeEdbOrder(data) : data;
  1226. if(e.ChartInfo.ChartType===3 && e.ChartInfo.ExtraConfig){
  1227. ExtraConfig=JSON.parse(e.ChartInfo.ExtraConfig)
  1228. }
  1229. newData.forEach((item,index)=>{
  1230. //轴位置值相同的下标
  1231. let sameSideIndex = newData.findIndex(i => i.IsAxis === item.IsAxis);
  1232. //堆叠图的yAxis必须一致 数据列所对应的y轴
  1233. let serie_yIndex = index;
  1234. if([4].includes(e.ChartInfo.ChartType)||(e.ChartInfo.ChartType ===3 && ExtraConfig.IsHeap==1)) {
  1235. // 类型为堆叠图时公用第一个指标y轴
  1236. serie_yIndex = 0;
  1237. } else if(e.ChartInfo.ChartType ===6 && ['areaspline','column'].includes(item.ChartStyle)) {
  1238. // 组合图找第一个堆叠柱状或面积的作为公用
  1239. serie_yIndex = newData.findIndex(i => i.ChartStyle === item.ChartStyle);
  1240. }
  1241. //数据对应的y轴是公用轴则配置也共享
  1242. item.IsAxis = serie_yIndex === index ? item.IsAxis : newData[serie_yIndex].IsAxis;
  1243. item.IsOrder = serie_yIndex === index ? item.IsOrder : newData[serie_yIndex].IsOrder;
  1244. temYLeftIndex = [4].includes(e.ChartInfo.ChartType)
  1245. ? (newData[serie_yIndex].IsAxis ? serie_yIndex : -1)
  1246. : data.findIndex((item) => item.IsAxis===1);
  1247. temYRightIndex = [4].includes(e.ChartInfo.ChartType)
  1248. ? (newData[serie_yIndex].IsAxis ? -1 : serie_yIndex)
  1249. : data.findIndex((item) => !item.IsAxis);
  1250. temYRightTwoIndex = [4].includes(e.ChartInfo.ChartType)
  1251. ? -1
  1252. : data.findIndex((item) => item.IsAxis===2);
  1253. axisLimitState.leftIndex=temYLeftIndex
  1254. axisLimitState.rightIndex=temYRightIndex
  1255. axisLimitState.rightTwoIndex=temYRightTwoIndex
  1256. let dynamic_title = item.EdbName;
  1257. let dynamic_arr = newData.filter(
  1258. (item) => dynamic_title === item.EdbName
  1259. );
  1260. //处理数据列name
  1261. let temName= setDyncmicSerieName(item,dynamic_arr,'zh')
  1262. let temNameEN=setDyncmicSerieName(item,dynamic_arr,'en')
  1263. //预测指标配置
  1264. let predict_params = item.EdbInfoCategoryType === 1 ? getPredictParams(item) : {};
  1265. //图表可配置的线条数就10条,第11条用第1条的配置,索引取下模
  1266. const lineIndex = chartTheme ? index%chartTheme.lineOptionList.length : index;
  1267. let stacking = e.ChartInfo.ChartType==6
  1268. ? !e.DataResp.IsHeap?undefined:'normal'
  1269. : (e.ChartInfo.ChartType==3&&ExtraConfig.IsHeap==1)?ExtraConfig.HeapWay==1?'normal':'percent':undefined;
  1270. let seriesItemObj={
  1271. data:[],
  1272. dataGrouping:{
  1273. enabled:false
  1274. },
  1275. type: e.ChartInfo.ChartType !== 3
  1276. ? (chartStyle || item.ChartStyle)
  1277. : ExtraConfig.IsHeap==1?'area':((chartTheme && chartTheme.lineOptionList[lineIndex].lineType) || item.ChartStyle),
  1278. yAxis:serie_yIndex,
  1279. name:temName,
  1280. nameZh:temName,
  1281. nameEn:temNameEN,
  1282. color: item.ChartColor,
  1283. lineWidth: Number(item.ChartWidth)||(chartTheme&&chartTheme.lineOptionList[lineIndex].lineWidth) || 1,
  1284. fillColor: (e.ChartInfo.ChartType === 3 || (e.ChartInfo.ChartType === 6 && item.ChartStyle === 'areaspline')) ? item.ChartColor : undefined,
  1285. visible:true,
  1286. LatestDate:item.LatestDate,
  1287. LatestValue:item.LatestValue,
  1288. ...predict_params,
  1289. stacking,
  1290. threshold: e.ChartInfo.ChartType==3
  1291. ?(item.ChartScale?Number(item.ChartScale):0)
  1292. :null
  1293. }
  1294. item.DataList = item.DataList || [];
  1295. for (let i of item.DataList) {
  1296. seriesItemObj.data.push([i.DataTimestamp, i.Value]);
  1297. }
  1298. series.push(seriesItemObj)
  1299. //获取上下限
  1300. let minLimit = 0,maxLimit = 0
  1301. //非ETA图库不使用自定义上下限
  1302. if(!useSelfLimit){
  1303. minLimit = newData[sameSideIndex].MinData
  1304. maxLimit = newData[sameSideIndex].MaxData
  1305. }else{
  1306. const limitMap = {
  1307. 0:['rightMin','rightMax'],
  1308. 1:['leftMin','leftMax'],
  1309. 2:['rightTwoMin','rightTwoMax']
  1310. }
  1311. if(limitMap[item.IsAxis]){
  1312. minLimit = axisLimitState[`${limitMap[item.IsAxis][0]}`]||0
  1313. maxLimit = axisLimitState[`${limitMap[item.IsAxis][1]}`]||0
  1314. }
  1315. }
  1316. // 设置y轴
  1317. if(item.IsAxis){
  1318. temYLeftArr.push(item)
  1319. }else{
  1320. temYRightArr.push(item)
  1321. }
  1322. const textZh = item.ConvertUnit||item.Unit
  1323. const textEn = item.ConvertEnUnit||item.UnitEn||item.ConvertUnit||item.Unit
  1324. let yItem={
  1325. ...basicYAxis,
  1326. IsAxis:item.IsAxis,
  1327. labels: {
  1328. formatter: function (ctx) {
  1329. return sameSideIndex !== index ? '' : e.ChartInfo.ChartType===3&&ExtraConfig.HeapWay==2?ctx.value+'%':ctx.value;
  1330. },
  1331. align: 'center',
  1332. x: [0,2].includes(item.IsAxis) ? 5 : -5,
  1333. style:{
  1334. ...chartTheme&&chartTheme.yAxisOptions.style
  1335. },
  1336. },
  1337. title: {
  1338. // text: sameSideIndex !== index ? '' : `${item.Unit}`,
  1339. text: textZh,
  1340. textZh:textZh, // 中文
  1341. // 中文不存在,无论英文有无都显示空
  1342. textEn:textZh?textEn||'英文单位':'', // 英文
  1343. align: 'high',
  1344. rotation: 0,
  1345. y: -15,
  1346. x: (item.IsAxis===0 && temYRightTwoIndex>-1) ? -newData[temYRightTwoIndex].Unit.length*12 : 0,
  1347. textAlign: item.IsAxis===1 ? 'left' : 'right',
  1348. reserveSpace: false,
  1349. style:{
  1350. ...chartTheme&&chartTheme.yAxisOptions.style
  1351. },
  1352. },
  1353. opposite: [0,2].includes(item.IsAxis),
  1354. reversed: item.IsOrder,
  1355. min: e.ChartInfo.ChartType===3&&ExtraConfig.HeapWay==2?null:Number(minLimit),
  1356. max: e.ChartInfo.ChartType===3&&ExtraConfig.HeapWay==2?null:Number(maxLimit),
  1357. tickWidth: sameSideIndex !== index ? 0 : 1,
  1358. visible: serie_yIndex === index && sameSideIndex ===index,
  1359. plotBands: setAxisPlotAreas(item.IsAxis),
  1360. plotLines: setAxisPlotLines(item.IsAxis),
  1361. chartEdbInfo:item//指标数据用于在保存时读取指标数据
  1362. }
  1363. yAxis.push(yItem)
  1364. if(item.DataList.length>0){
  1365. minAndMaxTimeTemArr.push(item.DataList[0].DataTimestamp)
  1366. minAndMaxTimeTemArr.push(item.DataList[item.DataList.length-1].DataTimestamp)
  1367. }
  1368. })
  1369. // 设置x轴
  1370. // 找出所有指标的最大和最小时间 分成6段
  1371. let minTime=Math.min.apply(null,minAndMaxTimeTemArr)
  1372. let maxTime=Math.max.apply(null,minAndMaxTimeTemArr)
  1373. const isLessThanOneYear = xTimeDiffer(minTime,maxTime,e.ChartInfo.DateType)
  1374. xAxis={
  1375. ...basicXAxis,
  1376. labels: {
  1377. formatter: function (ctx) {
  1378. return isLessThanOneYear
  1379. ? HighchartsFormat.dateFormat('%m/%d', ctx.value)
  1380. : HighchartsFormat.dateFormat('%y/%m', ctx.value);
  1381. },
  1382. style: {
  1383. ...chartTheme&&chartTheme.xAxisOptions.style
  1384. }
  1385. },
  1386. tickInterval:screen.value === 'phone'?((maxTime-minTime)/6)/(24*3600*1000)>30?(maxTime-minTime)/6:24*3600*1000*30:undefined,
  1387. plotBands: setAxisPlotAreas(3,'datetime'),
  1388. plotLines: setAxisPlotLines(3,'datetime')
  1389. }
  1390. yAxis.forEach(item=>{
  1391. if(item.IsAxis === 1){//左轴
  1392. axisLimitState.hasLeftAxis=true
  1393. if(!useSelfLimit){
  1394. axisLimitState.leftMin=data[temYLeftIndex].MinData
  1395. axisLimitState.leftMax=data[temYLeftIndex].MaxData
  1396. item.min=data[temYLeftIndex].MinData
  1397. item.max=data[temYLeftIndex].MaxData
  1398. }
  1399. }else if (item.IsAxis===2){ // 右2轴
  1400. axisLimitState.hasRightTwoAxis=true
  1401. if(!useSelfLimit){
  1402. axisLimitState.rightTwoMin=data[temYRightTwoIndex].MinData
  1403. axisLimitState.rightTwoMax=data[temYRightTwoIndex].MaxData
  1404. item.min=data[temYRightTwoIndex].MinData
  1405. item.max=data[temYRightTwoIndex].MaxData
  1406. }
  1407. }else{
  1408. axisLimitState.hasRightAxis=true
  1409. if(!useSelfLimit){
  1410. axisLimitState.rightMin=data[temYRightIndex].MinData
  1411. axisLimitState.rightMax=data[temYRightIndex].MaxData
  1412. item.min=data[temYRightIndex].MinData
  1413. item.max=data[temYRightIndex].MaxData
  1414. }
  1415. }
  1416. })
  1417. return {
  1418. series,
  1419. xAxis:xAxis,
  1420. yAxis,
  1421. rangeSelector:{ enabled: false}
  1422. }
  1423. }
  1424. /* 散点图 第一个指标值为x轴 第二个指标为y轴*/
  1425. function setScatterOptions(data){
  1426. axisLimitState.leftIndex=1
  1427. axisLimitState.rightIndex=-1
  1428. axisLimitState.rightTwoIndex=-1
  1429. const dataList=data.EdbInfoList
  1430. const { ChartInfo } = data;
  1431. /* 主题样式*/
  1432. const chartTheme = ChartInfo.ChartThemeStyle ? JSON.parse(ChartInfo.ChartThemeStyle) : null;
  1433. //上下限设置的是y轴,也就是第二个指标的值,改回来
  1434. axisLimitState.hasLeftAxis=true
  1435. /* axisLimitState.leftMin=Number(dataList[1].MinData)
  1436. axisLimitState.leftMax=Number(dataList[1].MaxData)
  1437. axisLimitData.leftMin=Number(dataList[1].MinData)
  1438. axisLimitData.leftMax=Number(dataList[1].MaxData) */
  1439. // 取2个指标中日期相同的数据
  1440. const real_data = [];
  1441. let tmpData_date = {};//用来取点对应的日期
  1442. let data1 = _.cloneDeep(dataList)[0].DataList || [];
  1443. let data2 = _.cloneDeep(dataList)[1].DataList || [];
  1444. data1.forEach((_item) => {
  1445. data2.forEach((_item2) => {
  1446. if(_item.DataTimestamp === _item2.DataTimestamp) {
  1447. //日期
  1448. let itemIndex =_item.Value + "_" +_item2.Value
  1449. if(tmpData_date[itemIndex]) {
  1450. tmpData_date[itemIndex].push( moment(_item.DataTimestamp).format('YYYY/MM/DD'))
  1451. } else {
  1452. tmpData_date[itemIndex] = [moment(_item.DataTimestamp).format('YYYY/MM/DD')]
  1453. }
  1454. //值
  1455. real_data.push({
  1456. x: _item.Value,
  1457. y: _item2.Value
  1458. })
  1459. }
  1460. })
  1461. })
  1462. real_data.sort((x,y) => x-y);
  1463. //悬浮窗 拼接日期 原始指标名称
  1464. let tooltip = {
  1465. formatter: function() {
  1466. return `<strong>${ tmpData_date[this.x+'_'+this.y].length > 4 ? tmpData_date[this.x+'_'+this.y].slice(0,4).join()+'...' : tmpData_date[this.x+'_'+this.y].join() }</strong><br>
  1467. ${dataList[0].EdbName}: <span style="font-weight: 600"> ${this.x}</span><br>
  1468. ${dataList[1].EdbName}: <span style="font-weight: 600"> ${this.y}</span>
  1469. `
  1470. },
  1471. // 中文
  1472. formatterCh: function() {
  1473. return `<strong>${ tmpData_date[this.x+'_'+this.y].length > 4 ? tmpData_date[this.x+'_'+this.y].slice(0,4).join()+'...' : tmpData_date[this.x+'_'+this.y].join() }</strong><br>
  1474. ${dataList[0].EdbName}: <span style="font-weight: 600"> ${this.x}</span><br>
  1475. ${dataList[1].EdbName}: <span style="font-weight: 600"> ${this.y}</span>
  1476. `
  1477. },
  1478. // 英文
  1479. formatterEn: function() {
  1480. let str1 = `${dataList[0].EdbNameEn}`
  1481. let str2 = `${dataList[1].EdbNameEn}`
  1482. return `<strong>${ tmpData_date[this.x+'_'+this.y].length > 4 ? tmpData_date[this.x+'_'+this.y].slice(0,4).join()+'...' : tmpData_date[this.x+'_'+this.y].join() }</strong><br>
  1483. ${str1}: <span style="font-weight: 600"> ${this.x}</span><br>
  1484. ${str2}: <span style="font-weight: 600"> ${this.y}</span>
  1485. `
  1486. }
  1487. }
  1488. const { IsOrder,ChartColor } = dataList[0];
  1489. //获取上下限
  1490. let minLimit = 0,maxLimit = 0
  1491. if(!useSelfLimit){
  1492. minLimit = data.ChartInfo.LeftMin||0;
  1493. maxLimit = data.ChartInfo.LeftMax||0;
  1494. }else{
  1495. minLimit = axisLimitState.leftMin||0
  1496. maxLimit = axisLimitState.leftMax||0
  1497. }
  1498. console.log('check limit',minLimit,maxLimit)
  1499. const textYZh = dataList[1].ConvertUnit||dataList[1].Unit
  1500. const textYEn = dataList[1].ConvertEnUnit||dataList[1].UnitEn||dataList[1].ConvertUnit||dataList[1].Unit
  1501. //y轴
  1502. let yAxis = {
  1503. title: {
  1504. text: `${textYZh}`,
  1505. textZh:textYZh,
  1506. textEn:textYZh?textYEn:'',
  1507. align: 'high',
  1508. rotation: 0,
  1509. y: -15,
  1510. x:0,
  1511. textAlign: 'left',
  1512. reserveSpace: false,
  1513. style:{
  1514. ...chartTheme&&chartTheme.yAxisOptions.style
  1515. },
  1516. },
  1517. labels: {
  1518. formatter: function (ctx) {
  1519. return ctx.value;
  1520. },
  1521. align: 'center',
  1522. style:{
  1523. ...chartTheme&&chartTheme.yAxisOptions.style
  1524. },
  1525. },
  1526. opposite: false,
  1527. reversed: IsOrder,
  1528. min: Number(minLimit),
  1529. max: Number(maxLimit),
  1530. tickWidth: 1,
  1531. tickLength: 5,
  1532. lineWidth: 1,
  1533. lineColor: '#bfbfbf',
  1534. tickColor: '#bfbfbf',
  1535. offset: 0,
  1536. visible: true,
  1537. gridLineWidth: 0,
  1538. tickPosition: 'inside',
  1539. endOnTick: false,
  1540. startOnTick: false,
  1541. showLastLabel: true,
  1542. tickPixelInterval: 50,
  1543. plotBands: setAxisPlotAreas(1),
  1544. plotLines: setAxisPlotLines(1)
  1545. }
  1546. //数据列
  1547. let series = {
  1548. data: [],
  1549. type: 'scatter',
  1550. name: `${ChartInfo.ChartName}${IsOrder ? '(逆序)' : ''}`,
  1551. nameZh:`${ChartInfo.ChartName}${IsOrder ? '(逆序)' : ''}`,
  1552. nameEn:ChartInfo.ChartNameEn?`${ChartInfo.ChartNameEn}${IsOrder ? '(reverse)' : ''}`:'',
  1553. color: ChartColor,
  1554. visible:true,
  1555. chartType: 'linear',
  1556. marker: {
  1557. radius: (chartTheme&&chartTheme.lineOptionList[0].radius)||5,
  1558. },
  1559. }
  1560. real_data.forEach(_ => {
  1561. series.data.push([_.x,_.y])
  1562. })
  1563. const textXZh = dataList[0].ConvertUnit||dataList[0].Unit
  1564. const textXEn = dataList[0].ConvertEnUnit||dataList[0].UnitEn||dataList[0].ConvertUnit||dataList[0].Unit
  1565. return {
  1566. title: {
  1567. text:''
  1568. },
  1569. series: [ series ],
  1570. yAxis,
  1571. xAxis: {
  1572. ...scatterXAxis,
  1573. title: {
  1574. text: `${textXZh}`,
  1575. textZh:textXZh,
  1576. textEn:textXZh?textXEn:'',
  1577. align: 'high',
  1578. rotation: 0,
  1579. x: 0,
  1580. offset: 20,
  1581. style: {
  1582. ...chartTheme&&chartTheme.xAxisOptions.style
  1583. },
  1584. },
  1585. labels: {
  1586. style: {
  1587. ...chartTheme&&chartTheme.xAxisOptions.style
  1588. }
  1589. },
  1590. },
  1591. tooltip
  1592. }
  1593. }
  1594. /* 奇怪柱形图 */
  1595. const barDateList = ref([]);//柱形图的绘图数据
  1596. const barXData = ref([]);//柱形图的x轴
  1597. const barEdbData = ref([]);//柱形图的表格数据 只用于取值
  1598. let axisLimitData={}
  1599. /* 奇怪柱状图 和其他逻辑无公用点 依赖数据为单独的数据
  1600. x轴为指标名称的柱形图 以日期作为series
  1601. */
  1602. function setBarChart (e){
  1603. let seriesData = [];
  1604. const data = _.cloneDeep(barDateList.value);
  1605. /* 主题样式*/
  1606. const chartTheme = e.ChartInfo.ChartThemeStyle ? JSON.parse(e.ChartInfo.ChartThemeStyle) : null;
  1607. //x轴
  1608. let xAxis = {
  1609. ...scatterXAxis,
  1610. categories: barXData.value,
  1611. tickWidth: 1,
  1612. labels: {
  1613. style: {
  1614. ...chartTheme&&chartTheme.xAxisOptions.style
  1615. }
  1616. }
  1617. }
  1618. const { leftMin,leftMax } = axisLimitState;
  1619. const textZh = e.ChartInfo?.Unit
  1620. const textEn = e.ChartInfo?.UnitEn||e.ChartInfo?.Unit
  1621. // console.log(leftMin,leftMax)
  1622. //y轴
  1623. let yAxis = {
  1624. ...basicYAxis,
  1625. title: {
  1626. text: textZh,
  1627. textZh: textZh,
  1628. textEn: textEn,
  1629. align: 'high',
  1630. rotation: 0,
  1631. y: -12,
  1632. x:0,
  1633. textAlign: 'left',
  1634. reserveSpace: false,
  1635. style:{
  1636. ...chartTheme&&chartTheme.yAxisOptions.style
  1637. },
  1638. },
  1639. labels: {
  1640. formatter: function (ctx) {
  1641. let val = ctx.value;
  1642. return val;
  1643. },
  1644. align: 'center',
  1645. style:{
  1646. ...chartTheme&&chartTheme.yAxisOptions.style
  1647. },
  1648. },
  1649. min: Number(leftMin),
  1650. max: Number(leftMax),
  1651. opposite: false,
  1652. tickWidth: 1,
  1653. plotBands: setAxisPlotAreas(1),
  1654. plotLines: setAxisPlotLines(1)
  1655. }
  1656. //数据列
  1657. data.forEach(item => {
  1658. let serie_item = {
  1659. data: item.Value,
  1660. type: 'column',
  1661. yAxis: 0,
  1662. name: item.Name || item.Date,
  1663. nameZh: item.Name || item.Date,
  1664. nameEn: item.Date,
  1665. color: item.Color,
  1666. chartType: 'linear',
  1667. visible:true,
  1668. };
  1669. seriesData.push(serie_item)
  1670. })
  1671. return {
  1672. title: {
  1673. text:''
  1674. },
  1675. plotOptions: {
  1676. column:{
  1677. stacking: null,
  1678. },
  1679. },
  1680. series: seriesData,
  1681. yAxis: [ yAxis ],
  1682. xAxis
  1683. }
  1684. }
  1685. /* 获取图表详情后赋值柱状图数据 */
  1686. function initBarData(data){
  1687. const { XEdbIdValue,YDataList,EdbInfoList,ChartInfo } = data;
  1688. let xData = XEdbIdValue.map(_ => EdbInfoList.find(edb => edb.EdbInfoId===_).EdbAliasName)
  1689. // console.log(xData)
  1690. axisLimitState.leftIndex=-1
  1691. axisLimitState.rightIndex=-1
  1692. axisLimitState.rightTwoIndex=-1
  1693. barDateList.value = YDataList;
  1694. barXData.value = xData;
  1695. barEdbData.value = EdbInfoList;
  1696. axisLimitState.hasLeftAxis=true
  1697. axisLimitState.leftMin=Number(ChartInfo.LeftMin)
  1698. axisLimitState.leftMax=Number(ChartInfo.LeftMax)
  1699. return setBarChart(data);
  1700. }
  1701. /* 商品价格曲线设置 绘图逻辑同奇怪柱形图*/
  1702. const commodityChartData = ref([]);//商品价格图的绘图数据
  1703. const commodityXData = ref([]);//商品价格图的x轴
  1704. const commodityEdbList = ref([]);//商品价格图的表格数据 只用于取值
  1705. /* 商品价格曲线设置 绘图逻辑同奇怪柱形图*/
  1706. const setCommodityChart = (leftMin,leftMax) => {
  1707. axisLimitState.leftIndex=-1
  1708. axisLimitState.rightIndex=-1
  1709. axisLimitState.rightTwoIndex=-1
  1710. /* 主题样式*/
  1711. const chartTheme = chartData.value.ChartInfo.ChartThemeStyle ? JSON.parse(chartData.value.ChartInfo.ChartThemeStyle) : null;
  1712. let seriesData = [];
  1713. const data = _.cloneDeep(commodityChartData.value);
  1714. console.log(data);
  1715. //x轴
  1716. let xAxis = {
  1717. ...scatterXAxis,
  1718. categories: commodityXData.value.map(_ => _.Name),
  1719. tickWidth: 1,
  1720. labels: {
  1721. style: {
  1722. ...chartTheme&&chartTheme.xAxisOptions.style
  1723. }
  1724. }
  1725. }
  1726. //y轴
  1727. let yAxis = {
  1728. ...basicYAxis,
  1729. title: {
  1730. text: commodityEdbList.value[0].Unit,
  1731. textZh: commodityEdbList.value[0].Unit,
  1732. textEn: commodityEdbList.value[0].Unit?(commodityEdbList.value[0].UnitEn||'英文单位'):'',
  1733. align: 'high',
  1734. rotation: 0,
  1735. y: -15,
  1736. textAlign: 'left',
  1737. reserveSpace: false,
  1738. style:{
  1739. ...chartTheme&&chartTheme.yAxisOptions.style
  1740. },
  1741. },
  1742. labels: {
  1743. formatter: function (ctx) {
  1744. let val = ctx.value;
  1745. return val;
  1746. },
  1747. align: 'center',
  1748. style:{
  1749. ...chartTheme&&chartTheme.yAxisOptions.style
  1750. },
  1751. },
  1752. min: Number(leftMin),
  1753. max: Number(leftMax),
  1754. opposite: false,
  1755. tickWidth: 1,
  1756. }
  1757. //数据列
  1758. data.forEach((item,index) => {
  1759. //处理首或/尾全是无效数据的以null填充
  1760. let filterData = filterInvalidData(item)
  1761. //图表可配置的线条数就10条,第11条用第1条的配置,索引取下模
  1762. const lineIndex = chartTheme ? index%chartTheme.lineOptionList.length : index
  1763. let serie_item = {
  1764. data: filterData,
  1765. type: (chartTheme&&chartTheme.lineOptionList[lineIndex].lineType) || 'spline',
  1766. dashStyle: (chartTheme&&chartTheme.lineOptionList[lineIndex].dashStyle)||'Solid',
  1767. yAxis: 0,
  1768. name: item.Name,
  1769. nameZh: item.Name,
  1770. nameEn: item.NameEn,
  1771. color: item.Color,
  1772. chartType: 'linear',
  1773. lineWidth: (chartTheme&&chartTheme.lineOptionList[lineIndex].lineWidth) || 3,
  1774. visible: true,
  1775. marker: {
  1776. enabled: false
  1777. }
  1778. };
  1779. seriesData.push(serie_item)
  1780. })
  1781. //tooltip
  1782. let tooltip = {
  1783. formatter: function() {
  1784. const ctx = this;
  1785. let str = '';
  1786. ctx.points.forEach(item => {
  1787. let obj_item = data.find(_ => _.Name === item.series.name);
  1788. let index = commodityXData.value.findIndex(_ => _.Name === ctx.x);
  1789. // 合约显示
  1790. const haveContract=obj_item.XEdbInfoIdList[index]
  1791. if(haveContract){
  1792. // 利润曲线指标名
  1793. let edb_name = chartData.value.ChartInfo.Source === 5
  1794. ? (index === 0 ? obj_item.NameList[index] : `${chartData.value.DataResp.ProfitName}(${obj_item.NameList[index]})`)
  1795. : commodityEdbList.value.find(_ => _.EdbInfoId === obj_item.XEdbInfoIdList[index]).EdbName;
  1796. str+=`<b>${ edb_name }</b>`
  1797. if(!obj_item.NoDataEdbList.includes(obj_item.XEdbInfoIdList[index])) {
  1798. str += `<br><span style="color:${item.color}">\u25CF</span>${obj_item.Date}: ${item.y}<br>`
  1799. }else {
  1800. str += `<br><span style="color:${item.color}">\u25CF</span>${obj_item.Date}: 无<br>`
  1801. }
  1802. }
  1803. })
  1804. return str||'无合约'
  1805. },
  1806. formatterCh: function() {
  1807. let str = '';
  1808. this.points.forEach(item => {
  1809. let obj_item = data.find(_ => _.Name === item.series.name);
  1810. let index = commodityXData.value.findIndex(_ => _.Name === this.x);
  1811. str+=`<b>${ commodityEdbList.value.find(_ => _.EdbInfoId === obj_item.XEdbInfoIdList[index]).EdbName }</b>`
  1812. if(!obj_item.NoDataEdbList.includes(obj_item.XEdbInfoIdList[index])) {
  1813. str += `<br><span style="color:${item.color}">\u25CF</span>${obj_item.Date}: ${item.y}<br>`
  1814. }else {
  1815. str += `<br><span style="color:${item.color}">\u25CF</span>${obj_item.Date}: 无<br>`
  1816. }
  1817. })
  1818. return str
  1819. },
  1820. formatterEn: function() {
  1821. let str = '';
  1822. this.points.forEach(item => {
  1823. let obj_item = data.find(_ => _.NameEn === item.series.name);
  1824. let index = commodityXData.value.findIndex(_ => _.NameEn === this.x);
  1825. str+=`<b>${ commodityEdbList.value.find(_ => _.EdbInfoId === obj_item.XEdbInfoIdList[index]).EdbNameEn }</b>`
  1826. if(!obj_item.NoDataEdbList.includes(obj_item.XEdbInfoIdList[index])) {
  1827. str += `<br><span style="color:${item.color}">\u25CF</span>${obj_item.Date}: ${item.y}<br>`
  1828. }else {
  1829. str += `<br><span style="color:${item.color}">\u25CF</span>${obj_item.Date}: 无<br>`
  1830. }
  1831. })
  1832. return str
  1833. },
  1834. shared: true
  1835. }
  1836. // console.log(seriesData);
  1837. return {
  1838. title: {
  1839. text:''
  1840. },
  1841. series: seriesData,
  1842. yAxis: [ yAxis ],
  1843. xAxis,
  1844. tooltip
  1845. }
  1846. };
  1847. /* 处理无效数据为null */
  1848. function filterInvalidData(item){
  1849. let validateArr = item.XEdbInfoIdList.filter(_ =>!item.NoDataEdbList.includes(_));
  1850. let first_index = item.XEdbInfoIdList.findIndex(_ => _ === validateArr[0]);
  1851. let last_index = item.XEdbInfoIdList.findIndex(_ => _ === validateArr[validateArr.length-1]);
  1852. // console.log('first_index',first_index)
  1853. // console.log('last_index',last_index)
  1854. let arr = item.Value.map((item,index) => {
  1855. if(index < first_index || index > last_index) {
  1856. return null
  1857. }else {
  1858. return item
  1859. }
  1860. })
  1861. return arr;
  1862. }
  1863. function initCommodityData(data){
  1864. const { XDataList,YDataList,EdbInfoList,ChartInfo,DataResp } = data;
  1865. commodityEdbList.value = EdbInfoList;
  1866. commodityChartData.value = ChartInfo.Source===5?DataResp.YDataList:YDataList
  1867. commodityXData.value = ChartInfo.Source===5?DataResp.XDataList:XDataList
  1868. axisLimitState.hasLeftAxis=true
  1869. axisLimitState.leftMin=Number(ChartInfo.LeftMin)
  1870. axisLimitState.leftMax=Number(ChartInfo.LeftMax)
  1871. return setCommodityChart(ChartInfo.LeftMin,ChartInfo.LeftMax);
  1872. }
  1873. //相关性图表
  1874. function initRelevanceChart(data){
  1875. /* 主题样式*/
  1876. const chartTheme = data.ChartInfo.ChartThemeStyle ? JSON.parse(data.ChartInfo.ChartThemeStyle) : null;
  1877. axisLimitState.leftIndex=-1
  1878. axisLimitState.rightIndex=-1
  1879. axisLimitState.rightTwoIndex=-1
  1880. // 处理X轴
  1881. let xAxis={
  1882. categories: data.ChartInfo.Source===3?data.XEdbIdValue:data.DataResp.XDateTimeValue,
  1883. tickWidth: 1,
  1884. title: {
  1885. text: data.ChartInfo.Source===3 ?`期数(${data.CorrelationChartInfo.LeadUnit})` : null,
  1886. textZh:data.ChartInfo.Source===3 ? `期数(${data.CorrelationChartInfo.LeadUnit})`:null,
  1887. textEn:data.ChartInfo.Source===3 ? `stage(${relevanceUnitEnMap[data.CorrelationChartInfo.LeadUnit]})`:null,
  1888. align: 'high',
  1889. rotation: 0,
  1890. x: 0,
  1891. y:10,
  1892. offset: 20,
  1893. style: {
  1894. ...chartTheme&&chartTheme.xAxisOptions.style
  1895. }
  1896. },
  1897. labels: {
  1898. style: {
  1899. ...chartTheme&&chartTheme.xAxisOptions.style
  1900. }
  1901. },
  1902. tickInterval: 1,
  1903. offset:0,
  1904. tickmarkPlacement:'on'
  1905. }
  1906. // 处理Y轴
  1907. let yAxis={
  1908. ...basicYAxis,
  1909. title: {
  1910. text: '相关性系数',
  1911. textZh: '相关性系数',
  1912. textEn: 'Correlation coefficient',
  1913. align: 'high',
  1914. rotation: 0,
  1915. y: -15,
  1916. textAlign: 'left',
  1917. reserveSpace: false,
  1918. style:{
  1919. ...chartTheme&&chartTheme.yAxisOptions.style
  1920. },
  1921. },
  1922. labels: {
  1923. formatter: function (ctx) {
  1924. let val = ctx.value;
  1925. return val;
  1926. },
  1927. align: 'center',
  1928. style:{
  1929. ...chartTheme&&chartTheme.yAxisOptions.style
  1930. },
  1931. },
  1932. opposite: false,
  1933. tickWidth: 1,
  1934. }
  1935. //处理series
  1936. let seriesData=[]
  1937. data.YDataList.forEach((item,index)=>{
  1938. //图表可配置的线条数就10条,第11条用第1条的配置,索引取下模
  1939. const lineIndex = chartTheme ? index%chartTheme.lineOptionList.length : index
  1940. let serie_item = {
  1941. data: item.Value,
  1942. type: (chartTheme&&chartTheme.lineOptionList[lineIndex].lineType) || 'spline',
  1943. dashStyle: (chartTheme&&chartTheme.lineOptionList[lineIndex].dashStyle)||'Solid',
  1944. yAxis: 0,
  1945. name: item.Name||data.ChartInfo.ChartName,
  1946. nameZh: item.Name||data.ChartInfo.ChartName,
  1947. nameEn: item.NameEn||data.ChartInfo.ChartNameEn,
  1948. color: item.Color,
  1949. chartType: 'linear',
  1950. lineWidth: (chartTheme&&chartTheme.lineOptionList[lineIndex].lineWidth) || 3,
  1951. visible:true,
  1952. marker: {
  1953. enabled: false
  1954. }
  1955. };
  1956. seriesData.push(serie_item)
  1957. })
  1958. const { LeadValue,LeadUnit } = data.CorrelationChartInfo;
  1959. const { Source } = data.ChartInfo;
  1960. let tooltip = {
  1961. formatter: function() {
  1962. let str = `<p>相关性系数:${this.y.toFixed(4)}</p><br><p>领先${ Source===3 ?this.x+'期' : LeadValue+LeadUnit}</p>`
  1963. return str
  1964. },
  1965. formatterCh: function() {
  1966. let str = `<p>相关性系数:${this.y.toFixed(4)}</p><br><p>领先${ Source===3 ?this.x+'期' : LeadValue+LeadUnit}</p>`
  1967. return str
  1968. },
  1969. formatterEn: function() {
  1970. let str = `<p>Correlation coefficient:${this.y.toFixed(4)}</p><br><p>lead${ Source===3 ? this.x+'stage' : LeadValue+relevanceUnitEnMap[LeadUnit]}</p>`
  1971. return str
  1972. }
  1973. }
  1974. nextTick(()=>{
  1975. // if(data.ChartInfo.Source===3){
  1976. // const hEl=document.getElementById(RenderDomId.value)
  1977. // // console.log(hEl.offsetHeight);
  1978. // xAxis.offset=-(hEl.offsetHeight-98)/2
  1979. // }
  1980. options.value = {
  1981. isRelevanceChart:data.ChartInfo.Source===3,
  1982. title: {
  1983. text:''
  1984. },
  1985. series: seriesData,
  1986. yAxis: [yAxis] ,
  1987. xAxis:xAxis,
  1988. tooltip
  1989. }
  1990. ChartIns.update(options.value,true)
  1991. })
  1992. return {
  1993. isRelevanceChart:true,
  1994. title: {
  1995. text:''
  1996. },
  1997. series: seriesData,
  1998. yAxis: [yAxis] ,
  1999. xAxis:xAxis,
  2000. tooltip
  2001. }
  2002. }
  2003. /* 截面散点图设置 sectionScatterData */
  2004. function setSectionScatterChart({DataResp,ChartInfo}) {
  2005. axisLimitState.leftIndex=-1
  2006. axisLimitState.rightIndex=-1
  2007. axisLimitState.rightTwoIndex=-1
  2008. /* 主题样式*/
  2009. const chartTheme = ChartInfo.ChartThemeStyle ? JSON.parse(ChartInfo.ChartThemeStyle) : null;
  2010. const { DataList,XName,XNameEn,XUnitName,XUnitNameEn,YName,YNameEn,YUnitName,YUnitNameEn } = DataResp;
  2011. const leftMin=Number(DataResp.YMinValue)
  2012. const leftMax=Number(DataResp.YMaxValue)
  2013. const xMin=Number(DataResp.XMinValue)
  2014. const xMax=Number(DataResp.XMaxValue)
  2015. axisLimitState.hasLeftAxis=true
  2016. axisLimitState.hasXAxis=true
  2017. axisLimitState.leftMin=leftMin
  2018. axisLimitState.leftMax=leftMax
  2019. axisLimitState.xMin=xMin
  2020. axisLimitState.xMax=xMax
  2021. //y轴
  2022. let yAxis = {
  2023. ...basicYAxis,
  2024. title: {
  2025. text: YName,
  2026. textZh:YName,// 中文
  2027. textEn:YNameEn|| '',
  2028. style:{
  2029. ...chartTheme&&chartTheme.yAxisOptions.style
  2030. },
  2031. align: 'middle',
  2032. },
  2033. labels: {
  2034. style:{
  2035. ...chartTheme&&chartTheme.yAxisOptions.style
  2036. },
  2037. },
  2038. opposite: false,
  2039. reversed: false,
  2040. min: Number(leftMin),
  2041. max: Number(leftMax),
  2042. tickWidth: 1,
  2043. plotBands: setAxisPlotAreas(1),
  2044. plotLines: setAxisPlotLines(1)
  2045. }
  2046. //x轴
  2047. let xAxis = {
  2048. ...scatterXAxis,
  2049. title: {
  2050. text: XName,
  2051. textZh:XName,// 中文
  2052. textEn:XNameEn || '',
  2053. style: {
  2054. ...chartTheme&&chartTheme.xAxisOptions.style
  2055. },
  2056. align: 'middle',
  2057. },
  2058. labels: {
  2059. style:{
  2060. ...chartTheme&&chartTheme.xAxisOptions.style
  2061. },
  2062. },
  2063. min: Number(xMin),
  2064. max: Number(xMax),
  2065. plotBands: setAxisPlotAreas(3),
  2066. plotLines: setAxisPlotLines(3)
  2067. }
  2068. //数据列
  2069. let series = [];
  2070. DataList.forEach((item,index) => {
  2071. //图表可配置的线条数就10条,第11条用第1条的配置,索引取下模
  2072. const lineIndex = chartTheme ? index%chartTheme.lineOptionList.length : index
  2073. //数据列
  2074. let series_item = {
  2075. data: [],
  2076. type: 'scatter',
  2077. name: item.Name,
  2078. nameZh: item.Name,
  2079. nameEn: item.NameEn,
  2080. color: item.Color,
  2081. lineWidth: 0,
  2082. chartType: 'linear',
  2083. zIndex:1,
  2084. visible: true,
  2085. marker: {
  2086. radius: (chartTheme&&chartTheme.lineOptionList[lineIndex].radius)||5,
  2087. },
  2088. }
  2089. item.EdbInfoList.forEach(_ => {
  2090. series_item.data.push({
  2091. x: _.XValue,
  2092. y: _.YValue,
  2093. dataLabels: {
  2094. enabled: _.IsShow,
  2095. allowOverlap: true,
  2096. align: 'left',
  2097. format: _.Name,
  2098. formatZh: _.Name,
  2099. formatEn: _.NameEn
  2100. }
  2101. })
  2102. })
  2103. series.push(series_item);
  2104. //趋势线
  2105. if(item.ShowTrendLine) {
  2106. let trend_data = item.TrendLimitData.map((_,_index) => (
  2107. _index === item.TrendLimitData.length-1 ? {
  2108. x: _.X,
  2109. y: _.Y,
  2110. dataLabels: {
  2111. enabled: item.ShowRSquare || item.ShowFitEquation,
  2112. align: 'left',
  2113. color: item.Color,
  2114. x: 20,
  2115. y: 30,
  2116. zIndex: 9,
  2117. allowOverlap: true,
  2118. formatter: function(){
  2119. let tag = '';
  2120. item.ShowRSquare && item.ShowFitEquation
  2121. ? tag =`<span>${item.TrendLine}</span><br><span>R²=${item.RSquare}</span>`
  2122. : item.ShowRSquare && !item.ShowFitEquation
  2123. ? tag =`<span>R²=${item.RSquare}</span>`
  2124. : item.ShowFitEquation && !item.ShowRSquare
  2125. ? tag =`<span>${item.TrendLine}</span>`
  2126. : ''
  2127. return tag
  2128. }
  2129. }
  2130. } : {
  2131. x: _.X,
  2132. y: _.Y,
  2133. }
  2134. ))
  2135. let trend_item = {
  2136. data: trend_data,
  2137. type: 'spline',
  2138. linkedTo: ':previous',
  2139. color: item.Color,
  2140. lineWidth: 1,
  2141. chartType: 'linear',
  2142. enableMouseTracking: false,
  2143. dashStyle:'Dash',
  2144. zIndex: 2,
  2145. visible: true,
  2146. marker: {
  2147. enabled: false
  2148. }
  2149. }
  2150. series.push(trend_item)
  2151. }
  2152. })
  2153. let tooltip = {
  2154. formatter: function() {
  2155. let series_obj = DataList.find(_ => _.Name === this.series.name);
  2156. let ponit_obj = series_obj.EdbInfoList.find(_ => _.XValue ===this.x && _.YValue===this.y);
  2157. let str=`<b>${ ponit_obj.Name }</b>`;
  2158. str += `<br><span style="color:${this.color}">\u25CF</span>${ponit_obj.XName}: ${this.x} ${ponit_obj.XDate}<br>`;
  2159. str += `<span style="color:${this.color}">\u25CF</span>${ponit_obj.YName}: ${this.y} (${ponit_obj.YDate})`;
  2160. return str
  2161. },
  2162. formatterCh: function() {
  2163. let series_obj = DataList.find(_ => _.Name === this.series.name);
  2164. let ponit_obj = series_obj.EdbInfoList.find(_ => _.XValue ===this.x && _.YValue===this.y);
  2165. let str=`<b>${ ponit_obj.Name }</b>`;
  2166. str += `<br><span style="color:${this.color}">\u25CF</span>${ponit_obj.XName}: ${this.x} ${ponit_obj.XDate}<br>`;
  2167. str += `<span style="color:${this.color}">\u25CF</span>${ponit_obj.YName}: ${this.y} (${ponit_obj.YDate})`;
  2168. return str
  2169. },
  2170. formatterEn: function() {
  2171. let series_obj = DataList.find(_ => _.NameEn === this.series.name);
  2172. let ponit_obj = series_obj.EdbInfoList.find(_ => _.XValue ===this.x && _.YValue===this.y);
  2173. let str=`<b>${ ponit_obj.NameEn }</b>`;
  2174. str += `<br><span style="color:${this.color}">\u25CF</span>${ponit_obj.XNameEn}: ${this.x} ${ponit_obj.XDate}<br>`;
  2175. str += `<span style="color:${this.color}">\u25CF</span>${ponit_obj.YNameEn}: ${this.y} ${ponit_obj.YDate}`;
  2176. return str
  2177. }
  2178. }
  2179. return {
  2180. title: {
  2181. text:''
  2182. },
  2183. series,
  2184. yAxis: [yAxis],
  2185. xAxis,
  2186. tooltip
  2187. }
  2188. }
  2189. /* 跨品种分析 */
  2190. function setCrossVarietyChart({DataResp,EdbInfoList,ChartInfo}) {
  2191. axisLimitState.leftIndex=-1
  2192. axisLimitState.rightIndex=-1
  2193. axisLimitState.rightTwoIndex=-1
  2194. /* 主题样式*/
  2195. const chartTheme = ChartInfo.ChartThemeStyle ? JSON.parse(ChartInfo.ChartThemeStyle) : null;
  2196. const { DataList,XName,YName,XNameEn,YNameEn,XMaxValue,XMinValue,YMaxValue,YMinValue } = DataResp;
  2197. const {leftMin,leftMax,xMin,xMax} = axisLimitState;
  2198. //y轴
  2199. let yAxis = {
  2200. ...basicYAxis,
  2201. title: {
  2202. text: YName,
  2203. textCh:YName,// 中文
  2204. textEn:YNameEn||YName,
  2205. align: 'middle',
  2206. style: {
  2207. ...chartTheme&&chartTheme.xAxisOptions.style
  2208. }
  2209. },
  2210. labels: {
  2211. style: {
  2212. ...chartTheme&&chartTheme.xAxisOptions.style
  2213. }
  2214. },
  2215. opposite: false,
  2216. reversed: false,
  2217. min: Number(leftMin),
  2218. max: Number(leftMax),
  2219. tickWidth: 1,
  2220. }
  2221. // x轴
  2222. let xAxis = {
  2223. ...scatterXAxis,
  2224. title: {
  2225. text: XName,
  2226. textCh:XName,// 中文
  2227. textEn:XNameEn || XName,
  2228. align: 'middle',
  2229. style: {
  2230. ...chartTheme&&chartTheme.xAxisOptions.style
  2231. }
  2232. },
  2233. labels: {
  2234. style: {
  2235. ...chartTheme&&chartTheme.xAxisOptions.style
  2236. }
  2237. },
  2238. min: Number(xMin),
  2239. max: Number(xMax),
  2240. }
  2241. //数据列
  2242. let series = [];
  2243. const tagMap = { //标签对应文字
  2244. 1: '最新',
  2245. 3: 'Fix'
  2246. }
  2247. DataList.forEach(item => {
  2248. //数据列
  2249. let series_item = {
  2250. data: [],
  2251. type: 'scatter',
  2252. name: item.Name,
  2253. nameZh: item.Name,
  2254. nameEn: item.NameEn||item.Name,
  2255. color: item.Color,
  2256. lineWidth: 0,
  2257. chartType: 'linear',
  2258. zIndex:1
  2259. }
  2260. item.CoordinatePointData.forEach(_ => {
  2261. series_item.data.push({
  2262. x: _.X,
  2263. y: _.Y,
  2264. dataLabels: {
  2265. enabled: _.ShowTips===1,
  2266. allowOverlap: true,
  2267. align: 'left',
  2268. format: tagMap[_.DateType] || `-${_.DaysAgo}D`,
  2269. }
  2270. })
  2271. })
  2272. series.push(series_item);
  2273. })
  2274. let tooltip = {
  2275. formatter: function() {
  2276. let series_obj = DataList.find(_ => _.Name === this.series.name);
  2277. let ponit_obj = series_obj.CoordinatePointData.find(_ => _.X ===this.x && _.Y===this.y);
  2278. let xEdbInfo = EdbInfoList.find(_ => _.EdbInfoId===ponit_obj.XEdbInfoId);
  2279. let yEdbInfo = EdbInfoList.find(_ => _.EdbInfoId===ponit_obj.YEdbInfoId);
  2280. let str=`<b>${ this.series.name }</b>`;
  2281. str += `<br><span style="color:${this.color}">\u25CF</span>${xEdbInfo.EdbName}: ${this.x} ${ponit_obj.XDate}<br>`;
  2282. str += `<span style="color:${this.color}">\u25CF</span>${yEdbInfo.EdbName}: ${this.y} ${ponit_obj.YDate}`;
  2283. return str
  2284. },
  2285. formatterCh: function() {
  2286. let series_obj = DataList.find(_ => _.Name === this.series.name);
  2287. let ponit_obj = series_obj.CoordinatePointData.find(_ => _.X ===this.x && _.Y===this.y);
  2288. let xEdbInfo = EdbInfoList.find(_ => _.EdbInfoId===ponit_obj.XEdbInfoId);
  2289. let yEdbInfo = EdbInfoList.find(_ => _.EdbInfoId===ponit_obj.YEdbInfoId);
  2290. let str=`<b>${ this.series.name }</b>`;
  2291. str += `<br><span style="color:${this.color}">\u25CF</span>${xEdbInfo.EdbName}: ${this.x} ${ponit_obj.XDate}<br>`;
  2292. str += `<span style="color:${this.color}">\u25CF</span>${yEdbInfo.EdbName}: ${this.y} ${ponit_obj.YDate}`;
  2293. return str
  2294. },
  2295. formatterEn: function() {
  2296. let series_obj = DataList.find(_ => _.NameEn === this.series.name);
  2297. let ponit_obj = series_obj.CoordinatePointData.find(_ => _.X ===this.x && _.Y===this.y);
  2298. let xEdbInfo = EdbInfoList.find(_ => _.EdbInfoId===ponit_obj.XEdbInfoId);
  2299. let yEdbInfo = EdbInfoList.find(_ => _.EdbInfoId===ponit_obj.YEdbInfoId);
  2300. let str=`<b>${ this.series.name }</b>`;
  2301. str += `<br><span style="color:${this.color}">\u25CF</span>${xEdbInfo.EdbNameEn}: ${this.x} ${ponit_obj.XDate}<br>`;
  2302. str += `<span style="color:${this.color}">\u25CF</span>${yEdbInfo.EdbNameEn}: ${this.y} ${ponit_obj.YDate}`;
  2303. return str
  2304. }
  2305. }
  2306. return {
  2307. title: {
  2308. text:''
  2309. },
  2310. series,
  2311. yAxis: [yAxis],
  2312. xAxis,
  2313. tooltip
  2314. }
  2315. }
  2316. /* 雷达图 */
  2317. function setRadarChart({DataResp,EdbInfoList,ChartInfo}) {
  2318. axisLimitState.leftIndex=-1
  2319. axisLimitState.rightIndex=-1
  2320. axisLimitState.rightTwoIndex=-1
  2321. const { YDataList,XEdbIdValue } = DataResp;
  2322. let XDataList = EdbInfoList.filter(_ => XEdbIdValue.includes(_.EdbInfoId));
  2323. axisLimitState.hasLeftAxis=true
  2324. axisLimitState.leftMin=Number(ChartInfo.LeftMin)
  2325. axisLimitState.leftMax=Number(ChartInfo.LeftMax)
  2326. /* 主题样式*/
  2327. const chartTheme = ChartInfo.ChartThemeStyle ? JSON.parse(ChartInfo.ChartThemeStyle) : null;
  2328. //x轴
  2329. let xAxis = {
  2330. lineWidth: 0,
  2331. tickLength: 0,
  2332. tickmarkPlacement: 'on',
  2333. categories:XDataList.map(_ => _.EdbAliasName||_.EdbName),
  2334. labels: {
  2335. allowOverlap: true,
  2336. autoRotationLimit: 40,
  2337. style: {
  2338. ...chartTheme&&chartTheme.xAxisOptions.style
  2339. }
  2340. }
  2341. }
  2342. //y轴
  2343. let yAxis = [{
  2344. gridLineInterpolation: 'polygon',
  2345. gridLineWidth: 1,
  2346. lineWidth: 0,
  2347. endOnTick: false,
  2348. startOnTick: false,
  2349. showLastLabel: true,
  2350. // tickAmount:4,
  2351. title: {
  2352. text: ChartInfo.Unit,
  2353. textCh: ChartInfo.Unit,
  2354. textEn: ChartInfo.UnitEn,
  2355. align: 'high',
  2356. rotation: 0,
  2357. y: 5,
  2358. x:10,
  2359. textAlign: 'left',
  2360. reserveSpace: false,
  2361. style:{
  2362. ...chartTheme&&chartTheme.yAxisOptions.style
  2363. },
  2364. },
  2365. labels: {
  2366. allowOverlap: true,
  2367. style:{
  2368. ...chartTheme&&chartTheme.yAxisOptions.style
  2369. }
  2370. },
  2371. min: Number(ChartInfo.LeftMin),
  2372. max: Number(ChartInfo.LeftMax),
  2373. }]
  2374. //系列
  2375. let series = [];
  2376. YDataList.forEach((item,index) => {
  2377. //图表可配置的线条数就10条,第11条用第1条的配置,索引取下模
  2378. const lineIndex = chartTheme ? index%chartTheme.lineOptionList.length : index
  2379. let serie_item = {
  2380. name: item.Name || item.Date,
  2381. nameZh: item.Name || item.Date,
  2382. nameEn: item.Date,
  2383. data: item.Value,
  2384. pointPlacement: 'on',
  2385. type: (chartTheme&&chartTheme.lineOptionList[lineIndex].lineType) || 'line',
  2386. dashStyle: (chartTheme&&chartTheme.lineOptionList[lineIndex].dashStyle)||'Solid',
  2387. yAxis: 0,
  2388. color: item.Color,
  2389. lineWidth: (chartTheme&&chartTheme.lineOptionList[lineIndex].lineWidth) || 1,
  2390. chartType: 'linear'
  2391. };
  2392. series.push(serie_item)
  2393. })
  2394. return {
  2395. chart: {
  2396. ...chartDefaultOpts.chart,
  2397. ...chartTheme?.drawOption,
  2398. spacing: [2,10,2,10],
  2399. polar:true,
  2400. },
  2401. title: {
  2402. text:''
  2403. },
  2404. pane: {
  2405. size: '85%'
  2406. },
  2407. series,
  2408. yAxis,
  2409. xAxis
  2410. }
  2411. }
  2412. //获取RGBA的透明度
  2413. function parseRgbaColor(color='rgba(51, 51, 51, 1)'){
  2414. const arr = color.match(/(\d(\.\d+)?)+/g) || ['','','',1];
  2415. return parseFloat(arr[3]||1)
  2416. }
  2417. /* ----自定义上下限相关--- */
  2418. /* 计算y轴上下限 */
  2419. function calcYAxislimit(tableData=[],ChartInfo,DataResp={}){
  2420. //散点图单独处理
  2421. if(ChartInfo.ChartType===5){
  2422. if(tableData[1]){
  2423. axisLimitState.leftMin = tableData[1].MinData
  2424. axisLimitState.leftMax = tableData[1].MaxData
  2425. }
  2426. return
  2427. }
  2428. //分组
  2429. const leftData = tableData.filter(i => i.IsAxis === 1).map(i => [Number(i.MinData), Number(i.MaxData)])
  2430. const rightData = tableData.filter(i => !i.IsAxis).map(i => [Number(i.MinData), Number(i.MaxData)])
  2431. const rightTwoData = tableData.filter(i => i.IsAxis === 2).map(i => [Number(i.MinData), Number(i.MaxData)])
  2432. //计算最大最小值
  2433. if (leftData.length) {
  2434. const {
  2435. Max,
  2436. Min
  2437. } = calcLimit(leftData.flat())
  2438. axisLimitState.leftMin = Min
  2439. axisLimitState.leftMax = Max
  2440. }
  2441. if (rightData.length) {
  2442. const {
  2443. Max,
  2444. Min
  2445. } = calcLimit(rightData.flat())
  2446. axisLimitState.rightMin = Min
  2447. axisLimitState.rightMax = Max
  2448. }
  2449. if (rightTwoData.length) {
  2450. const {
  2451. Max,
  2452. Min
  2453. } = calcLimit(rightTwoData.flat())
  2454. axisLimitState.rightTwoMin = Min
  2455. axisLimitState.rightTwoMax = Max
  2456. }
  2457. //季节性图-右轴单独处理
  2458. if(ChartInfo.ChartType===2){
  2459. if(DataResp.RightAxis&&DataResp.RightAxis.IsAdd&&DataResp.RightAxis.IsShow){
  2460. if(DataResp.RightAxis.IndicatorType===1){
  2461. axisLimitState.rightMin = DataResp.RightAxis.EdbInfoList[0].MinData||0
  2462. axisLimitState.rightMax = DataResp.RightAxis.EdbInfoList[0].MaxData||0
  2463. }else{
  2464. axisLimitState.rightMin = tableData[1].MinData||0
  2465. axisLimitState.rightMax = tableData[1].MaxData||0
  2466. }
  2467. }
  2468. }
  2469. }
  2470. function calcLimit(arr) {
  2471. return {
  2472. Max: Math.max(...arr),
  2473. Min: Math.min(...arr)
  2474. }
  2475. }
  2476. //图表详情-设置图表上下限
  2477. function setLimitData({EdbInfoList,ChartInfo,DataResp}){
  2478. const {
  2479. //左右轴极值字段
  2480. LeftMin=0,LeftMax=0,
  2481. RightMin=0,RightMax=0,
  2482. Right2Min=0,Right2Max=0,
  2483. MinMaxSave
  2484. } = ChartInfo
  2485. if(MinMaxSave){
  2486. axisLimitState.leftMin = Number(LeftMin)
  2487. axisLimitState.leftMax = Number(LeftMax)
  2488. axisLimitState.rightMin = Number(RightMin)
  2489. axisLimitState.rightMax = Number(RightMax)
  2490. axisLimitState.rightTwoMin = Number(Right2Min)
  2491. axisLimitState.rightTwoMax = Number(Right2Max)
  2492. //若用户修改过,则检测轴的上下限是否为空,若为空,则需要计算对应轴的上下限
  2493. checkLimit(EdbInfoList,ChartInfo)
  2494. console.log('check',axisLimitState.leftMin,axisLimitState.leftMax)
  2495. }else{
  2496. calcYAxislimit(EdbInfoList,ChartInfo,DataResp?DataResp:{})
  2497. }
  2498. }
  2499. function checkLimit(tableData=[],ChartInfo){
  2500. //散点图单独处理
  2501. if(ChartInfo.ChartType===5){
  2502. if(tableData[1]){
  2503. if(Number(axisLimitState.leftMin)===0&&Number(axisLimitState.leftMax)===0){
  2504. axisLimitState.leftMin = tableData[1].MinData
  2505. axisLimitState.leftMax = tableData[1].MaxData
  2506. }
  2507. }
  2508. return
  2509. }
  2510. //若轴的上下限均为0,则不管用户有没有修改过,都重新赋值
  2511. if(Number(axisLimitState.leftMin)===0&&Number(axisLimitState.leftMax)===0){
  2512. const leftData = tableData.filter(i=>i.IsAxis===1).map(i=>[Number(i.MinData),Number(i.MaxData)])
  2513. if(leftData.length){
  2514. const {Max,Min} = calcLimit(leftData.flat())
  2515. axisLimitState.leftMin = Min
  2516. axisLimitState.leftMax = Max
  2517. }
  2518. }
  2519. if(Number(axisLimitState.rightMin)===0&&Number(axisLimitState.rightMax)===0){
  2520. const rightData = tableData.filter(i => !i.IsAxis).map(i=>[Number(i.MinData),Number(i.MaxData)])
  2521. if(rightData.length){
  2522. const {Max,Min} = calcLimit(rightData.flat())
  2523. axisLimitState.rightMin = Min
  2524. axisLimitState.rightMax = Max
  2525. }
  2526. }
  2527. if(Number(axisLimitState.rightTwoMin)===0&&Number(axisLimitState.rightTwoMax)===0){
  2528. const rightTwoData = tableData.filter(i=>i.IsAxis===2).map(i=>[Number(i.MinData),Number(i.MaxData)])
  2529. if(rightTwoData.length){
  2530. const {Max,Min} = calcLimit(rightTwoData.flat())
  2531. axisLimitState.rightTwoMin = Min
  2532. axisLimitState.rightTwoMax = Max
  2533. }
  2534. }
  2535. }
  2536. /*-------------------- */