|
@@ -1,7 +1,7 @@
|
|
// 图渲染逻辑模块
|
|
// 图渲染逻辑模块
|
|
|
|
|
|
import {onMounted,ref,nextTick,reactive} from 'vue'
|
|
import {onMounted,ref,nextTick,reactive} from 'vue'
|
|
-import {chartDefaultOpts,scatterXAxis,basicYAxis,basicXAxis,leadUnitEnMap,relevanceUnitEnMap,seasonOptions} from './config'
|
|
|
|
|
|
+import {chartDefaultOpts,scatterXAxis,basicYAxis,basicXAxis,leadUnitEnMap,relevanceUnitEnMap,seasonOptions, yearSelector} from './config'
|
|
import Highcharts from 'highcharts/highstock';
|
|
import Highcharts from 'highcharts/highstock';
|
|
import HighchartsFormat from 'highcharts';
|
|
import HighchartsFormat from 'highcharts';
|
|
import HighchartsMore from 'highcharts/highcharts-more';
|
|
import HighchartsMore from 'highcharts/highcharts-more';
|
|
@@ -51,6 +51,9 @@ const axisLimitState = reactive({//极值数据
|
|
let useSelfLimit = false
|
|
let useSelfLimit = false
|
|
let isUseSelfLimit = ref(false)
|
|
let isUseSelfLimit = ref(false)
|
|
|
|
|
|
|
|
+const year_select = yearSelector[0].value
|
|
|
|
+const select_date = '' //自定义时间段
|
|
|
|
+
|
|
const screen = ref(document.body.clientWidth < 1200 ? 'phone' : 'pc');
|
|
const screen = ref(document.body.clientWidth < 1200 ? 'phone' : 'pc');
|
|
// webcomponent的EtaChart.ce.vue文件用到了这里的逻辑
|
|
// webcomponent的EtaChart.ce.vue文件用到了这里的逻辑
|
|
// 有修改了 chartRender,setLimitData 这俩方法的,需要重新编辑下webcomponent(npm run build.lib),然后替换掉report项目的对应文件eta_comp.js
|
|
// 有修改了 chartRender,setLimitData 这俩方法的,需要重新编辑下webcomponent(npm run build.lib),然后替换掉report项目的对应文件eta_comp.js
|
|
@@ -108,6 +111,8 @@ export function chartRender({data,renderId,lang='zh',changeLangIsCheck,showChart
|
|
chartData.value=data
|
|
chartData.value=data
|
|
/* useSelfLimit = ['/myETA/chartdetail','/chartETA/chartdetail'].includes(window.location.pathname) */
|
|
/* useSelfLimit = ['/myETA/chartdetail','/chartETA/chartdetail'].includes(window.location.pathname) */
|
|
useSelfLimit = shouldUseSelfLimit
|
|
useSelfLimit = shouldUseSelfLimit
|
|
|
|
+ console.log(data.ChartInfo.Source);
|
|
|
|
+
|
|
if([1,11,12].includes(data.ChartInfo.Source)){
|
|
if([1,11,12].includes(data.ChartInfo.Source)){
|
|
const chartSetMap = {
|
|
const chartSetMap = {
|
|
1: setSplineOpt,
|
|
1: setSplineOpt,
|
|
@@ -142,6 +147,12 @@ export function chartRender({data,renderId,lang='zh',changeLangIsCheck,showChart
|
|
axisLimitState.xMax=data.ChartInfo.XMax?Number(data.ChartInfo.XMax):Number(data.DataResp.XMaxValue),
|
|
axisLimitState.xMax=data.ChartInfo.XMax?Number(data.ChartInfo.XMax):Number(data.DataResp.XMaxValue),
|
|
|
|
|
|
chartOpt = setCrossVarietyChart(data)
|
|
chartOpt = setCrossVarietyChart(data)
|
|
|
|
+ }else if (data.ChartInfo.Source === 14 || data.ChartInfo.Source === 15) {
|
|
|
|
+ if (data.ChartInfo.Source === 14) {
|
|
|
|
+ chartOpt = setAIPredictChartDaily(data);
|
|
|
|
+ } else {
|
|
|
|
+ chartOpt = setAIPredictChart(data);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -2715,7 +2726,228 @@ function setRadarChart({DataResp,EdbInfoList,ChartInfo}) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// AI预测模型日度预测图表
|
|
|
|
+function setAIPredictChartDaily({ DataResp, EdbInfoList, ChartInfo }) {
|
|
|
|
+ axisLimitState.leftIndex = -1;
|
|
|
|
+ axisLimitState.rightIndex = -1;
|
|
|
|
+ axisLimitState.rightTwoIndex = -1;
|
|
|
|
+
|
|
|
|
+ const chart = {
|
|
|
|
+ spacing: [2,10,2,10],
|
|
|
|
+ plotBorderColor: '#000',
|
|
|
|
+ plotBorderWidth: 1
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ const plotLines = [
|
|
|
|
+ {
|
|
|
|
+ color: '#000',
|
|
|
|
+ width: 1,
|
|
|
|
+ dashStyle: 'Dash',
|
|
|
|
+ label: {
|
|
|
|
+ text: 'Future Split',
|
|
|
|
+ verticalAlign: 'middle',
|
|
|
|
+ textAlign: 'center'
|
|
|
|
+ },
|
|
|
|
+ value: DataResp ? DataResp.ActualLatestTimestamp : 0
|
|
|
|
+ }
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ const xAxis = {
|
|
|
|
+ tickPosition: 'inside',
|
|
|
|
+ lineColor: '#bfbfbf',
|
|
|
|
+ labels: {
|
|
|
|
+ formatter: function (ctx) {
|
|
|
|
+ return Highcharts.dateFormat('%Y-%m', ctx.value);
|
|
|
|
+ },
|
|
|
|
+ style: {}
|
|
|
|
+ },
|
|
|
|
+ lineColor: '#000',
|
|
|
|
+ tickWidth: 0,
|
|
|
|
+ tickColor: '#ccc',
|
|
|
|
+ gridLineColor: '#ccc',
|
|
|
|
+ gridLineWidth: 1,
|
|
|
|
+ plotLines: plotLines
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ const yAxis = {
|
|
|
|
+ ...basicYAxis,
|
|
|
|
+ title: {
|
|
|
|
+ enabled: false,
|
|
|
|
+ text: ChartInfo.Unit,
|
|
|
|
+ textCh: ChartInfo.Unit, // 中文
|
|
|
|
+ textEn: ChartInfo.UnitEn, // 英文
|
|
|
|
+ style: {},
|
|
|
|
+ align: 'high',
|
|
|
|
+ rotation: 0,
|
|
|
|
+ y: 12,
|
|
|
|
+ x: -20,
|
|
|
|
+ textAlign: 'left',
|
|
|
|
+ reserveSpace: false
|
|
|
|
+ },
|
|
|
|
+ labels: {
|
|
|
|
+ formatter: function (ctx) {
|
|
|
|
+ return ctx.value;
|
|
|
|
+ },
|
|
|
|
+ align: 'center',
|
|
|
|
+ x: -5,
|
|
|
|
+ y: 8,
|
|
|
|
+ style: {}
|
|
|
|
+ },
|
|
|
|
+ opposite: false,
|
|
|
|
+ min: Number(ChartInfo.LeftMin || 0),
|
|
|
|
+ max: Number(ChartInfo.LeftMax || 0),
|
|
|
|
+ tickWidth: 0,
|
|
|
|
+ tickColor: '#ccc',
|
|
|
|
+ lineColor: '#000',
|
|
|
|
+ gridLineColor: '#ccc',
|
|
|
|
+ gridLineWidth: 1
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ const data = [];
|
|
|
|
+ const chartData = _.cloneDeep(EdbInfoList) || [];
|
|
|
|
+ chartData.forEach((item, index) => {
|
|
|
|
+ const obj = {
|
|
|
|
+ data: [],
|
|
|
|
+ type: 'line',
|
|
|
|
+ dashStyle: index === 1 ? 'Dash' : 'Solid',
|
|
|
|
+ yAxis: 0,
|
|
|
|
+ name: item.EdbName,
|
|
|
|
+ nameCh: item.EdbName,
|
|
|
|
+ nameEn: item.EdbName,
|
|
|
|
+ color: item.ChartColor, // 控制线条颜色
|
|
|
|
+ lineWidth: Number(item.ChartWidth) || 1
|
|
|
|
+ };
|
|
|
|
+ item.DataList = item.DataList || [];
|
|
|
|
+ for (const i of item.DataList) {
|
|
|
|
+ obj.data.push([i.DataTimestamp, i.Value]);
|
|
|
|
+ }
|
|
|
|
+ data.push(obj);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ const legend = {
|
|
|
|
+ enabled: true,
|
|
|
|
+ align: 'left', // 图例水平对齐到左侧
|
|
|
|
+ verticalAlign: 'top', // 图例垂直对齐到顶部
|
|
|
|
+ layout: 'vertical', // 图例水平布局
|
|
|
|
+ x: 45, // 距离图表左侧的偏移量
|
|
|
|
+ y: 5, // 距离图表顶部的偏移量
|
|
|
|
+ floating: true, // 使图例悬浮在图表之上
|
|
|
|
+ backgroundColor: 'rgba(255, 255, 255, 0.8)', // 图例背景(可选)
|
|
|
|
+ borderWidth: 1, // 图例边框宽度(可选)
|
|
|
|
+ itemStyle: {
|
|
|
|
+ color: '#000', // 图例文本颜色
|
|
|
|
+ fontSize: '10px' // 图例字体大小
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ return {
|
|
|
|
+ chart,
|
|
|
|
+ series: data,
|
|
|
|
+ yAxis: [yAxis],
|
|
|
|
+ xAxis,
|
|
|
|
+ legend
|
|
|
|
+ };
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// AI预测模型
|
|
|
|
+function setAIPredictChart({ DataResp, EdbInfoList, ChartInfo }) {
|
|
|
|
+ axisLimitState.leftIndex = -1;
|
|
|
|
+ axisLimitState.rightIndex = -1;
|
|
|
|
+ axisLimitState.rightTwoIndex = -1;
|
|
|
|
|
|
|
|
+ const isLessThanOneYear = xLabelDealHandle();
|
|
|
|
+ const xAxis = {
|
|
|
|
+ tickPosition: 'inside',
|
|
|
|
+ lineColor: '#bfbfbf',
|
|
|
|
+ labels: {
|
|
|
|
+ formatter: function (ctx) {
|
|
|
|
+ return isLessThanOneYear
|
|
|
|
+ ? Highcharts.dateFormat('%m/%d', ctx.value)
|
|
|
|
+ : Highcharts.dateFormat('%y/%m', ctx.value);
|
|
|
|
+ },
|
|
|
|
+ style: {}
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ const yAxis = {
|
|
|
|
+ ...basicYAxis,
|
|
|
|
+ title: {
|
|
|
|
+ text: ChartInfo.Unit,
|
|
|
|
+ textCh: ChartInfo.Unit, // 中文
|
|
|
|
+ textEn: ChartInfo.UnitEn, // 英文
|
|
|
|
+ style: {},
|
|
|
|
+ align: 'high',
|
|
|
|
+ rotation: 0,
|
|
|
|
+ y: -12,
|
|
|
|
+ x: 0,
|
|
|
|
+ textAlign: 'left',
|
|
|
|
+ reserveSpace: false
|
|
|
|
+ },
|
|
|
|
+ labels: {
|
|
|
|
+ formatter: function (ctx) {
|
|
|
|
+ return ctx.value;
|
|
|
|
+ },
|
|
|
|
+ align: 'center',
|
|
|
|
+ x: -5,
|
|
|
|
+ style: {}
|
|
|
|
+ },
|
|
|
|
+ opposite: false,
|
|
|
|
+ min: Number(ChartInfo.LeftMin || 0),
|
|
|
|
+ max: Number(ChartInfo.LeftMax || 0),
|
|
|
|
+ tickWidth: 1
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ const data = [];
|
|
|
|
+ const chartData = _.cloneDeep(EdbInfoList) || [];
|
|
|
|
+ chartData.forEach((item, index) => {
|
|
|
|
+ const obj = {
|
|
|
|
+ data: [],
|
|
|
|
+ type: 'line',
|
|
|
|
+ dashStyle: index === 1 ? 'Dash' : 'Solid',
|
|
|
|
+ yAxis: 0,
|
|
|
|
+ name: item.EdbName,
|
|
|
|
+ nameCh: item.EdbName,
|
|
|
|
+ nameEn: item.EdbName,
|
|
|
|
+ color: item.ChartColor, // 控制线条颜色
|
|
|
|
+ lineWidth: Number(item.ChartWidth) || 1,
|
|
|
|
+ marker: index > 0 ? {
|
|
|
|
+ enabled: true,
|
|
|
|
+ symbol: 'circle',
|
|
|
|
+ fillColor: "#f00",
|
|
|
|
+ radius: 3
|
|
|
|
+ } : {}
|
|
|
|
+ };
|
|
|
|
+ item.DataList = item.DataList || [];
|
|
|
|
+ for (const i of item.DataList) {
|
|
|
|
+ obj.data.push([i.DataTimestamp, i.Value]);
|
|
|
|
+ }
|
|
|
|
+ data.push(obj);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return {
|
|
|
|
+ series: data,
|
|
|
|
+ yAxis: [yAxis],
|
|
|
|
+ xAxis
|
|
|
|
+ };
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* 查询范围为1年内 x轴显示为月/日 否则默认年/月 */
|
|
|
|
+function xLabelDealHandle() {
|
|
|
|
+ const end =
|
|
|
|
+ year_select === 5
|
|
|
|
+ ? select_date[1]
|
|
|
|
+ : year_select === 6
|
|
|
|
+ ? new Date()
|
|
|
|
+ : '';
|
|
|
|
+
|
|
|
|
+ const year_differ = moment(end).diff(moment(select_date[0]), 'years', true);
|
|
|
|
+ // console.log(year_differ)
|
|
|
|
+ if ([5, 6].includes(year_select) && year_differ <= 1) {
|
|
|
|
+ return true;
|
|
|
|
+ } else {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+}
|
|
//获取RGBA的透明度
|
|
//获取RGBA的透明度
|
|
function parseRgbaColor(color='rgba(51, 51, 51, 1)'){
|
|
function parseRgbaColor(color='rgba(51, 51, 51, 1)'){
|
|
const arr = color.match(/(\d(\.\d+)?)+/g) || ['','','',1];
|
|
const arr = color.match(/(\d(\.\d+)?)+/g) || ['','','',1];
|