feat: 黄金指标项图表默认不选
This commit is contained in:
@@ -160,14 +160,68 @@ function fnTableChange(pagination: any, filters: any, sorter: any, extra: any) {
|
|||||||
type StateType = {
|
type StateType = {
|
||||||
/**网元类型 */
|
/**网元类型 */
|
||||||
neType: string[];
|
neType: string[];
|
||||||
|
/**图表标签选择 */
|
||||||
|
chartLegendSelected: Record<string, boolean>;
|
||||||
/**图表配置数据 */
|
/**图表配置数据 */
|
||||||
chartsOption: Record<string, any>;
|
chartOption: EChartsOption;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**对象信息状态 */
|
/**对象信息状态 */
|
||||||
let state: StateType = reactive({
|
let state: StateType = reactive({
|
||||||
neType: [],
|
neType: [],
|
||||||
chartsOption: {},
|
chartLegendSelected: {},
|
||||||
|
chartOption: {
|
||||||
|
tooltip: {
|
||||||
|
trigger: 'axis',
|
||||||
|
position: function (pt: any) {
|
||||||
|
return [pt[0], '10%'];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
xAxis: {
|
||||||
|
type: 'category',
|
||||||
|
boundaryGap: false,
|
||||||
|
data: [],
|
||||||
|
},
|
||||||
|
yAxis: {
|
||||||
|
type: 'value',
|
||||||
|
boundaryGap: [0, '100%'],
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
type: 'scroll',
|
||||||
|
orient: 'vertical',
|
||||||
|
top: 40,
|
||||||
|
right: 20,
|
||||||
|
itemWidth: 20,
|
||||||
|
itemGap: 25,
|
||||||
|
textStyle: {
|
||||||
|
color: '#646A73',
|
||||||
|
},
|
||||||
|
icon: 'circle',
|
||||||
|
selected: {
|
||||||
|
// 选中'系列1'
|
||||||
|
系列1: true,
|
||||||
|
// 不选中'系列2'
|
||||||
|
系列2: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
left: '10%',
|
||||||
|
right: '30%',
|
||||||
|
bottom: '20%',
|
||||||
|
},
|
||||||
|
dataZoom: [
|
||||||
|
{
|
||||||
|
type: 'inside',
|
||||||
|
start: 90,
|
||||||
|
end: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
start: 90,
|
||||||
|
end: 100,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
series: [],
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
function fnChangShowType() {
|
function fnChangShowType() {
|
||||||
@@ -309,11 +363,7 @@ function fnGetList() {
|
|||||||
})
|
})
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if (result) {
|
if (result) {
|
||||||
if (kpiChart.value == null) {
|
fnRanderChartData();
|
||||||
fnRanderChart();
|
|
||||||
} else {
|
|
||||||
fnRanderChartData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -324,7 +374,7 @@ function fnRanderChart() {
|
|||||||
if (!container) return;
|
if (!container) return;
|
||||||
kpiChart.value = markRaw(echarts.init(container, 'light'));
|
kpiChart.value = markRaw(echarts.init(container, 'light'));
|
||||||
|
|
||||||
fnRanderChartData();
|
kpiChart.value.setOption(state.chartOption);
|
||||||
|
|
||||||
// 创建 ResizeObserver 实例
|
// 创建 ResizeObserver 实例
|
||||||
var observer = new ResizeObserver(entries => {
|
var observer = new ResizeObserver(entries => {
|
||||||
@@ -346,10 +396,8 @@ function fnRanderChartData() {
|
|||||||
const yDatas: Record<string, any>[] = [];
|
const yDatas: Record<string, any>[] = [];
|
||||||
|
|
||||||
const tableColumnsKeyArr: string[] = [];
|
const tableColumnsKeyArr: string[] = [];
|
||||||
|
const chartLegendSelected: Record<string, boolean> = {};
|
||||||
const columnsLen = tableColumnsDnd.value.length;
|
for (const columns of tableColumns.value) {
|
||||||
for (let i = 0; i < columnsLen; i++) {
|
|
||||||
const columns = tableColumnsDnd.value[i];
|
|
||||||
if (
|
if (
|
||||||
columns.key === 'neName' ||
|
columns.key === 'neName' ||
|
||||||
columns.key === 'startIndex' ||
|
columns.key === 'startIndex' ||
|
||||||
@@ -381,6 +429,7 @@ function fnRanderChartData() {
|
|||||||
data: [],
|
data: [],
|
||||||
});
|
});
|
||||||
tableColumnsKeyArr.push(`${columns.key}`);
|
tableColumnsKeyArr.push(`${columns.key}`);
|
||||||
|
chartLegendSelected[`${columns.title}`] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用降序就反转
|
// 用降序就反转
|
||||||
@@ -400,60 +449,17 @@ function fnRanderChartData() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// console.log(queryParams.sortOrder, xDatas, yDatas);
|
// console.log(queryParams.sortOrder, xDatas, yDatas);
|
||||||
|
// 图标签选择状态标记
|
||||||
const option: EChartsOption = {
|
state.chartLegendSelected = chartLegendSelected;
|
||||||
tooltip: {
|
kpiChart.value.setOption({
|
||||||
trigger: 'axis',
|
legend: {
|
||||||
position: function (pt: any) {
|
selected: chartLegendSelected,
|
||||||
return [pt[0], '10%'];
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'category',
|
|
||||||
boundaryGap: false,
|
|
||||||
data: xDatas,
|
data: xDatas,
|
||||||
},
|
},
|
||||||
yAxis: {
|
|
||||||
type: 'value',
|
|
||||||
boundaryGap: [0, '100%'],
|
|
||||||
},
|
|
||||||
legend: {
|
|
||||||
type: 'scroll',
|
|
||||||
orient: 'vertical',
|
|
||||||
top: 40,
|
|
||||||
right: 20,
|
|
||||||
itemWidth: 20,
|
|
||||||
itemGap: 25,
|
|
||||||
textStyle: {
|
|
||||||
color: '#646A73',
|
|
||||||
},
|
|
||||||
icon: 'circle',
|
|
||||||
selected: {
|
|
||||||
// 选中'系列1'
|
|
||||||
系列1: true,
|
|
||||||
// 不选中'系列2'
|
|
||||||
系列2: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
grid: {
|
|
||||||
left: '10%',
|
|
||||||
right: '30%',
|
|
||||||
bottom: '20%',
|
|
||||||
},
|
|
||||||
dataZoom: [
|
|
||||||
{
|
|
||||||
type: 'inside',
|
|
||||||
start: 90,
|
|
||||||
end: 100,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
start: 90,
|
|
||||||
end: 100,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
series: yDatas,
|
series: yDatas,
|
||||||
};
|
});
|
||||||
kpiChart.value.setOption(option);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@@ -491,10 +497,13 @@ onMounted(() => {
|
|||||||
// 查询当前小时
|
// 查询当前小时
|
||||||
const nowDate: Date = new Date();
|
const nowDate: Date = new Date();
|
||||||
nowDate.setMinutes(0, 0, 0);
|
nowDate.setMinutes(0, 0, 0);
|
||||||
queryRangePicker.value[0] = '2024-01-30 00:00:00'; // parseDateToStr(nowDate);
|
queryRangePicker.value[0] = parseDateToStr(nowDate);
|
||||||
|
// queryRangePicker.value[0] = '2024-01-30 00:00:00';
|
||||||
nowDate.setMinutes(59, 59, 59);
|
nowDate.setMinutes(59, 59, 59);
|
||||||
queryRangePicker.value[1] = parseDateToStr(nowDate);
|
queryRangePicker.value[1] = parseDateToStr(nowDate);
|
||||||
fnGetListTitle();
|
fnGetListTitle();
|
||||||
|
// 绘图
|
||||||
|
fnRanderChart();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
message.warning({
|
message.warning({
|
||||||
|
|||||||
Reference in New Issue
Block a user