add legend config

This commit is contained in:
Fine 2022-11-01 17:05:27 +08:00
parent 643f461eba
commit 6e15317835
4 changed files with 47 additions and 3 deletions

View File

@ -168,6 +168,9 @@ const msg = {
maxTraceDuration: "Maximum Duration", maxTraceDuration: "Maximum Duration",
minTraceDuration: "Minimum Duration", minTraceDuration: "Minimum Duration",
legendOptions: "Legend Options", legendOptions: "Legend Options",
showLegend: "Show Legend",
asTable: "As Table",
toTheRight: "To The Right",
seconds: "Seconds", seconds: "Seconds",
hourTip: "Select Hour", hourTip: "Select Hour",
minuteTip: "Select Minute", minuteTip: "Select Minute",

View File

@ -172,6 +172,9 @@ const msg = {
maxTraceDuration: "Duración máxima", maxTraceDuration: "Duración máxima",
minTraceDuration: "Duración mínima", minTraceDuration: "Duración mínima",
legendOptions: "Opciones de leyenda", legendOptions: "Opciones de leyenda",
showLegend: "Mostrar leyenda",
asTable: "Como tabla",
toTheRight: "Derecha",
second: "s", second: "s",
yearSuffix: "Año", yearSuffix: "Año",
monthsHead: "Ene_Feb_Mar_Abr_May_Jun_Jul_Ago_Set_Oct_Nov_Dic", monthsHead: "Ene_Feb_Mar_Abr_May_Jun_Jul_Ago_Set_Oct_Nov_Dic",

View File

@ -165,6 +165,9 @@ const msg = {
maxTraceDuration: "最大持续时间", maxTraceDuration: "最大持续时间",
minTraceDuration: "最小持续时间", minTraceDuration: "最小持续时间",
legendOptions: "图例选项", legendOptions: "图例选项",
showLegend: "显示图例",
asTable: "作为表格",
toTheRight: "在右边",
seconds: "秒", seconds: "秒",
hourTip: "选择小时", hourTip: "选择小时",
minuteTip: "选择分钟", minuteTip: "选择分钟",

View File

@ -13,13 +13,36 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div> <div class="legend">
<span class="label">{{ t("legendOptions") }}</span> <span class="label">{{ t("legendOptions") }}</span>
<span class="label">{{ t("showLegend") }}</span>
<el-switch <el-switch
v-model="graph.showLegend" v-model="legend.showLegend"
active-text="Yes" active-text="Yes"
inactive-text="No" inactive-text="No"
@change="updateConfig({ showLegend: graph.showLegend })" @change="updateLegendConfig({ showLegend: legend.showLegend })"
/>
<span class="label">{{ t("asTable") }}</span>
<el-switch
v-model="legend.asTable"
active-text="Yes"
inactive-text="No"
@change="updateLegendConfig({ asTable: legend.asTable })"
/>
<span class="label">{{ t("toTheRight") }}</span>
<el-switch
v-model="legend.toTheRight"
active-text="Yes"
inactive-text="No"
@change="updateLegendConfig({ toTheRight: legend.toTheRight })"
/>
<span class="label">{{ t("width") }}</span>
<el-input
v-model="legend.width"
class="input"
size="small"
placeholder="Please input the width"
@change="updateLegendConfig({ toTheRight: legend.width })"
/> />
</div> </div>
<div> <div>
@ -79,6 +102,7 @@ const graph = computed(() => dashboardStore.selectedGrid.graph || {});
const smooth = ref(graph.value.smooth); const smooth = ref(graph.value.smooth);
const showSymbol = ref(graph.value.showSymbol); const showSymbol = ref(graph.value.showSymbol);
const step = ref(graph.value.step); const step = ref(graph.value.step);
const legend = computed(() => graph.value.legend || {});
function updateConfig(param: { [key: string]: unknown }) { function updateConfig(param: { [key: string]: unknown }) {
const graph = { const graph = {
@ -87,6 +111,17 @@ function updateConfig(param: { [key: string]: unknown }) {
}; };
dashboardStore.selectWidget({ ...dashboardStore.selectedGrid, graph }); dashboardStore.selectWidget({ ...dashboardStore.selectedGrid, graph });
} }
function updateLegendConfig(param: { [key: string]: unknown }) {
const g = {
...dashboardStore.selectedGrid.graph,
legend: {
...dashboardStore.selectedGrid.graph.legend,
...param,
},
};
dashboardStore.selectWidget({ ...dashboardStore.selectedGrid, g });
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.label { .label {