render.js 96 KB

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