chartTrendRender.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849
  1. <template>
  2. <div class="chart-trend-render">
  3. <div class="header">
  4. <template v-if="chart_type===1">
  5. <el-button
  6. type="primary"
  7. v-for="item in yearSelector"
  8. :key="item.value"
  9. size="mini"
  10. :plain="item.value !== year_select"
  11. class="year-btn"
  12. @click.native="changeYear(item)"
  13. >{{ item.name }}</el-button
  14. >
  15. <el-button type="primary" plain size="mini" class="btn-sty" @click="openDateDia">{{
  16. dateTip
  17. }}</el-button>
  18. <el-button type="primary" plain size="mini" class="btn-sty" @click="showOnChart('toggle')" v-if="!isOnlyShowBaseChart&&isShowChartBasis">
  19. <!-- <i class="el-icon-view"></i> -->
  20. {{ isShowOnyearData ? '隐藏同比图' : '展示同比图'}}
  21. </el-button>
  22. </template>
  23. <!-- 季节图时间选择 -->
  24. <!-- <template v-else-if="chart_type===2">
  25. <date-picker
  26. v-model="season_year"
  27. type="month"
  28. value-type="format"
  29. range
  30. placeholder="年份日期选择"
  31. @change="getDataByPath"
  32. />
  33. </template> -->
  34. <div v-else-if="chart_type === 2" @click="openDateDia" class="date-setting">
  35. {{ season_year && season_year.length>0 ? season_year[0]+'~'+season_year[1]:"年份日期选择" }}
  36. </div>
  37. <el-button type="primary" plain size="mini" class="btn-sty" style="margin-left:auto;"
  38. @click="chartTypeChange" v-if="!isOnlyShowBaseChart&&isAllowSwitchSeason">
  39. <i class="el-icon-sort" style="transform: rotate(90deg);"></i>
  40. 切换{{chart_type==1?'季节性图':'曲线图'}}
  41. </el-button>
  42. </div>
  43. <div class="min-wrapper">
  44. <div class="chartWrapper" id="chartWrapper" v-if="showChart">
  45. <Chart :options="options" ref="chartRef" @clickYAxisTitle="clickYAxisTitle"/>
  46. <div class="range-cont left" v-if="leftIndex != -1">
  47. <el-input
  48. style="width: 80px; display: block"
  49. size="mini"
  50. type="number"
  51. placeholder="上限"
  52. :disabled="!isAllowEditLimit"
  53. v-model="chartInfo.MaxValue"
  54. @change="() => { chart_type===1?setOptions():setSeasonOptions() }"
  55. />
  56. <el-input
  57. class="min-data-input"
  58. size="mini"
  59. type="number"
  60. placeholder="下限"
  61. :disabled="!isAllowEditLimit"
  62. v-model="chartInfo.MinValue"
  63. @change="() => { chart_type===1?setOptions():setSeasonOptions() }"
  64. />
  65. </div>
  66. <div class="range-cont right" v-if="isShowOnyearData">
  67. <el-input
  68. style="width: 80px; display: block"
  69. size="mini"
  70. type="number"
  71. placeholder="上限"
  72. v-model="limitData.rightMax"
  73. :disabled="!isAllowEditLimit"
  74. @change="changeLimit"
  75. />
  76. <el-input
  77. class="min-data-input"
  78. size="mini"
  79. type="number"
  80. placeholder="下限"
  81. v-model="limitData.rightMin"
  82. :disabled="!isAllowEditLimit"
  83. @change="changeLimit"
  84. />
  85. </div>
  86. <!-- 公历农历切换 只用于季节性图 -->
  87. <div style="text-align:center;">
  88. <el-radio-group
  89. v-model="calendar_type"
  90. class="calendar-cont"
  91. v-if="chart_type===2"
  92. @change="getDataByPath"
  93. >
  94. <el-radio-button label="公历" />
  95. <el-radio-button label="农历" />
  96. </el-radio-group>
  97. </div>
  98. </div>
  99. </div>
  100. <div class="table-data">
  101. </div>
  102. <!-- 自定义时间段选择弹窗 -->
  103. <DateChooseDia
  104. :isDateDia="isDateDia"
  105. :dateForm="dateForm"
  106. @cancel="isDateDia = false"
  107. @dateBack="dataChangeBack"
  108. />
  109. </div>
  110. </template>
  111. <script>
  112. import { dataBaseInterface } from '@/api/api.js';
  113. import * as supplyApi from '@/api/modules/supplyApi.js';
  114. import { yearSelector,defaultOpts,seasonOptions } from '@/utils/defaultOptions'
  115. import Chart from '../components/chart'
  116. import DateChooseDia from '../components/DateChooseDia';
  117. import Highcharts from 'highcharts'
  118. export default {
  119. components: { Chart,DateChooseDia },
  120. props: {
  121. edbid: {
  122. type: Number,
  123. },
  124. // 语言 ch/en
  125. chartLang:{
  126. type: String,
  127. default:()=> 'ch'
  128. },
  129. isShowChartBasis:{
  130. type:Boolean,
  131. default:false
  132. },
  133. isAllowSwitchSeason:{
  134. type:Boolean,
  135. default:false
  136. },
  137. isAllowEditLimit:{
  138. type:Boolean,
  139. default:false
  140. }
  141. },
  142. computed: {
  143. // 同比,环比,环差,超季节性、 残差展示基础图
  144. isOnlyShowBaseChart() {
  145. return [6,12,13,35,37].includes(this.chartInfo.Source)
  146. }
  147. },
  148. watch: {
  149. edbid:{
  150. handler(newVal){
  151. if(newVal){
  152. this.init()
  153. this.chart_type = 1
  154. this.isShowOnyearData = false
  155. this.getDataByPath()
  156. }
  157. },
  158. immediate:true
  159. }
  160. },
  161. data () {
  162. return {
  163. year_select: 10, //年份选择项 默认全部
  164. yearSelector: [
  165. {
  166. name: '全部',
  167. value: 10,
  168. },
  169. ...yearSelector,
  170. ],
  171. select_date: [], // 自定义时间段项
  172. options: {},
  173. showChart: false,
  174. chart_type: 1,// 1曲线 2季节
  175. isShowOnyearData: false, //是否展示同比
  176. chartInfo: {},
  177. dataList: [],
  178. leftIndex: 0,
  179. season_year:[],//季节图日期选择
  180. calendar_type:'公历',
  181. /* 日期弹窗 */
  182. isDateDia: false, // 时间段弹窗
  183. dateForm: {},
  184. dateTip: '请选择时间段',
  185. limitData: {
  186. letMin: 0,
  187. leftMax: 0,
  188. rightMin: 0,
  189. rightMax: 0,
  190. },
  191. oldOptions: {
  192. MinValue: 0,
  193. MaxValue: 0
  194. },
  195. // 最近几年
  196. count_year:'',
  197. };
  198. },
  199. methods: {
  200. getDataByPath() {
  201. const apiMap = {
  202. '/database': this.getEdbData,
  203. '/analyseVariety': this.getPlantEdbData
  204. }
  205. apiMap[this.$route.path]()
  206. },
  207. /* 获取指标所有数据 */
  208. async getEdbData() {
  209. let params = {
  210. EdbInfoId: this.edbid,
  211. DateType: this.year_select,
  212. StartYear:this.count_year || 0,
  213. StartDate: this.select_date[0] || '',
  214. EndDate: this.select_date[1] || ''
  215. }
  216. const res = this.chart_type === 1
  217. ? await dataBaseInterface.ebd_data(params)
  218. : await dataBaseInterface.ebdSeasonData({
  219. EdbInfoId: this.edbid,
  220. DateType: this.year_select,
  221. Calendar: this.calendar_type,
  222. StartYear:this.count_year || 0,
  223. StartDate: this.season_year[0] || '',
  224. EndDate: this.season_year[1] || '',
  225. })
  226. if(res.Ret !== 200) return
  227. const { DataList,EdbInfo } = res.Data;
  228. // DataList 表格数据列表
  229. this.chartInfo = (this.oldOptions.MinValue || this.oldOptions.MaxValue) ? {
  230. ...EdbInfo,
  231. ...this.oldOptions
  232. } : EdbInfo;
  233. this.tableData = DataList || [];
  234. if(this.chart_type==2 && !(this.season_year && this.season_year.length>0)){
  235. // 第一次进行初始化显示
  236. let latestYear = parseInt(this.chartInfo.LatestDate.substring(0,4))
  237. this.season_year = [`${latestYear-this.count_year+1}-01-01`,`${latestYear}-12-31`];
  238. }
  239. this.chart_type === 1 ? this.setOptions() : this.setSeasonOptions();
  240. this.showChart = true;
  241. this.$nextTick(()=>{
  242. if(!EdbInfo.ChartImage){
  243. //设置图表缩略图
  244. this.saveEdbImg(EdbInfo)
  245. }
  246. })
  247. },
  248. //保存指标缩略图
  249. async saveEdbImg(EdbInfo){
  250. let svg = this.$refs.chartRef.chart.getSVG({
  251. chart: {
  252. width: 340,
  253. height: 230,
  254. },
  255. });
  256. let form = new FormData();
  257. form.append("Img", svg);
  258. let { Data } = await dataBaseInterface.uploadImgSvg(form);
  259. await dataBaseInterface.saveEdbChartImg({
  260. EdbInfoId: EdbInfo.EdbInfoId,
  261. ImageUrl: Data.ResourceUrl,
  262. });
  263. },
  264. /* 获取装置指标数据 */
  265. async getPlantEdbData() {
  266. let params = {
  267. VarietyEdbId: this.edbid,
  268. DateType: this.year_select,
  269. StartYear:this.count_year || 0,
  270. StartDate: this.select_date[0] || '',
  271. EndDate: this.select_date[1] || ''
  272. }
  273. const res = this.chart_type === 1
  274. ? await supplyApi.getEdbDetailData(params)
  275. : await supplyApi.getEdbSeasonData({
  276. VarietyEdbId: this.edbid,
  277. DateType: this.year_select,
  278. Calendar: this.calendar_type,
  279. StartYear:this.count_year || 0,
  280. StartDate: this.season_year[0] || '',
  281. EndDate: this.season_year[1] || '',
  282. })
  283. if(res.Ret !== 200) return
  284. const { DataList,EdbInfo } = res.Data;
  285. // DataList 表格数据列表
  286. this.chartInfo = (this.oldOptions.MinValue || this.oldOptions.MinValue) ? {
  287. ...EdbInfo,
  288. ...this.oldOptions
  289. } : EdbInfo;
  290. this.tableData = DataList || [];
  291. if(this.chart_type==2 && !(this.season_year && this.season_year.length>0)){
  292. // 第一次进行初始化显示
  293. let latestYear = parseInt(this.chartInfo.LatestDate.substring(0,4))
  294. this.season_year = [`${latestYear-this.count_year+1}-01-01`,`${latestYear}-12-31`];
  295. }
  296. this.chart_type === 1 ? this.setOptions() : this.setSeasonOptions();
  297. this.showChart = true;
  298. },
  299. /* 年份改变 重新刷新图表接口 保存当前的图表配置和上下限 只改变图表 */
  300. changeYear(item) {
  301. this.year_select = item.value;
  302. this.select_date = [];
  303. this.dateTip = '请选择时间段';
  304. const { MinValue,MaxValue } = this.chartInfo;
  305. this.oldOptions = {
  306. MinValue: Number(MinValue),
  307. MaxValue: Number(MaxValue)
  308. }
  309. this.getDataByPath()
  310. },
  311. /* 打开时间段弹窗 */
  312. openDateDia() {
  313. // 自定义时间段回显
  314. let selectDateStart = this.chart_type === 2?this.season_year[0]:this.select_date[0]
  315. let selectDateEnd = this.chart_type === 2?this.season_year[1]:this.select_date[1]
  316. this.dateForm = {
  317. date_type: this.year_select,
  318. start_date:
  319. this.year_select === 5 || this.year_select === 6
  320. ? selectDateStart
  321. : '',
  322. end_date: this.year_select === 5 ? selectDateEnd : '',
  323. count_year: this.year_select === 20 ? this.count_year : ''
  324. };
  325. this.isDateDia = true;
  326. },
  327. /* 保存完自定义日期 刷新数据 保存当前的图表配置和上下限 只改变图表*/
  328. dataChangeBack(data) {
  329. this.year_select = data.dateType;
  330. this.isDateDia = false;
  331. this.select_date = [data.start_date, data.end_date];
  332. this.count_year = data.count_year
  333. this.dateTip =
  334. data.dateType === 5
  335. ? `${data.start_date}~${data.end_date}`
  336. : data.dateType === 6
  337. ?`${data.start_date}~至今`
  338. :`最近${this.count_year}年`
  339. if(this.chart_type === 2){
  340. let latestYear = parseInt(this.chartInfo.LatestDate.substring(0,4))
  341. let dateStart = data.start_date
  342. let dateEnd = data.end_date
  343. if(data.dateType==20){
  344. dateStart = `${latestYear-this.count_year+1}-01-01`
  345. dateEnd = `${latestYear}-12-31`
  346. }else if(data.dateType==6){
  347. dateEnd = this.chartInfo.LatestDate
  348. }
  349. this.season_year = [dateStart, dateEnd];
  350. }
  351. const { MinValue,MaxValue } = this.chartInfo;
  352. this.oldOptions = {
  353. MinValue,
  354. MaxValue
  355. }
  356. this.getDataByPath();
  357. },
  358. chartTypeChange() {
  359. this.chart_type = this.chart_type===1 ? 2 : 1;
  360. this.init('no_reset')
  361. this.getDataByPath();
  362. },
  363. // 展示同比图
  364. async showOnChart(scene='') {
  365. if(scene==='toggle') {
  366. this.isShowOnyearData = this.isShowOnyearData ? false : true;
  367. if(!this.isShowOnyearData){
  368. const { MinValue,MaxValue } = this.chartInfo;
  369. this.oldOptions = {
  370. MinValue: Number(MinValue),
  371. MaxValue: Number(MaxValue)
  372. }
  373. this.getDataByPath();
  374. }
  375. }
  376. if(!this.isShowOnyearData) return;
  377. let params = {
  378. DateType: this.year_select,
  379. StartDate: this.select_date[0] || '',
  380. EndDate: this.select_date[1] || ''
  381. }
  382. const res = this.$route.path === '/analyseVariety'
  383. ? await supplyApi.getEdbOnyearData({VarietyEdbId:this.edbid,...params})
  384. : await dataBaseInterface.edbOnyearData({EdbInfoId: this.edbid,...params});
  385. if(res.Ret !== 200) return
  386. const { EdbInfo,DataList } = res.Data;
  387. if(!this.limitData.rightMin && !this.limitData.rightMax) {
  388. this.limitData.rightMin = Number(EdbInfo.MinValue);
  389. this.limitData.rightMax = Number(EdbInfo.MaxValue);
  390. }
  391. this.options.yAxis.push({
  392. title: {
  393. text: '',
  394. align: 'high',
  395. rotation: 0,
  396. y: -15,
  397. offset: 0
  398. },
  399. labels: {
  400. formatter: function (ctx) {
  401. return ctx.value;
  402. },
  403. align: 'center',
  404. },
  405. min: Number(this.limitData.rightMin),
  406. max: Number(this.limitData.rightMax),
  407. ...seasonOptions.yAxis,
  408. opposite: true,
  409. })
  410. this.options.series.push({
  411. data: DataList.map(item=>([item.DataTimestamp, item.Value])),
  412. type: 'spline',
  413. yAxis: 1,
  414. name: this.chartLang=='ch'?`${EdbInfo.EdbName}同比`:EdbInfo.EdbNameEn?`${EdbInfo.EdbNameEn}同比`:'无英文名称',
  415. lineWidth: 1
  416. })
  417. console.log(this.options.series)
  418. },
  419. changeLimit() {
  420. const { rightMax,rightMin } = this.limitData;
  421. this.options.yAxis[1].max = Number(rightMax);
  422. this.options.yAxis[1].min = Number(rightMin);
  423. },
  424. /* 图表配置 曲线*/
  425. setOptions() {
  426. const chartData = _.cloneDeep(this.tableData);
  427. //拼接标题 数据列
  428. let data = [],
  429. ydata = [];
  430. //y轴
  431. // 单位 中文时 为无不显示 英文时 为空提示点击输入
  432. // 中文不存在或等于无时 英文显示为空 中文存在且英文不存在时 显示'英文单位'
  433. let yTitleText = this.chartLang=='ch'?
  434. (this.chartInfo.Unit && this.chartInfo.Unit!='无') ? this.chartInfo.Unit:'':
  435. !this.chartInfo.UnitEn && this.chartInfo.Unit && this.chartInfo.Unit!='无' ? '英文单位':this.chartInfo.UnitEn
  436. // title样式 英文为空时,提示文字样式 英文可以点击设置
  437. let yTitleStyle = {}
  438. if(this.chartLang=='en'){
  439. yTitleStyle.cursor='pointer'
  440. if(yTitleText=='英文单位'){
  441. yTitleStyle.color="#999"
  442. }
  443. }
  444. let yItem = {
  445. title: {
  446. text: yTitleText,
  447. align: 'high',
  448. rotation: 0,
  449. y: -15,
  450. offset: 0,
  451. style:yTitleStyle
  452. },
  453. labels: {
  454. formatter: function (ctx) {
  455. return ctx.value;
  456. },
  457. align: 'center',
  458. },
  459. min: Number(this.chartInfo.MinValue),
  460. max: Number(this.chartInfo.MaxValue),
  461. ...seasonOptions.yAxis,
  462. };
  463. // 图例名称和图例文字样式
  464. let dataName = this.chartLang=='ch'?this.chartInfo.EdbName:this.chartInfo.EdbNameEn?this.chartInfo.EdbNameEn:'无英文名称'
  465. let color = this.chartLang=='en'&&(!this.chartInfo.EdbNameEn)?'#999':'#333'
  466. let legend={
  467. ...defaultOpts.legend,
  468. itemStyle: {
  469. color
  470. },
  471. }
  472. //数据列
  473. let obj = {
  474. data: [],
  475. type: 'spline',
  476. yAxis: 0,
  477. name: dataName,
  478. lineWidth: 3
  479. };
  480. chartData.forEach((item, index) => {
  481. obj.data.push([item.DataTimestamp, item.Value]);
  482. });
  483. data.push(obj);
  484. ydata.push(yItem);
  485. // 范围为1年内 x轴显示为月/日 否则默认年/月
  486. let xAxis = {};
  487. const bool_time = this.xTimeDiffer();
  488. xAxis = bool_time
  489. ? {
  490. ...defaultOpts.xAxis,
  491. labels: {
  492. formatter: function (ctx) {
  493. return Highcharts.dateFormat('%m/%d', ctx.value);
  494. },
  495. },
  496. }
  497. : {
  498. ...defaultOpts.xAxis,
  499. labels: {
  500. formatter: function (ctx) {
  501. return Highcharts.dateFormat('%y/%m', ctx.value);
  502. },
  503. },
  504. };
  505. this.options = {
  506. series: data,
  507. yAxis: ydata,
  508. xAxis,
  509. legend
  510. };
  511. this.showOnChart();
  512. },
  513. /* 季节图 */
  514. setSeasonOptions() {
  515. console.log(this.tableData)
  516. const chartData = _.cloneDeep(this.tableData);
  517. let seasonYdata = [],
  518. seasonData = [];
  519. /* 公历数据处理 处理数据列 y轴 */
  520. if (this.calendar_type === '公历')
  521. for (let j of chartData) {
  522. let serie_item = {
  523. data: [],
  524. type: 'spline',
  525. yAxis: 0,
  526. name: j.Year,
  527. };
  528. const data_array = this.calendar_type === '农历'?_.cloneDeep(j.Items):_.cloneDeep(j.DataList);
  529. data_array &&
  530. data_array.forEach((item) => {
  531. serie_item.data.push([item.DataTimestamp, item.Value]);
  532. });
  533. const index = chartData.findIndex(
  534. (item) => item.Year === j.Year
  535. );
  536. const s_yItem = {
  537. labels: {
  538. formatter: function () {
  539. let val = this.value;
  540. return index !== 0 ? '' : val;
  541. },
  542. align: 'center',
  543. },
  544. title: {
  545. text: this.chartLang=='ch'?this.chartInfo.Unit:
  546. !this.chartInfo.UnitEn && this.chartInfo.Unit && this.chartInfo.Unit!='无' ? '英文单位':this.chartInfo.UnitEn,
  547. align: 'high',
  548. rotation: 0,
  549. y: -15,
  550. offset: -(12 * this.chartInfo.Unit.length),
  551. },
  552. max: Number(this.chartInfo.MaxValue),
  553. min: Number(this.chartInfo.MinValue),
  554. ...seasonOptions.yAxis,
  555. };
  556. seasonData.push(serie_item);
  557. seasonYdata.push(s_yItem);
  558. }
  559. /* 农历数据处理 */
  560. let filterArr =
  561. this.calendar_type === '农历'
  562. ? chartData.List.filter((item, index) => index > 0)
  563. : [];
  564. if (this.calendar_type === '农历')
  565. for (let j of filterArr) {
  566. let serie_item = {
  567. data: [],
  568. type: 'spline',
  569. yAxis: 0,
  570. name: j.Year
  571. };
  572. const data_array = _.cloneDeep(j.Items);
  573. data_array &&
  574. data_array.forEach((item) => {
  575. serie_item.data.push([item.DataTimestamp, item.Value]);
  576. });
  577. const index = filterArr.findIndex((item) => item.Year === j.Year);
  578. const s_yItem = {
  579. labels: {
  580. formatter: function () {
  581. let val = this.value;
  582. return index !== 0 ? '' : val;
  583. },
  584. align: 'center',
  585. },
  586. title: {
  587. text: this.chartLang=='ch'?this.chartInfo.Unit:
  588. !this.chartInfo.UnitEn && this.chartInfo.Unit && this.chartInfo.Unit!='无' ? '英文单位':this.chartInfo.UnitEn,
  589. align: 'high',
  590. rotation: 0,
  591. y: -15,
  592. offset: -(12 * this.chartInfo.Unit.length),
  593. },
  594. max: Number(this.chartInfo.MaxValue),
  595. min: Number(this.chartInfo.MinValue),
  596. ...seasonOptions.yAxis,
  597. };
  598. seasonData.push(serie_item);
  599. seasonYdata.push(s_yItem);
  600. }
  601. /* x轴显示月日 提示框显示月日*/
  602. defaultOpts.xAxis.labels = {
  603. formatter: function () {
  604. return Highcharts.dateFormat('%m/%d', this.value);
  605. },
  606. };
  607. const tooltip = {
  608. ...defaultOpts.tooltip,
  609. dateTimeLabelFormats: {
  610. // 时间格式化字符
  611. day: '%m/%d',
  612. week: '%m/%d',
  613. month: '%m/%d',
  614. year: '%m/%d',
  615. },
  616. xDateFormat: '%m/%d',
  617. }
  618. let rangeSelector =
  619. this.calendar_type === '农历'
  620. ? {
  621. enabled: true,
  622. selected: 0,
  623. inputStyle: {
  624. display: 'none',
  625. },
  626. labelStyle: {
  627. display: 'none',
  628. },
  629. buttonTheme: {
  630. style: {
  631. display: 'none',
  632. },
  633. },
  634. buttons: [
  635. {
  636. type: 'month',
  637. count: 12,
  638. text: '12月',
  639. },
  640. {
  641. type: 'month',
  642. count: 15,
  643. text: '15月',
  644. },
  645. {
  646. type: 'all',
  647. text: '全部',
  648. type: 'all',
  649. },
  650. ],
  651. }
  652. : {
  653. enabled: false,
  654. };
  655. this.options = {
  656. colors:
  657. this.calendar_type === '公历'
  658. ? seasonOptions.colors.slice(-chartData.length)
  659. : seasonOptions.colors.slice(-filterArr.length),
  660. series: seasonData,
  661. yAxis: seasonYdata,
  662. rangeSelector,
  663. tooltip
  664. };
  665. console.log(this.options)
  666. },
  667. /* 查询范围为1年内 x轴显示为月/日 否则默认年/月 */
  668. xTimeDiffer() {
  669. const end_date =
  670. this.year_select === 5
  671. ? this.select_date[1]
  672. : this.year_select === 6
  673. ? new Date()
  674. : '';
  675. //年限差
  676. const year_differ = this.$moment(end_date).diff(
  677. this.$moment(this.select_date[0]),
  678. 'years',
  679. true
  680. );
  681. // console.log(year_differ)
  682. if ([5, 6].includes(this.year_select) && year_differ <= 1) {
  683. return true;
  684. } else {
  685. return false;
  686. }
  687. },
  688. init(type='') {
  689. if(type!=='no_reset') this.chart_type = 1;
  690. this.isShowOnyearData = false;
  691. this.year_select = this.chart_type==1 ? 10 : 20;
  692. // 季节性图默认展示最近5年数据
  693. this.count_year=5
  694. this.select_date = [];
  695. this.options = {};
  696. this.dateTip = '请选择时间段';
  697. this.oldOptions = {};
  698. this.calendar_type = '公历';
  699. this.season_year = [];
  700. this.limitData = {
  701. letMin: 0,
  702. leftMax: 0,
  703. rightMin: 0,
  704. rightMax: 0,
  705. }
  706. },
  707. // 编辑英文信息弹窗
  708. editEnName(){
  709. this.$emit('editEnName','chart')
  710. },
  711. // 竖轴标题点击事件
  712. clickYAxisTitle(){
  713. console.log(this.chartLang);
  714. if(this.chartLang == 'en') this.editEnName()
  715. }
  716. },
  717. created() {},
  718. mounted() {},
  719. }
  720. </script>
  721. <style lang='scss'>
  722. .chart-trend-render {
  723. width:100%;
  724. box-sizing: border-box;
  725. @media screen and (min-width: 1711px) {
  726. .min-data-input { margin-top: 300px; }
  727. }
  728. @media screen and (max-width:1710px) {
  729. .min-data-input { margin-top: 210px; }
  730. }
  731. .header {
  732. display: flex;
  733. position: relative;
  734. .year-btn,.btn-sty {
  735. min-width: 98px;
  736. font-size: 14px;
  737. margin-right: 5px;
  738. margin-bottom: 5px;
  739. }
  740. .btn-sty {
  741. background-color: #fff;
  742. color: #0052D9;
  743. }
  744. .date-setting{
  745. width: 210px;
  746. // height: 40px;
  747. padding: 10px;
  748. border: 1px solid #DCDFE6;
  749. border-radius: 4px;
  750. cursor: pointer;
  751. font-size: 14px;
  752. color: #333333;
  753. box-sizing: border-box;
  754. }
  755. .change-chart-btn{
  756. float: right;
  757. color: #409eff;
  758. font-size: 16px;
  759. cursor: pointer;
  760. &::before{
  761. content:'';
  762. display: inline-block;
  763. width: 18px;
  764. height: 18px;
  765. background-image: url('~@/assets/img/chart_m/change.png');
  766. background-size: cover;
  767. position: relative;
  768. top: 4px;
  769. right: 4px;
  770. }
  771. }
  772. }
  773. .min-wrapper {
  774. .el-input__inner {
  775. padding: 0 0 0 5px;
  776. }
  777. /* margin: 20px 0 0 0; */
  778. min-height: 320px;
  779. .chartWrapper {
  780. position: relative;
  781. padding: 0 105px 0 100px;
  782. .range-cont {
  783. position: absolute;
  784. top: 8%;
  785. .min-data-input {
  786. width: 80px;
  787. display: block;
  788. }
  789. &.left {
  790. left: 0px;
  791. }
  792. &.right {
  793. right: 0;
  794. }
  795. }
  796. }
  797. }
  798. }
  799. </style>