提交 90ba14a9 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!72 UI support histogram visualization(5th commit)

Merge pull request !72 from 潘慧/master_ph
...@@ -511,6 +511,7 @@ export default { ...@@ -511,6 +511,7 @@ export default {
cursor: pointer; cursor: pointer;
width: 12px; width: 12px;
height: 12px; height: 12px;
z-index: 999;
display: inline-block; display: inline-block;
background-image: url('../../assets/images/full-screen.png'); background-image: url('../../assets/images/full-screen.png');
} }
...@@ -529,7 +530,6 @@ export default { ...@@ -529,7 +530,6 @@ export default {
width: 100%; width: 100%;
} }
#sidebar { #sidebar {
top: 32px;
.node-info-con { .node-info-con {
height: calc(100% - 280px); height: calc(100% - 280px);
} }
......
...@@ -207,6 +207,7 @@ export default { ...@@ -207,6 +207,7 @@ export default {
}, },
// echart parallel line coordinate system // echart parallel line coordinate system
parallelEchart: null, parallelEchart: null,
deviceNum: 'device_num',
shuffleTitle: 'Shuffle', shuffleTitle: 'Shuffle',
repeatTitle: 'Repeat', repeatTitle: 'Repeat',
categoryType: 'category', categoryType: 'category',
...@@ -406,7 +407,8 @@ export default { ...@@ -406,7 +407,8 @@ export default {
const obj = {dim: i, name: content.name, id: content.id}; const obj = {dim: i, name: content.name, id: content.id};
if ( if (
content.name === this.repeatTitle || content.name === this.repeatTitle ||
content.name === this.shuffleTitle content.name === this.shuffleTitle ||
content.id === this.deviceNum
) { ) {
obj.scale = true; obj.scale = true;
obj.minInterval = 1; obj.minInterval = 1;
......
...@@ -149,6 +149,7 @@ export default { ...@@ -149,6 +149,7 @@ export default {
'test_dataset_count', 'test_dataset_count',
'epoch', 'epoch',
'batch_size', 'batch_size',
'device_num',
], // All keys whose values are int ], // All keys whose values are int
echart: { echart: {
chart: null, chart: null,
......
...@@ -21,6 +21,12 @@ limitations under the License. ...@@ -21,6 +21,12 @@ limitations under the License.
<div class="cl-dashboard-top-title"> <div class="cl-dashboard-top-title">
{{$t('trainingDashboard.trainingDashboardTitle')}} {{$t('trainingDashboard.trainingDashboardTitle')}}
</div> </div>
<div class="path-message">
<span>{{$t("symbols.leftbracket")}}</span>
<span>{{$t("trainingDashboard.summaryDirPath")}}</span>
<span>{{summaryPath}}</span>
<span>{{$t("symbols.rightbracket")}}</span>
</div>
</div> </div>
<div class="cl-dashboard-center"> <div class="cl-dashboard-center">
<div class="cl-dashboard-con-up" <div class="cl-dashboard-con-up"
...@@ -166,12 +172,14 @@ export default { ...@@ -166,12 +172,14 @@ export default {
return { return {
// training job id // training job id
trainingJobId: '', trainingJobId: '',
summaryPath: '',
defColorCount: CommonProperty.commonColorArr.length, // default color defColorCount: CommonProperty.commonColorArr.length, // default color
colorNum: 0, colorNum: 0,
charObj: null, charObj: null,
histogramObj: null, histogramObj: null,
histogramOption: {}, histogramOption: {},
histogramData: {}, histogramData: [],
histogramOriData: {},
charOption: {}, charOption: {},
charData: [], charData: [],
originImageDataArr: [], // List of all image data. originImageDataArr: [], // List of all image data.
...@@ -283,6 +291,7 @@ export default { ...@@ -283,6 +291,7 @@ export default {
init() { init() {
if (this.$route.query && this.$route.query.id) { if (this.$route.query && this.$route.query.id) {
this.trainingJobId = this.$route.query.id; this.trainingJobId = this.$route.query.id;
this.summaryPath = decodeURIComponent(this.trainingJobId);
} else { } else {
this.trainingJobId = ''; this.trainingJobId = '';
this.$message.error(this.$t('trainingDashboard.invalidId')); this.$message.error(this.$t('trainingDashboard.invalidId'));
...@@ -795,19 +804,20 @@ export default { ...@@ -795,19 +804,20 @@ export default {
) { ) {
return; return;
} }
const data = res.data; const data = JSON.parse(JSON.stringify(res.data));
this.histogramTag = histogramTag; this.histogramTag = histogramTag;
this.histogramData = this.formOriData(data); this.histogramData = this.formOriData(data);
const charOption = this.formatDataToChar(); this.formatDataToChar();
this.updateHistogramSampleData(charOption); this.updateHistogramSampleData();
}); });
}, },
formOriData(dataItem) { formOriData(dataItem) {
const chartData = []; const chartData = [];
dataItem.histograms.forEach((histogram, index) => { dataItem.histograms.forEach((histogram, index) => {
const step = histogram.step.toString();
const chartItem = { const chartItem = {
wall_time: histogram.wall_time, wall_time: histogram.wall_time,
step: `${histogram.step}`, step: step,
items: [], items: [],
}; };
const chartArr = []; const chartArr = [];
...@@ -817,7 +827,7 @@ export default { ...@@ -817,7 +827,7 @@ export default {
if (!filter.length) { if (!filter.length) {
chartArr.push([ chartArr.push([
histogram.wall_time, histogram.wall_time,
`${histogram.step}`, step,
xData, xData,
Math.floor(bucket[2]), Math.floor(bucket[2]),
]); ]);
...@@ -828,33 +838,26 @@ export default { ...@@ -828,33 +838,26 @@ export default {
const minItem = chartArr[0][2]; const minItem = chartArr[0][2];
const maxItem = chartArr[chartArr.length - 1][2]; const maxItem = chartArr[chartArr.length - 1][2];
const chartAll = [ const chartAll = [
[histogram.wall_time, `${histogram.step}`, minItem, 0], [histogram.wall_time, step, minItem, 0],
].concat(chartArr, [ ].concat(chartArr, [[histogram.wall_time, step, maxItem, 0]]);
[histogram.wall_time, `${histogram.step}`, maxItem, 0],
]);
chartItem.items = chartAll; chartItem.items = chartAll;
chartData.push(chartItem); chartData.push(chartItem);
} }
}); });
return {tag: dataItem.tag, train_id: dataItem.train_id, chartData}; return chartData;
}, },
formatDataToChar() { formatDataToChar() {
const dataItem = this.histogramData; const chartData = this.histogramData;
const seriesData = []; const seriesData = [];
let maxStep = -Infinity;
let minStep = Infinity;
let maxX = -Infinity; let maxX = -Infinity;
let minX = Infinity; let minX = Infinity;
let maxZ = -Infinity; let maxZ = -Infinity;
let minZ = Infinity; let minZ = Infinity;
const gridData = []; const gridData = [];
if (dataItem.chartData && dataItem.chartData.length) { if (chartData && chartData.length) {
dataItem.chartData.forEach((histogram) => { chartData.forEach((histogram) => {
const seriesItem = []; const seriesItem = [];
gridData.push(histogram.step); gridData.push(histogram.step);
maxStep = Math.max(maxStep, histogram.step);
minStep = Math.min(minStep, histogram.step);
histogram.items.sort((a, b) => a[0] - b[0]);
histogram.items.forEach((bucket) => { histogram.items.forEach((bucket) => {
seriesItem.push(bucket[2], histogram.step, bucket[3]); seriesItem.push(bucket[2], histogram.step, bucket[3]);
maxX = Math.max(maxX, bucket[2]); maxX = Math.max(maxX, bucket[2]);
...@@ -865,10 +868,8 @@ export default { ...@@ -865,10 +868,8 @@ export default {
seriesData.push(seriesItem); seriesData.push(seriesItem);
}); });
} }
return { this.histogramOriData = {
seriesData, seriesData,
maxStep,
minStep,
maxX, maxX,
minX, minX,
maxZ, maxZ,
...@@ -876,16 +877,17 @@ export default { ...@@ -876,16 +877,17 @@ export default {
gridData, gridData,
}; };
}, },
formatCharOption(charOption) { formatCharOption() {
const colorMin = '#346E69'; const colorMin = '#346E69';
const colorMax = '#EBFFFD'; const colorMax = '#EBFFFD';
const oriData = this.histogramOriData;
const colorArr = this.getGrientColor( const colorArr = this.getGrientColor(
colorMin, colorMin,
colorMax, colorMax,
charOption.seriesData.length, oriData.seriesData.length,
); );
const seriesData = []; const seriesData = [];
charOption.seriesData.forEach((item, dataIndex) => { oriData.seriesData.forEach((item, dataIndex) => {
const dataItem = { const dataItem = {
name: item[1], name: item[1],
value: item, value: item,
...@@ -903,13 +905,13 @@ export default { ...@@ -903,13 +905,13 @@ export default {
bottom: 43, bottom: 43,
}, },
xAxis: { xAxis: {
max: charOption.maxX, max: oriData.maxX,
min: charOption.minX, min: oriData.minX,
axisLine: {onZero: false}, axisLine: {onZero: false},
axisLabel: { axisLabel: {
fontSize: '11', fontSize: '11',
formatter: function(value) { formatter: function(value) {
if (value.toString().length > 6) { if (value.toString().length >= 6) {
return value.toExponential(3); return value.toExponential(3);
} else { } else {
return Math.round(value * 1000) / 1000; return Math.round(value * 1000) / 1000;
...@@ -925,6 +927,7 @@ export default { ...@@ -925,6 +927,7 @@ export default {
splitLine: {show: true}, splitLine: {show: true},
inverse: true, inverse: true,
axisTick: {show: false}, axisTick: {show: false},
boundaryGap: false,
axisLabel: { axisLabel: {
fontSize: '11', fontSize: '11',
}, },
...@@ -938,7 +941,6 @@ export default { ...@@ -938,7 +941,6 @@ export default {
params.dataIndex, params.dataIndex,
api.coord, api.coord,
params.coordSys.y - 10, params.coordSys.y - 10,
charOption,
); );
return { return {
...@@ -1021,10 +1023,9 @@ export default { ...@@ -1021,10 +1023,9 @@ export default {
}, },
/** /**
* update sample data * update sample data
* @param {Object} charOption data
*/ */
updateHistogramSampleData(charOption) { updateHistogramSampleData() {
this.histogramOption = this.formatCharOption(charOption); this.histogramOption = this.formatCharOption();
setTimeout(() => { setTimeout(() => {
if (!this.histogramObj) { if (!this.histogramObj) {
this.histogramObj = echarts.init( this.histogramObj = echarts.init(
...@@ -1038,11 +1039,11 @@ export default { ...@@ -1038,11 +1039,11 @@ export default {
getValue(seriesData, dataIndex, i) { getValue(seriesData, dataIndex, i) {
return seriesData[dataIndex][i]; return seriesData[dataIndex][i];
}, },
makePolyPoints(dataIndex, getCoord, yValueMapHeight, charOption) { makePolyPoints(dataIndex, getCoord, yValueMapHeight) {
const points = []; const points = [];
const rawData = charOption.seriesData; const rawData = this.histogramOriData.seriesData;
const maxZ = charOption.maxZ; const maxZ = this.histogramOriData.maxZ;
const minZ = charOption.minZ; const minZ = this.histogramOriData.minZ;
for (let i = 0; i < rawData[dataIndex].length; ) { for (let i = 0; i < rawData[dataIndex].length; ) {
const x = this.getValue(rawData, dataIndex, i++); const x = this.getValue(rawData, dataIndex, i++);
const y = this.getValue(rawData, dataIndex, i++); const y = this.getValue(rawData, dataIndex, i++);
...@@ -1727,6 +1728,12 @@ export default { ...@@ -1727,6 +1728,12 @@ export default {
height: 56px; height: 56px;
vertical-align: middle; vertical-align: middle;
background: #ffffff; background: #ffffff;
.path-message {
display: inline-block;
line-height: 20px;
padding: 18px 16px;
font-weight: bold;
}
.cl-dashboard-top-title { .cl-dashboard-top-title {
float: left; float: left;
color: #000000; color: #000000;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册