add custom echarts demo
This commit is contained in:
@@ -78,41 +78,7 @@
|
||||
class="graphs"
|
||||
v-show="graphList.length"
|
||||
id="status-chart"
|
||||
style="height: 1px; flex: 1">
|
||||
<!-- <div class="graph" v-for="eq in graphList" :key="eq.key">
|
||||
<h2 class="graph-title">{{ eq.key }}</h2>
|
||||
|
||||
<div class="graph-content">
|
||||
<el-popover
|
||||
trigger="hover"
|
||||
v-for="blc in eq"
|
||||
:key="blc.startTime"
|
||||
:title="
|
||||
blc.status == 0
|
||||
? '运行'
|
||||
: blc.status == 2
|
||||
? '故障'
|
||||
: '计划停机'
|
||||
"
|
||||
placement="top"
|
||||
:content="new Date(blc.startTime).toLocaleTimeString()">
|
||||
<div
|
||||
slot="reference"
|
||||
:key="blc.startTime + '__div'"
|
||||
class="graph-item-fixed tick"
|
||||
:class="{
|
||||
running: blc.status == 0,
|
||||
fault: blc.status == 2,
|
||||
stop: blc.status == 1,
|
||||
}"
|
||||
:style="{ height: '32px', width: blc.duration * 2 + 'px' }"
|
||||
:data-time="
|
||||
new Date(blc.startTime).toLocaleTimeString()
|
||||
"></div>
|
||||
</el-popover>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
style="height: 1px; flex: 1"></div>
|
||||
<h2 v-if="!graphList || graphList.length == 0" class="no-data-bg"></h2>
|
||||
</div>
|
||||
</el-row>
|
||||
@@ -141,46 +107,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as echarts from 'echarts';
|
||||
|
||||
var types = [
|
||||
{ name: '运行', color: '#5ad8a6' },
|
||||
{ name: '故障', color: '#fc9c91' },
|
||||
{ name: '计划停机', color: '#000' },
|
||||
];
|
||||
function getStartTime(timestamp) {
|
||||
return new Date(new Date(timestamp).toLocaleDateString()).getTime();
|
||||
}
|
||||
function renderItem(params, api) {
|
||||
var categoryIndex = api.value(0);
|
||||
var start = api.coord([api.value(1), categoryIndex]);
|
||||
var end = api.coord([api.value(2), categoryIndex]);
|
||||
var height = api.size([0, 1])[1] * 1;
|
||||
// var height = api.size([0, 1])[1] * 0.8;
|
||||
// var height = 56;
|
||||
var rectShape = echarts.graphic.clipRectByRect(
|
||||
{
|
||||
x: start[0],
|
||||
y: start[1] - height / 2,
|
||||
width: end[0] - start[0],
|
||||
height: height,
|
||||
},
|
||||
{
|
||||
x: params.coordSys.x,
|
||||
y: params.coordSys.y,
|
||||
width: params.coordSys.width,
|
||||
height: params.coordSys.height,
|
||||
}
|
||||
);
|
||||
return (
|
||||
rectShape && {
|
||||
type: 'rect',
|
||||
transition: ['shape'],
|
||||
shape: rectShape,
|
||||
style: api.style(),
|
||||
}
|
||||
);
|
||||
}
|
||||
// import * as echarts from 'echarts';
|
||||
import Gantt from './gantt';
|
||||
|
||||
export default {
|
||||
name: 'SGStatus',
|
||||
@@ -209,18 +137,13 @@ export default {
|
||||
{
|
||||
type: 'datePicker',
|
||||
label: '时间段',
|
||||
// dateType: 'daterange', // datetimerange
|
||||
dateType: 'date',
|
||||
// format: 'yyyy-MM-dd HH:mm:ss',
|
||||
format: 'yyyy-MM-dd',
|
||||
valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
||||
// valueFormat: 'timestamp',
|
||||
rangeSeparator: '-',
|
||||
// startPlaceholder: '开始日期',
|
||||
// endPlaceholder: '结束日期',
|
||||
placeholder: '选择日期',
|
||||
// defaultTime: ['00:00:00', '23:59:59'],
|
||||
param: 'recordTime',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
@@ -248,6 +171,8 @@ export default {
|
||||
graphList: [],
|
||||
open: false,
|
||||
eqList: [],
|
||||
startTime: null,
|
||||
gantt: null
|
||||
// demo: [
|
||||
// [
|
||||
// {
|
||||
@@ -268,176 +193,6 @@ export default {
|
||||
// },
|
||||
// ],
|
||||
// ],
|
||||
chartOption: {
|
||||
grid: {
|
||||
top: 32,
|
||||
left: 128,
|
||||
right: 128,
|
||||
bottom: 64,
|
||||
},
|
||||
tooltip: {
|
||||
// show: false,
|
||||
formatter: function (params) {
|
||||
return (
|
||||
params.marker +
|
||||
params.name +
|
||||
': ' +
|
||||
new Date(params.value[1]).toLocaleTimeString() +
|
||||
' - ' +
|
||||
new Date(params.value[2]).toLocaleTimeString()
|
||||
);
|
||||
},
|
||||
},
|
||||
xAxis: {
|
||||
type: 'time',
|
||||
min: getStartTime(1691568181000), // <===
|
||||
max: getStartTime(1691568181000 + 3600 * 24 * 1000), // <===
|
||||
splitNumber: 10,
|
||||
axisLabel: {
|
||||
// rotate: -15,
|
||||
formatter: function (val) {
|
||||
return new Date(val).toLocaleTimeString();
|
||||
},
|
||||
},
|
||||
axisTick: {
|
||||
show: true,
|
||||
},
|
||||
splitLine: {
|
||||
show: false,
|
||||
},
|
||||
},
|
||||
yAxis: [
|
||||
{
|
||||
interval: 40,
|
||||
axisLine: {
|
||||
// show: false,
|
||||
lineStyle: {
|
||||
color: '',
|
||||
},
|
||||
},
|
||||
axisLabel: {
|
||||
fontSize: 18,
|
||||
},
|
||||
axisTick: {
|
||||
show: false,
|
||||
},
|
||||
splitLine: {
|
||||
show: true,
|
||||
},
|
||||
// data: [], // <====
|
||||
data: ['设备1', '设备2', '设备3', '设备4'],
|
||||
},
|
||||
{
|
||||
axisLine: {
|
||||
// show: false,
|
||||
lineStyle: {
|
||||
color: '',
|
||||
},
|
||||
},
|
||||
data: [],
|
||||
},
|
||||
],
|
||||
series: [
|
||||
{
|
||||
type: 'custom',
|
||||
renderItem: renderItem,
|
||||
itemStyle: {
|
||||
opacity: 0.8,
|
||||
},
|
||||
encode: {
|
||||
x: [1, 2],
|
||||
y: 0,
|
||||
},
|
||||
// data: [], // <===
|
||||
data: [
|
||||
{
|
||||
name: '运行',
|
||||
value: [
|
||||
0,
|
||||
1691568181000,
|
||||
1691568181000 + 60 * 60 * 1000,
|
||||
60 * 10 * 1000,
|
||||
],
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: types[0].color,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: '计划停机',
|
||||
value: [
|
||||
0,
|
||||
1691578581000,
|
||||
1691578581000 + 10 * 60 * 1000,
|
||||
60 * 10 * 1000,
|
||||
],
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: types[2].color,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: '运行',
|
||||
value: [
|
||||
1,
|
||||
1691568181000,
|
||||
1691568181000 + 60 * 60 * 1000,
|
||||
60 * 10 * 1000,
|
||||
],
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: types[0].color,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: '故障',
|
||||
value: [
|
||||
2,
|
||||
1691538181000,
|
||||
1691538181000 + 60 * 60 * 1000,
|
||||
60 * 10 * 1000,
|
||||
],
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: types[1].color,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: '运行',
|
||||
value: [
|
||||
2,
|
||||
1691578181000,
|
||||
1691578181000 + 90 * 60 * 1000,
|
||||
90 * 10 * 1000,
|
||||
],
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: types[0].color,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: '计划停机',
|
||||
value: [
|
||||
3,
|
||||
1691528181000,
|
||||
1691528181000 + 240 * 60 * 1000,
|
||||
240 * 10 * 1000,
|
||||
],
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: types[2].color,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
@@ -445,7 +200,7 @@ export default {
|
||||
this.initProductline();
|
||||
this.initWorksection();
|
||||
this.initEquipment();
|
||||
this.getList();
|
||||
// this.getList();
|
||||
},
|
||||
mounted() {},
|
||||
watch: {
|
||||
@@ -514,7 +269,8 @@ export default {
|
||||
|
||||
initChart() {
|
||||
const el = document.getElementById('status-chart');
|
||||
this.chart = echarts.init(el);
|
||||
this.gantt = new Gantt(el);
|
||||
this.gantt.init();
|
||||
},
|
||||
|
||||
/** 重置查询条件 */
|
||||
@@ -595,6 +351,10 @@ export default {
|
||||
},
|
||||
|
||||
handleSearchBarSelectChange({ param, value }) {
|
||||
if (!value) {
|
||||
this.searchBarFormConfig[1].selectOptions = [];
|
||||
return;
|
||||
}
|
||||
switch (param) {
|
||||
case 'lineId':
|
||||
this.$axios({
|
||||
@@ -619,6 +379,13 @@ export default {
|
||||
handleSearchBarBtnClick({ btnName, ...payload }) {
|
||||
switch (btnName) {
|
||||
case 'search':
|
||||
if (!payload.recordTime || payload.recordTime.length <= 0) {
|
||||
this.$message.error('请选择时间段');
|
||||
return;
|
||||
}
|
||||
|
||||
this.startTime = new Date(payload.recordTime).getTime();
|
||||
|
||||
this.queryParams.lineId = payload.lineId || null;
|
||||
this.queryParams.sectionId = payload.sectionId || null;
|
||||
this.queryParams.equipmentId = payload.equipmentId || null;
|
||||
|
||||
Reference in New Issue
Block a user