提交 2a24ffd6 编写于 作者: P ph

update histogram

上级 fe3b7843
...@@ -46,8 +46,9 @@ ...@@ -46,8 +46,9 @@
"modelSize": "模型大小", "modelSize": "模型大小",
"dataProcess": "数据处理", "dataProcess": "数据处理",
"noDataFound":"暂无满足筛选条件的数据", "noDataFound":"暂无满足筛选条件的数据",
"noDataTips":"请点击“显示全量数据”按钮查看全量数据" "noDataTips":"请点击“显示全量数据”按钮查看全量数据",
"userDefined": "自定义数据",
"metric": "度量指标"
}, },
"dataTraceback": { "dataTraceback": {
"details": "详情", "details": "详情",
...@@ -102,21 +103,21 @@ ...@@ -102,21 +103,21 @@
}, },
"histogram": { "histogram": {
"titleText": "参数分布图", "titleText": "参数分布图",
"xAxisTitle": "水平轴", "xAxisTitle": "轴",
"viewType": "直方图模式", "viewType": "视角",
"centerValue": "中心值", "centerValue": "中心值",
"step": "步骤", "step": "步骤",
"relativeTime": "相对时间", "relativeTime": "相对时间",
"absoluteTime": "绝对时间", "absoluteTime": "绝对时间",
"overlay": "覆盖", "overlay": "正视",
"offset": "偏移", "offset": "俯视",
"fullScreen": "切换全屏" "fullScreen": "切换全屏"
}, },
"dataMap": { "dataMap": {
"titleText": "数据图可视" "titleText": "数据图"
}, },
"graph": { "graph": {
"titleText": "计算图可视", "titleText": "计算图",
"downloadPic": "下载", "downloadPic": "下载",
"nodeInfo": "节点信息", "nodeInfo": "节点信息",
"legend": "图例", "legend": "图例",
......
...@@ -34,26 +34,28 @@ limitations under the License. ...@@ -34,26 +34,28 @@ limitations under the License.
</div> </div>
<!-- Area for selecting a view type --> <!-- Area for selecting a view type -->
<div class="cl-histogram-view-type-select-content"> <div class="cl-histogram-view-type-select-content">
<div class="view-title">{{$t('histogram.xAxisTitle')}}</div> <div class="view-title">{{$t('histogram.viewType')}}</div>
<el-radio-group v-model="curViewName"
fill="#00A5A7"
text-color="#FFFFFF"
size="small"
@change="viewTypeChange">
<el-radio-button :label=0>{{$t('histogram.overlay')}}</el-radio-button>
<el-radio-button :label=1>{{$t('histogram.offset')}}</el-radio-button>
</el-radio-group>
<div class="view-title"
v-if="!!curViewName">{{$t('histogram.xAxisTitle')}}</div>
<el-radio-group v-model="curAxisName" <el-radio-group v-model="curAxisName"
fill="#00A5A7" fill="#00A5A7"
text-color="#FFFFFF" text-color="#FFFFFF"
size="small" size="small"
v-if="!!curViewName"
:disabled="curViewName === 0" :disabled="curViewName === 0"
@change="timeTypeChange"> @change="timeTypeChange">
<el-radio-button :label=0>{{$t('histogram.step')}}</el-radio-button> <el-radio-button :label=0>{{$t('histogram.step')}}</el-radio-button>
<el-radio-button :label=1>{{$t('histogram.relativeTime')}}</el-radio-button> <el-radio-button :label=1>{{$t('histogram.relativeTime')}}</el-radio-button>
<el-radio-button :label=2>{{$t('histogram.absoluteTime')}}</el-radio-button> <el-radio-button :label=2>{{$t('histogram.absoluteTime')}}</el-radio-button>
</el-radio-group> </el-radio-group>
<div class="view-title">{{$t('histogram.viewType')}}</div>
<el-radio-group v-model="curViewName"
fill="#00A5A7"
text-color="#FFFFFF"
size="small"
@change="viewTypeChange">
<el-radio-button :label=0>{{$t('histogram.overlay')}}</el-radio-button>
<el-radio-button :label=1>{{$t('histogram.offset')}}</el-radio-button>
</el-radio-group>
</div> </div>
<!-- Content display area --> <!-- Content display area -->
<div class="cl-histogram-show-data-content"> <div class="cl-histogram-show-data-content">
...@@ -207,6 +209,13 @@ export default { ...@@ -207,6 +209,13 @@ export default {
clearInterval(this.autoUpdateTimer); clearInterval(this.autoUpdateTimer);
this.autoUpdateTimer = null; this.autoUpdateTimer = null;
} }
if (this.curPageArr.length) {
this.curPageArr.forEach((item) => {
if (item.zr) {
item.zr.off('mouseout', 'mousemove');
}
});
}
// Stop refreshing // Stop refreshing
if (this.isReloading) { if (this.isReloading) {
this.$store.commit('setIsReload', false); this.$store.commit('setIsReload', false);
...@@ -289,6 +298,7 @@ export default { ...@@ -289,6 +298,7 @@ export default {
dataList.push({ dataList.push({
tagName: tagName, tagName: tagName,
sampleIndex: sampleIndex, sampleIndex: sampleIndex,
zr: null,
show: false, show: false,
fullScreen: false, fullScreen: false,
domId: `${tagName}`, domId: `${tagName}`,
...@@ -368,7 +378,6 @@ export default { ...@@ -368,7 +378,6 @@ export default {
}, },
updateCurPageSamples(sampleIndex) { updateCurPageSamples(sampleIndex) {
const item = this.originDataArr[sampleIndex]; const item = this.originDataArr[sampleIndex];
const promiseArr = [];
if (!item || !item.tagName) { if (!item || !item.tagName) {
return; return;
} }
...@@ -376,18 +385,11 @@ export default { ...@@ -376,18 +385,11 @@ export default {
train_id: this.trainingJobId, train_id: this.trainingJobId,
tag: item.tagName, tag: item.tagName,
}; };
promiseArr.push(this.addPromise(params)); RequestService.getHistogramData(params).then((res) => {
Promise.all( if (!res || !res.data) {
promiseArr.map(function(promiseItem) {
return promiseItem.catch(function(err) {
return err;
});
}),
).then((res) => {
if (!res || !res.length || !res[0].data) {
return; return;
} }
const data = res[0].data; const data = JSON.parse(JSON.stringify(res.data));
this.originDataArr[sampleIndex].charData.oriData = this.formOriData( this.originDataArr[sampleIndex].charData.oriData = this.formOriData(
data, data,
); );
...@@ -395,22 +397,6 @@ export default { ...@@ -395,22 +397,6 @@ export default {
this.updateSampleData(sampleIndex, charOption); this.updateSampleData(sampleIndex, charOption);
}); });
}, },
addPromise(params) {
return new Promise((resolve, reject) => {
RequestService.getHistogramData(params)
.then((res) => {
if (res) {
res.params = params;
resolve(res);
}
})
.catch((error) => {
if (error) {
reject(error);
}
});
});
},
/** /**
* The time display type is changed * The time display type is changed
* @param {Number} val Current mode * @param {Number} val Current mode
...@@ -604,9 +590,10 @@ export default { ...@@ -604,9 +590,10 @@ export default {
const sampleIndex = this.originDataArr.length; const sampleIndex = this.originDataArr.length;
this.originDataArr.push({ this.originDataArr.push({
tagName: tagName, tagName: tagName,
sampleIndex: sampleIndex,
zr: null,
show: false, show: false,
fullScreen: false, fullScreen: false,
sampleIndex: sampleIndex,
domId: `${tagName}`, domId: `${tagName}`,
charData: { charData: {
oriData: [], oriData: [],
...@@ -644,7 +631,10 @@ export default { ...@@ -644,7 +631,10 @@ export default {
setTimeout(() => { setTimeout(() => {
sampleObject.charObj.setOption(sampleObject.charData.charOption, true); sampleObject.charObj.setOption(sampleObject.charData.charOption, true);
}, 10); }, 10);
const zr = sampleObject.charObj.getZr(); if (sampleObject.zr) {
sampleObject.zr.off('mouseout', 'mousemove');
}
sampleObject.zr = sampleObject.charObj.getZr();
const p = Math.max(0, d3.precisionRound(0.01, 1.01) - 1); const p = Math.max(0, d3.precisionRound(0.01, 1.01) - 1);
const yValueFormat = d3.format('.' + p + 'e'); const yValueFormat = d3.format('.' + p + 'e');
const chartData = sampleObject.charData.oriData.chartData; const chartData = sampleObject.charData.oriData.chartData;
...@@ -751,14 +741,15 @@ export default { ...@@ -751,14 +741,15 @@ export default {
yIndex, yIndex,
}; };
} }
zr.on('mouseout', (e) => { if (sampleObject.zr) {
sampleObject.zr.on('mouseout', (e) => {
if (!rawData || !rawData.length) { if (!rawData || !rawData.length) {
return; return;
} }
this.chartTipFlag = false; this.chartTipFlag = false;
this.removeTooltip(sampleIndex); this.removeTooltip(sampleIndex);
}); });
zr.on('mousemove', (e) => { sampleObject.zr.on('mousemove', (e) => {
if (!rawData || !rawData.length) { if (!rawData || !rawData.length) {
return; return;
} }
...@@ -792,7 +783,10 @@ export default { ...@@ -792,7 +783,10 @@ export default {
) { ) {
chartData[yIndex].items.forEach((item) => { chartData[yIndex].items.forEach((item) => {
linePoints.push( linePoints.push(
sampleObject.charObj.convertToPixel('grid', [item[2], item[3]]), sampleObject.charObj.convertToPixel('grid', [
item[2],
item[3],
]),
); );
}); });
} }
...@@ -803,7 +797,7 @@ export default { ...@@ -803,7 +797,7 @@ export default {
}, },
z: 999, z: 999,
}); });
zr.add(this.zrDrawElement.hoverLine); sampleObject.zr.add(this.zrDrawElement.hoverLine);
this.zrDrawElement.tooltip = new echarts.graphic.Text({}); this.zrDrawElement.tooltip = new echarts.graphic.Text({});
let itemX; let itemX;
const x = chartData[yIndex].items[binIndex][2]; const x = chartData[yIndex].items[binIndex][2];
...@@ -822,7 +816,8 @@ export default { ...@@ -822,7 +816,8 @@ export default {
z = items[k][3]; z = items[k][3];
break; break;
} else if (items[k][2] < x && nextX > x) { } else if (items[k][2] < x && nextX > x) {
const proportionX = (x - items[k][2]) / (nextX - items[k][2]); const proportionX =
(x - items[k][2]) / (nextX - items[k][2]);
z = (nextZ - items[k][3]) * proportionX + items[k][3]; z = (nextZ - items[k][3]) * proportionX + items[k][3];
break; break;
} }
...@@ -834,7 +829,8 @@ export default { ...@@ -834,7 +829,8 @@ export default {
}; };
if (curViewName === 1) { if (curViewName === 1) {
pt[1] -= pt[1] -=
((z - charOption.minZ) / (charOption.maxZ - charOption.minZ)) * ((z - charOption.minZ) /
(charOption.maxZ - charOption.minZ)) *
gridRectY; gridRectY;
circleOption.shape = { circleOption.shape = {
cx: itemX, cx: itemX,
...@@ -853,7 +849,7 @@ export default { ...@@ -853,7 +849,7 @@ export default {
); );
} }
const dot = new echarts.graphic.Circle(circleOption); const dot = new echarts.graphic.Circle(circleOption);
zr.add(dot); sampleObject.zr.add(dot);
this.zrDrawElement.hoverDots.push(dot); this.zrDrawElement.hoverDots.push(dot);
}); });
...@@ -949,7 +945,7 @@ export default { ...@@ -949,7 +945,7 @@ export default {
}, },
z: 2000, z: 2000,
}); });
zr.add(this.zrDrawElement.tooltipX); sampleObject.zr.add(this.zrDrawElement.tooltipX);
if (curViewName === 1 && linePoints && linePoints.length) { if (curViewName === 1 && linePoints && linePoints.length) {
this.zrDrawElement.tooltipY = new echarts.graphic.Text({ this.zrDrawElement.tooltipY = new echarts.graphic.Text({
position: [ position: [
...@@ -969,10 +965,11 @@ export default { ...@@ -969,10 +965,11 @@ export default {
}, },
z: 2000, z: 2000,
}); });
zr.add(this.zrDrawElement.tooltipY); sampleObject.zr.add(this.zrDrawElement.tooltipY);
} }
} }
}); });
}
}, },
dealrelativeTime(time) { dealrelativeTime(time) {
const arr = time.split(' '); const arr = time.split(' ');
...@@ -985,26 +982,27 @@ export default { ...@@ -985,26 +982,27 @@ export default {
*/ */
removeTooltip(sampleIndex) { removeTooltip(sampleIndex) {
const sampleObject = this.originDataArr[sampleIndex]; const sampleObject = this.originDataArr[sampleIndex];
if (sampleObject.charObj) { if (sampleObject.zr) {
const zr = sampleObject.charObj.getZr();
if (this.zrDrawElement.hoverLine) { if (this.zrDrawElement.hoverLine) {
zr.remove(this.zrDrawElement.hoverLine); sampleObject.zr.remove(this.zrDrawElement.hoverLine);
} }
if (this.zrDrawElement.tooltip) { if (this.zrDrawElement.tooltip) {
zr.remove(this.zrDrawElement.tooltip); sampleObject.zr.remove(this.zrDrawElement.tooltip);
} }
if (this.zrDrawElement.tooltipY) { if (this.zrDrawElement.tooltipY) {
zr.remove(this.zrDrawElement.tooltipY); sampleObject.zr.remove(this.zrDrawElement.tooltipY);
} }
if ( if (
this.zrDrawElement.hoverDots && this.zrDrawElement.hoverDots &&
this.zrDrawElement.hoverDots.length this.zrDrawElement.hoverDots.length
) { ) {
this.zrDrawElement.hoverDots.forEach((dot) => zr.remove(dot)); this.zrDrawElement.hoverDots.forEach((dot) =>
sampleObject.zr.remove(dot),
);
this.zrDrawElement.hoverDots.length = 0; this.zrDrawElement.hoverDots.length = 0;
} }
if (this.zrDrawElement.tooltipX) { if (this.zrDrawElement.tooltipX) {
zr.remove(this.zrDrawElement.tooltipX); sampleObject.zr.remove(this.zrDrawElement.tooltipX);
} }
} }
}, },
...@@ -1115,6 +1113,8 @@ export default { ...@@ -1115,6 +1113,8 @@ export default {
}; };
}, },
formatCharOption(sampleIndex, charOption) { formatCharOption(sampleIndex, charOption) {
const colorMin = '#346E69';
const colorMax = '#EBFFFD';
const sampleObject = this.originDataArr[sampleIndex]; const sampleObject = this.originDataArr[sampleIndex];
const fullScreenFun = this.toggleFullScreen; const fullScreenFun = this.toggleFullScreen;
const curAxisName = this.curAxisName; const curAxisName = this.curAxisName;
...@@ -1125,17 +1125,16 @@ export default { ...@@ -1125,17 +1125,16 @@ export default {
textStyle: { textStyle: {
fontSize: '16', fontSize: '16',
fontWeight: '600', fontWeight: '600',
},
bottom: 6, bottom: 6,
left: 'center', left: 'center',
}, },
},
grid: { grid: {
left: 15, left: 15,
top: 60, top: 60,
right: 40, right: 40,
bottom: 60, bottom: 60,
}, },
color: ['#346E69'],
xAxis: { xAxis: {
max: charOption.maxX, max: charOption.maxX,
min: charOption.minX, min: charOption.minX,
...@@ -1244,10 +1243,15 @@ export default { ...@@ -1244,10 +1243,15 @@ export default {
dimension: 1, dimension: 1,
range: [charOption.minStep, charOption.maxStep], range: [charOption.minStep, charOption.maxStep],
inRange: { inRange: {
colorLightness: [0.3, 0.9], color: [colorMin, colorMax],
}, },
}; };
} else if (this.curViewName === 0) { } else if (this.curViewName === 0) {
option.color = this.getGrientColor(
colorMin,
colorMax,
charOption.seriesData.length,
);
option.series = []; option.series = [];
charOption.seriesData.forEach((k) => { charOption.seriesData.forEach((k) => {
option.series.push({ option.series.push({
...@@ -1262,6 +1266,66 @@ export default { ...@@ -1262,6 +1266,66 @@ export default {
} }
return option; return option;
}, },
formatColor(str) {
if (!str) {
return;
}
const colorReg = /^([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
let colorStr = str.toLowerCase().slice(1);
if (colorReg.test(colorStr)) {
let colorStrNew = '';
if (colorStr.length === 3) {
for (let i = 0; i < 3; i++) {
colorStrNew += colorStrNew
.slice(i, i + 1)
.concat(colorStrNew.slice(i, i + 1));
}
colorStr = colorStrNew;
}
const colorFormat = [];
for (let i = 0; i < 6; i += 2) {
colorFormat.push(parseInt(`0x${colorStr.slice(i, i + 2)}`));
}
return colorFormat;
} else {
return colorStr;
}
},
formatColorToHex(rgb) {
const regRgb = /^(rgb|RGB)/g;
if (regRgb.test(rgb)) {
const colorSplit = rgb.replace(/(?:(|)|rgb|RGB)*/g, '').split(',');
let hexStr = '';
for (let i = 0; i < colorSplit.length; i++) {
let hexItem = Number(colorSplit[i]).toString(16);
hexItem = hexItem < 10 ? `0${hexItem}` : hexItem;
if (hexItem === '0') {
hexItem += hexItem;
}
hexStr += hexItem;
}
if (hexStr.length !== 6) {
hexStr = rgb;
}
return hexStr;
}
},
getGrientColor(startColor, endColor, step) {
const startRgb = this.formatColor(startColor);
const endRgb = this.formatColor(endColor);
const gapRgbR = (endRgb[0] - startRgb[0]) / step;
const gapRgbG = (endRgb[1] - startRgb[1]) / step;
const gapRgbB = (endRgb[2] - startRgb[2]) / step;
const colorResult = [];
for (let i = 0; i < step; i++) {
const sR = parseInt(gapRgbR * i + startRgb[0]);
const sG = parseInt(gapRgbG * i + startRgb[1]);
const sB = parseInt(gapRgbB * i + startRgb[2]);
const hex = this.formatColorToHex(`rgb(${sR},${sG},${sB})`);
colorResult.push(hex);
}
return colorResult;
},
toggleFullScreen(sampleIndex) { toggleFullScreen(sampleIndex) {
const sampleObject = this.originDataArr[sampleIndex]; const sampleObject = this.originDataArr[sampleIndex];
if (!sampleObject) { if (!sampleObject) {
...@@ -1370,7 +1434,9 @@ export default { ...@@ -1370,7 +1434,9 @@ export default {
padding: 24px 32px; padding: 24px 32px;
text-align: right; text-align: right;
} }
// No data available.
.image-noData { .image-noData {
// Set the width and white on the right.
width: 100%; width: 100%;
height: 450px; height: 450px;
display: flex; display: flex;
......
...@@ -51,15 +51,15 @@ limitations under the License. ...@@ -51,15 +51,15 @@ limitations under the License.
</div> </div>
</div> </div>
<div class="cl-dashboard-con-up" <div class="cl-dashboard-con-up"
:class="!!histogramTag ? '' : 'no-data-hover'" :class="!!histogramTag && !wrongPlugin ? '' : 'no-data-hover'"
@click="viewMoreHistogram"> @click="viewMoreHistogram">
<div class="cl-dashboard-title">{{$t("histogram.titleText")}}</div> <div class="cl-dashboard-title">{{$t("histogram.titleText")}}</div>
<div class="cl-module"> <div class="cl-module">
<div id="distribution-chart" <div id="distribution-chart"
v-show="!!histogramTag"></div> v-show="!!histogramTag && !wrongPlugin"></div>
<div class="no-data-img" <div class="no-data-img"
key="no-chart-data" key="no-chart-data"
v-show="!histogramTag"> v-show="!histogramTag || wrongPlugin">
<img :src="require('@/assets/images/nodata.png')" <img :src="require('@/assets/images/nodata.png')"
alt="" /> alt="" />
<p class='no-data-text'> <p class='no-data-text'>
...@@ -769,15 +769,18 @@ export default { ...@@ -769,15 +769,18 @@ export default {
if (!tagList) { if (!tagList) {
return; return;
} }
let histogramTag = '';
if (!this.histogramTag || tagList.indexOf(this.histogramTag) === -1) { if (!this.histogramTag || tagList.indexOf(this.histogramTag) === -1) {
this.histogramTag = tagList[0] || ''; histogramTag = tagList[0] || '';
} else {
histogramTag = this.histogramTag;
} }
if (!this.histogramTag) { if (!histogramTag) {
return; return;
} }
const params = { const params = {
train_id: this.trainingJobId, train_id: this.trainingJobId,
tag: this.histogramTag, tag: histogramTag,
}; };
// tag // tag
RequestService.getHistogramData(params).then((res) => { RequestService.getHistogramData(params).then((res) => {
...@@ -790,6 +793,7 @@ export default { ...@@ -790,6 +793,7 @@ export default {
return; return;
} }
const data = res.data; const data = res.data;
this.histogramTag = histogramTag;
this.histogramData = this.formOriData(data); this.histogramData = this.formOriData(data);
const charOption = this.formatDataToChar(); const charOption = this.formatDataToChar();
this.updateHistogramSampleData(charOption); this.updateHistogramSampleData(charOption);
...@@ -873,7 +877,7 @@ export default { ...@@ -873,7 +877,7 @@ export default {
textStyle: {fontFamily: 'Merriweather Sans'}, textStyle: {fontFamily: 'Merriweather Sans'},
title: { title: {
text: charOption.title || '', text: charOption.title || '',
textStyle: {fontSize: '16', fontWeight: '600'}, textStyle: {fontSize: '12', fontWeight: '400'},
bottom: 6, bottom: 6,
left: 'center', left: 'center',
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册