add legend component

This commit is contained in:
Fine 2022-11-07 16:23:36 +08:00
parent 5389d346c5
commit f0fcc63ff5
5 changed files with 18 additions and 8 deletions

View File

@ -18,6 +18,9 @@ import { LegendOptions } from "@/types/dashboard";
export default function useLegendProcess() { export default function useLegendProcess() {
function showEchartsLegend(keys: string[], legend?: LegendOptions) { function showEchartsLegend(keys: string[], legend?: LegendOptions) {
if (legend && !legend.show === undefined) {
return legend.show;
}
if (keys.length === 1) { if (keys.length === 1) {
return false; return false;
} }

View File

@ -183,7 +183,7 @@ export type EventParams = {
color: string; color: string;
}; };
export type LegendOptions = { export type LegendOptions = {
showLegend: boolean; show: boolean;
total: boolean; total: boolean;
min: boolean; min: boolean;
max: boolean; max: boolean;

View File

@ -14,6 +14,16 @@ See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div> <div>
<span class="label mr-5">{{ t("showLegend") }}</span>
<el-switch
v-model="legend.show"
active-text="Yes"
inactive-text="No"
@change="updateLegendConfig({ show: legend.show })"
/>
</div>
<div>
<span class="label">{{ t("legendOptions") }}</span>
<span class="label mr-5">{{ t("asTable") }}</span> <span class="label mr-5">{{ t("asTable") }}</span>
<el-switch <el-switch
v-model="legend.asTable" v-model="legend.asTable"
@ -21,9 +31,6 @@ limitations under the License. -->
inactive-text="No" inactive-text="No"
@change="updateLegendConfig({ asTable: legend.asTable })" @change="updateLegendConfig({ asTable: legend.asTable })"
/> />
</div>
<div>
<span class="label">{{ t("legendOptions") }}</span>
<span class="title ml-20 mr-5">{{ t("toTheRight") }}</span> <span class="title ml-20 mr-5">{{ t("toTheRight") }}</span>
<el-switch <el-switch
v-model="legend.toTheRight" v-model="legend.toTheRight"
@ -82,7 +89,7 @@ const { t } = useI18n();
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
const graph = computed(() => dashboardStore.selectedGrid.graph || {}); const graph = computed(() => dashboardStore.selectedGrid.graph || {});
const legend = reactive<LegendOptions>({ const legend = reactive<LegendOptions>({
showLegend: true, show: true,
total: false, total: false,
min: false, min: false,
max: false, max: false,

View File

@ -13,7 +13,7 @@ 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 class="graph"> <div class="graph flex-v">
<Graph <Graph
:option="option" :option="option"
@select="clickEvent" @select="clickEvent"

View File

@ -13,7 +13,7 @@ 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> <div>legend</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import type { PropType } from "vue"; import type { PropType } from "vue";
@ -32,5 +32,5 @@ const props = defineProps({
}), }),
}, },
}); });
// console.log(props); console.log(props);
</script> </script>