未验证 提交 c6928456 编写于 作者: A abigale Li 提交者: GitHub

resolve the histogram hover circle problem and adjust code (#141)

* modify overlay and offset chart view interplay problem

* resolve frontend fecs problem

* resolve the hover circle problem for histogram

* modify the color of multiple lines in scalar

* adjust the frontend code

* modify san template

* adjust histogramHelper code

* reslove fecs code style problem
上级 7b3e837b
{ {
"name": "front", "name": "VisualDL",
"version": "1.0.0", "version": "1.0.0",
"description": "Visualization toolkit for deep learning", "description": "Visualization toolkit for deep learning",
"scripts": { "scripts": {
......
...@@ -37,8 +37,8 @@ export default { ...@@ -37,8 +37,8 @@ export default {
location.hash = '#/scalars'; location.hash = '#/scalars';
} }
}, },
menuChange({value, url, title}) { menuChange(dataItem) {
routeTo(url); routeTo(dataItem.url);
} }
}; };
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<san-appbar title="VisualDL"> <san-appbar title="VisualDL">
<san-menu slot="right"> <san-menu slot="right">
<san-menu-item <san-menu-item
san-for="item in items" s-for="item in items"
class="{{selected === item.name ? 'sm-menu-item-selected' : ''}}" class="{{selected === item.name ? 'sm-menu-item-selected' : ''}}"
on-click="handleItemClick(item)" on-click="handleItemClick(item)"
title="{{item.title}}" /> title="{{item.title}}" />
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<label class="label">{{label}}</label> <label class="label">{{label}}</label>
<div class="group-box"> <div class="group-box">
<san-checkbox <san-checkbox
san-if="showAll" s-if="showAll"
class="checkbox-all" class="checkbox-all"
label="全选" label="全选"
value="all" value="all"
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
></san-checkbox> ></san-checkbox>
<div class="san-form-check-group"> <div class="san-form-check-group">
<san-checkbox <san-checkbox
san-for="item in items" s-for="item in items"
label="{{item.name}}" label="{{item.name}}"
value="{{item.value}}" value="{{item.value}}"
disabled="{{item.disabled}}" disabled="{{item.disabled}}"
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</span> </span>
</h3> </h3>
<div <div
san-if="{{isShow}}" s-if="{{isShow}}"
class="visaul-dl-expand-panel-content" class="visaul-dl-expand-panel-content"
> >
<slot></slot> <slot></slot>
......
...@@ -6,16 +6,16 @@ ...@@ -6,16 +6,16 @@
```san Notification ```san Notification
<template> <template>
<div> <div>
<san-button <s-button
variants="raised info" variants="raised info"
on-click="handleClick01"> on-click="handleClick01">
auto close auto close
</san-button> </s-button>
<san-button <s-button
variants="raised info" variants="raised info"
on-click="handleClick02"> on-click="handleClick02">
no auto close no auto close
</san-button> </s-button>
</div> </div>
</template> </template>
...@@ -53,31 +53,31 @@ export default { ...@@ -53,31 +53,31 @@ export default {
```san Notification ```san Notification
<template> <template>
<div> <div>
<san-button <s-button
variants="raised info" variants="raised info"
on-click="handleClick01"> on-click="handleClick01">
success success
</san-button> </s-button>
<san-button <s-button
variants="raised info" variants="raised info"
on-click="handleClick02"> on-click="handleClick02">
warning warning
</san-button> </s-button>
<san-button <s-button
variants="raised info" variants="raised info"
on-click="handleClick03"> on-click="handleClick03">
info info
</san-button> </s-button>
<san-button <s-button
variants="raised info" variants="raised info"
on-click="handleClick04"> on-click="handleClick04">
error error
</san-button> </s-button>
<san-button <s-button
variants="raised info" variants="raised info"
on-click="handleClick05"> on-click="handleClick05">
simplify simplify
</san-button> </s-button>
</div> </div>
</template> </template>
...@@ -130,11 +130,11 @@ export default { ...@@ -130,11 +130,11 @@ export default {
```san Notification ```san Notification
<template> <template>
<div> <div>
<san-button <s-button
variants="raised info" variants="raised info"
on-click="handleClick01"> on-click="handleClick01">
width offset width offset
</san-button> </s-button>
</div> </div>
</template> </template>
......
...@@ -16,15 +16,15 @@ export default class NotificationItem extends Component { ...@@ -16,15 +16,15 @@ export default class NotificationItem extends Component {
on-mouseenter="clearTimer" on-mouseenter="clearTimer"
on-mouseleave="startTimer" on-mouseleave="startTimer"
on-click="handleClick"> on-click="handleClick">
<san-icon <s-icon
san-if="type" s-if="type"
class="sm-notification-type type-{{type}}" class="sm-notification-type type-{{type}}"
size="50">{{iconType}}</san-icon> size="50">{{iconType}}</s-icon>
<div class="sm-notification-group" > <div class="sm-notification-group" >
<p class="sm-notification-title">{{title}}</p> <p class="sm-notification-title">{{title}}</p>
<div class="sm-notification-content">{{message}}</div> <div class="sm-notification-content">{{message}}</div>
<div on-click="close($event)" class="sm-notification-close"> <div on-click="close($event)" class="sm-notification-close">
<san-icon size="20" class="sm-notification-close-btn">close</san-icon> <s-icon size="20" class="sm-notification-close-btn">close</s-icon>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<div class="group-box"> <div class="group-box">
<san-radio <san-radio
on-change="handleChange($event)" on-change="handleChange($event)"
san-for="item in items" s-for="item in items"
label="{{item.name}}" label="{{item.name}}"
value="{{item.value}}" value="{{item.value}}"
disabled="{{item.disabled}}" disabled="{{item.disabled}}"
......
...@@ -10,16 +10,6 @@ ...@@ -10,16 +10,6 @@
step="{{step}}" step="{{step}}"
/> />
<span>{{value}}</span> <span>{{value}}</span>
<!--
<san-input-number
min="{{min}}"
max="{{max}}"
step="{{step}}"
value="{=value=}"
on-change="handlerChange($event)"
size="small">
</san-input-number>
-->
</div> </div>
</div> </div>
</template> </template>
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
</template> </template>
<script> <script>
import {getPluginGraphsGraph} from '../service';
import autoAdjustHeight from '../common/util/autoAdjustHeight'; import autoAdjustHeight from '../common/util/autoAdjustHeight';
import config from './ui/config'; import config from './ui/config';
import chart from './ui/chart'; import chart from './ui/chart';
......
<template> <template>
<div class="visual-dl-graph-charts"> <div class="visual-dl-graph-charts">
<!-- <div s-if="graphUrl" class="visual-dl-img-box">
<div class="visual-dl-chart-box">
</div>
-->
<div san-if="graphUrl" class="visual-dl-img-box">
<div class="small-img-box"> <div class="small-img-box">
<img class="small-img" width="30" src="{{graphUrl}}" /> <img class="small-img" width="30" src="{{graphUrl}}" />
<div class="screen-handler"></div> <div class="screen-handler"></div>
...@@ -48,9 +44,6 @@ export default { ...@@ -48,9 +44,6 @@ export default {
}, },
inited() { inited() {
this.watch('filtScreen', filtScreen => { this.watch('filtScreen', filtScreen => {
// this.myChart.clear();
// let data = this.data.get('originData');
// this.initChartChartOption(data);
this.clearDragedTransform(this.getBigImgEl()); this.clearDragedTransform(this.getBigImgEl());
this.clearDragedTransform(this.getSmallImgDragHandler()); this.clearDragedTransform(this.getSmallImgDragHandler());
}); });
...@@ -67,11 +60,6 @@ export default { ...@@ -67,11 +60,6 @@ export default {
this.getOriginChartsData(); this.getOriginChartsData();
}, },
// initCharts(tagInfo) {
// this.createChart();
// this.getOriginChartsData();
// },
createChart() { createChart() {
let el = this.el.getElementsByClassName('visual-dl-chart-box')[0]; let el = this.el.getElementsByClassName('visual-dl-chart-box')[0];
this.myChart = echarts.init(el); this.myChart = echarts.init(el);
...@@ -113,8 +101,6 @@ export default { ...@@ -113,8 +101,6 @@ export default {
addDragEventForImg() { addDragEventForImg() {
let that = this; let that = this;
// this.initCharts();
// target elements with the "draggable" class // target elements with the "draggable" class
interact('.draggable').draggable({ interact('.draggable').draggable({
// enable inertial throwing // enable inertial throwing
......
...@@ -14,13 +14,6 @@ ...@@ -14,13 +14,6 @@
<ui-icon style="margin-right: 6px">file_download</ui-icon> <ui-icon style="margin-right: 6px">file_download</ui-icon>
Download image Download image
</ui-button> </ui-button>
<!--
<ui-dropdown-menu
label="Session runs"
items="{{sessionItems}}"
value="{=config.session=}"
/>
-->
<ui-slider <ui-slider
label="Scale" label="Scale"
value="{=config.scale=}" value="{=config.scale=}"
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
title="Tags matching {{config.groupNameReg}}" title="Tags matching {{config.groupNameReg}}"
></ui-chart-page> ></ui-chart-page>
<ui-chart-page <ui-chart-page
san-for="item in groupedTags" s-for="item in groupedTags"
config="{{config}}" config="{{config}}"
runsItems="{{runsItems}}" runsItems="{{runsItems}}"
tagList="{{item.tags}}" tagList="{{item.tags}}"
...@@ -94,16 +94,6 @@ export default { ...@@ -94,16 +94,6 @@ export default {
}; };
}); });
} }
// ,
// filteredConfig() {
// let config = this.data.get('config') || {};
// let filteredConfig = {};
// Object.keys(config).forEach(key => {
// let val = config[key];
// filteredConfig[key] = val;
// });
// return filteredConfig;
// }
}, },
initData() { initData() {
return { return {
...@@ -131,7 +121,7 @@ export default { ...@@ -131,7 +121,7 @@ export default {
this.data.set('config.runs', data); this.data.set('config.runs', data);
}); });
// need debounce, can't use computed // Need debounce, can't use computed
this.watch('config.groupNameReg', debounce(this.filterTagsList, 300)); this.watch('config.groupNameReg', debounce(this.filterTagsList, 300));
}, },
......
import {min, max, range} from 'lodash'; import {min, max, range} from 'lodash';
export const tansformBackendData = histogramData => { export function tansformBackendData(histogramData) {
let [time, step, items] = histogramData; let [time, step, items] = histogramData;
return { return {
time, time,
...@@ -9,9 +9,9 @@ export const tansformBackendData = histogramData => { ...@@ -9,9 +9,9 @@ export const tansformBackendData = histogramData => {
max: max(items.map(([left, right, count]) => right)), max: max(items.map(([left, right, count]) => right)),
items: items.map(([left, right, count]) => ({left, right, count})) items: items.map(([left, right, count]) => ({left, right, count}))
}; };
}; }
export const computeNewHistogram = (histogram, min, max, binsNum = 30) => { export function computeNewHistogram(histogram, min, max, binsNum = 30) {
if (max === min) { if (max === min) {
// Create bins even if all the data has a single value. // Create bins even if all the data has a single value.
max = min * 1.1 + 1; max = min * 1.1 + 1;
...@@ -38,16 +38,19 @@ export const computeNewHistogram = (histogram, min, max, binsNum = 30) => { ...@@ -38,16 +38,19 @@ export const computeNewHistogram = (histogram, min, max, binsNum = 30) => {
} }
return {x: binLeft, dx: stepWidth, y: yValue}; return {x: binLeft, dx: stepWidth, y: yValue};
}); });
}; }
export const tansformToVisData export function tansformToVisData(tempData, time, step) {
= (tempData, time, step) => tempData.map(({x, dx, y}) => [time, step, x + dx / 2, Math.floor(y)]); return tempData.map(function (dataItem) {
return [time, step, dataItem.x + dataItem.dx / 2, Math.floor(dataItem.y)];
});
}
export const originDataToChartData = originData => { export function originDataToChartData(originData) {
let tempDatas = originData.map(tansformBackendData); let tempData = originData.map(tansformBackendData);
let globalMin = min(tempDatas.map(({min}) => min)); let globalMin = min(tempData.map(({min}) => min));
let globalMax = max(tempDatas.map(({max}) => max)); let globalMax = max(tempData.map(({max}) => max));
let chartData = tempDatas.map(item => { let chartData = tempData.map(function (item) {
let histoBins = computeNewHistogram(item, globalMin, globalMax); let histoBins = computeNewHistogram(item, globalMin, globalMax);
let {time, step} = item; let {time, step} = item;
return { return {
...@@ -61,4 +64,4 @@ export const originDataToChartData = originData => { ...@@ -61,4 +64,4 @@ export const originDataToChartData = originData => {
max: globalMax, max: globalMax,
chartData chartData
}; };
}; }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
</div> </div>
<div class="visual-dl-chart-actions"> <div class="visual-dl-chart-actions">
<san-button on-click="expandArea"> <san-button on-click="expandArea">
<san-icon size="20">settings_overscan</san-icon> <san-icon size="20">settings_overscan</s-icon>
</san-button> </san-button>
</div> </div>
</div> </div>
...@@ -17,7 +17,6 @@ import Icon from 'san-mui/Icon'; ...@@ -17,7 +17,6 @@ import Icon from 'san-mui/Icon';
// libs // libs
import echarts from 'echarts'; import echarts from 'echarts';
import {maxBy} from 'lodash';
import {originDataToChartData} from '../histogramHelper'; import {originDataToChartData} from '../histogramHelper';
import {format, precisionRound} from 'd3-format'; import {format, precisionRound} from 'd3-format';
...@@ -60,8 +59,6 @@ export default { ...@@ -60,8 +59,6 @@ export default {
attached() { attached() {
let tagInfo = this.data.get('tagInfo'); let tagInfo = this.data.get('tagInfo');
this.initChart(tagInfo); this.initChart(tagInfo);
// this.initChartEvent();
if (this.data.get('running')) { if (this.data.get('running')) {
this.startInterval(); this.startInterval();
} }
...@@ -86,6 +83,11 @@ export default { ...@@ -86,6 +83,11 @@ export default {
initChartOption() { initChartOption() {
this.myChart.clear(); this.myChart.clear();
let zr = this.myChart.getZr();
let hoverDots = zrDrawElement.hoverDots;
if (hoverDots != null && hoverDots.length !== 0) {
hoverDots.forEach(dot => zr.remove(dot));
}
let chartType = this.data.get('chartType'); let chartType = this.data.get('chartType');
let data = this.data.get('originData'); let data = this.data.get('originData');
let visData = originDataToChartData(data); let visData = originDataToChartData(data);
...@@ -126,7 +128,6 @@ export default { ...@@ -126,7 +128,6 @@ export default {
animationDuration: 100, animationDuration: 100,
lineStyle: { lineStyle: {
normal: { normal: {
// opacity: originLinesOpacity,
width: 1, width: 1,
color: '#008c99' color: '#008c99'
} }
...@@ -204,8 +205,6 @@ export default { ...@@ -204,8 +205,6 @@ export default {
rawData.push(lineData); rawData.push(lineData);
}); });
// Max point in every polygon.
// let maxValuePoints = [];
let option = { let option = {
title, title,
color: ['#006069'], color: ['#006069'],
...@@ -263,17 +262,7 @@ export default { ...@@ -263,17 +262,7 @@ export default {
}; };
}, },
data: rawData data: rawData
} }]
// {
// type: 'custom',
// dimension: ['x', 'y'],
// renderItem: function (params, api) {
// },
// data: rawData
// }
]
}; };
function makePolyPoints(dataIndex, getValue, getCoord, yValueMapHeight) { function makePolyPoints(dataIndex, getValue, getCoord, yValueMapHeight) {
...@@ -349,7 +338,7 @@ export default { ...@@ -349,7 +338,7 @@ export default {
let x = dataItem[binIndex * 3]; let x = dataItem[binIndex * 3];
let y = dataItem[binIndex * 3 + 1]; let y = dataItem[binIndex * 3 + 1];
let z = dataItem[binIndex * 3 + 2]; let z = dataItem[binIndex * 3 + 2];
let pt = getPoint(x, y, z, getCoord); let pt = getPoint(x, y, z, getCoord, gridRect.y - 10);
itemX = pt[0]; itemX = pt[0];
let dot = new echarts.graphic.Circle({ let dot = new echarts.graphic.Circle({
shape: { shape: {
...@@ -456,9 +445,7 @@ export default { ...@@ -456,9 +445,7 @@ export default {
} }
} }
} }
ecChart.setOption(option, {notMerge: true}); ecChart.setOption(option, {notMerge: true});
}, },
// get origin data per 60 seconds // get origin data per 60 seconds
...@@ -485,33 +472,6 @@ export default { ...@@ -485,33 +472,6 @@ export default {
}); });
}, },
// lightHoveredLine({seriesIndex}) {
// let series = this.myChart.getOption().series;
// let newSeries = series.map((item, index) => {
// if (seriesIndex === index) {
// item.lineStyle.normal.color = highlightLineColor;
// item.zlevel = 1;
// }
// else {
// item.lineStyle.normal.color = defaultLineColor;
// item.zlevel = 0;
// }
// return item;
// });
// this.myChart.setOption({
// series: newSeries
// });
// },
// initChartEvent() {
// this.myChart.on('mousemove', params => {
// let chartType = this.data.get('chartType');
// if (chartType === 'overlay') {
// this.lightHoveredLine(params);
// }
// });
// },
expandArea() { expandArea() {
let isExpand = this.data.get('isExpand'); let isExpand = this.data.get('isExpand');
let pageBoxWidth = document.getElementsByClassName('visual-dl-chart-page')[0].offsetWidth; let pageBoxWidth = document.getElementsByClassName('visual-dl-chart-page')[0].offsetWidth;
......
<template> <template>
<!-- className visual-dl-chart-page used in chart.san, change they all if you need!--> <!-- ClassName visual-dl-chart-page used in chart.san, change they all if you need!-->
<div class="visual-dl-chart-page"> <div class="visual-dl-chart-page">
<ui-expand-panel isShow="{{expand}}" info="{{total}}" title="{{title}}"> <ui-expand-panel isShow="{{expand}}" info="{{total}}" title="{{title}}">
<ui-chart <ui-chart
san-for="tag in filteredPageList" s-for="tag in filteredPageList"
tagInfo="{{tag}}" tagInfo="{{tag}}"
runs="{{config.runs}}" runs="{{config.runs}}"
chartType="{{config.chartType}}" chartType="{{config.chartType}}"
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
runsItems="{{runsItems}}" runsItems="{{runsItems}}"
></ui-chart> ></ui-chart>
<ui-pagination <ui-pagination
san-if="total > pageSize" s-if="total > pageSize"
on-pageChange="handlePageChange($event)" on-pageChange="handlePageChange($event)"
current="{{currentPage}}" current="{{currentPage}}"
pageSize="{{pageSize}}" pageSize="{{pageSize}}"
......
...@@ -10,13 +10,6 @@ ...@@ -10,13 +10,6 @@
value="{=config.chartType=}" value="{=config.chartType=}"
items="{{charTypeItems}}" items="{{charTypeItems}}"
/> />
<!--
<ui-radio-group
label="Horizontal"
value="{=config.horizontal=}"
items="{{horizontalItems}}"
/>
-->
<ui-checkbox-group <ui-checkbox-group
value="{=config.runs=}" value="{=config.runs=}"
label="Runs" label="Runs"
......
<template> <template>
<article> <article>
<h1> <h1>
{{text}} {{text}}
</h1> </h1>
</article> </article>
</template> </template>
<script> <script>
export default { export default {
initData() { initData() {
...@@ -18,5 +14,4 @@ ...@@ -18,5 +14,4 @@
}; };
} }
}; };
</script> </script>
import {router} from 'san-router'; import {router} from 'san-router';
import HomePage from './Home'; import HomePage from './Home';
router.add({ router.add({
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
title="Tags matching {{config.groupNameReg}}" title="Tags matching {{config.groupNameReg}}"
></ui-chart-page> ></ui-chart-page>
<ui-chart-page <ui-chart-page
san-for="item in groupedTags" s-for="item in groupedTags"
config="{{filteredConfig}}" config="{{filteredConfig}}"
runsItems="{{runsItems}}" runsItems="{{runsItems}}"
tagList="{{item.tags}}" tagList="{{item.tags}}"
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<ui-expand-panel isShow="{{expand}}" info="{{total}}" title="{{title}}"> <ui-expand-panel isShow="{{expand}}" info="{{total}}" title="{{title}}">
<ui-image <ui-image
class="visual-dl-chart-image" class="visual-dl-chart-image"
san-for="tag in filteredPageList" s-for="tag in filteredPageList"
tagInfo="{{tag}}" tagInfo="{{tag}}"
isActualImageSize="{{config.isActualImageSize}}" isActualImageSize="{{config.isActualImageSize}}"
runs="{{config.runs}}" runs="{{config.runs}}"
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
></ui-image> ></ui-image>
<ui-pagination <ui-pagination
class="visual-dl-sm-pagination" class="visual-dl-sm-pagination"
san-if="total > pageSize" s-if="total > pageSize"
on-pageChange="handlePageChange($event)" on-pageChange="handlePageChange($event)"
current="{{currentPage}}" current="{{currentPage}}"
pageSize="{{pageSize}}" pageSize="{{pageSize}}"
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<span>{{imgData.step}};</span> <span>{{imgData.step}};</span>
<span>{{imgData.wall_time | formatTime}}</span> <span>{{imgData.wall_time | formatTime}}</span>
</p> </p>
<san-slider <s-slider
on-change="handleSlideChange($event)" on-change="handleSlideChange($event)"
value="{{currentIndex}}" value="{{currentIndex}}"
min="{{slider.min}}" min="{{slider.min}}"
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
title="Tags matching {{config.groupNameReg}}" title="Tags matching {{config.groupNameReg}}"
></ui-chart-page> ></ui-chart-page>
<ui-chart-page <ui-chart-page
san-for="item in groupedTags" s-for="item in groupedTags"
config="{{filteredConfig}}" config="{{filteredConfig}}"
runsItems="{{runsItems}}" runsItems="{{runsItems}}"
tagList="{{item.tags}}" tagList="{{item.tags}}"
...@@ -139,7 +139,7 @@ export default { ...@@ -139,7 +139,7 @@ export default {
this.data.set('config.runs', data); this.data.set('config.runs', data);
}); });
// need debounce can't use computed // need debounce, can't use computed
this.watch('config.groupNameReg', debounce(this.filterTagsList, 300)); this.watch('config.groupNameReg', debounce(this.filterTagsList, 300));
}, },
attached() { attached() {
......
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
<san-icon size="20">settings_overscan</san-icon> <san-icon size="20">settings_overscan</san-icon>
</san-button> </san-button>
<ui-dropdown-menu <ui-dropdown-menu
san-if="downloadLink" s-if="downloadLink"
stlye="width:100px;" stlye="width:100px;"
hintText="download type" hintText="download type"
items="{{runsItems}}" items="{{runsItems}}"
value="{=downloadType=}" value="{=downloadType=}"
/> />
<san-button <san-button
san-if="downloadLink" s-if="downloadLink"
on-click="handleDownLoad"> on-click="handleDownLoad">
<san-icon size="20">file_download</san-icon> <san-icon size="20">file_download</san-icon>
</san-button> </san-button>
...@@ -122,11 +122,11 @@ export default { ...@@ -122,11 +122,11 @@ export default {
}, },
initDownloadType() { initDownloadType() {
let runsItems = this.data.get('runsItems') || []; let runsItems = this.data.get('runsItems');
if (runsItems.length === 0) { if (runsItems.length === 0) {
return; return;
} }
this.data.set('downloadType', runsItems.find((item, index) => index === 0).value); this.data.set('downloadType', runsItems[0].value);
}, },
initChart(tagInfo) { initChart(tagInfo) {
...@@ -178,16 +178,22 @@ export default { ...@@ -178,16 +178,22 @@ export default {
let that = this; let that = this;
let option = { let option = {
color: [ color: [
'#c23531', '#C3D769',
'#61a0a8', '#A2D168',
'#d48265', '#F6E753',
'#91c7ae', '#DFDE53',
'#749f83', '#89C864',
'#ca8622', '#6FC16E',
'#bda29a', '#5FAE7C',
'#6e7074', '#54957D',
'#546570', '#458C8D',
'#c4ccd3' '#4B7C8A',
'#3E7586',
'#42638E',
'#405288',
'#464887',
'#3D3168',
'#391E57'
], ],
title: { title: {
text: tag, text: tag,
...@@ -234,7 +240,7 @@ export default { ...@@ -234,7 +240,7 @@ export default {
yAxis: { yAxis: {
type: 'value', type: 'value',
axisLabel: { axisLabel: {
formatter(value, index) { formatter(value) {
return value.toString().slice(0, 5); return value.toString().slice(0, 5);
} }
} }
...@@ -244,7 +250,7 @@ export default { ...@@ -244,7 +250,7 @@ export default {
this.myChart.setOption(option); this.myChart.setOption(option);
}, },
// get origin data per 60 seconds // Get origin data per 60 seconds
startInterval() { startInterval() {
this.getOringDataInterval = setInterval(() => { this.getOringDataInterval = setInterval(() => {
let tagInfo = this.data.get('tagInfo'); let tagInfo = this.data.get('tagInfo');
...@@ -280,18 +286,19 @@ export default { ...@@ -280,18 +286,19 @@ export default {
{ {
data: lineData, data: lineData,
encode: { encode: {
// map 1 to xAixs // map 1 dimension to xAixs.
x: [1], x: [1],
// map 2 to yAixs // map 2 dimension to yAixs.
y: [2] y: [2]
} }
}, },
{ {
data: lineData, data: lineData,
encode: { encode: {
// map 1 to xAixs // Map 1 dimension to xAixs.
x: [1], x: [1],
// map 3 to yAixs, the third number is smoothed value // Map 3 dimension to yAixs,
// the third number is smoothed value.
y: [3] y: [3]
} }
} }
...@@ -334,12 +341,12 @@ export default { ...@@ -334,12 +341,12 @@ export default {
let startValue; let startValue;
data.forEach((d, i) => { data.forEach((d, i) => {
let nextVal = d[2]; let nextVal = d[2];
// second to millisecond // second to millisecond.
let millisecond = Math.floor(d[0] * 1000); let millisecond = Math.floor(d[0] * 1000);
if (i === 0) { if (i === 0) {
startValue = millisecond; startValue = millisecond;
} }
// relative time, millisecond to hours // Relative time, millisecond to hours.
d[4] = Math.floor(millisecond - startValue) / (60 * 60 * 1000); d[4] = Math.floor(millisecond - startValue) / (60 * 60 * 1000);
if (!isFinite(nextVal)) { if (!isFinite(nextVal)) {
d[3] = nextVal; d[3] = nextVal;
...@@ -355,40 +362,39 @@ export default { ...@@ -355,40 +362,39 @@ export default {
}); });
}, },
// chart outlier options methods and functions ---- start // Chart outlier options methods and functions ---- start.
// Compute Y domain from originData.
// compute Y domain from originData
setChartsOutlier(seriesData) { setChartsOutlier(seriesData) {
let outlier = this.data.get('outlier'); let outlier = this.data.get('outlier');
let originData = this.data.get('originData'); let originData = this.data.get('originData');
let domainRangeArray = originData.map(seriesData => this.computeDataRange(seriesData, outlier)); let domainRangeArray = originData.map(seriesData => this.computeDataRange(seriesData, outlier));
// compare,get the best Y domain。 // Compare, get the best Y domain.
let flattenNumbers = flatten(domainRangeArray); let flattenNumbers = flatten(domainRangeArray);
let finalMax = max(flattenNumbers); let finalMax = max(flattenNumbers);
let finalMin = min(flattenNumbers); let finalMin = min(flattenNumbers);
// add padding // Add padding.
let PaddedYDomain = this.paddedYDomain(finalMin, finalMax); let PaddedYDomain = this.paddedYDomain(finalMin, finalMax);
this.setChartOutlierOptions(PaddedYDomain); this.setChartOutlierOptions(PaddedYDomain);
// store Y domain,if originData is not change,Y domain keep same. // Store Y domain, if originData is not change, Y domain keep same.
}, },
// compute max and min from array, if outlier is true, return quantile range // Compute max and min from array, if outlier is true, return quantile range.
computeDataRange(arr, isQuantile) { computeDataRange(arr, isQuantile) {
// get data range // Get data range.
let max; let max;
let min; let min;
if (!isQuantile) { if (!isQuantile) {
// get the orgin data range // Get the orgin data range.
max = maxBy(arr, item => item[2])[2]; max = maxBy(arr, item => item[2])[2];
min = minBy(arr, item => item[2])[2]; min = minBy(arr, item => item[2])[2];
} }
else { else {
// get the quantile range // Get the quantile range.
let sorted = sortBy(arr, [item => item[2]]); let sorted = sortBy(arr, [item => item[2]]);
min = quantile(sorted, minQuantile, item => item[2]); min = quantile(sorted, minQuantile, item => item[2]);
max = quantile(arr, maxQuantile, item => item[2]); max = quantile(arr, maxQuantile, item => item[2]);
...@@ -412,7 +418,7 @@ export default { ...@@ -412,7 +418,7 @@ export default {
}); });
}, },
// chart horizontal options methods and functions ---- start // Chart horizontal options methods and functions ---- start.
setChartHorizon() { setChartHorizon() {
let horizontal = this.data.get('horizontal'); let horizontal = this.data.get('horizontal');
let seriesOption = this.myChart.getOption().series; let seriesOption = this.myChart.getOption().series;
...@@ -523,7 +529,7 @@ export default { ...@@ -523,7 +529,7 @@ export default {
sortedPoints = sortBy(points, one => one.item[3]); sortedPoints = sortBy(points, one => one.item[3]);
break; break;
case 'nearest': case 'nearest':
// compare other ponts width the trigger point, caculate the nearest sort. // Compare other ponts width the trigger point, caculate the nearest sort.
sortedPoints = sortBy(points, one => one.item[3] - triggerValue); sortedPoints = sortBy(points, one => one.item[3] - triggerValue);
break; break;
default: default:
...@@ -552,13 +558,13 @@ export default { ...@@ -552,13 +558,13 @@ export default {
let data = item.item; let data = item.item;
return { return {
Run: item.run, Run: item.run,
// keep six number for easy-read // Keep six number for easy-read.
Smoothed: data[indexPropMap.Smoothed].toString().slice(0, 6), Smoothed: data[indexPropMap.Smoothed].toString().slice(0, 6),
Value: data[indexPropMap.Value].toString().slice(0, 6), Value: data[indexPropMap.Value].toString().slice(0, 6),
Step: data[indexPropMap.Step], Step: data[indexPropMap.Step],
Time: moment(Math.floor(data[indexPropMap.Time] * 1000), 'X').format('YYYY-MM-DD HH:mm:ss'), Time: moment(Math.floor(data[indexPropMap.Time] * 1000), 'X').format('YYYY-MM-DD HH:mm:ss'),
// relative display value should take easy-read into consideration. // Relative display value should take easy-read into consideration.
// better to tranform data to 'day:hour', 'hour:minutes', 'minute: seconds' and second only. // Better to tranform data to 'day:hour', 'hour:minutes', 'minute: seconds' and second only.
Relative: Math.floor(data[indexPropMap.Relative] * 60 * 60) + 's' Relative: Math.floor(data[indexPropMap.Relative] * 60 * 60) + 's'
}; };
}); });
...@@ -580,20 +586,6 @@ export default { ...@@ -580,20 +586,6 @@ export default {
return '<table style="text-align: left;table-layout: fixed;width: 480px;"><thead>' + headerHtml + '</thead>' return '<table style="text-align: left;table-layout: fixed;width: 480px;"><thead>' + headerHtml + '</thead>'
+ '<tbody>' + content + '</tbody><table>'; + '<tbody>' + content + '</tbody><table>';
},
setChartsRuns() {
// let tagInfo = this.data.get('tagInfo');
// let runs = this.data.get('config.runs');
// let seriesOption = [
// {
// lineStyle: {
// normal: {
// opacity: originLinesOpacity
// }
// }
// }
// ];
} }
}; };
</script> </script>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<ui-expand-panel isShow="{{expand}}" info="{{tagList.length}}" title="{{title}}"> <ui-expand-panel isShow="{{expand}}" info="{{tagList.length}}" title="{{title}}">
<div class="visual-dl-chart-page-box"> <div class="visual-dl-chart-page-box">
<ui-chart <ui-chart
san-for="tag in filteredTagList" s-for="tag in filteredTagList"
tagInfo="{{tag}}" tagInfo="{{tag}}"
groupNameReg="{{config.groupNameReg}}" groupNameReg="{{config.groupNameReg}}"
smoothing="{{config.smoothing}}" smoothing="{{config.smoothing}}"
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
></ui-chart> ></ui-chart>
</div> </div>
<ui-pagination <ui-pagination
san-if="total > pageSize" s-if="total > pageSize"
on-pageChange="handlePageChange($event)" on-pageChange="handlePageChange($event)"
current="{{currentPage}}" current="{{currentPage}}"
pageSize="{{pageSize}}" pageSize="{{pageSize}}"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册