update graph

This commit is contained in:
Qiuxia Fan 2022-03-27 22:53:07 +08:00
parent 713c1d1459
commit e8b8cf5fb4

View File

@ -159,8 +159,8 @@ states.visTypes = setVisTypes();
setDashboards(); setDashboards();
setMetricType(); setMetricType();
async function setMetricType() { async function setMetricType(chart?: any) {
const { graph } = dashboardStore.selectedGrid; const graph = chart || dashboardStore.selectedGrid.graph;
const json = await dashboardStore.fetchMetricList(); const json = await dashboardStore.fetchMetricList();
if (json.errors) { if (json.errors) {
ElMessage.error(json.errors); ElMessage.error(json.errors);
@ -203,6 +203,7 @@ async function setMetricType() {
...dashboardStore.selectedGrid, ...dashboardStore.selectedGrid,
metrics: states.metrics, metrics: states.metrics,
metricTypes: states.metricTypes, metricTypes: states.metricTypes,
graph,
}); });
states.metricTypeList = []; states.metricTypeList = [];
for (const metric of metrics) { for (const metric of metrics) {
@ -266,7 +267,6 @@ function setVisTypes() {
function changeChartType(item: Option) { function changeChartType(item: Option) {
const graph = DefaultGraphConfig[item.value]; const graph = DefaultGraphConfig[item.value];
dashboardStore.selectWidget({ ...dashboardStore.selectedGrid, graph });
states.isList = ListChartTypes.includes(graph.type); states.isList = ListChartTypes.includes(graph.type);
if (states.isList) { if (states.isList) {
dashboardStore.selectWidget({ dashboardStore.selectWidget({
@ -278,7 +278,7 @@ function changeChartType(item: Option) {
states.metricTypes = [""]; states.metricTypes = [""];
defaultLen.value = 5; defaultLen.value = 5;
} }
setMetricType(); setMetricType(graph);
setDashboards(); setDashboards();
states.dashboardName = ""; states.dashboardName = "";
defaultLen.value = 10; defaultLen.value = 10;